;**************************************************************** ; MARS Check Program ; SH2 Sysreg Test ; ; Copyright SEGA ENTERPRISES,LTD. 1994 ; SEGA ENTERPRISES,LTD. ; CS Hardware R&D Dept. ; T.Okawa ;---------------------------------------------------------------* ; ;**************************************************************** .global comm_test,fmbit_test,intmask_test .global hcnt_test,timer_test,pwmc_test,freq_test .global lch_test,rch_test,mono_test,dl_comm_test .global dl_fm_test,dl_dreq_test,dl_dsrc_test,dl_ddest_test .global dl_dlen_test,vint_test,hint1_test,hint2_test .global hint3_test,sh_rom_test,sh_serial_test .include "include\shmap.i" .include "include\sdram.ass" .include "include\sh_const.ass" ;---------------------------------------------------------------* ; Communication Reg. R/W Test ;---------------------------------------------------------------* comm_test: stc gbr,r10 add #comm0,r10 mov.l #h'ffff,r4 mov #8,r7 comm_00: mov #17,r6 mov #1,r1 comm_01: mov.w r1,@r10 mov.w @r10,r3 extu.w r3,r2 cmp/eq r1,r2 bf comm_err shll r1 and r4,r1 dt r6 bf comm_01 add #2,r10 dt r7 bf comm_00 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop comm_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; FM bit R/W Test ;---------------------------------------------------------------* fmbit_test: stc gbr,r10 add #adapter,r10 mov.l #h'80,r3 mov.l #h'80,r1 mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf fmbit_err mov #0,r1 mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf fmbit_err mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop fmbit_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; Interrupt Mask R/W Test ;---------------------------------------------------------------* intmask_test: stc gbr,r10 add #intmask,r10 mov.l #h'8f,r3 mov #h'10,r4 mov #0,r1 intmask_00: mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf intmask_err dt r4 bf intmask_00 mov.l #h'8f,r1 mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf intmask_err mov #h'0f,r1 mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf intmask_err mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) mov #b'1010,r0 mov.b r0,@(intmask,gbr) rts nop intmask_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #b'1010,r0 mov.b r0,@(intmask,gbr) rts nop ;---------------------------------------------------------------* ; H Counter R/W Test ;---------------------------------------------------------------* hcnt_test: stc gbr,r10 add #hcount,r10 mov #9,r5 mov.l #h'ff,r3 mov #1,r1 hcnt_00: mov.b r1,@r10 mov.b @r10,r2 and r3,r2 cmp/eq r1,r2 bf hcnt_err shll r1 and r3,r1 dt r5 bf hcnt_00 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop hcnt_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; PWM Timer Reg. R/W Test ;---------------------------------------------------------------* timer_test: stc gbr,r10 add #timerctl,r10 mov #4,r5 mov.l #h'100,r1 mov.l #h'f00,r3 timer_00: mov.w r1,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf timer_err shll r1 and r3,r1 dt r5 bf timer_00 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop timer_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; PWM Control Reg. R/W Test ;---------------------------------------------------------------* pwmc_test: stc gbr,r10 add #timerctl,r10 mov #h'10,r5 mov #1,r1 mov #h'0f,r3 pwmc_00: mov.w r1,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf pwmc_err shll r1 and r3,r1 dt r5 bf pwmc_00 mov.l #h'80,r1 mov r1,r3 mov.w r1,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf pwmc_err mov #0,r1 mov.w r1,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf pwmc_err mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop pwmc_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; PWM Frequency Reg. R/W Test ;---------------------------------------------------------------* freq_test: stc gbr,r10 add #cycle,r10 mov #12,r5 mov.l #h'fff,r3 mov #2,r1 freq_00: mov.w r1,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf freq_err shll r1 and r3,r1 dt r5 bf freq_00 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop freq_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; PWM Lch Reg. R/W Test ;---------------------------------------------------------------* lch_test: stc gbr,r10 add #lchwidth,r10 mov.l #h'800,r0 mov.w r0,@(cycle,gbr) mov #1,r0 mov.w r0,@(timerctl,gbr) mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #30,r4 lch_w: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bf lch_w mov.l #h'4000,r3 mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #5,r4 mov r3,r1 lch_00: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt lch_empty_err mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf lch_00 shll r3 mov #0,r1 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf lch_full_err shlr r3 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf lch_empty_err shll r3 mov #0,r0 mov #60*2,r4 mov.w r0,@(m_vint_timer,workbase) lch_01: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt lch_full_err mov r3,r1 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf lch_01 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop lch_empty_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"E",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop lch_full_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"F",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop ;---------------------------------------------------------------* ; PWM Rch Reg. R/W Test ;---------------------------------------------------------------* rch_test: stc gbr,r10 add #rchwidth,r10 mov.l #h'800,r0 mov.w r0,@(cycle,gbr) mov #b'100,r0 mov.w r0,@(timerctl,gbr) mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #30,r4 rch_w: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bf rch_w mov.l #h'4000,r3 mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #5,r4 mov r3,r1 rch_00: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt rch_empty_err mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf rch_00 shll r3 mov #0,r1 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf rch_full_err shlr r3 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf rch_empty_err shll r3 mov #0,r0 mov #60*2,r4 mov.w r0,@(m_vint_timer,workbase) rch_01: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt rch_full_err mov r3,r1 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf rch_01 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop rch_empty_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"E",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop rch_full_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"F",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop ;---------------------------------------------------------------* ; PWM Mnaural Reg. R/W Test ;---------------------------------------------------------------* mono_test: stc gbr,r10 add #monowidth,r10 mov.l #h'800,r0 mov.w r0,@(cycle,gbr) mov #b'101,r0 mov.w r0,@(timerctl,gbr) mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #30,r4 mono_w: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bf mono_w mov.l #h'4000,r3 mov #0,r0 mov.w r0,@(m_vint_timer,workbase) mov #5,r4 mov r3,r1 mono_00: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt mono_empty_err mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf mono_00 shll r3 mov #0,r1 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf mono_full_err shlr r3 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf mono_empty_err shll r3 mov #0,r0 mov #60*2,r4 mov.w r0,@(m_vint_timer,workbase) mono_01: mov.w @(m_vint_timer,workbase),r0 cmp/hs r4,r0 bt mono_full_err mov r3,r1 mov.w r0,@r10 mov.w r0,@r10 mov.w @r10,r2 and r3,r2 cmp/eq r1,r2 bf mono_01 mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop mono_empty_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"E",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop mono_full_err: mov r1,r0 mov.w r0,@(comm4,gbr) mov #"F",r0 mov.w r0,@(comm6,gbr) mov r2,r0 mov.w r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) mov #0,r0 mov.w r0,@(timerctl,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH Communication Reg. Test ;---------------------------------------------------------------* dl_comm_test: mov.l #"END ",r1 dl_comm_00: mov.l @(comm0,gbr),r0 mov.l r0,@(comm8,gbr) cmp/eq r0,r1 bt dl_comm_end mov.l @(comm4,gbr),r0 mov.l r0,@(comm12,gbr) bra dl_comm_00 nop dl_comm_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH FM bit Test ;---------------------------------------------------------------* dl_fm_test: mov.l #"SHWR",r1 mov.l #h'80,r2 dl_fm_00: mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bt dl_fm_01 mov.b @(adapter,gbr),r0 and r2,r0 mov.b r0,@(comm4,gbr) bra dl_fm_00 nop dl_fm_01: mov.l #"END ",r1 mov r2,r0 mov.b r0,@(adapter,gbr) dl_fm_02: mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bt dl_fm_end mov.b @(comm4,gbr),r0 extu.b r0,r3 cmp/eq r3,r2 bf dl_fm_02 mov #0,r0 mov.b r0,@(adapter,gbr) mov r0,r2 dl_fm_03: mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bt dl_fm_end mov.b @(comm4,gbr),r0 extu.b r0,r3 cmp/eq r3,r2 bf dl_fm_03 dl_fm_end: mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bf dl_fm_end mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH DREQ Control Reg. Test ;---------------------------------------------------------------* dl_dreq_test: mov.l #"END ",r1 mov.l #h'87,r2 dl_dreq_00: mov.l @(comm0,gbr),r0 cmp/eq r1,r0 bt dl_dreq_end mov.b @(dreqctl,gbr),r0 and r2,r0 mov.b r0,@(comm4,gbr) bra dl_dreq_00 nop dl_dreq_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH DREQ Source Address Reg. Test ;---------------------------------------------------------------* dl_dsrc_test: mov.l #"END ",r1 mov.l #h'ffffff,r2 dl_dsrc_00: mov.l @(comm0,gbr),r0 cmp/eq r1,r0 bt dl_dsrc_end mov.l @(dreqsource,gbr),r0 mov.l r0,@(comm4,gbr) bra dl_dsrc_00 nop dl_dsrc_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH DREQ Destination Address Reg. Test ;---------------------------------------------------------------* dl_ddest_test: mov.l #"END ",r1 mov.l #h'ffffff,r2 dl_ddest_00: mov.l @(comm0,gbr),r0 cmp/eq r1,r0 bt dl_ddest_end mov.l @(dreqdest,gbr),r0 mov.l r0,@(comm4,gbr) bra dl_ddest_00 nop dl_ddest_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; MD & SH DREQ Length Reg. Test ;---------------------------------------------------------------* dl_dlen_test: mov.l #"END ",r1 mov.l #h'ffffff,r2 dl_dlen_00: mov.l @(comm0,gbr),r0 cmp/eq r1,r0 bt dl_dlen_end mov.w @(dreqlen,gbr),r0 mov.w r0,@(comm4,gbr) bra dl_dlen_00 nop dl_dlen_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; SH2 V Interrupt Test ;---------------------------------------------------------------* vint_test: mov.l #"END ",r1 mov #0,r0 mov.w r0,@(m_vint_timer,workbase) vint_00: mov.w @(m_vint_timer,workbase),r0 mov.w r0,@(comm4,gbr) mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bf vint_00 vint_end: mov #0,r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; SH2 H Interrupt (Mode 0) Test ;---------------------------------------------------------------* hint1_test: mov.l #"END ",r1 mov #b'1110,r0 mov.b r0,@(intmask,gbr) mov #0,r0 mov.b r0,@(hcount,gbr) mov.w r0,@(m_hint1_timer,workbase) hint1_00: mov.w @(m_hint1_timer,workbase),r0 mov.w r0,@(comm4,gbr) mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bf hint1_00 hint1_end: mov #0,r0 mov.l r0,@(comm0,gbr) mov #b'1010,r0 mov.b r0,@(intmask,gbr) rts nop ;---------------------------------------------------------------* ; SH2 H Interrupt (Mode 1) Test ;---------------------------------------------------------------* hint2_test: mov.l #"END ",r1 mov #b'10001110,r0 mov.b r0,@(intmask,gbr) mov #0,r0 mov.b r0,@(hcount,gbr) mov.w r0,@(m_hint1_timer,workbase) hint2_00: mov.w @(m_hint1_timer,workbase),r0 mov.w r0,@(comm4,gbr) mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bf hint2_00 hint2_end: mov #0,r0 mov.l r0,@(comm0,gbr) mov #b'1010,r0 mov.b r0,@(intmask,gbr) rts nop ;---------------------------------------------------------------* ; SH2 H Interrupt (Mode 2) Test ;---------------------------------------------------------------* hint3_test: mov.l #"END ",r1 mov #b'10001110,r0 mov.b r0,@(intmask,gbr) mov #5,r0 mov.b r0,@(hcount,gbr) mov #0,r0 mov.w r0,@(m_hint1_timer,workbase) hint3_00: mov.w @(m_hint1_timer,workbase),r0 mov.w r0,@(comm4,gbr) mov.l @(comm0,gbr),r0 cmp/eq r0,r1 bf hint3_00 hint3_end: mov #0,r0 mov.l r0,@(comm0,gbr) mov.b r0,@(hcount,gbr) mov #b'1010,r0 mov.b r0,@(intmask,gbr) rts nop ;---------------------------------------------------------------* ; SH2 ROM Read Test ;---------------------------------------------------------------* sh_rom_test: mov.l #"BK00",r1 mov.l #CS1TH+h'ffffc,r10 mov.l @r10,r2 cmp/eq r2,r1 bf rom_test_err mov.l #"BK01",r1 mov.l #CS1TH+h'1ffffc,r10 mov.l @r10,r2 cmp/eq r2,r1 bf rom_test_err mov.l #"BK10",r1 mov.l #CS1TH+h'2ffffc,r10 mov.l @r10,r2 cmp/eq r2,r1 bf rom_test_err mov.l #"BK11",r1 mov.l #CS1TH+h'3ffffc,r10 mov.l @r10,r2 cmp/eq r2,r1 bf rom_test_err mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop rom_test_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;---------------------------------------------------------------* ; SH serial test ;---------------------------------------------------------------* sh_serial_test: mov.l #_SCI,r10 serial00: mov.b @(_SSR,r10),r0 tst #h'80,r0 bt serial00 mov #SCI_RXI,r0 not r0,r1 mov.b @(m_sysflug,flugbase),r0 and r1,r0 mov.b r0,@(m_sysflug,flugbase) mov #h'aa,r0 mov.b r0,@(_TDR,r10) mov #h'7f,r0 mov.b r0,@(_SSR,r10) ; TDRE clear mov.b @(_SSR,r10),r0 serial01: mov.b @(m_sysflug,flugbase),r0 tst #SCI_RXI,r0 bt serial01 mov.b @(m_receivedata,flugbase),r0 mov.l #h'aa,r1 extu.b r0,r2 cmp/eq r1,r2 bf serial_err mov.l #"OK ",r0 mov.l r0,@(comm0,gbr) rts nop serial_err: mov r1,r0 mov.b r0,@(comm4,gbr) mov r2,r0 mov.b r0,@(comm8,gbr) mov r10,r0 mov.l r0,@(comm12,gbr) mov.l #"ERR ",r0 mov.l r0,@(comm0,gbr) rts nop ;**************************************************************** ; end of file ;**************************************************************** .end