Porting an RTOS to a New Hardware Platform
by Byron Miller


Listing One
;  NPE specific code in cstart.a66
;
; NPE-167 Special Function Register Addresses
P2        DEFR      0FFC0H
DP2       DEFR      0FFC2H
ODP2    DEFR        0F1C2H
P7        DEFR      0FFD0H
DP7       DEFR      0FFD2H
ODP7    DEFR        0F1D2H
PICON   DEFR        0F1C4H
CC8IC   DEFR        0FF88H
EXICON  DEFR        0F1C0H
T6CON   DEFR        0FF48H
;----------------------------------------------------------------
;   HARDWARE INITIALIZATION FOR NPE-167 A
;       This code initializes the processor to work with the peripherials
;       on the NPE-167 A.
$IF (WATCHDOG = 1)
        SRVWDT              ; SERVICE WATCHDOG
$ENDIF
        BCLR    T6CON.6     ; Shut off timer.
;       Initialize Ports 2,3,7 and 8 as standard TTL levels.
        MOV     R5,0
        MOV     PICON,R5
;
;       Initialize Port 2.
;           Set Output  = P2.0:         IO Bus Reset
;                       = P2.1, P2.2:   System LED
;                       = P2.3, P2.4:   CAN LED
;                       = P2.6, p2.7:   Memory Page Select
;
;           Set Input   = P2.10, P2.11: CAN Speed Select (SW8, SW9)
;
        MOV     R5,#001Fh   ; Set outputs to off.
        MOV     P2,R5
        MOV     R5,#0001h   ; IO is open drain.
        MOV     ODP2,R5
        MOV     R5,#00DFh   ; Set output direction.
        MOV     DP2,R5
;
;       Initialize Port 7.
;           Set Output  = P7.0 - P7.3:  IO Bus Slot Select.
;
        MOV     R5,#000Fh   ; Set outputs to off.
        MOV     P7,R5
        MOV     R5,#000Fh   ; IO is open drain.
        MOV     ODP7,R5
        MOV     R5,#000Fh   ; Set output direction.
        MOV     DP7,R5
;
;       Setup IO Interrupt (EX0IN).
;           Disable external interrupts and set Interrupt level to 7,
;           group level to 3, negative edge.
;
        MOV     R5,#001Fh
        MOV     CC8IC,R5
        MOV     R5,#0001h
        OR      EXICON,R5


Listing Two

;========================================================================
; ** Beginning of RTXC specific code **
$IF MICROVISION
;========================================================================
;                    NULL STACK SIZE DEFINITION
;
; define the size of the stack for the null task.
; NOTE: Ensure you modify the 'C' level constant of the same name in
;       the RTXCOPTS.H file.
;----------------------------------------------------------------
NULLSTKSZ EQU 80H
$ELSE
$INCLUDE(rtxcopts.inc)                  ; include kernel assembly definitions
$ENDIF
; ** END RTXC specific code **
;=========================================================================

;=========================================================================
; ** Beginning of RTXC specific code **
; This user stack is used only for startup and entry into main()

USTSZ   EQU     40H   ; set User Stack Size to 64 Bytes.

; ** END RTXC of RTXC specific code **
;=========================================================================

;=========================================================================
; ** Beginning of RTXC specific code **

   EXTRN nullstack:WORD

   EXTRN DPP3:DPP1_INITVALUE:WORD
   EXTRN DPP3:DPP2_INITVALUE:WORD

   ; Initialize the 'C' variables for task frame initialization
   MOV     DPP1_INITVALUE, DPP1
   MOV     DPP2_INITVALUE, DPP2
$IF NOT TINY
     MOV     R0, #POF nullstack      ; restore user stack pointer
     MOV     R5, #PAG nullstack
     MOV     DPP2,R5
     NOP
     BSET    R0.0FH                         ; User stack uses DPP1
$ELSE
     MOV     R0, #nullstack              ; restore user stack pointer
$ENDIF

   MOV     R10, #NULLSTKSZ
   ADD     R0, R10                           ; get to top of stack

; ** END RTXC of RTXC specific code **
;===============================================================


1


