📄 dsp_c6x_vectors.asm
字号:
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
; TI C6711 DSP Specific Functions
; Little Endian Mode
;
; Code Composer Studio V2.2
;
; File : DSP_C6x.ASM
; By : Ming Zeng (ming@zming.net) 2003.11
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC and EXTERNAL REFERENCES
;********************************************************************************************************
FP .set A15
DP .set B14
SP .set B15
.global $bss
MUXH .set 0x019C0000 ;Interrupt Multiplexer High Register
MUXL .set 0x019C0004 ;Interrupt Multiplexer Low Register
EXTPOL .set 0x019C0008 ;External Interrupt Polarity Register
T0_CTL .set 0x01940000 ;Timer Control Register of Timer-0
T0_PRD .set 0x01940004 ;Timer Period Register of Timer-0
T0_CNT .set 0x01940008 ;Timer Counter Register of Timer-0
EMIF_CE2 .set 0x01800010
_StartAddress .set 0+4 ;structrue of task/int stack
_A0 .set 4 +4
_A1 .set 8 +4
_A2 .set 12 +4
_A3 .set 16 +4
_A4 .set 20 +4
_A5 .set 24 +4
_A6 .set 28 +4
_A7 .set 32 +4
_A8 .set 36 +4
_A9 .set 40 +4
_A10 .set 44 +4
_A11 .set 48 +4
_A12 .set 52 +4
_A13 .set 56 +4
_A14 .set 60 +4
_A15 .set 64 +4
_B0 .set 68 +4
_B1 .set 72 +4
_B2 .set 76 +4
_B3 .set 80 +4
_B4 .set 84 +4
_B5 .set 88 +4
_B6 .set 92 +4
_B7 .set 96 +4
_B8 .set 100 +4
_B9 .set 104 +4
_B10 .set 108 +4
_B11 .set 112 +4
_B12 .set 116 +4
_B13 .set 120 +4
_B14 .set 124 +4
_B15 .set 128 +4
_AMR .set 132 +4
_CSR .set 136 +4
_IER .set 140 +4
_IRP .set 144 +4
_DUMMY .set 148 +4
_Framesize .set 148 +4
.global _DSP_C6x_TimerInit ; Inintial the Timer0 for OSTickISR
.global _DSP_C6x_SystemInit ; Initial the whole system
.global _DSP_C6x_Save ; Save all register context, used in ISR
.global _DSP_C6x_Resume ; Resume all register context, used in ISR
.global _DSP_C6x_GetCurrentDP ; It's used in OSTaskStkInit function
.global _DSP_C6x_GetCurrentSP ; It's used in any ISR function
.ref _c_int00 ; entry of C language
.ref _OSTickISR ; OSTickISR for uC/OS-II, as the ISR of Timer0
.global _DSP_C6x_Int4Init ;for EthernetDaughterCard
.ref _ne2k_isr
;.ref _int4;
; /*$PAGE*/
;******************************************************************************
; Vector Table
;
; ====== vectors in use ========
; Plug in the entry point at the ISR function in the interrupt vector table
;
; ====== unused ========
; plug inifinite loop -- with nested branches to
; disable interrupts -- for all undefined vectors
;
;******************************************************************************
unused .macro id
.global unused:id:
unused:id:
b unused:id: ; nested branches to block interrupts
nop 4
b unused:id:
nop
nop
nop
nop
nop
.endm
.align 32*8*4 ; must be aligned on 256 word boundary
RESET: ; reset vector
mvkl _c_int00,b0 ; load destination function address to b0
mvkh _c_int00,b0
b b0 ; start branch to destination function
mvc PCE1,b0 ; address of interrupt vectors
mvc b0,ISTP ; set table to point here
nop 3 ; fill delay slot
nop
nop
;------------------------------------------------
unused 1 ;NMI ; plug unused interrupts with infinite loops to
unused 2 ;Reserved ; catch stray interrupts
unused 3 ;Reserved ;------------------------------------------------
INT4:
nop
nop
b _ne2k_isr
nop
nop
nop
nop
nop
;unused 4 ;INT4
unused 5 ;INT5
unused 6 ;INT6
unused 7 ;INT7
unused 8 ;INT8
unused 9 ;INT9
unused 10 ;INT10
unused 11 ;INT11
unused 12 ;INT12
unused 13 ;INT13
INT14:
nop
nop
b _OSTickISR
nop
nop
nop
nop
nop
unused 15 ;INT15
; /*$PAGE*/;
;***********************************************************************
; Inintial the Int4 for EthernetDaughterCard
;
;***********************************************************************
;
_DSP_C6x_Int4Init:
mvc IER,B0
set B0,1,1,B0 ; set IER enable INT14(Timer0)
set B0,4,4,B0 ; set IER enable INT14(Timer0)
mvc B0,IER
mvk 0x0,B0 ; clear ICR/IFR
mvc B0,ICR
mvc CSR,B4 ; Set GIE bit in CSR , enable global interrupt
SET B4,0,0,B4
mvc B4,CSR
B B3
NOP 5
; /*$PAGE*/;
;***********************************************************************
; Inintial the Timer0 for OSTickISR
;
;***********************************************************************
;
_DSP_C6x_TimerInit: ; Inintial the Timer0 for OSTickISR
;set time cycle; Timer clk = SysClk / 4 (DSK6713 SysClk = 225MHz)
mvkl T0_PRD,B4 ; Set Timer to 100Hz
mvkh T0_PRD,B4 ; Timer Period Register of Timer-0
mvkl 0x89544,B5
mvkh 0x89544,B5
stw B5,*B4
mvkl T0_CTL,B4 ; Timer Control Register of Timer-0
mvkh T0_CTL,B4
ldw *B4,B5
nop 4
; set B5,9,9,B5
set B5,6,9,B5
stw B5,*B4
;enable Timer in IER & GIE
mvk 0x0,B0 ; clear ICR/IFR
mvc B0,ICR
mvc IER,B0
set B0,14,14,B0 ; set IER enable INT14(Timer0)
mvc B0,IER
mvc CSR,B4 ; Set GIE bit in CSR , enable global interrupt
SET B4,0,0,B4
mvc B4,CSR
B B3
NOP 5
; /*$PAGE*/;
;***********************************************************************
; Initial the whole system
;
;***********************************************************************
;
_DSP_C6x_SystemInit: ; Initial the whole system
MVK 0x0,B0
mvc B0,AMR
mvc B0,ISR
mvc B0,ICR
mvc B0,IER
mvc B0,IRP
mvc B0,ICR
mvc B0,NRP
MVK 0x0100,B0
mvc B0,CSR
mvkl RESET,B0
mvkh RESET,B0
mvc B0,ISTP
;for uC/OS-II
MVK 0x0A0,A0
MVK 0x0A1,A1
MVK 0x0A2,A2
MVK 0x0A3,A3
MVK 0x0A4,A4
MVK 0x0A5,A5
MVK 0x0A6,A6
MVK 0x0A7,A7
MVK 0x0A8,A8
MVK 0x0A9,A9
MVK 0x0A10,A10
MVK 0x0A11,A11
MVK 0x0A12,A12
MVK 0x0A13,A13
MVK 0x0A14,A14
; MVK 0x0,A15 ; Frame pointer
MVK .S2 0x0B0,B0
MVK .S2 0x0B1,B1
MVK .S2 0x0B2,B2
; MVK 0x0B3,B3 Return address
MVK .S2 0x0B4,B4
MVK .S2 0x0B5,B5
MVK .S2 0x0B6,B6
MVK .S2 0x0B7,B7
MVK .S2 0x0B8,B8
MVK .S2 0x0B9,B9
MVK .S2 0x0B10,B10
MVK .S2 0x0B11,B11
MVK .S2 0x0B12,B12
MVK .S2 0x0B13,B13
; MVK 0xA140,B14 ; data pointer
; MVK 0x0,B15 ; Stack pointer
B B3
NOP 5
; /*$PAGE*/;
;***********************************************************************
; Save all register context, used in ISR
;
;***********************************************************************
;
_DSP_C6x_Save: ; Save all register context, used in ISR
addk (8-_Framesize),SP ; Push one Frame
STW B0,*+SP(_B0) ; ; Save B0
|| mvc AMR,B0 ; B0 = AMR
STW B1,*+SP(_B1) ; ; Save B1
|| mvc CSR,B1 ; B1 = CSR
STW B2,*+SP(_B2) ; ; Save B2
|| mvc IER,B2 ; B2 = IER
STW B0,*+SP(_AMR) ; ; Save AMR
STW B1,*+SP(_CSR) ; ; Save CSR
STW B2,*+SP(_IER) ; ; Save IER
STW B4,*+SP(_B4) ; ; Save B4
|| mvc IRP,B4 ; The return address in the interrupted environment
STW B4,*+SP (_StartAddress) ; Save return address in interrupt handler start address
STW B4,*+SP (_IRP)
STW B5,*+SP(_B5) ; Save B5
STW B6,*+SP(_B6) ;
STW B7 ,*+SP(_B7 ) ;
STW B8 ,*+SP(_B8 ) ;
STW B9 ,*+SP(_B9 ) ;
STW B10,*+SP(_B10) ;
STW B11,*+SP(_B11) ;
STW B12,*+SP(_B12) ;
STW B13,*+SP(_B13) ;
STW B14,*+SP(_B14) ;
STW A0,*+SP(_A0) ; Save A0
LDW *+SP(_DUMMY),A0 ;Get the outside B3
STW A1,*+SP(_A1) ; Save A1
STW A2,*+SP(_A2) ; Save A2
STW A3,*+SP(_A3) ; Save A3
STW A4,*+SP(_A4) ; Save A4
STW A0,*+SP(_B3) ; Save B3
STW A5,*+SP(_A5) ;
STW A6,*+SP(_A6) ;
STW A7,*+SP(_A7) ;
STW A8,*+SP(_A8) ;
STW A9,*+SP(_A9) ;
|| MV SP,A0 ; A0 = SP
STW A10,*+SP(_A10) ;
|| addk (_Framesize),A0 ; A0 = SP + FRAME Correct SP for POP of TCB
STW A0,*+SP(_B15) ; B15 = A0 = SP + FRAME
|| B b3 ; Branch to continue in the interrupt handler
STW A11,*+SP(_A11) ;
STW A12,*+SP(_A12) ;
STW A13,*+SP(_A13) ;
STW A14,*+SP(_A14) ;
STW A15,*+SP(_A15) ;
; /*$PAGE*/;
;***********************************************************************
; Resume all register context, used in ISR
;
;***********************************************************************
;
_DSP_C6x_Resume: ; Resume all register context, used in ISR
LDW *+SP(_StartAddress),B3 ; b3 start address
LDW *+SP(_AMR),B10 ; B10 = AMR
LDW *+SP(_CSR),B9 ; B9 = CSR
LDW *+SP(_IER),B8 ; B8 = IER
LDW *+SP(_IRP),B7 ; B7 = IRP
mvk 0,B13
mvc B13,IER
LDW *+SP(_A0),A0 ;
LDW *+SP(_A1),A1 ;
LDW *+SP(_A2),A2 ;
LDW *+SP(_A3),A3 ;
LDW *+SP(_A4),A4 ;
LDW *+SP(_A5),A5 ;
LDW *+SP(_A6),A6 ;
LDW *+SP(_A7),A7 ;
LDW *+SP(_A8),A8 ;
LDW *+SP(_A9),A9 ;
LDW *+SP(_A10),A10 ;
LDW *+SP(_A11),A11 ;
LDW *+SP(_A12),A12 ;
LDW *+SP(_A13),A13 ;
LDW *+SP(_A14),A14 ;
LDW *+SP(_A15),A15 ;
LDW *+SP(_B0),B0 ;
LDW *+SP(_B1),B1 ;
LDW *+SP(_B2),B2 ;
LDW *+SP(_B4),B4 ;
LDW *+SP(_B5),B5 ;
LDW *+SP(_B6),B6 ;
LDW *+SP(_B11),B11 ;
LDW *+SP(_B12),B12 ;
LDW *+SP(_B13),B13 ;
LDW *+SP(_B14),B14 ;
mvc B7,IRP ; Restore IRP
or 3,b9,B9 ; Set GIE
mvc B9,CSR ; set csr if IRP did not put a GIE
mvc B10,AMR ; Restore AMR
LDW *+SP(_B7),B7 ;
LDW *+SP(_B9),B9 ;
LDW *+SP(_B10),B10 ;
LDW *+SP(_B3),B3 ;
LDW *+SP(_B8),B8 ;
LDW *+SP(_B15),B15 ;
B b3 ;
mvc B8,IER ;
nop 5
; /*$PAGE*/
;******************************************************************************
;* FUNCTION NAME: _DSP_C6x_GetCurrentDP (It's used in OSTaskStkInit function) *
;* *
;* Regs Modified : A4 *
;* Regs Used : A4,B3 *
;* Local Frame Size : 0 Args + 0 Auto + 0 Save = 0 byte *
;******************************************************************************
;.align 32
_DSP_C6x_GetCurrentDP:
mv DP,A4
B B3
NOP 5
; /*$PAGE*/
;******************************************************************************
;* FUNCTION NAME: _DSP_C6x_GetCurrentSP (It's used in any ISR function) *
;* *
;* Regs Modified : A4 *
;* Regs Used : A4,B3 *
;* Local Frame Size : 0 Args + 0 Auto + 0 Save = 0 byte *
;******************************************************************************
;.align 32
_DSP_C6x_GetCurrentSP:
mv SP,A4
B B3
NOP 5
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -