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

📄 os_cpu_c.lst

📁 UCOS在51上的移植,绝对经典!可以较少开发人员的工作量
💻 LST
📖 第 1 页 / 共 2 页
字号:
 185   1          //INT16U *stk;
 186   1              OS_STK  *stk;
 187   1      
 188   1          opt    = opt;                           /* 'opt' is not used, prevent warning                      */
 189   1          stk    = (OS_STK *)ptos;                /* Load stack pointer                                      */
 190   1                                                                                              //装入堆栈指针ptos到stk
 191   1              *--stk = ((INT16U)task) &  0x00ff;              //保存任务地址底字节
 192   1              *--stk = ((INT16U)task) >> 8;                   //保存任务地址高字节
 193   1      //      *--stk = 'S';                                                   //保存堆栈指针SP
 194   1              *--stk = 'A';                                                   //入栈:ACC
 195   1              *--stk = 'B';                                                   //入栈:B
 196   1              *--stk = 'H';                                                   //入栈:DPH             //暂时忽略第二指针
 197   1              *--stk = 'L';                                                   //入栈:DPL
 198   1              *--stk = PSW;                                                   //入栈:PSW
 199   1              *--stk = '0';                                                   //入栈:R0
 200   1              *--stk = (((INT16U)os_pdata) & 0x00ff); //偏移底位即R1
 201   1              *--stk = (((INT16U)os_pdata) & 0xff00) >> 8;//偏移高位即R2
 202   1              *--stk = 0x01;                                                  //空间编码
 203   1                                                                                              //用寄存器传递os_pdata
 204   1              *--stk = '4';                                                   //入栈:R4-R7
 205   1              *--stk = '5';
 206   1              *--stk = '6';
 207   1              *--stk = '7';
 208   1      
 209   1                                                                                              //END
 210   1          return ((OS_STK *)stk);
 211   1      }
 212          
 213          /*$PAGE*/
 214          
 215          /*$PAGE*/
 216          /*
 217          *********************************************************************************************************
 218          *                        INITIALIZE A TASK'S STACK FOR FLOATING POINT EMULATION
 219          *
 220          * Description: This function MUST be called BEFORE calling either OSTaskCreate() or OSTaskCreateExt() in
 221          *              order to initialize the task's stack to allow the task to use the Borland floating-point 
 222          *              emulation.  The returned pointer MUST be used in the task creation call.
 223          *
 224          *              Ex.:   OS_STK TaskStk[1000];
 225          *
 226          *
 227          *                     void main (void)
 228          *                     {
 229          *                         OS_STK *ptos;
 230          *                         OS_STK *pbos;
 231          *                         INT32U  size;
 232          *
 233          *
 234          *                         OSInit();
 235          *                         .
 236          *                         .
 237          *                         ptos  = &TaskStk[999];
 238          *                         pbos  = &TaskStk[0];
 239          *                         psize = 1000;
C51 COMPILER V7.20   OS_CPU_C                                                              04/25/2005 23:03:52 PAGE 5   

 240          *                         OSTaskStkInit_FPE_x86(&ptos, &pbos, &size);
 241          *                         OSTaskCreate(Task, (void *)0, ptos, 10);
 242          *                         .
 243          *                         .
 244          *                         OSStart();
 245          *                     }
 246          *
 247          * Arguments  : pptos         is the pointer to the task's top-of-stack pointer which would be passed to 
 248          *                            OSTaskCreate() or OSTaskCreateExt().
 249          *
 250          *              ppbos         is the pointer to the new bottom of stack pointer which would be passed to
 251          *                            OSTaskCreateExt().
 252          *
 253          *              psize         is a pointer to the size of the stack (in number of stack elements).  You 
 254          *                            MUST allocate sufficient stack space to leave at least 384 bytes for the 
 255          *                            floating-point emulation.
 256          *
 257          * Returns    : The new size of the stack once memory is allocated to the floating-point emulation.
 258          *
 259          * Note(s)    : 1) _SS  is a Borland 'pseudo-register' and returns the contents of the Stack Segment (SS)
 260          *              2) The pointer to the top-of-stack (pptos) will be modified so that it points to the new
 261          *                 top-of-stack.
 262          *              3) The pointer to the bottom-of-stack (ppbos) will be modified so that it points to the new
 263          *                 bottom-of-stack.
 264          *              4) The new size of the stack is adjusted to reflect the fact that memory was reserved on
 265          *                 the stack for the floating-point emulation.
 266          *********************************************************************************************************
 267          */
 268          
 269          /*$PAGE*/
 270          //void  OSTaskStkInit_FPE_x86 (OS_STK **pptos, OS_STK **ppbos, INT32U *psize)
 271          //{
 272          //    INT32U   lin_tos;                                 /* 'Linear' version of top-of-stack    address   *
             -/
 273          //    INT32U   lin_bos;                                 /* 'Linear' version of bottom-of-stack address   *
             -/
 274          //    INT16U   seg;
 275          //    INT16U   off;
 276          //    INT32U   bytes;
 277          
 278          
 279          //    seg      = FP_SEG(*pptos);                        /* Decompose top-of-stack pointer into seg:off   *
             -/
 280          //    off      = FP_OFF(*pptos);
 281          //    lin_tos  = ((INT32U)seg << 4) + (INT32U)off;      /* Convert seg:off to linear address             *
             -/
 282          //    bytes    = *psize * sizeof(OS_STK);               /* Determine how many bytes for the stack        *
             -/
 283          //    lin_bos  = (lin_tos - bytes + 15) & 0xFFFFFFF0L;  /* Ensure paragraph alignment for BOS            *
             -/
 284              
 285          //    seg      = (INT16U)(lin_bos >> 4);                /* Get new 'normalized' segment                  *
             -/
 286          //    *ppbos   = (OS_STK *)MK_FP(seg, 0x0000);          /* Create 'normalized' BOS pointer               *
             -/
 287          //    memcpy(*ppbos, MK_FP(_SS, 0), 384);               /* Copy FP emulation memory to task's stack      *
             -/
 288          //    bytes    = bytes - 16;                            /* Loose 16 bytes because of alignment           *
             -/
 289          //    *pptos   = (OS_STK *)MK_FP(seg, (INT16U)bytes);   /* Determine new top-of-stack                    *
             -/
 290          //    *ppbos   = (OS_STK *)MK_FP(seg, 384);             /* Determine new bottom-of-stack                 *
C51 COMPILER V7.20   OS_CPU_C                                                              04/25/2005 23:03:52 PAGE 6   

             -/
 291          //    bytes    = bytes - 384;
 292          //    *psize   = bytes / sizeof(OS_STK);                /* Determine new stack size                      *
             -/
 293          //}
 294          
 295          /*$PAGE*/
 296          /*
 297          *********************************************************************************************************
 298          *                                           TASK SWITCH HOOK
 299          *
 300          * Description: This function is called when a task switch is performed.  This allows you to perform other
 301          *              operations during a context switch.
 302          *
 303          * Arguments  : none
 304          *
 305          * Note(s)    : 1) Interrupts are disabled during this call.
 306          *              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
 307          *                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the 
 308          *                 task being switched out (i.e. the preempted task).
 309          *********************************************************************************************************
 310          */
 311          #if OS_CPU_HOOKS_EN > 0 
 312          void  OSTaskSwHook (void) LG_REENTRANT
 313          {
 314   1      }
 315          #endif
 316          
 317          /*
 318          *********************************************************************************************************
 319          *                                           OSTCBInit() HOOK
 320          *
 321          * Description: This function is called by OS_TCBInit() after setting up most of the TCB.
 322          *
 323          * Arguments  : ptcb    is a pointer to the TCB of the task being created.
 324          *
 325          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
 326          *********************************************************************************************************
 327          */
 328          #if OS_CPU_HOOKS_EN > 0 && OS_VERSION > 203
 329          void  OSTCBInitHook (OS_TCB *ptcb) LG_REENTRANT
 330          {
 331   1          ptcb = ptcb;                                           /* Prevent Compiler warning                 */
 332   1      }
 333          #endif
 334          
 335          
 336          /*
 337          *********************************************************************************************************
 338          *                                               TICK HOOK
 339          *
 340          * Description: This function is called every tick.
 341          *
 342          * Arguments  : none
 343          *
 344          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
 345          *********************************************************************************************************
 346          */
 347          #if OS_CPU_HOOKS_EN > 0 
 348          void  OSTimeTickHook (void) LG_REENTRANT
 349          {
 350   1      }
C51 COMPILER V7.20   OS_CPU_C                                                              04/25/2005 23:03:52 PAGE 7   

 351          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    634    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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