Example #1
0
static void acm_received(uint32_t _tkn, int32_t _amt)
{
	if(acm_file_ptr != NULL && acm_file_recv_left > 0)
	{
		if(_amt >= acm_file_recv_left)
		{
			memcpy(acm_file_ptr, acm_recv_buffer, acm_file_recv_left);

			bufferPrintf("ACM: Received file (finished at 0x%08x)!\n", acm_file_ptr + acm_file_recv_left);

			acm_busy = FALSE;

			acm_file_ptr = NULL;
			acm_file_recv_left = 0;
			usb_receive_bulk(ACM_EP_RECV, acm_recv_buffer, acm_usb_mps);
			return;
		}
		else
		{

			memcpy(acm_file_ptr, acm_recv_buffer, _amt);
			acm_file_ptr += _amt;
			acm_file_recv_left -= _amt;
			//bufferPrintf("ACM: Got %d of file (%d remain).\n", _amt, acm_file_recv_left);

			usb_receive_bulk(ACM_EP_RECV, acm_recv_buffer, acm_usb_mps);
			return;
		}
	}

	task_start(&acm_parse_task, &acm_parse, (void*)_amt);
}
Example #2
0
int task_init(void)
{
  struct desc_seg *gdt = (struct desc_seg *) CFG_MEM_GDTHEAD;
  struct TASK *task_new;
  int idletask;

  tasktbl = (struct TASK*)mem_alloc(TASK_TBLSZ * sizeof(struct TASK));
  if(tasktbl==0)
    return ERRNO_RESOURCE;

/*
{char s[10];
console_puts("tasktbl size=");
int2dec(TASK_TBLSZ * sizeof(struct TASK),s);
console_puts(s);
console_puts("\n");
}
*/
  memset(tasktbl,0,(TASK_TBLSZ * sizeof(struct TASK)));

  list_init(tasktbl);

  task_new = &tasktbl[1];
  task_new->id=1;
  task_new->tss.cr3 = (unsigned int)page_get_system_pgd();
  task_new->tss.es = DESC_SELECTOR(DESC_KERNEL_DATA);
  task_new->tss.cs = DESC_SELECTOR(DESC_KERNEL_CODE);
  task_new->tss.ss = DESC_SELECTOR(DESC_KERNEL_STACK);
  task_new->tss.ds = DESC_SELECTOR(DESC_KERNEL_DATA);
  task_new->tss.fs = DESC_SELECTOR(DESC_KERNEL_DATA);
  task_new->tss.gs = DESC_SELECTOR(DESC_KERNEL_DATA);
  task_new->tss.ldtr = 0;
  task_new->tss.iobase = TASK_IOBASE;
  memset( &(task_new->tss.ioenable), 0xff, TASK_IOENABLE_SIZE );

  task_new->fpu = 0;
  task_new->status = TASK_STAT_RUN;
  task_new->tick = 0;
  list_add_tail(tasktbl, task_new);
  task_real_taskid = 1;

  desc_set_tss32(&gdt[DESC_KERNEL_TASK], (int)&(task_new->tss), sizeof(task_new->tss)-1, DESC_DPL_SYSTEM);
  desc_set_tss32(&task_new->gdt, (int)&(task_new->tss), sizeof(task_new->tss)-1, DESC_DPL_SYSTEM);


  Asm("ltr %%ax"::"a"(DESC_SELECTOR(DESC_KERNEL_TASK)));

  idletask = task_create(task_idle_process);
  if(idletask<0)
    return idletask;
  task_start(idletask);
  tasktbl[idletask].status = TASK_STAT_IDLE;

  return 0;
}
Example #3
0
int main() {
    i2c_init();
    uart_init();
    task_init();

    task_create(hmc5883l_task, NULL);

    task_start();

    return 0; // Never reached
}
Example #4
0
int main(void) {
    DDRB |= 0b1111111;
    DDRA |= 0b11100001;
    PORTB = 0;

    adc_setup();
    task_setup();
    task_start();

    task_manager();
    return 0;
}
Example #5
0
static void acm_received(uint32_t _tkn, int32_t _amt)
{
	int attempts;
	for(attempts = 0; attempts < 5; attempts++)
	{
		if(task_start(&acm_parse_task, &acm_parse, (void*)_amt))
			break;

		bufferPrintf("ACM: Worker already running, yielding...\n");

		task_yield();
	}
}
Example #6
0
File: main.c Project: aep/moorlight
int dc_task_start(struct task *task)
{
    if (task->running != 0)
        return 0;
    task->running = 1;
    int r = 0;
    r =  mod_process(task_start(task));
    if (r != 0) {
        log_error("dc", "task starting failed for %s", task->name);
        task->running = 4;
        dc_task_stop(r);
        return r;
    }

    dc_on_task_started(task);
    return r;
}
Example #7
0
void *task_thread(void *args)
{
  struct task_params *params = args;
  params->exit_status = 0;

  /* Be an RT thread with the second highest priority */
  int second_max_prio;
  gracious_assert(sched_fifo_prio(1, &second_max_prio) == 0);
  gracious_assert(sched_fifo_enter(second_max_prio, NULL) == 0);  
  /* END: Be an RT thread with the second highest priority */

  /* Run the task */
  gracious_assert(task_start(params->tau) == 0);
  /* END: Run the task */

  return &params->exit_status;
}
Example #8
0
/* si_kernel_start: start real-time kernel */ 
void si_kernel_start(void)
{
    /* task_id for task with highest priority */ 
    int task_id_highest; 
  
    /* the kernel is running */ 
    Kernel_Running = 1; 

    /* print version information */ 
    console_put_string(SIMPLE_OS_VERSION_STRING); 

    /* get task_id for task with highest priority */ 
    task_id_highest = ready_list_get_task_id_highest_prio(); 

    /* start the task with highest priority */ 
    task_start(task_id_highest); 
}
Example #9
0
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();
	
	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
	wdt_setup();

	// Other devices
	uart_setup();
	i2c_setup();

//	dma_setup();

	spi_setup();

	LeaveCriticalSection();

	aes_setup();

	displaypipe_init();
	framebuffer_setup();
	framebuffer_setdisplaytext(TRUE);
	lcd_set_backlight_level(186);

//	audiohw_init();
	
	//TODO: remove
	task_init(&iboot_loader_task, "iboot loader", TASK_DEFAULT_STACK_SIZE);
	task_start(&iboot_loader_task, &iboot_loader_run, NULL);
}
Example #10
0
error_t module_timer (system_state_t _state)
{
    usize_t idx;
    error_t ecode;
    static task_handle_t handle;

    if (STATE_UP == _state) {
        STACK_DECLARE (stack, CONFIG_TIMER_TASK_STACK_SIZE);
        QUEUE_BUFFER_DECLARE (buffer, sizeof (timer_handle_t),
                              CONFIG_TIMER_QUEUE_SIZE);

        ecode = queue_create ("Timer", &g_timer_queue, buffer,
                              sizeof (timer_handle_t), CONFIG_TIMER_QUEUE_SIZE);
        if (0 != ecode) {
            return ecode;
        }
        ecode = task_create (&handle, "Timer", CONFIG_TIMER_TASK_PRIORITY,
                             stack, sizeof (stack));
        if (0 != ecode) {
            return ecode;
        }
        ecode = task_start (handle, task_timer, g_timer_queue);
        if (0 != ecode) {
            return ecode;
        }
    }
    else if (STATE_DOWN == _state) {
        if (0 != task_delete (handle)) {
            console_print ("Error: cannot delete task \"Timer\"");
        }
        if (0 != queue_delete (g_timer_queue)) {
            console_print ("Error: cannot delete queue \"Timer\"");
        }
    }
    else if (STATE_DESTROYING == _state) {
        for (idx = 0; idx <= BUCKET_LAST_INDEX; ++ idx) {
            (void) dll_traverse (&g_buckets [idx].dll_, timer_check_for_each, 0);
        }
        (void) dll_traverse (&g_inactive_timer, timer_check_for_each, 0);
    }
    return 0;
}
Example #11
0
/**
 *
 * @brief Perform all selected benchmarks
 * see config.h to select or to unselect
 *
 * @return N/A
 */
void BenchTask(void)
{
	int autorun = 0, continuously = 0;

	init_output(&continuously, &autorun);
	bench_test_init();

	PRINT_STRING(newline, output_file);
	do {
		PRINT_STRING(dashline, output_file);
		PRINT_STRING("|          S I M P L E   S E R V I C E    "
					 "M E A S U R E M E N T S  |  nsec    |\n",
					 output_file);
		PRINT_STRING(dashline, output_file);
		task_start(RECVTASK);
		call_test();
		queue_test();
		sema_test();
		mutex_test();
		memorymap_test();
		mempool_test();
		event_test();
		mailbox_test();
		pipe_test();
		PRINT_STRING("|         END OF TESTS                     "
					 "                                   |\n",
					 output_file);
		PRINT_STRING(dashline, output_file);
		PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n",output_file);
	} while (continuously && !kbhit());

	WAIT_FOR_USER();

	if (autorun) {
		task_sleep(SECONDS(2));
	}

	output_close();
}
Example #12
0
/**
 * Initialize the resources used by the framework's timer services
 *
 * IMPORTANT : this function must be called during the initialization
 *             of the OS abstraction layer.
 *             this function shall only be called once after reset, otherwise
 *             it may cause the take/lock and give/unlock services to fail
 */
void framework_init_timer(void)
{
    uint8_t idx;

#ifdef CONFIG_NANOKERNEL
    nano_sem_init ( &g_TimerSem );
    nano_timer_init (&g_NanoTimer, &g_NanoTimerData);
#else
    g_TimerSem = OS_TIMER_SEM;
#endif

    /* start with empty list of active timers: */
    g_CurrentTimerHead = NULL;

    /* memset ( g_TimerPool_elements, 0 ):  */
    for (idx = 0; idx < TIMER_POOL_SIZE; idx++)
    {
        g_TimerPool_elements[idx].desc.callback = NULL;
        g_TimerPool_elements[idx].desc.data = NULL;
        g_TimerPool_elements[idx].desc.delay = 0;
        g_TimerPool_elements[idx].desc.expiration = 0;
        g_TimerPool_elements[idx].desc.repeat = false;
        g_TimerPool_elements[idx].prev = NULL;
        g_TimerPool_elements[idx].next = NULL;
        /* hopefully, the init function is performed before
         *  timer_create and timer_stop can be called,
         *  hence there is no need for a critical section
         *  here */
    }

    /* start "timer_task" in a new fiber for NanoK, or a new task for microK */
#ifdef CONFIG_NANOKERNEL
        fiber_fiber_start ((char *) g_TimerFiberStack, TIMER_CBK_TASK_STACK_SIZE,
                timer_task,0,0,
                TIMER_CBK_TASK_PRIORITY, TIMER_CBK_TASK_OPTIONS);
#else
        task_start(OS_TASK_TIMER);
#endif
}
Example #13
0
int test_basic()

{
	task_info *info1=(task_info*)malloc(sizeof(task_info));


	//initialize the signal
	//signal_init();

	// initialize the  task
	info1->task=task1;
	info1->tv.tv_sec = 5;
	info1->tv.tv_usec = 0;
	info1->arg=(int *)100;


	if( task_start(info1) )
		ERR_EXIT("task_start task1 failure!");
	sleep(1);
	printf("wakeup serval times\n");
	//wake up several times
	if(task_wakeup(info1))
		ERR_EXIT("task_wakeup task1 failure!");
	if(task_wakeup(info1))
		ERR_EXIT("task_wakeup task1 failure!");
	if(task_wakeup(info1))
		ERR_EXIT("task_wakeup task1 failure!");




	sleep(1);
	printf("the nomal flow\n");
	sleep(10);

	//suspend the task
	if(task_suspend(info1))
		ERR_EXIT("task_suspend task1 failure!");
	printf("be suspend here for 30 seconds\n");

	sleep(30);

	printf("will be resume here\n");
	//resume the task
	if(task_resume(info1))
		ERR_EXIT("task_resume task1 failure!");


	sleep(20);
	if(task_suspend(info1))
		ERR_EXIT("task_suspend task1 failure!");
	printf("be suspend here for 10 seconds\n");
	sleep(10);
	printf("be stop here\n");
	//stop the task
	if(task_stop(info1))
		ERR_EXIT("task_stop task1 failure!");

	//join the tasks 
	pthread_join(info1->tid,NULL);
	return 0;
}
Example #14
0
int test_robust()
{


	//int num=500;
	//int num=FD_SETSIZE;
	int num=2000;
	task_info *tasks[num];
	int loop;

	for(loop=0;loop<num;++loop)
	{
		task_info *info1=(task_info*)malloc(sizeof(task_info));
		// initialize the  task
		info1->task=task1;
		info1->tv.tv_sec =2 ;
		info1->tv.tv_usec =0;
		info1->arg=(int *)loop;

		tasks[loop]=info1;


	}
	for(loop=0;loop<num;++loop)
	{
		if( task_start(tasks[loop]) )
			ERR_EXIT("task_start task1 failure!");
	}
	printf("will be wakeup here for several times\n");
	sleep(10);
	for(loop=0;loop<1;++loop)
	{
		if(task_wakeup(tasks[loop]))
			ERR_EXIT("task_suspend task1 failure!");
	}
	sleep(10);
	printf("will be suspended here for 10 seconds\n");
	sleep(10);
	for(loop=0;loop<num;++loop)
	{
		if(task_suspend(tasks[loop]))
			ERR_EXIT("task_suspend task1 failure!");
	}
	sleep(10);
	printf("will be resumed here\n");
	sleep(2);
	for(loop=0;loop<num;++loop)
	{
		if(task_resume(tasks[loop]))
			ERR_EXIT("task_resume task1 failure!");
	}
	sleep(10);
	printf("will be stop here\n");
	sleep(2);
	for(loop=0;loop<num;++loop)
	{
		if(task_stop(tasks[loop]))
			ERR_EXIT("task_stop task1 failure!");
	}
	for(loop=0;loop<num;++loop)
	{
		pthread_join(tasks[loop]->tid,NULL);
	}
	return 0;

}
Example #15
0
char task_preempt(struct task *tsk, unsigned char *rec) 
{
	task_fake_stack_push(tsk);
	
	return task_start(tsk, rec);
}
Example #16
0
int init_execve(char *filepath)
{
    struct vm_file *vmfile;
    struct exec_file_desc efd;
    struct tcb *new_task, *self;
    struct args_struct args, env;
    char env_string[30];
    int err;
    int fd;

    struct task_ids ids = {
        .tid = TASK_ID_INVALID,
        .spid = TASK_ID_INVALID,
        .tgid = TASK_ID_INVALID,
    };

    sprintf(env_string, "pagerid=%d", self_tid());

    /* Set up args_struct */
    args.argc = 1;
    args.argv = alloca(sizeof(args.argv));
    args.argv[0] = alloca(strlen(filepath) + 1);
    strncpy(args.argv[0], filepath, strlen(filepath) + 1);
    args.size = sizeof(args.argv) * args.argc + strlen(filepath) + 1;

    /* Set up environment */
    env.argc = 1;
    env.argv = alloca(sizeof(env.argv));
    env.argv[0] = alloca(strlen(env_string) + 1);
    strncpy(env.argv[0], env_string, strlen(env_string) + 1);
    env.size = sizeof(env.argv) + strlen(env_string) + 1;

    self = find_task(self_tid());
    if ((fd = sys_open(self, filepath,
                       O_RDONLY, 0)) < 0) {
        printf("FATAL: Could not open file "
               "to write initial task.\n");
        BUG();
    }
    /* Get the low-level vmfile */
    vmfile = self->files->fd[fd].vmfile;

    if (IS_ERR(new_task = task_create(0, &ids,
                                      TCB_NO_SHARING,
                                      TC_NEW_SPACE))) {
        sys_close(self, fd);
        return (int)new_task;
    }

    /*
     * Fill and validate tcb memory
     * segment markers from executable file
     */
    if ((err = task_setup_from_executable(vmfile,
                                          new_task,
                                          &efd)) < 0) {
        sys_close(self, fd);
        kfree(new_task);
        return err;
    }

    /* Map task's new segment markers as virtual memory regions */
    if ((err = task_mmap_segments(new_task, vmfile,
                                  &efd, &args, &env)) < 0) {
        sys_close(self, fd);
        kfree(new_task);
        return err;
    }

    /* Set up task registers via exchange_registers() */
    task_setup_registers(new_task, 0,
                         new_task->args_start,
                         new_task->pagerid);


    /* Add new task to global list */
    global_add_task(new_task);

    /* Start the task */
    task_start(new_task);

    return 0;
}
Example #17
0
int do_execve(struct tcb *sender, char *filename,
              struct args_struct *args,
              struct args_struct *env)
{
    struct vm_file *vmfile;
    struct exec_file_desc efd;
    struct tcb *new_task, *tgleader, *self;
    int err;
    int fd;

    self = find_task(self_tid());
    if ((fd = sys_open(self, filename, O_RDONLY, 0)) < 0)
        return fd;

    /* Get the low-level vmfile */
    vmfile = self->files->fd[fd].vmfile;

    /* Create a new tcb */
    if (IS_ERR(new_task = tcb_alloc_init(TCB_NO_SHARING))) {
        sys_close(self, fd);
        return (int)new_task;
    }

    /*
     * Fill and validate tcb memory
     * segment markers from executable file
     */
    if ((err = task_setup_from_executable(vmfile,
                                          new_task,
                                          &efd)) < 0) {
        sys_close(self, fd);
        kfree(new_task);
        return err;
    }

    /*
     * If sender is a thread in a group, need to find the
     * group leader and destroy all threaded children in
     * the group.
     */
    if (sender->clone_flags & TCB_SHARED_TGROUP) {
        struct tcb *thread;

        /* Find the thread group leader of sender */
        BUG_ON(!(tgleader = find_task(sender->tgid)));

        /* Destroy all children threads. */
        list_foreach_struct(thread,
                            &tgleader->children,
                            child_ref)
        do_exit(thread, 0);
    } else {
        /* Otherwise group leader is same as sender */
        tgleader = sender;
    }

    /*
     * Copy data to be retained from exec'ing task to new one.
     * Release all task resources, do everything done in
     * exit() except destroying the actual thread.
     */
    if ((err = execve_recycle_task(new_task, tgleader)) < 0) {
        sys_close(self, fd);
        kfree(new_task);
        return err;
    }

    /* Map task's new segment markers as virtual memory regions */
    if ((err = task_mmap_segments(new_task, vmfile,
                                  &efd, args, env)) < 0) {
        sys_close(self, fd);
        kfree(new_task);
        return err;
    }

    /* Set up task registers via exchange_registers() */
    task_setup_registers(new_task, 0,
                         new_task->args_start,
                         new_task->pagerid);

    /* Add new task to global list */
    global_add_task(new_task);

    /* Start the task */
    task_start(new_task);

    return 0;
}
Example #18
0
File: main.c Project: ESLab/rtdl
int main()
{
	Elf32_Ehdr *simple_elfh = APPLICATION_ELF(simple);
	Elf32_Ehdr *writer_elfh = APPLICATION_ELF(writer);
	Elf32_Ehdr *reader_elfh = APPLICATION_ELF(reader);
	Elf32_Ehdr *rtuapp_elfh = APPLICATION_ELF(rtuappv1);

	Elf32_Ehdr *sys_elfh = SYSTEM_ELF;

	if (check_elf_magic(sys_elfh))
		INFO_MSG("System ELF magic checks out @ 0x%x\n", (u_int32_t)sys_elfh);
	else {
		ERROR_MSG("Wrong System ELF magic @ 0x%x\n", (u_int32_t)sys_elfh);	
		goto exit;
	}

	/*
	 * Registering tasks
	 */

	task_register_cons *simplec = task_register("simple", simple_elfh);
	task_register_cons *readerc = task_register("reader", reader_elfh);
	task_register_cons *writerc = task_register("writer", writer_elfh);
	task_register_cons *rtuappc = task_register("rtuapp", rtuapp_elfh);

	if (!task_alloc(simplec)) {
		ERROR_MSG("Could not alloc memory for task \"simple\"\n");
		goto exit;
	}
	if (!task_alloc(readerc)) {
		ERROR_MSG("Could not alloc memory for task \"reader\"\n");
		goto exit;
	}
	if (!task_alloc(writerc)) {
		ERROR_MSG("Could not alloc memory for task \"writer\"\n");
		goto exit;
	}
	if (!task_alloc(rtuappc)) {
		ERROR_MSG("Could not alloc memory for task \"rtuapp\"\n");
		goto exit;
	}

	/*
	 * Linking tasks
	 */

	if (!task_link(simplec)) {
		ERROR_MSG("Could not link \"simple\" task\n");
		goto exit;
	}
	if (!task_link(readerc)) {
		ERROR_MSG("Could not link \"reader\" task\n");
		goto exit;
	}
	if (!task_link(writerc)) {
		ERROR_MSG("Could not link \"writer\" task\n");
		goto exit;
	}
	if (!task_link(rtuappc)) {
		ERROR_MSG("Could not link \"rtuapp\" task\n");
		goto exit;
	}

	/*
	 * Starting tasks
	 */
	
	if (!task_start(simplec)) {
		ERROR_MSG("Could not start \"simple\" task\n");
		goto exit;
	}

	if (!task_start(readerc)) {
		ERROR_MSG("Could not start \"reader\" task\n");
		goto exit;
	}

	if (!task_start(writerc)) {
		ERROR_MSG("Could not start \"writer\" task\n");
		goto exit;
	}

	if (!task_start(rtuappc)) {
		ERROR_MSG("Could not start \"rtuapp\" task\n");
		goto exit;
	}

	/*
	 * Create migration task.
	 */

	if (!migrator_start()) {
		ERROR_MSG("Could not start migrator.\n");
		goto exit;
	}
	
	INFO_MSG("Starting scheduler\n");
	vTaskStartScheduler();

exit:
	INFO_MSG("Going into infinite loop...\n");
	while(1)
		;
}
Example #19
0
int __rtenv_start()
{
	int i;
#ifdef TRACE	
	logfile = host_action(SYS_OPEN, "logqemu", 4);
#endif
	init_rs232();

    /* Initialize memory pool */
    memory_pool_init(&memory_pool, MEM_LIMIT, memory_space);

	/* Initialize all files */
	for (i = 0; i < FILE_LIMIT; i++)
		files[i] = NULL;

	/* Initialize ready lists */
	for (i = 0; i <= PRIORITY_LIMIT; i++)
		list_init(&ready_list[i]);

    /* Initialise event monitor */
    event_monitor_init(&event_monitor, events, ready_list);

	/* Initialize fifos */
	for (i = 0; i <= PATHSERVER_FD; i++)
		file_mknod(i, -1, files, S_IFIFO, &memory_pool, &event_monitor);

    /* Register IRQ events, see INTR_LIMIT */
	for (i = -15; i < INTR_LIMIT - 15; i++)
	    event_monitor_register(&event_monitor, INTR_EVENT(i), intr_release, 0);

    /* Register TASK blocked event -> pthread_join, atomic etc. */
	for (i = 0; i < TASK_LIMIT; i++) {
	    int pid = i;
		event_monitor_register(&event_monitor, TASK_EVENT(i), task_release, &pid);
	}

    /* Register MUTEX events */
	for (i = 0; i < MUTEX_LIMIT; i++)
	    event_monitor_register(&event_monitor, MUTEX_EVENT(i), mutex_release, 0);

	event_monitor_register(&event_monitor, TIME_EVENT, time_release, &tick_count);
    /* Initialize all task threads */
	task_create(0, pathserver, NULL);
	task_create(0, signal_server, NULL);
	task_create(0, romdev_driver, NULL);
	task_create(0, romfs_server, NULL);
	task_create(0, mount_task, NULL);

	task_create(PRIORITY_LIMIT, kernel_thread, NULL);

	current_tcb = &tasks[current_task];

	__mutex.count = 0;
	__mutex.ishead = 1;

	SysTick_Config(configCPU_CLOCK_HZ / configTICK_RATE_HZ);

	task_start();	
	
	/*	never execute here	*/
	return 0;
}
Example #20
0
test_mockable int main(void)
{
	/*
	 * Pre-initialization (pre-verified boot) stage.  Initialization at
	 * this level should do as little as possible, because verified boot
	 * may need to jump to another image, which will repeat this
	 * initialization.  In particular, modules should NOT enable
	 * interrupts.
	 */
#ifdef CONFIG_BOARD_PRE_INIT
	board_config_pre_init();
#endif

#ifdef CONFIG_MPU
	mpu_pre_init();
#endif

	/* Configure the pin multiplexers and GPIOs */
	jtag_pre_init();
	gpio_pre_init();

#ifdef CONFIG_BOARD_POST_GPIO_INIT
	board_config_post_gpio_init();
#endif
	/*
	 * Initialize interrupts, but don't enable any of them.  Note that
	 * task scheduling is not enabled until task_start() below.
	 */
	task_pre_init();

	/*
	 * Initialize the system module.  This enables the hibernate clock
	 * source we need to calibrate the internal oscillator.
	 */
	system_pre_init();
	system_common_pre_init();

#ifdef CONFIG_FLASH
	/*
	 * Initialize flash and apply write protect if necessary.  Requires
	 * the reset flags calculated by system initialization.
	 */
	flash_pre_init();
#endif

	/* Set the CPU clocks / PLLs.  System is now running at full speed. */
	clock_init();

	/*
	 * Initialize timer.  Everything after this can be benchmarked.
	 * get_time() and udelay() may now be used.  usleep() requires task
	 * scheduling, so cannot be used yet.  Note that interrupts declared
	 * via DECLARE_IRQ() call timer routines when profiling is enabled, so
	 * timer init() must be before uart_init().
	 */
	timer_init();

	/* Main initialization stage.  Modules may enable interrupts here. */
	cpu_init();

#ifdef CONFIG_DMA
	/* Initialize DMA.  Must be before UART. */
	dma_init();
#endif

	/* Initialize UART.  Console output functions may now be used. */
	uart_init();

	if (system_jumped_to_this_image()) {
		CPRINTS("UART initialized after sysjump");
	} else {
		CPUTS("\n\n--- UART initialized after reboot ---\n");
		CPUTS("[Reset cause: ");
		system_print_reset_flags();
		CPUTS("]\n");
	}
	CPRINTF("[Image: %s, %s]\n",
		 system_get_image_copy_string(), system_get_build_info());

#ifdef CONFIG_WATCHDOG
	/*
	 * Intialize watchdog timer.  All lengthy operations between now and
	 * task_start() must periodically call watchdog_reload() to avoid
	 * triggering a watchdog reboot.  (This pretty much applies only to
	 * verified boot, because all *other* lengthy operations should be done
	 * by tasks.)
	 */
	watchdog_init();
#endif

	/*
	 * Verified boot needs to read the initial keyboard state and EEPROM
	 * contents.  EEPROM must be up first, so keyboard_scan can toggle
	 * debugging settings via keys held at boot.
	 */
#ifdef CONFIG_EEPROM
	eeprom_init();
#endif
#ifdef CONFIG_EOPTION
	eoption_init();
#endif
#ifdef HAS_TASK_KEYSCAN
	keyboard_scan_init();
#endif

	/* Initialize the hook library.  This calls HOOK_INIT hooks. */
	hook_init();

	/*
	 * Print the init time.  Not completely accurate because it can't take
	 * into account the time before timer_init(), but it'll at least catch
	 * the majority of the time.
	 */
	CPRINTS("Inits done");

	/* Launch task scheduling (never returns) */
	return task_start();
}
Example #21
0
void  ds_task
(
  dword ignored
    /* lint -esym(715,ignored)
    ** Have lint not complain about the ignored parameter 'ignored' which is
    ** specified to make this routine match the template for rex_def_task().
    */
)
{
  rex_sigs_type   requested_sigs;   /* Signal mask to suspend on           */
  rex_sigs_type   set_sigs;         /* Signals set upon return from wait   */
  #ifndef FEATURE_DATA_STRIP_ATCOP
  rex_sigs_type   siolib_sigs = 0;  /* SIOLIB signals to suspend on        */
  rex_sigs_type   atcop_sigs  = 0;  /* ATCoP signals to suspend on         */
  #endif
  rex_sigs_type   ucsd_sigs   = 0;  /* UMTS CS Hdlr signals to suspend on */
  rex_sigs_type   wpsd_sigs   = 0;  /* WCDMA PS Hdlr signals to suspend on */
  rex_sigs_type   cdma_sigs   = 0;  /* CDMA sub-task signals to suspend on */
  #ifndef FEATURE_ASYNC_DATA_NOOP
  rex_sigs_type   async707_sigs= 0; /* 707 async signals to suspend on     */
  #endif /* FEATURE_ASYNC_DATA_NOOP */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  /*-------------------------------------------------------------------------
    Do task initialization. The init function performs all the task-level
    initialization.
  -------------------------------------------------------------------------*/
  dsi_task_init();

  /*-------------------------------------------------------------------------
    Initialize timers
  -------------------------------------------------------------------------*/
  ds3gi_timer_init();
  
  #ifndef FEATURE_DATA_STRIP_ATCOP
  /*-------------------------------------------------------------------------
    Initialize SIOLIB
  -------------------------------------------------------------------------*/
  siolib_sigs = ds3g_siolib_init();
  #endif
  
  /*-------------------------------------------------------------------------
    Wait for the task start signal from task controller.
  -------------------------------------------------------------------------*/
  task_start(DS_DOG_RPT_TIMER_SIG, DOG_DS_RPT, &ds_dog_rpt_timer);

  /*-------------------------------------------------------------------------
    Perform sub-task initialization. 
  -------------------------------------------------------------------------*/
#if defined(FEATURE_DATA_WCDMA_PS) || defined(FEATURE_GSM_GPRS)
#error code not present
#endif /*(FEATURE_DATA_WCDMA_PS) || defined(FEATURE_GSM_GPRS) */

  /*-------------------------------------------------------------------------
    Each sub-task returns a signal mask containing the signals it wishes 
    to suspend on. 
    Note that ATCoP initialization should always be performed first, 
    since other sub-tasks may use AT parameter values during initialization.
  -------------------------------------------------------------------------*/ 
#ifndef FEATURE_DATA_STRIP_ATCOP
  atcop_sigs = dsat_init();
#else
#ifdef FEATURE_UIM_SUPPORT_3GPD
  dsatprofile_init_me();
#endif /* FEATURE_UIM_SUPPORT_3GPD */
  dsatprofile_nv_sync();
#endif /* FEATURE_DATA_STRIP_ATCOP */

  ds3g_init();

#ifdef FEATURE_HDR
#error code not present
#endif /* FEATURE_HDR */

#if ((defined(FEATURE_WCDMA) && defined(FEATURE_DATA_WCDMA_CS)) || \
     (defined(FEATURE_GSM) && defined(FEATURE_DATA_GCSD)))
#error code not present
#endif

#if ((defined(FEATURE_WCDMA) && defined(FEATURE_DATA_WCDMA_PS)) || \
     (defined(FEATURE_GSM  ) && defined(FEATURE_GSM_GPRS)))
#error code not present
#endif

#if defined(FEATURE_DATA_IS707)
  /*-------------------------------------------------------------------------
    Make sure that Pkt iface is always initialized before Async iface. This
    is because ps_iface assigns instance numbers to iface in sequential 
    order. We want pkt iface to get instance 0...max_pkt_ifaces since Apps 
    call ioctls on pkt iface using those instance numbers.
  -------------------------------------------------------------------------*/
  cdma_sigs = ds707_pkt_mgr_init();
#ifndef FEATURE_ASYNC_DATA_NOOP
  async707_sigs= ds707_async_mgr_powerup_init();
#endif /*FEATURE_ASYNC_DATA_NOOP*/
#endif

  /*-------------------------------------------------------------------------
    Get DS NV Items.
  -------------------------------------------------------------------------*/
  dsi_nv_init();


  /*-------------------------------------------------------------------------
    Signal mask to suspend on is the combination of all the signals requested
    by each of the sub-tasks.
  -------------------------------------------------------------------------*/
  requested_sigs = DS_CMD_Q_SIG        | 
                   DS_TASK_STOP_SIG    | 
                   DS_TASK_OFFLINE_SIG |
                   #ifndef FEATURE_DATA_STRIP_ATCOP
                   siolib_sigs  | 
                   atcop_sigs   |
                   #endif                   
                   ucsd_sigs    |
                   wpsd_sigs    |
                   #ifndef FEATURE_ASYNC_DATA_NOOP
                   async707_sigs |
                   #endif /* FEATURE_ASYNC_DATA_NOOP */
                   cdma_sigs;                                     
                   

  /*-------------------------------------------------------------------------
    Main task loop, never exits.
  -------------------------------------------------------------------------*/
  for( ;; )
  {
    /*----------------------------------------------------------------------
      Wait for one of the specified signals to be set. Note that watchdog
      kicking is performed in the wait.
    -----------------------------------------------------------------------*/
    set_sigs = dsi_wait( requested_sigs );
	
	/*----------------------------------------------------------------------
	We used to individually clear the wrong set of signals and some signals
	were getting lost.  Here, we clear ds_tcb with set_sigs.  set_sigs is
	not altered.
	----------------------------------------------------------------------*/
    (void)rex_clr_sigs( &ds_tcb, set_sigs );

    /*----------------------------------------------------------------------
      If any of the task signals were received, invoke the function to ACK
      task conroller.
    -----------------------------------------------------------------------*/
    if( (set_sigs & DS_TASK_STOP_SIG) != 0 )
    {
      task_stop();
    }

    if( (set_sigs & DS_TASK_OFFLINE_SIG) != 0 )
    {
      task_offline();
    }
    /*----------------------------------------------------------------------
      If the command queue signal was set, clear the signal and invoke the
      function that dispatches commands to the appropriate sub-task.
    -----------------------------------------------------------------------*/
    if( (set_sigs & DS_CMD_Q_SIG) != 0 )
    {
      dsi_process_cmds();
    }

    /*----------------------------------------------------------------------
      If any of the 3G SIOLIB signals were set, clear the signals and invoke
      a function to process the signals.
    -----------------------------------------------------------------------*/
    #ifndef FEATURE_DATA_STRIP_ATCOP
    if( (set_sigs & siolib_sigs) != 0 )
    {
      ds3g_siolib_process_signals( set_sigs );
    }

    /*----------------------------------------------------------------------
      If any of the ATCoP signals were set, clear the signals and invoke a
      function to process the signals.
    -----------------------------------------------------------------------*/
    if( (set_sigs & atcop_sigs) != 0 )
    {
      dsat_process_async_signal( set_sigs );
    }
    #endif

#if ((defined(FEATURE_WCDMA) && defined(FEATURE_DATA_WCDMA_CS)) || \
     (defined(FEATURE_GSM) && defined(FEATURE_DATA_GCSD)))
#error code not present
#endif

#if ((defined(FEATURE_WCDMA) && defined(FEATURE_DATA_WCDMA_PS)) ||\
     (defined(FEATURE_GSM  ) && defined(FEATURE_GSM_GPRS)))
#error code not present
#endif

#if defined(FEATURE_DATA_IS707)
    /*----------------------------------------------------------------------
      If any of the WCDMA CS Hdlr signals were set, clear the signals and
      invoke a function to process the signals.
    -----------------------------------------------------------------------*/
    if( (set_sigs & cdma_sigs) != 0 )
    {
      ds707_pkt_process_signals( set_sigs );
    }

    /*----------------------------------------------------------------------
      If any of the WCDMA CS Hdlr signals were set, clear the signals and
      invoke a function to process the signals.
    -----------------------------------------------------------------------*/
#ifndef FEATURE_ASYNC_DATA_NOOP
    if( (set_sigs & async707_sigs) != 0 )
    {
      ds707_async_process_signals( set_sigs );
    }
#endif /* FEATURE_ASYNC_DATA_NOOP */
#endif

  } /* forever */
} /* ds_task() */
Example #22
0
File: tx.c Project: bgtwoigu/1110
void tx_task
(
  dword dummy
    /* Parameter required for REX.  Tell lint to ignore it. */
    /*lint -esym(715,dummy) */
)
{

  rex_sigs_type rex_signals_mask;  /* Mask of signals returned by rex */

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /*------------------------*/
  /* Perform initialization */
  /*------------------------*/
#ifdef FEATURE_ACP
#error code not present
#endif /* FEATURE_ACP */
  txc_powerup_init();

  /*------------------*/
  /* Initialize timer */
  /*------------------*/
  rex_def_timer( &tx_rpt_timer, &tx_tcb, TX_RPT_TIMER_SIG );

  /*-----------------------------------------------------*/
  /* Process task startup procedure from task controller */
  /*-----------------------------------------------------*/
   task_start(
    TX_RPT_TIMER_SIG,             /* report timer signal for task */
    DOG_TX_RPT,                   /* watchdog report signal */
    &tx_rpt_timer                 /* pointer to report timer */
  );

  /*--------------------------------------------------------------------*/
  /* Initially kick watchdog and set timer for watchdog report interval */
  /*--------------------------------------------------------------------*/
  TX_WATCHDOG_REPORT( );

  for (;;) { /* Never exit this loop... */

#ifdef FEATURE_ACP
#error code not present
#else
    rex_signals_mask =
      rex_wait( TX_RPT_TIMER_SIG | TX_CDMA_CMD_Q_SIG |
                TASK_OFFLINE_SIG | TASK_STOP_SIG );
#endif

    if ((rex_signals_mask & TX_RPT_TIMER_SIG) != 0) {
      /*-------------------------------*/
      /* Kick watchdog and reset timer */
      /*-------------------------------*/
      TX_WATCHDOG_REPORT( );
    }

    /*---------------------------------------------------------*/
    /* Check if powerdown command signal was set.  If set then */
    /* clear signal, process task stop procedure, and proceed. */
    /*---------------------------------------------------------*/
    if ((rex_signals_mask & TASK_STOP_SIG) != 0) {
      MSG_MED( "TASK_STOP_SIG received", 0,0,0 );
      (void) rex_clr_sigs( &tx_tcb, TASK_STOP_SIG );
      task_stop();

      #if (TG==T_PC)
#error code not present
      #endif
    }

    /*-------------------------------------------------------*/
    /* Check if offline command signal was set.  If set then */
    /* clear signal, process task offline procedure, and     */
    /* proceed.                                              */
    /*-------------------------------------------------------*/
    if ((rex_signals_mask & TASK_OFFLINE_SIG) != 0) {
      MSG_MED( "TASK_OFFLINE_SIG received", 0,0,0 );
      (void) rex_clr_sigs( &tx_tcb, TASK_OFFLINE_SIG );
      task_offline();
    }

    /*------------------------------------------------------------------*/
    /* The (analog or CDMA) MC subtask indicates it wishes to acvtivate */
    /* the (analog or CDMA) subtask by setting the command queue signal */
    /* (via a call to acptx_cmd() or txc_cmd()).                        */
    /*------------------------------------------------------------------*/
    if ((rex_signals_mask & TX_CDMA_CMD_Q_SIG) != 0)
    {
      /*--------------------------------------------------------*/
      /* Clear watchdog timer before passing control to subtask */
      /*--------------------------------------------------------*/
      TX_CLEAR_WATCHDOG_TIMER( );

      /*------------------------------------*/
      /* Activate the CDMA Transmit subtask */
      /*------------------------------------*/
      MSG_LOW( "Entering txc_subtask", 0,0,0 );

      txc_subtask();

      MSG_LOW( "Exiting txc_subtask", 0,0,0 );

      /*-------------------------------*/
      /* Kick watchdog and reset timer */
      /*-------------------------------*/
      TX_WATCHDOG_REPORT( );
    } /* end if ((rex_signals_mask & TX_CDMA_CMD_Q_SIG) != 0) */

#ifdef FEATURE_ACP
#error code not present
#endif /* FEATURE_ACP */
  } /* end for (;;) */
} /* end tx_task */
Example #23
0
test_mockable __keep int main(void)
{
#ifdef CONFIG_REPLACE_LOADER_WITH_BSS_SLOW
	/*
	 * Now that we have started execution, we no longer need the loader.
	 * Instead, variables placed in the .bss.slow section will use this
	 * space.  Therefore, clear out this region now.
	 */
	memset((void *)(CONFIG_PROGRAM_MEMORY_BASE + CONFIG_LOADER_MEM_OFF), 0,
	       CONFIG_LOADER_SIZE);
#endif /* defined(CONFIG_REPLACE_LOADER_WITH_BSS_SLOW) */
	/*
	 * Pre-initialization (pre-verified boot) stage.  Initialization at
	 * this level should do as little as possible, because verified boot
	 * may need to jump to another image, which will repeat this
	 * initialization.  In particular, modules should NOT enable
	 * interrupts.
	 */
#ifdef CONFIG_BOARD_PRE_INIT
	board_config_pre_init();
#endif

#ifdef CONFIG_MPU
	mpu_pre_init();
#endif

	/* Configure the pin multiplexers and GPIOs */
	jtag_pre_init();
	gpio_pre_init();

#ifdef CONFIG_BOARD_POST_GPIO_INIT
	board_config_post_gpio_init();
#endif
	/*
	 * Initialize interrupts, but don't enable any of them.  Note that
	 * task scheduling is not enabled until task_start() below.
	 */
	task_pre_init();

	/*
	 * Initialize the system module.  This enables the hibernate clock
	 * source we need to calibrate the internal oscillator.
	 */
	system_pre_init();
	system_common_pre_init();

#ifdef CONFIG_FLASH
	/*
	 * Initialize flash and apply write protect if necessary.  Requires
	 * the reset flags calculated by system initialization.
	 */
	flash_pre_init();
#endif

#if defined(CONFIG_CASE_CLOSED_DEBUG)
	/*
	 * If the device is locked we assert PD_NO_DEBUG, preventing the EC
	 * from interfering with the AP's access to the SPI flash.
	 * The PD_NO_DEBUG signal is latched in hardware, so changing this
	 * GPIO later has no effect.
	 */
	gpio_set_level(GPIO_PD_DISABLE_DEBUG, system_is_locked());
#endif

	/* Set the CPU clocks / PLLs.  System is now running at full speed. */
	clock_init();

	/*
	 * Initialize timer.  Everything after this can be benchmarked.
	 * get_time() and udelay() may now be used.  usleep() requires task
	 * scheduling, so cannot be used yet.  Note that interrupts declared
	 * via DECLARE_IRQ() call timer routines when profiling is enabled, so
	 * timer init() must be before uart_init().
	 */
	timer_init();

	/* Main initialization stage.  Modules may enable interrupts here. */
	cpu_init();

#ifdef CONFIG_DMA
	/* Initialize DMA.  Must be before UART. */
	dma_init();
#endif

	/* Initialize UART.  Console output functions may now be used. */
	uart_init();

	if (system_jumped_to_this_image()) {
		CPRINTS("UART initialized after sysjump");
	} else {
		CPUTS("\n\n--- UART initialized after reboot ---\n");
		CPUTS("[Reset cause: ");
		system_print_reset_flags();
		CPUTS("]\n");
	}
	CPRINTF("[Image: %s, %s]\n",
		 system_get_image_copy_string(), system_get_build_info());

#ifdef CONFIG_BRINGUP
	ccprintf("\n\nWARNING: BRINGUP BUILD\n\n\n");
#endif

#ifdef CONFIG_WATCHDOG
	/*
	 * Intialize watchdog timer.  All lengthy operations between now and
	 * task_start() must periodically call watchdog_reload() to avoid
	 * triggering a watchdog reboot.  (This pretty much applies only to
	 * verified boot, because all *other* lengthy operations should be done
	 * by tasks.)
	 */
	watchdog_init();
#endif

	/*
	 * Verified boot needs to read the initial keyboard state and EEPROM
	 * contents.  EEPROM must be up first, so keyboard_scan can toggle
	 * debugging settings via keys held at boot.
	 */
#ifdef CONFIG_EEPROM
	eeprom_init();
#endif
#ifdef HAS_TASK_KEYSCAN
	keyboard_scan_init();
#endif

#ifdef CONFIG_RWSIG
	/*
	 * Check the RW firmware signature
	 * and eventually jump to it if it is good.
	 */
	check_rw_signature();
#endif

	/*
	 * Print the init time.  Not completely accurate because it can't take
	 * into account the time before timer_init(), but it'll at least catch
	 * the majority of the time.
	 */
	CPRINTS("Inits done");

	/* Launch task scheduling (never returns) */
	return task_start();
}