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