⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_cpu_c.s

📁 ucos在avr mega128上的移植
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module OS_CPU_C.C
	.area vector(rom, abs)
	.org 64
	jmp _OSTickISR
	.area text(rom, con, rel)
	.even
_OSInitHookBegin::
L1:
	.dbline 0 ; func end
	ret
	.even
_OSInitHookEnd::
; /*
; *********************************************************************************************************
; *                                              uC/OS-II
; *                                        The Real-Time Kernel
; * 
; *                                       ATmega128 Specific code
; *
; * File     : OS_CPU_C.C
; * By       : Ole Saether
; *            Jean J. Labrosse
; *********************************************************************************************************
; */
; 
; #define  OS_CPU_GLOBALS
; #include	<ucos_ii.h>
; 
; /*
; *********************************************************************************************************
; *                                       OS INITIALIZATION HOOK
; *                                            (BEGINNING)
; *
; * Description: This function is called by OSInit() at the beginning of OSInit().
; *
; * Arguments  : none
; *
; * Note(s)    : 1) Interrupts should be disabled during this call.
; *********************************************************************************************************
; */
; #if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
; void  OSInitHookBegin (void)
; {
; }
; #endif
; 
; /*
; *********************************************************************************************************
; *                                       OS INITIALIZATION HOOK
; *                                               (END)
; *
; * Description: This function is called by OSInit() at the end of OSInit().
; *
; * Arguments  : none
; *
; * Note(s)    : 1) Interrupts should be disabled during this call.
; *********************************************************************************************************
; */
; #if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
; void  OSInitHookEnd (void)
; {
L2:
	.dbline 0 ; func end
	ret
;           ptcb -> R16,R17
	.even
_OSTaskCreateHook::
; }
; #endif
; 
; /*$PAGE*/
; /*
; *********************************************************************************************************
; *                                          TASK CREATION HOOK
; *
; * Description: This function is called when a task is created.
; *
; * Arguments  : ptcb   is a pointer to the task control block of the task being created.
; *
; * Note(s)    : 1) Interrupts are disabled during this call.
; *********************************************************************************************************
; */
; #if OS_CPU_HOOKS_EN > 0 
; void  OSTaskCreateHook (OS_TCB *ptcb)
; {
; #ifdef OS_VIEW_MODULE
;     OSView_TaskCreateHook(ptcb);
; #else
;     ptcb = ptcb;                       /* Prevent compiler warning                                     */
L3:
	.dbline 0 ; func end
	ret
;           ptcb -> R16,R17
	.even
_OSTaskDelHook::
; #endif
; }
; #endif
; 
; 
; /*
; *********************************************************************************************************
; *                                           TASK DELETION HOOK
; *
; * Description: This function is called when a task is deleted.
; *
; * Arguments  : ptcb   is a pointer to the task control block of the task being deleted.
; *
; * Note(s)    : 1) Interrupts are disabled during this call.
; *********************************************************************************************************
; */
; #if OS_CPU_HOOKS_EN > 0 
; void  OSTaskDelHook (OS_TCB *ptcb)
; {
;     ptcb = ptcb;                       /* Prevent compiler warning                                     */
L4:
	.dbline 0 ; func end
	ret
	.even
_OSTaskIdleHook::
; }
; #endif
; 
; /*
; *********************************************************************************************************
; *                                             IDLE TASK HOOK
; *
; * Description: This function is called by the idle task.  This hook has been added to allow you to do  
; *              such things as STOP the CPU to conserve power.
; *
; * Arguments  : none
; *
; * Note(s)    : 1) Interrupts are enabled during this call.
; *********************************************************************************************************
; */
; #if OS_CPU_HOOKS_EN > 0 && OS_VERSION >= 251
; void  OSTaskIdleHook (void)
; {
L5:
	.dbline 0 ; func end
	ret
	.even
_OSTaskStatHook::
; }
; #endif
; 
; /*
; *********************************************************************************************************
; *                                           STATISTIC TASK HOOK
; *
; * Description: This function is called every second by uC/OS-II's statistics task.  This allows your 
; *              application to add functionality to the statistics task.
; *
; * Arguments  : none
; *********************************************************************************************************
; */
; 
; #if OS_CPU_HOOKS_EN > 0 
; void  OSTaskStatHook (void)
; {
L6:
	.dbline 0 ; func end
	ret
;      phard_stk -> R10,R11
;            tmp -> R22,R23
;      psoft_stk -> R20,R21
;            opt -> y+8
;           ptos -> y+6
;          p_arg -> R18,R19
;           task -> R16,R17
	.even
_OSTaskStkInit::
	xcall push_gset3
; }
; #endif
; 
; /*$PAGE*/
; /*
; **********************************************************************************************************
; *                                       INITIALIZE A TASK'S STACK
; *
; * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
; *              stack frame of the task being created. This function is highly processor specific.
; *
; * Arguments  : task          is a pointer to the task code
; *
; *              p_arg         is a pointer to a user supplied data area that will be passed to the task
; *                            when the task first executes.
; *
; *              ptos          is a pointer to the top of stack. It is assumed that 'ptos' points to the
; *                            highest valid address on the stack.
; *
; *              opt           specifies options that can be used to alter the behavior of OSTaskStkInit().
; *                            (see uCOS_II.H for OS_TASK_OPT_???).
; *
; * Returns    : Always returns the location of the new top-of-stack' once the processor registers have
; *              been placed on the stack in the proper order.
; *
; * Note(s)    : Interrupts are enabled when your task starts executing. You can change this by setting the
; *              SREG to 0x00 instead. In this case, interrupts would be disabled upon task startup. The
; *              application code would be responsible for enabling interrupts at the beginning of the task
; *              code. You will need to modify OSTaskIdle() and OSTaskStat() so that they enable interrupts.
; *              Failure to do this will make your system crash!
; *
; *              The AVR return stack is placed OS_TASK_HARD_STK_SIZE bytes before the bottom of the task's
; *              stack.
; *
; *              (1) IMPORTANT: The ICC compiler handles function pointers by actually passing the pointer
; *                             to a location in Flash that actually contains the pointer to the function.
; **********************************************************************************************************
; */
; 
; OS_STK  *OSTaskStkInit (void (*task)(void *pd), void *p_arg, OS_STK *ptos, INT16U opt)
; {
;     INT8U  *psoft_stk;
;     INT8U  *phard_stk;                      /* Temp. variable used for setting up AVR hardware stack    */
;     INT16U  tmp;
; 
; 
;     opt          = opt;                     /* 'opt' is not used, prevent warning                       */
;     psoft_stk    = (INT8U *)ptos;
	ldd R20,y+6
	ldd R21,y+7
;     phard_stk    = (INT8U *)ptos
	lds R2,_OSTaskStkSize
	lds R3,_OSTaskStkSize+1
	movw R4,R20
	sub R4,R2
	sbc R5,R3
	lds R10,_OSTaskHardStkSize
	lds R11,_OSTaskHardStkSize+1
	add R10,R4
	adc R11,R5
;                  - OSTaskStkSize            /* Task stack size                                          */
;                  + OSTaskHardStkSize;       /* AVR return stack ("hardware stack")                      */
; 
;     tmp          = *(INT16U const *)task;   /* (1) ICC compiler handles function pointers indirectly!   */
	movw R30,R16
	lpm R22,Z+
	lpm R23,Z
; 
;     *phard_stk-- = (INT8U)tmp;              /* Put task start address on top of "hardware stack"        */
	movw R2,R10
	movw R24,R2
	sbiw R24,1
	movw R30,R2
	std z+0,R22
;     *phard_stk-- = (INT8U)(tmp >> 8);
	movw R2,R24
	sbiw R24,1
	movw R10,R24
	movw R4,R22
	mov R4,R5
	clr R5
	movw R30,R2
	std z+0,R4
; 
;     *psoft_stk-- = (INT8U)0x00;             /* R0    = 0x00                                             */
	movw R2,R20
	subi R20,1
	sbci R21,0
	clr R4
	movw R30,R2
	std z+0,R4
;     *psoft_stk-- = (INT8U)0x01;             /* R1    = 0x01                                             */
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,1
	movw R30,R2
	std z+0,R24
;     *psoft_stk-- = (INT8U)0x02;             /* R2    = 0x02                                             */
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,2
	movw R30,R2
	std z+0,R24
;     *psoft_stk-- = (INT8U)0x03;             /* R3    = 0x03                                             */
	movw R2,R20
	subi R20,1
	sbci R21,0
	ldi R24,3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -