Exemplo n.º 1
0
__naked void os_sys_init1 (void) {
  /* Initialize system and start up a first task. */
  U32 i;

  rt_init ();
  tsk_lock ();

  /* Initialize dynamic memory and task TCB pointers to NULL. */
  for (i = 0; i < os_maxtaskrun; i++) {
    os_active_TCB[i] = NULL;
  }
  _init_box (&mp_tcb, mp_tcb_size, sizeof(struct OS_TCB));
  _init_box (&mp_stk, mp_stk_size, BOX_ALIGN_8 | (U16)(os_stackinfo));
  _init_box ((U32 *)m_tmr, mp_tmr_size, sizeof(struct OS_TMR));

  /* Set up TCB of idle demon */
  os_idle_TCB.task_id    = 255;
  os_idle_TCB.priv_stack = 0;
  os_init_context (&os_idle_TCB, 0, os_idle_demon, __FALSE);

  /* Set up ready list: initially empty */
  os_rdy.cb_type = HCB;
  os_rdy.p_lnk   = NULL;
  /* Set up delay list: initially empty */
  os_dly.cb_type = HCB;
  os_dly.p_dlnk  = NULL;
  os_dly.p_blnk  = NULL;
  os_dly.delta_time = 0;

  /* Fix SP and system variables to assume idle task is running */
  /* Transform main program into idle task by assuming idle TCB */
  os_set_env (&os_idle_TCB);
  os_runtask = &os_idle_TCB;
  os_runtask->state = RUNNING;

  /* Initialize ps queue */
  os_psq->first = 0;
  os_psq->last  = 0;
  os_psq->size  = os_fifo_size;

  /* Initialize system clock timer */
  os_tmr_init ();
  os_init_robin ();

  /* Start up first user task before entering the endless loop */
  os_sys_run ((FUNCP)os_tsk_create0);

  /* Call body of idle task: contains an endless loop */
  os_idle_demon();

  /* This point never reached if idle task contains endless loop */
  for (;;);
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------------
 *        Main: Initialize and start RTX Kernel
 *---------------------------------------------------------------------------*/
int main (void) {                     /* program execution starts here       */

 	SystemInit();         /* initialize the LPC17xx MCU */
  uart0_init();         /* initilize the first UART */
  
	

  printf("Calling os_sys_init()...\n");

	
	_init_box (mpool, sizeof(mpool),    /* initialize the 'mpool' memory for   */
              sizeof(T_NUM));        /* the membox dynamic allocation       */
	os_sys_init(init);	  /* initilize the OS and start the first task */
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------*/
__task void init(void)
{
	//Initialize the memory pool
	_init_box(box_mem, sizeof(box_mem), 4);
	
  os_mut_init(&g_mut_uart);
  
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: TID = %d\n", os_tsk_self());
  os_mut_release(g_mut_uart);
  
	g_tid = os_tsk_create(task1, 1);  /* task 1 at priority 1 */
	os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task1 with TID %d\n", g_tid);
  os_mut_release(g_mut_uart);
  
  g_tid = os_tsk_create(task2, 4);  /* task 2 at priority 2 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task2 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task3, 3);  /* task 3 at priority 3 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task3 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task4, 4);  /* task 4 at priority 4 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task4 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task5, 1);  /* task 5 at priority 1 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task5 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
  os_tsk_delete_self();     /* task MUST delete itself before exiting */
}