📄 artx_config.lst
字号:
317 1 } /* end of os_tmr_force_irq */
318
319 /*--------------------------- os_tmr_inspect_cnt ----------------------------*/
320
321 U32 os_tmr_inspect_cnt (void) {
322 1 /* Inspect current value of rtx timer. */
ARM COMPILER V2.50a, ARTX_Config 05/04/06 21:09:48 PAGE 6
323 1 return (OS_TVAL);
324 1 } /* end of os_tmr_inspect_cnt */
325
326 /*--------------------------- os_tmr_inspect_ovf ----------------------------*/
327
328 BOOL os_tmr_inspect_ovf (void) {
329 1 /* Inspect current state of timer overflow flag. */
330 1 return (OS_TOVF);
331 1 } /* end of os_tmr_inspect_ovf */
332
333 /*--------------------------- tsk_lock --------------------------------------*/
334
335 void tsk_lock (void) {
336 1 /* Lock out tasks: prevents task switching by locking out scheduler */
337 1 /* activation on interrupt. . */
338 1 OS_LOCK();
339 1 } /* end of tsk_lock */
340
341 /*--------------------------- tsk_unlock ------------------------------------*/
342
343 void tsk_unlock (void) {
344 1 /* Enable AR System Tick Timer Interrupts. */
345 1 OS_UNLOCK();
346 1 } /* end of tsk_unlock */
347
348 /*--------------------------- os_init_mem -----------------------------------*/
349
350 void os_init_mem (void) {
351 1 U32 i;
352 1
353 1 for (i = 0; i < OS_TASKCNT; i++) {
354 2 os_active_TCB[i] = NULL;
355 2 }
356 1 _init_box (&m_tcb, sizeof(m_tcb), sizeof(struct OS_TCB));
357 1 _init_box (&m_stk, sizeof(m_stk), OS_STKSIZE*4);
358 1 #if (OS_TIMERCNT != 0)
_init_box (&m_tmr, sizeof(m_tmr), sizeof(struct OS_TMR));
#endif
361 1 } /* end of os_init_mem */
362
363 /*--------------------------- os_alloc_TCB ----------------------------------*/
364
365 P_TCB os_alloc_TCB () {
366 1 return (_alloc_box (m_tcb));
367 1 } /* end of os_alloc_TCB */
368
369 /*--------------------------- os_free_TCB -----------------------------------*/
370
371 void os_free_TCB (P_TCB p_TCB) {
372 1 /* Free allocated memory resources for the task "p_TCB" */
373 1 _free_box (m_stk, p_TCB->stack);
374 1 _free_box (m_tcb, p_TCB);
375 1 #if (OS_STKCHECK == 1)
376 1 if (os_runtask == p_TCB) {
377 2 /* os_tsk_delete_self() called. */
378 2 os_del_flag = __TRUE;
379 2 }
380 1 #endif
381 1 } /* end of os_free_TCB */
382
383 /*--------------------------- os_alloc_TMR ----------------------------------*/
384
385 P_TMR os_alloc_TMR () {
386 1 #if (OS_TIMERCNT != 0)
return (_alloc_box (m_tmr));
#else
ARM COMPILER V2.50a, ARTX_Config 05/04/06 21:09:48 PAGE 7
389 1 return (NULL);
390 1 #endif
391 1 } /* end of os_alloc_TMR */
392
393 /*--------------------------- os_free_TMR -----------------------------------*/
394
395 void os_free_TMR (P_TMR timer) {
396 1 /* Free allocated memory resources for user timer 'timer' */
397 1 #if (OS_TIMERCNT != 0)
_free_box (m_tmr, timer);
#else
400 1 timer = timer;
401 1 #endif
402 1 } /* end of os_free_TMR */
403
404 /*--------------------------- os_init_context -------------------------------*/
405
406 void os_init_context (P_TCB p_TCB, U8 priority,
407 FUNCP task_body, U8 full_context) {
408 1 /* Prepare TCB and saved context for a first time start of a task */
409 1 /* "p_TCB" points to TCB to be initialised. "priority" indicates desired */
410 1 /* execution priority. "task_body" is the start address of the task. */
411 1 /* "full_context" identifies context type. */
412 1 U32 *stk,i;
413 1
414 1 /* Initialize general part of TCB */
415 1 p_TCB->cb_type = TCB;
416 1 p_TCB->state = READY;
417 1 p_TCB->prio = priority;
418 1 p_TCB->p_lnk = NULL;
419 1 p_TCB->p_rlnk = NULL;
420 1 p_TCB->p_dlnk = NULL;
421 1 p_TCB->p_blnk = NULL;
422 1 p_TCB->delta_time = 0;
423 1 p_TCB->interval_time = 0;
424 1 p_TCB->events = 0;
425 1 p_TCB->waits = 0;
426 1
427 1 /* Initialize ARM specific part of TCB */
428 1 p_TCB->full_ctx = full_context;
429 1
430 1 /* Prepare a complete interrupt frame for first task start */
431 1 if (p_TCB->priv_stack != 0) {
432 2 /* User has provided a memory space for the stack. */
433 2 stk = &p_TCB->stack[p_TCB->priv_stack>>2];
434 2 }
435 1 else {
436 2 /* Allocate the memory space for the stack. */
437 2 p_TCB->stack = _alloc_box (m_stk);
438 2 /* Write to the top of stack. */
439 2 stk = &p_TCB->stack[OS_STKSIZE];
440 2 }
441 1
442 1 /* Initial PC and default CPSR */
443 1 *--stk = (U32)task_body;
444 1 i = INITIAL_CPSR;
445 1
446 1 /* If a task in THUMB mode, set T-bit. */
447 1 if ((U32)task_body & 1) {
448 2 i |= 0x00000020;
449 2 }
450 1 *--stk = i;
451 1
452 1 /* Write initial registers. */
453 1 for (i = full_context ? 13 : 4; i; i--) {
454 2 *--stk = 0;
ARM COMPILER V2.50a, ARTX_Config 05/04/06 21:09:48 PAGE 8
455 2 }
456 1
457 1 /* For "full_context" assign a void pointer to R0. */
458 1 if (full_context) {
459 2 *--stk = (U32)p_TCB->p_msg;
460 2 }
461 1
462 1 /* Initial Task stack pointer. */
463 1 p_TCB->tsk_stack = (U32)stk;
464 1
465 1 /* Task entry point. */
466 1 p_TCB->ptask = task_body;
467 1 #if (OS_STKCHECK == 1)
468 1 /* Set a magic word for checking of stack overflow. */
469 1 p_TCB->stack[0] = MAGIC_WORD;
470 1 #endif
471 1 } /* end of os_init_context */
472
473
474 /*--------------------------- os_set_env ------------------------------------*/
475
476 void os_set_env (P_TCB p_TCB) {
477 1 /* Fix up runtime environment to fit idle task. It is called after the */
478 1 /* idle task TCB initialization. "p_TCB" identifies the TCB to be used. */
479 1 p_TCB = p_TCB;
480 1 __asm {
481 1 LDR R0,[R0,#TCB_TSTACK] ; p_TCB in R0
482 1 MOV SP,R0
483 1 ADD SP,SP,#24 ; ignore default context
484 1 }
485 1 } /* end of os_set_env */
486
487
488 /*--------------------------- os_switch_tasks -------------------------------*/
489
490 void os_switch_tasks (P_TCB p_new) __swi (0) {
491 1 /* Switch to next task (identified by "p_new"). Saving old and restoring */
492 1 /* new context is written in assembly (module: Swi_ARTX.s) */
493 1
494 1 #if (OS_STKCHECK == 1)
495 1 if (tstclrb (&os_del_flag) == __FALSE) {
496 2 /* Do not check if task has deleted itself. */
497 2 if ((os_runtask->tsk_stack < (U32)os_runtask->stack) ||
498 2 (os_runtask->stack[0] != MAGIC_WORD )) {
499 3 os_stk_overflow ();
500 3 }
501 2 }
502 1 #endif
503 1 os_runtask->full_ctx = __FALSE;
504 1 os_runtask = p_new;
505 1 p_new->state = RUNNING;
506 1 #if (OS_ROBIN == 1)
507 1 if (p_new->full_ctx == __TRUE) {
508 2 os_tsk_robin = p_new;
509 2 }
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. */
ARM COMPILER V2.50a, ARTX_Config 05/04/06 21:09:48 PAGE 9
521 1 #if (OS_ROBIN == 1)
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.50a, ARTX_Config 05/04/06 21:09:48 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.50a, ARTX_Config 05/04/06 21:09:48 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 0006 DW 0x6
00000012 END_INIT
*** DATA SEGMENT '?DT0?ARTX_Config':
00000000 m_tcb:
00000000 DS 300
0000012C m_stk:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -