📄 68hc16.txt
字号:
/*
Gary Schneider
Systems Software Engineer
Aeroflex Labs.
35 South Service Rd.
Plainview, NY 11803
516-752-2421
Mr. Jean Labrosse:
This disk contains the code to run the uCOS kernal on
a M68HC16 micro-controller. The \SOURCE directory contains
the code which is not microprocessor specific. The \M68HC16
directory contains the code which allows UCOS to be ported
to a M68HC16. The \OBJ directory contains the relocatable
object files and output file produced by the INTROL compiler,
assembler and linker. Note that the file MAIN.ABS can run
on an emulator and MAIN.HEX is suitable for the target proms.
Also, this directory contains the *.mix files which are produced
by INTROL'S IMERGE.EXE.
Thank you for your time and patience in answering all of my
questions concerning your uCOS kernal. I look forward to using your
kernal in my next project and if you have any questions (or improvements)
concerning my code don't hesitate to call!
Thank You,
Gary Schneider
*/
/*
*********************************************************************************************************
* uCOS
* Microcomputer Real-Time Multitasking Operating System
*
* (c) Copyright 1992, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
* 68HC16 Specific code
*
* Filename : DEFS.H
* By : GGS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define FALSE 0
#define TRUE 1
/*
*********************************************************************************************************
* MACROS
*********************************************************************************************************
*/
#define OS_ENTER_CRITICAL() asm(" ORP #$00E0");
#define OS_EXIT_CRITICAL() asm(" ANDP #$FF1F");
#define OS_TASK_SW() asm(" SWI uCOS");
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
typedef unsigned char BOOLEAN;
typedef unsigned char UBYTE; /* Unsigned 8 bit quantity */
typedef signed char BYTE; /* Signed 8 bit quantity */
typedef unsigned int UWORD; /* Unsigned 16 bit quantity */
typedef signed int WORD; /* Signed 16 bit quantity */
typedef unsigned long ULONG; /* Unsigned 32 bit quantity */
typedef signed long LONG; /* Signed 32 bit quantity */
/*
**************************************************************************
* uCOS
* Microcomputer Real-Time Multitasking Operating System
*
* (c) Copyright 1992, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* MC68HC16 Specific code
*
* File : task16.C
* By : Gary Schneider
**************************************************************************
*/
#include "DEFS.H"
#include "UCOS.H"
/*
**************************************************************************
* CREATE A TASK
**************************************************************************
*/
UBYTE OSTaskCreate( void (*task) (void), void *pstk, UBYTE p)
{
UWORD *stk;
UBYTE err;
OS_ENTER_CRITICAL();
if (OSTCBPrioTbl[p] == (OS_TCB *)0) { /* Make sure task doesn't already exist at this priority */
OS_EXIT_CRITICAL();
stk = (UWORD *) pstk; /* Load stack pointer */
/* Load the PC */
/* RTI subtracts 6 bytes (3 words) from PC due to pipeline */
*--stk = (UWORD) (((ULONG) task)+4);
*--stk = (UWORD) (((ULONG) task)>>16); /* Load PK onto stack */
*--stk = (UWORD) ((ULONG) task); /* Place-holder since SP gets */
/* incr. by 2 by an RTI */
*--stk = (UWORD)0x0000; /* Accumulator D = 0 */
*--stk = (UWORD)0x0000; /* Accumulator E = 0 */
*--stk = (UWORD)0x0000; /* IX = 0 */
*--stk = (UWORD)0x0000; /* IY = 0 */
*--stk = (UWORD)0x0000; /* IZ = 0 */
*--stk = (UWORD)0x0000; /* XK,YK,ZK = 0 */
err = OSTCBInit(p, (void *)stk); /* Get and initialize a TCB */
if (err == OS_NO_ERR) {
if (OSRunning) { /* Find highest priority task if multitasking has started */
OSSched();
}
}
return (err);
} else {
OS_EXIT_CRITICAL();
return (OS_PRIO_EXIST);
}
}
**************************************************************************
* uCOS
* Microcomputer Real-Time Multitasking Operating System
*
* (c) Copyright 1992, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* MC68HC16 Specific code
*
* File : tasksw16.s
* By : Gary Schneider
***************************************************************************
export OSStartHighRdy
export OSCtxSw
export OSIntCtxSw
import OSIntEnter
import OSIntExit
import OSTimeTick
import OSTCBCur
import OSTCBHighRdy
section .text
******************************************************************
* START MULTITASKING
* void OSStartHighRdy(void)
*
******************************************************************
OSStartHighRdy:
LDAB #OSTCBHighRdy>>16
TBXK
LDX OSTCBHighRdy
MOVW OSTCBHighRdy,OSTCBCur * Point to TCB of highest priority task ready to run
* OSTCBCur = OSTCBHighRdy
LDS $0,X * SP = OSTCBHighRdy->OSTCBStkPtr
PULM D,E,X,Y,Z,K * Load task's context
RTI * Run task
********************************************************************
* PERFORM A CONTEXT SWITCH (From task level)
* void OSCtxSw(void)
*
********************************************************************
OSCtxSw:
PSHM D,E,X,Y,Z,K * Save current task's context
LDAB #OSTCBHighRdy>>16
TBXK
LDX OSTCBHighRdy
LDAB #OSTCBCur>>16
TBYK
LDY OSTCBCur
STS $0,Y * OSTCBCur->OSTCBStkPtr = SP
MOVW OSTCBHighRdy,OSTCBCur * OSTCBCur = OSTCBHighRdy
LDS $0,X * SP = OSTCBHighRdy->OSTCBStkPtr
PULM D,E,X,Y,Z,K * Load task's context
RTI * Return to new task
************************************************************************
* PERFORM A CONTEXT SWITCH (From an ISR)
* void OSIntCtxSw(void)
************************************************************************
OSIntCtxSw:
AIS #$0C * Ignore calls to OSIntExit and OSIntCtxSw (8 bytes)
* Call to OSIntExit does pshm z,k (4 bytes)
LDAB #OSTCBHighRdy>>16
TBXK
LDX OSTCBHighRdy
LDAB #OSTCBCur>>16
TBYK
LDY OSTCBCur
STS $0,Y * OSTCBCur->OSTCBStkPtr = SP
MOVW OSTCBHighRdy,OSTCBCur * OSTCBCur = OSTCBHighRdy
LDS $0,X * SP = OSTCBHighRdy->OSTCBStkPtr
PULM D,E,X,Y,Z,K * Load task's context
RTI * Return to new task
*---------------------------------------------------------------------
* uCOS
* Microcomputer Real-Time Multitasking Operating System
* KERNEL
* (c) Copyright 1992, Jean J. Labrosse, Plantation, FL
* All Rights Reserved
*
*
* Filename: TICK16.S
*
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -