📄 platform.inc
字号:
# plant a pointer to the interrupt VSR handler in the # correct vsr table slot. Leave the rest for the monitor. .macro hal_mon_init_vsr_table la v0,__default_interrupt_vsr la v1,hal_vsr_table sw v0,(0*4)(v1) # plant a pointer to our own bus error handler. See the # comments in platform.S. .extern hal_bus_error_vsr la v0,hal_bus_error_vsr sw v0,(7*4)(v1) .endm#else # The other_vector trampoline is already installed as part of # the executable image. However, the TLB exception is, in RAM # in the analogous place to the reset vector in ROM. In a # ROM or ROMRAM startup we need to copy it into place.#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) .macro hal_mon_copy_trampoline la a0,utlb_vector la a1,utlb_vector_end la t0,0xa00000001: lw v0,0(a0) sw v0,0(t0) sw v0,0x80(t0) addiu a0,a0,4 bne a0,a1,1b addiu t0,t0,4#if defined(CYG_HAL_STARTUP_ROM) la a0,other_vector la a1,other_vector_end la t0,0xa00001801: lw v0,0(a0) sw v0,0(t0) addiu a0,a0,4 bne a0,a1,1b addiu t0,t0,4#endif .endm#else .macro hal_mon_copy_trampoline .endm#endif # Fill the VSR table with the default VSRs. # If we contain the stubs, the default VSR will pass # exceptions on to the stubs. .macro hal_mon_init_vsr_table la v0,__default_exception_vsr la v1,hal_vsr_table sw v0,(1*4)(v1) sw v0,(2*4)(v1) sw v0,(3*4)(v1) sw v0,(4*4)(v1) sw v0,(5*4)(v1) sw v0,(6*4)(v1)# sw v0,(7*4)(v1) # Bus error sw v0,(8*4)(v1) sw v0,(9*4)(v1) sw v0,(10*4)(v1) sw v0,(11*4)(v1) sw v0,(12*4)(v1) sw v0,(13*4)(v1) sw v0,(14*4)(v1) sw v0,(15*4)(v1) sw v0,(23*4)(v1) sw v0,(24*4)(v1)# sw v0,(32*4)(v1) # debug sw v0,(33*4)(v1) # utlb sw v0,(34*4)(v1) # nmi la v0,__default_interrupt_vsr sw v0,(0*4)(v1) # plant a pointer to our own bus error handler. See the # comments in platform.S. .extern hal_bus_error_vsr la v0,hal_bus_error_vsr sw v0,(7*4)(v1) .endm#endif#define CYGPKG_HAL_MIPS_MON_DEFINED#endif #------------------------------------------------------------------------------# Diagnostic macros#ifndef CYGPKG_HAL_MIPS_DIAG_DEFINED#if 0 # This code generates characters and hex values to a # Grammar Engine PromICE AI interface.#define AILOC 0xbfc70000 .macro hal_diag_init la v0,AILOC1: lbu v1,3(v0) nop ; nop ; nop subu v1,0xCC beqz v1,1b nop lbu v1,2(v0) b 9f nop .global hal_diag_ai_write_charhal_diag_ai_write_char: .set noat la v0,AILOC # v0 = AI location 1: lbu v1,3(v0) # v1 = status register nop ; nop ; nop andi v1,v1,1 # v1 = TDA bit bnez v1,1b # loop while non-zero nop sll a0,a0,1 # a0 = a0<<1 ori a0,a0,0x0201 # or in start and stop bits li $at,10 # we have 10 bits to send2: andi v1,a0,1 # v1 = ls bit of char add v1,v0,v1 # v1 = address of ZERO or ONE register lbu zero,0(v1) # read it to send bit la v1,100 # delay a bit to let PROMICE deal with it3: bnez v1,3b # loop while non-zero add v1,v1,-1 # decrement in delay slot srl a0,a0,1 # a0 = a0>>1 subu $at,1 # decrement count bnez $at,2b # loop while non-zero nop jr ra # all done, return nop .set at .global hal_diag_ai_write_hex1hal_diag_ai_write_hex1: la v0,9 andi a0,a0,0xf ble a0,v0,1f nop addi a0,a0,('A'-'9'-1)1: addi a0,a0,'0' b hal_diag_ai_write_char nop .global hal_diag_ai_write_hex2hal_diag_ai_write_hex2: move t0,ra # save ra move t1,a0 # save arg srl a0,a0,4 # ms nibble bal hal_diag_ai_write_hex1 nop move a0,t1 # retrieve a0 move ra,t0 # retrieve ra b hal_diag_ai_write_hex1 nop .global hal_diag_ai_write_hex4hal_diag_ai_write_hex4: move t2,ra # save ra move t3,a0 # save arg srl a0,a0,8 # ms byte bal hal_diag_ai_write_hex2 nop move a0,t3 # retrieve a0 move ra,t2 # retrieve ra b hal_diag_ai_write_hex2 nop .global hal_diag_ai_write_hex8hal_diag_ai_write_hex8: move t4,ra # save ra move t5,a0 # save arg srl a0,a0,16 # ms short bal hal_diag_ai_write_hex4 nop move a0,t5 # retrieve a0 move ra,t4 # retrieve ra b hal_diag_ai_write_hex4 nop 9: # Output a '!' to check that the interface is working li a0,'!' bal hal_diag_ai_write_char nop .endm # Utility macro to emit a character .macro hal_diag_writec char .extern hal_diag_ai_write_char la a0,\char lar v0,hal_diag_ai_write_char jalr v0# bal hal_diag_ai_write_char nop .endm#if 0 # This macro outputs a '+', the exception number as a # character offset from 'A' and the exception address # in hex. .macro hal_diag_excpt_start hal_diag_writec '+' srl k0,k0,2 addi a0,k0,'A' jal hal_diag_ai_write_char nop move a0,t6 # we know t6 contains the epc value jal hal_diag_ai_write_hex8 nop .endm#else .macro hal_diag_excpt_start .endm#endif#if 0 # This macro outputs a '=' and the vector number as a # character offset from 'A'. .macro hal_diag_intr_start .extern hal_diag_ai_write_char hal_diag_writec '=' addi a0,s2,'A' jal hal_diag_ai_write_char nop .endm#else .macro hal_diag_intr_start .endm#endif#if 0 .macro hal_diag_restore hal_diag_writec '^' lw a0,mipsreg_pc(sp) lar k0,hal_diag_ai_write_hex8 jalr k0 .endm#else .macro hal_diag_restore .endm#endif#define CYGPKG_HAL_MIPS_DIAG_DEFINED #elif 0#define DELAY(n) \ li $at,n; \9: bnez $at,9b; \ subu $at,1; \ /* Zilog Access Delay */#define DELZ DELAY( (200) ) .macro hal_diag_init la v0,0xc2000000 DELZ lbu v1,8(v0) andi v1,v1,0xfc DELZ sb v1,8(v0) .endm .macro hal_diag_excpt_start .endm .macro hal_diag_intr_start la v0,0xc2000000 DELZ lbu v1,8(v0) xori v1,v1,0x01 DELZ sb v1,8(v0) .endm .macro hal_diag_restore la v0,0xc2000000 DELZ lbu v1,8(v0) xori v1,v1,0x01 DELZ sb v1,8(v0)# li a0,0x0310 # a0 = type = INTR,RAISE# lw a1,mipsreg_sr(sp) # a1 = sr# mfc0 a2,status# jal cyg_instrument # call instrument function# nop .endm#define CYGPKG_HAL_MIPS_DIAG_DEFINED#endif#endif #------------------------------------------------------------------------------#endif // ifndef CYGONCE_HAL_PLATFORM_INC# end of platform.inc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -