#include <machine/asm.h>
.text
ASENTRY_NOPROFILE(start)
|| clear bss (this should not hurt us i.e. cause an exception)
movel #_C_LABEL(edata),%a2 | start of BSS
movel #_C_LABEL(end),%a3 | end
Lclr:
clrb %a2@+ | clear BSS
cmpl %a2,%a3 | done?
bne Lclr | no, keep going
movl #0x0808,%d0
movc %d0,%cacr | clear and disable on-chip cache(s)
|| catch exceptions myself
movec %vbr,%a3
movel %a3,save_vbr | save register for restoration
lea vectbl,%a4
movel %a3@(4),%a4@(4) | copy mg, just for sure
movel %a3@(180),%a4@(180) | copy vector for trap #13
movel %a3@(124),%a4@(124) | copy vector for int 7
movec %a4,%vbr | use the new table
|| save mg as pi
movel %a3@(4),_C_LABEL(mg)
|| make sure we disallow interrupts
movew #0x2600,%sr
|| away we go
movel %sp@(4),%sp@- | copy the argument we got
jsr _C_LABEL(main) | call C
addql #4,%sp
|| restore prom vectors
movel save_vbr,%a0
movec %a0,%vbr
|| return kernel start address (still in d0)
rts
ENTRY(_halt)
movel save_vbr,%a0
movec %a0,%vbr | restore prom vbr
hloop:
movel #halt,%d0
trap #13 | halt the system
bra hloop | and do not allow continuation
ASENTRY_NOPROFILE(astrap)
moveml %d0-%d7/%a0-%a7,%sp@- | save all registers
movel %sp,%sp@- | push pointer to registers
jsr _C_LABEL(trap) | call C to handle things (dump regs)
addql #4,%sp
tstl %d0
jeq Lstop
moveml %sp@+,%d0-%d7/%a0-%a7
rte
Lstop:
bra Lstop | stay here
.data
save_vbr:
.long 0
halt:
.asciz "-h"
#define TRAP16 \
VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); \
VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); \
VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); \
VECTOR(astrap); VECTOR(astrap); VECTOR(astrap); VECTOR(astrap);
vectbl:
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16
TRAP16