?? artx_config.lst
字號:
317 1 /* Force a timer interrupt. */
318 1 OS_TFIRQ();
319 1 } /* end of os_tmr_force_irq */
320
321 /*--------------------------- os_tmr_inspect_cnt ----------------------------*/
322
323 U32 os_tmr_inspect_cnt (void) {
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 6
324 1 /* Inspect current value of rtx timer. */
325 1 return (OS_TVAL);
326 1 } /* end of os_tmr_inspect_cnt */
327
328 /*--------------------------- os_tmr_inspect_ovf ----------------------------*/
329
330 BOOL os_tmr_inspect_ovf (void) {
331 1 /* Inspect current state of timer overflow flag. */
332 1 return (OS_TOVF);
333 1 } /* end of os_tmr_inspect_ovf */
334
335 /*--------------------------- tsk_lock --------------------------------------*/
336
337 void tsk_lock (void) {
338 1 /* Lock out tasks: prevents task switching by locking out scheduler */
339 1 /* activation on interrupt. . */
340 1 OS_LOCK();
341 1 } /* end of tsk_lock */
342
343 /*--------------------------- tsk_unlock ------------------------------------*/
344
345 void tsk_unlock (void) {
346 1 /* Enable AR System Tick Timer Interrupts. */
347 1 OS_UNLOCK();
348 1 } /* end of tsk_unlock */
349
350 /*--------------------------- os_init_mem -----------------------------------*/
351
352 void os_init_mem (void) {
353 1 U32 i;
354 1
355 1 for (i = 0; i < OS_TASKCNT; i++) {
356 2 os_active_TCB[i] = NULL;
357 2 }
358 1 _init_box (&m_tcb, sizeof(m_tcb), sizeof(struct OS_TCB));
359 1 _init_box (&m_stk, sizeof(m_stk), OS_STKSIZE*4);
360 1 #if (OS_TIMERCNT != 0)
_init_box (&m_tmr, sizeof(m_tmr), sizeof(struct OS_TMR));
#endif
363 1 } /* end of os_init_mem */
364
365 /*--------------------------- os_alloc_TCB ----------------------------------*/
366
367 P_TCB os_alloc_TCB () {
368 1 return (_alloc_box (m_tcb));
369 1 } /* end of os_alloc_TCB */
370
371 /*--------------------------- os_free_TCB -----------------------------------*/
372
373 void os_free_TCB (P_TCB p_TCB) {
374 1 /* Free allocated memory resources for the task "p_TCB" */
375 1 _free_box (m_stk, p_TCB->stack);
376 1 _free_box (m_tcb, p_TCB);
377 1 #if (OS_STKCHECK == 1)
378 1 if (os_runtask == p_TCB) {
379 2 /* os_tsk_delete_self() called. */
380 2 os_del_flag = __TRUE;
381 2 }
382 1 #endif
383 1 } /* end of os_free_TCB */
384
385 /*--------------------------- os_alloc_TMR ----------------------------------*/
386
387 P_TMR os_alloc_TMR () {
388 1 #if (OS_TIMERCNT != 0)
return (_alloc_box (m_tmr));
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 7
#else
391 1 return (NULL);
392 1 #endif
393 1 } /* end of os_alloc_TMR */
394
395 /*--------------------------- os_free_TMR -----------------------------------*/
396
397 void os_free_TMR (P_TMR timer) {
398 1 /* Free allocated memory resources for user timer 'timer' */
399 1 #if (OS_TIMERCNT != 0)
_free_box (m_tmr, timer);
#else
402 1 timer = timer;
403 1 #endif
404 1 } /* end of os_free_TMR */
405
406 /*--------------------------- os_init_context -------------------------------*/
407
408 void os_init_context (P_TCB p_TCB, U8 priority,
409 FUNCP task_body, U8 full_context) {
410 1 /* Prepare TCB and saved context for a first time start of a task */
411 1 /* "p_TCB" points to TCB to be initialised. "priority" indicates desired */
412 1 /* execution priority. "task_body" is the start address of the task. */
413 1 /* "full_context" identifies context type. */
414 1 U32 *stk,i;
415 1
416 1 /* Initialize general part of TCB */
417 1 p_TCB->cb_type = TCB;
418 1 p_TCB->state = READY;
419 1 p_TCB->prio = priority;
420 1 p_TCB->p_lnk = NULL;
421 1 p_TCB->p_rlnk = NULL;
422 1 p_TCB->p_dlnk = NULL;
423 1 p_TCB->p_blnk = NULL;
424 1 p_TCB->delta_time = 0;
425 1 p_TCB->interval_time = 0;
426 1 p_TCB->events = 0;
427 1 p_TCB->waits = 0;
428 1
429 1 /* Initialize ARM specific part of TCB */
430 1 p_TCB->full_ctx = full_context;
431 1
432 1 /* Prepare a complete interrupt frame for first task start */
433 1 if (p_TCB->priv_stack != 0) {
434 2 /* User has provided a memory space for the stack. */
435 2 stk = &p_TCB->stack[p_TCB->priv_stack>>2];
436 2 }
437 1 else {
438 2 /* Allocate the memory space for the stack. */
439 2 p_TCB->stack = _alloc_box (m_stk);
440 2 /* Write to the top of stack. */
441 2 stk = &p_TCB->stack[OS_STKSIZE];
442 2 }
443 1
444 1 /* Initial PC and default CPSR */
445 1 *--stk = (U32)task_body;
446 1 i = INITIAL_CPSR;
447 1
448 1 /* If a task in THUMB mode, set T-bit. */
449 1 if ((U32)task_body & 1) {
450 2 i |= 0x00000020;
451 2 }
452 1 *--stk = i;
453 1
454 1 /* Write initial registers. */
455 1 for (i = full_context ? 13 : 4; i; i--) {
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 8
456 2 *--stk = 0;
457 2 }
458 1
459 1 /* For "full_context" assign a void pointer to R0. */
460 1 if (full_context) {
461 2 *--stk = (U32)p_TCB->p_msg;
462 2 }
463 1
464 1 /* Initial Task stack pointer. */
465 1 p_TCB->tsk_stack = (U32)stk;
466 1
467 1 /* Task entry point. */
468 1 p_TCB->ptask = task_body;
469 1 #if (OS_STKCHECK == 1)
470 1 /* Set a magic word for checking of stack overflow. */
471 1 p_TCB->stack[0] = MAGIC_WORD;
472 1 #endif
473 1 } /* end of os_init_context */
474
475
476 /*--------------------------- os_set_env ------------------------------------*/
477
478 void os_set_env (P_TCB p_TCB) {
479 1 /* Fix up runtime environment to fit idle task. It is called after the */
480 1 /* idle task TCB initialization. "p_TCB" identifies the TCB to be used. */
481 1 p_TCB = p_TCB;
482 1 __asm {
483 1 LDR R0,[R0,#TCB_TSTACK] ; p_TCB in R0
484 1 MOV SP,R0
485 1 ADD SP,SP,#24 ; ignore default context
486 1 }
487 1 } /* end of os_set_env */
488
489
490 /*--------------------------- os_switch_tasks -------------------------------*/
491
492 void os_switch_tasks (P_TCB p_new) __swi (0) {
493 1 /* Switch to next task (identified by "p_new"). Saving old and restoring */
494 1 /* new context is written in assembly (module: Swi_ARTX.s) */
495 1
496 1 #if (OS_STKCHECK == 1)
497 1 if (tstclrb (&os_del_flag) == __FALSE) {
498 2 /* Do not check if task has deleted itself. */
499 2 if ((os_runtask->tsk_stack < (U32)os_runtask->stack) ||
500 2 (os_runtask->stack[0] != MAGIC_WORD )) {
501 3 os_stk_overflow ();
502 3 }
503 2 }
504 1 #endif
505 1 os_runtask->full_ctx = __FALSE;
506 1 os_runtask = p_new;
507 1 p_new->state = RUNNING;
508 1 #if (OS_ROBIN == 1)
509 1 os_tsk_robin = p_new;
510 1 #endif
511 1 /* Tsk_Unlock */
512 1 OS_UNLOCK();
513 1 } /* end of os_switch_tasks */
514
515
516 /*--------------------------- os_chk_robin ----------------------------------*/
517
518 void os_chk_robin (void) {
519 1 /* Check if Round Robin timeout expired and switch to the next ready task.*/
520 1 /* This function is called from the "os_clock_demon()" task scheduler. */
521 1 #if (OS_ROBIN == 1)
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 9
522 1 P_TCB p_new;
523 1
524 1 if (os_rdy.p_lnk != os_tsk_robin) {
525 2 os_robin_time = os_time + OS_ROBINTOUT;
526 2 return;
527 2 }
528 1 if (os_robin_time == os_time) {
529 2 /* Round Robin timeout has expired. */
530 2 os_robin_time += OS_ROBINTOUT;
531 2 p_new = os_get_first (&os_rdy);
532 2 os_put_prio ((P_XCB)&os_rdy, p_new);
533 2 }
534 1 #endif
535 1 } /* end of os_chk_robin */
536
537 /*----------------------------------------------------------------------------
538 * end of file
539 *---------------------------------------------------------------------------*/
540
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 10
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (os_put_rdy_first?T)
EXTERN CODE16 (os_put_prio?T)
EXTERN CODE16 (os_get_first?T)
EXTERN CODE32 (tstclrb?A)
EXTERN CODE16 (os_get_TID?T)
EXTERN CODE16 (_init_box?T)
EXTERN CODE16 (_alloc_box?T)
EXTERN CODE16 (_free_box?T)
EXTERN DATA (os_runtask)
EXTERN DATA (os_rdy)
EXTERN DATA (os_clock_TCB)
EXTERN DATA (os_time)
EXTERN CODE32 (os_put_rdy_first?A)
EXTERN CODE16 (tstclrb?T)
*** PUBLICS:
PUBLIC os_init_context?T
PUBLIC os_init_context?A
PUBLIC os_init_mem?T
PUBLIC os_init_mem?A
PUBLIC os_alloc_TCB?T
PUBLIC os_alloc_TCB?A
PUBLIC os_free_TCB?T
PUBLIC os_free_TCB?A
PUBLIC os_set_env?T
PUBLIC os_set_env?A
PUBLIC os_switch_tasks?T
PUBLIC os_switch_tasks?A
PUBLIC tsk_lock?T
PUBLIC tsk_lock?A
PUBLIC tsk_unlock?T
PUBLIC tsk_unlock?A
PUBLIC os_tmr_call?T
PUBLIC os_tmr_call?A
PUBLIC os_alloc_TMR?T
PUBLIC os_alloc_TMR?A
PUBLIC os_free_TMR?T
PUBLIC os_free_TMR?A
PUBLIC os_idle_demon?T
PUBLIC os_idle_demon?A
PUBLIC os_tmr_init?T
PUBLIC os_tmr_init?A
PUBLIC os_tmr_reload?T
PUBLIC os_tmr_reload?A
PUBLIC os_tmr_force_irq?T
PUBLIC os_tmr_force_irq?A
PUBLIC os_tmr_inspect_cnt?T
PUBLIC os_tmr_inspect_cnt?A
PUBLIC os_tmr_inspect_ovf?T
PUBLIC os_tmr_inspect_ovf?A
PUBLIC os_chk_robin?T
PUBLIC os_chk_robin?A
PUBLIC os_clock_interrupt?A
PUBLIC os_clock_interrupt?T
PUBLIC os_def_interrupt?A
PUBLIC os_def_interrupt?T
PUBLIC os_maxtaskrun
PUBLIC os_stackinfo
PUBLIC os_clockrate
PUBLIC os_timernum
PUBLIC os_rrobin
PUBLIC os_active_TCB
ARM COMPILER V2.42, ARTX_Config 20/01/06 15:26:03 PAGE 11
*** DATA SEGMENT '?CON?ARTX_Config':
00000000 os_stackinfo:
00000000 BEGIN_INIT
00000000 010000C8 DD 0x10000C8
00000004 END_INIT
00000004 os_clockrate:
00000004 BEGIN_INIT
00000004 00002710 DD 0x2710
00000008 END_INIT
00000008 os_timernum:
00000008 BEGIN_INIT
00000008 00010000 DD 0x10000
0000000C END_INIT
0000000C os_rrobin:
0000000C BEGIN_INIT
0000000C 00010005 DD 0x10005
00000010 END_INIT
00000010 os_maxtaskrun:
00000010 BEGIN_INIT
00000010 000A DW 0xA
00000012 END_INIT
*** DATA SEGMENT '?DT0?ARTX_Config':
00000000 m_tcb:
00000000 DS 492
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -