📄 os_cpu_c.src
字号:
CC2_CC30IC_IE BIT CC2_CC30IC.6
CC1_CC13IC_IE BIT CC1_CC13IC.6
PECISNC_C7IR BIT PECISNC.15
ODP3_P7 BIT ODP3.7
ODP4_P6 BIT ODP4.6
ODP9_P1 BIT ODP9.1
RTC_ISNC_CNT0IE BIT RTC_ISNC.2
ASSUME DPP3 : SYSTEM
REGDEF R0 - R15
?PR?OS_CPU_C SECTION CODE WORD 'FCODE'
; line 1: /*---------------------------------------------------------------------------
; line 2: //
; line 3: // FILE : $Workfile: Os_cpu_c.c $
; line 4: //
; line 5: // ORIGINATOR : Martin Rodier
; line 6: // CREATION DATE : March, 7 2002
; line 7: // REVISION : 1.10
; line 8: // PURPOSE : This uC/OS-II port is intended for Infineon Technologies and ST10R167
; line 9: // C16x Extended Architecture Micro Controller Targets (C167CR-LM)
; line 10: // PART OF : uC/OS-II version 2.00
; line 11: // COMPILE WITH : KEIL C166/ST10 V4.20 Ansi C Compiler
; line 12: //
; line 13: //---------------------------------------------------------------------------
; line 14: // uC/OS-II
; line 15: // The Real-Time Kernel
; line 16: // Infineon C16x/C167CR
; line 17: // Extended Architecture Specific Code
; line 18: // HLARGE MEMORY MODEL
; line 19: //---------------------------------------------------------------------------
; line 20: //
; line 21: // Revision history:
; line 22: //
; line 23: // $Log: /.../UCOS-II/C167/Os_cpu_c.c $
; line 24: *
; line 25: * 5 3/07/02 3:49p Mrodier
; line 26: * Revised Version of the port that include a copy of the interrupting
; line 27: * task PSW to fix the problem of the multiplication when the interrupted
; line 28: * task had a multiplication in progress and the interrupting task do not
; line 29: * return to it.
; line 30: *
; line 31: * Addition into OSTaskBuildStk of the PSW at position -2E of the task
; line 32: * stack to let the interrupting task memorize the state of PSW into the
; line 33: * task stack.
; line 34: *
; line 35: * 4 6/13/01 10:42a Mrodier
; line 36: * Revised to final version as relased in uCOSII port
; line 37: //
; line 38: //-------------------------------------------------------------------------
; line 39: */
; line 40:
; line 41:
; line 42:
; line 43: #define OS_CPU_GLOBALS
; line 44: #include "includes.h"
; line 45: #include <intrins.h>
; line 46:
; line 47:
; line 48: #pragma SRC
; line 49: /*
; line 50: *********************************************************************************************************
; line 51: * INITIALISE A TASK'S STACK
; line 52: *
; line 53: * Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialise the
; line 54: * stack frame of the task being created. This function is highly processor specific.
; line 55: *
; line 56: * Arguments : task is a pointer to the task code
; line 57: *
; line 58: * pdata is a pointer to a user supplied data area that will be passed to the task
; line 59: * when the task first executes.
; line 60: *
; line 61: * ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
; line 62: * a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then
; line 63: * 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if
; line 64: * OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
; line 65: * of the stack.
; line 66: *
; line 67: * opt specifies options that can be used to alter the behavior of OSTaskStkInit().
; line 68: *
; line 69: * TASK STACK AREA (High Memory)
; line 70: * +14 TASK DATA PARAMETER SEGMENT pointer of task
; line 71: * +12 TASK DATA PARAMETER OFFSET pointer of task
; line 72: * +10 SEGMENT of task code address
; line 73: * +0E OFFSET of task code address
; line 74: * +0C SP of System stack of task
; line 75: * +0A USER STACK OFFSET POINTER (R0) of task
; line 76: * +08 USER STACK PAGE POINTER (DPP2) of task
; line 77: * +06 PSW of task
; line 78: * +04 OFFSET of task return address (IP)
; line 79: * +02 SEGMENT of task return address (CSP)
; line 80: * 0 (Low Memory)
; line 81: *
; line 82: * Returns : Always returns the location of the new top-of-stack' once the processor registers have
; line 83: * been placed on the stack in the proper order.
; line 84: *
; line 85: * Note(s) : Interrupts are enabled when your task starts executing. You can change this by setting the
; line 86: * PSW to 0x0800 instead. In this case, interrupts would be disabled upon task startup. The
; line 87: * application code would be responsible for enabling interrupts at the beginning of the task
; line 88: * code. You will need to modify OSTaskIdle() and OSTaskStat() so that they enable
; line 89: * interrupts. Failure to do this will make your system crash!
; line 90: *
; line 91: *********************************************************************************************************
; line 92: */
; line 93: OS_STK *OSTaskStkInit (void (*task)(void *pd), void *pdata, OS_STK *ptos, INT16U opt)
OSTaskStkInit PROC FAR
PUBLIC OSTaskStkInit
; FUNCTION OSTaskStkInit (BEGIN RMASK = @0x3FFF)
PUSH R13
PUSH R14
PUSH R15
MOV [-R0],R12
MOV R2,R10
MOV R3,R11
;---- Variable 'pdata' assigned to Register 'R2/R3' ----
MOV R10,R8
MOV R11,R9
;---- Variable 'task' assigned to Register 'R10/R11' ----
; line 94: {
; line 95: INT16U *stk;
; line 96: INT32U usr;
; line 97: INT16U page;
; line 98: INT16U offset;
; line 99: INT16U data_seg;
; line 100: INT16U data_sof;
; line 101:
; line 102: opt = opt; /* 'opt' is not used, prevent warning */
; line 103: data_seg = (INT16U)((INT32U)pdata >> 16);
MOV R4,R2
MOV R5,R3
BMOV R4.14,R5.0
BMOV R4.15,R5.1
SHR R5,#2
MOV R4,R5
MOV R9,R4
;---- Variable 'data_seg' assigned to Register 'R9' ----
; line 104: data_sof = ((INT16U) pdata & 0xFFFF);
MOV R5,R3
MOV R4,R2
SHL R5,#14
OR R4,R5
MOV R12,R4
;---- Variable 'data_sof' assigned to Register 'R12' ----
; line 105: stk = (INT16U *)ptos; /* Load stack pointer */
MOV R5,[R0+#2] ; ptos+2
MOV R4,[R0] ; ptos
;---- Variable 'stk' assigned to Register 'R4/R5' ----
; line 106:
; line 107: *stk-- = data_seg; /* TASK DATA PARAMETER SEGMENT pointer of task */
MOV R6,R4
SUB R4,#2
;---- Variable 'stk' assigned to Register 'R4/R5' ----
EXTP R5,#1
MOV [R6],R9
; line 108: *stk-- = data_sof; /* TASK DATA PARAMETER OFFSET pointer of task */
MOV R6,R4
SUB R4,#2
MOV R2,R4
MOV R3,R5
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R5,#1
MOV [R6],R12
; line 109: *stk-- = (INT16U)((INT32U)task >> 16); /* Task segment start address */
MOV R6,R2
MOV R4,R2
SUB R4,#2
MOV R5,R3
MOV R2,R4
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R3,#1
MOV [R6],R11
; line 110: *stk-- = ((INT16U)task & 0xFFFF); /* Task offset start address */
MOV R4,R10
MOV R4,R2
SUB R4,#2
;---- Variable 'stk' assigned to Register 'R4/R5' ----
EXTP R3,#1
MOV [R2],R10
; line 111: *stk-- = (INT16U)0xFC00; /* Task SP of System stack of task */
MOV R8,#64512
MOV R6,R4
SUB R4,#2
MOV R2,R4
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R3,#1
MOV [R6],R8
; line 112:
; line 113: usr = (INT32U)stk; /* Keep a copy of STACK OFFSET POINTER location */
MOV R14,R4
MOV R15,R3
BMOV R14.14,R15.0
BMOV R14.15,R15.1
SHR R15,#2
;---- Variable 'usr' assigned to Register 'R14/R15' ----
; line 114:
; line 115: offset = (INT16U)((((usr) & 0x3FFF) - 0x0A) | 0x4000); /* First adress of stack offset pointer of the task */
MOV R4,R14
AND R4,#16383
MOV R5,R15
AND R5,#0
SUB R4,#10
OR R4,#16384
MOV R1,R4
;---- Variable 'offset' assigned to Register 'R1' ----
; line 116: *stk-- = offset; /* Task user stack offset R0 */
MOV R6,R2
MOV R4,R2
SUB R4,#2
MOV R5,R3
MOV R2,R4
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R3,#1
MOV [R6],R1
; line 117:
; line 118: page = (INT16U)(usr >> 0x000E); /* Task user stack page DPP2 */
MOV R4,R14
MOV R5,R15
MOV R6,R15
SHR R4,#14
SHL R6,#2
OR R4,R6
MOV R13,R4
;---- Variable 'page' assigned to Register 'R13' ----
; line 119: *stk-- = page; /* Task user stack page DPP2 */
MOV R4,R2
SUB R4,#2
MOV R5,R3
;---- Variable 'stk' assigned to Register 'R4/R5' ----
EXTP R3,#1
MOV [R2],R13
; line 120:
; line 121: *stk-- = (INT16U)0x0800; /* Task PSW = Interrupt enabled */
MOV R8,#2048
MOV R6,R4
SUB R4,#2
MOV R2,R4
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R3,#1
MOV [R6],R8
; line 122: *stk-- = ((INT16U)task & 0xFFFF); /* Task offset return address */
MOV R4,R10
MOV R6,R2
MOV R4,R2
SUB R4,#2
MOV R2,R4
;---- Variable 'stk' assigned to Register 'R2/R3' ----
EXTP R3,#1
MOV [R6],R10
; line 123: *stk-- = (INT16U)((INT32U)task >> 16); /* Task segment return address */
MOV R4,R2
SUB R4,#2
MOV R5,R3
MOV R14,R4
MOV R15,R3
;---- Variable 'stk' assigned to Register 'R14/R15' ----
EXTP R3,#1
MOV [R2],R11
; line 124:
; line 125: OSTaskBuildStk(page, offset, data_seg, data_sof);
MOV R11,R12
MOV R10,R9
MOV R9,R1
MOV R8,R13
CALL OSTaskBuildStk
; line 126:
; line 127: return ((OS_STK *)stk);
MOV R5,R15
MOV R4,R14
; line 128: }
ADD R0,#2
POP R15
POP R14
POP R13
RETS
; FUNCTION OSTaskStkInit (END RMASK = @0x3FFF)
OSTaskStkInit ENDP
; line 129:
; line 130:
; line 131: /*$PAGE*/
; line 132: #if OS_CPU_HOOKS_EN
; line 133: /*
; line 134: *********************************************************************************************************
; line 135: * TASK CREATION HOOK
; line 136: *
; line 137: * Description: This function is called when a task is created.
; line 138: *
; line 139: * Arguments : ptcb is a pointer to the task control block of the task being created.
; line 140: *
; line 141: * Note(s) : 1) Interrupts are disabled during this call.
; line 142: *********************************************************************************************************
; line 143: */
; line 144: void OSTaskCreateHook (OS_TCB *ptcb)
OSTaskCreateHook PROC FAR
PUBLIC OSTaskCreateHook
; FUNCTION OSTaskCreateHook (BEGIN RMASK = @0x8000)
;---- Variable 'ptcb' assigned to Register 'R8/R9' ----
; line 145: {
; line 146: ptcb = ptcb; /* Prevent compiler warning */
; line 147: }
RETS
; FUNCTION OSTaskCreateHook (END RMASK = @0x8000)
OSTaskCreateHook ENDP
; line 148:
; line 149:
; line 150: /*
; line 151: *********************************************************************************************************
; line 152: * TASK DELETION HOOK
; line 153: *
; line 154: * Description: This function is called when a task is deleted.
; line 155: *
; line 156: * Arguments : ptcb is a pointer to the task control block of the task being deleted.
; line 157: *
; line 158: * Note(s) : 1) Interrupts are disabled during this call.
; line 159: *********************************************************************************************************
; line 160: */
; line 161: void OSTaskDelHook (OS_TCB *ptcb)
OSTaskDelHook PROC FAR
PUBLIC OSTaskDelHook
; FUNCTION OSTaskDelHook (BEGIN RMASK = @0x8000)
;---- Variable 'ptcb' assigned to Register 'R8/R9' ----
; line 162: {
; line 163: ptcb = ptcb; /* Prevent compiler warning */
; line 164: }
RETS
; FUNCTION OSTaskDelHook (END RMASK = @0x8000)
OSTaskDelHook ENDP
; line 165:
; line 166: /*
; line 167: *********************************************************************************************************
; line 168: * TASK SWITCH HOOK
; line 169: *
; line 170: * Description: This function is called when a task switch is performed. This allows you to perform other
; line 171: * operations during a context switch.
; line 172: *
; line 173: * Arguments : none
; line 174: *
; line 175: * Note(s) : 1) Interrupts are disabled during this call.
; line 176: * 2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
; line 177: * will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
; line 178: * task being switched out (i.e. the preempted task).
; line 179: *********************************************************************************************************
; line 180: */
; line 181: void OSTaskSwHook (void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -