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