1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
|
| execute NetBSD kernel
|
|
|
|
|
|
|
|
|
| written by Yasha (ITOH Yasufumi)
|
|
|
|
| public domain
|
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
| $NetBSD: execkern.S,v 1.2 2001/06/12 16:57:27 minoura Exp $
|
1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
/* XXX this value is from <machine/exec_aout.h> */
|
|
|
|
#define __LDPGSZ 8192
|
|
|
|
|
|
|
|
#define MFP 0x00E88000 /* MFP */
|
|
|
|
#define MFP_IERA (MFP+0x07) /* (B) interrupt enable reg A */
|
|
|
|
#define MFP_IERB (MFP+0x09) /* (B) interrupt enable reg B */
|
|
|
|
#define MFP_RSR (MFP+0x2B) /* (B) USART receiver status reg */
|
|
|
|
|
|
|
|
#ifndef SRAM_MEMSZ
|
|
|
|
#define SRAM 0x00ED0000 /* SRAM start addr */
|
|
|
|
#define SRAM_MEMSZ (SRAM + 8) /* (L) size of main memory */
|
|
|
|
#endif
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
| %a3+0 kernel image top address (a.out header is excluded)
|
|
|
|
| %a3+4 load address
|
|
|
|
| %a3+8 text size
|
|
|
|
| %a3+12 data size
|
|
|
|
| %a3+16 bss size
|
|
|
|
| %a3+20 symbol size
|
|
|
|
| %a3+24 (reserved) (%d5)
|
|
|
|
| %a3+28 bootdev (%d6)
|
|
|
|
| %a3+32 boothowto (%d7)
|
|
|
|
| %a3+36 entry address (absolute address)
|
1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
#ifndef XK_NO_C_INTERFACE
|
|
|
|
.text
|
|
|
|
.even
|
2001-06-12 20:57:27 +04:00
|
|
|
ENTRY_NOPROFILE(exec_kernel)
|
|
|
|
addql #4,%sp
|
|
|
|
moveal %sp@+,%a3 | struct execkern_arg *
|
1998-09-01 23:51:56 +04:00
|
|
|
#endif
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
moveal %a3@+,%a0 | image address
|
|
|
|
moveal %a3@+,%a1 | load address
|
|
|
|
movel %a1,%d3
|
1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
| copy image
|
|
|
|
|
|
|
|
|
|
|
|
|
| copy text segment
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%d0 | text size
|
|
|
|
movel %d0,%d1
|
1998-09-01 23:51:56 +04:00
|
|
|
jbsr copy
|
|
|
|
|
|
|
|
| clear gap between text and data
|
2001-06-12 20:57:27 +04:00
|
|
|
negl %d1
|
|
|
|
andil #__LDPGSZ-1,%d1
|
|
|
|
movel %d1,%d0 | gap size between text and data
|
1998-09-01 23:51:56 +04:00
|
|
|
jbsr clear
|
|
|
|
|
|
|
|
| copy data segment
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%d0 | data size
|
1998-09-01 23:51:56 +04:00
|
|
|
jbsr copy
|
|
|
|
|
|
|
|
| clear bss
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%d0 | bss size
|
1998-09-01 23:51:56 +04:00
|
|
|
jbsr clear
|
|
|
|
|
|
|
|
| copy symbol table
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%d0 | symbol table size
|
|
|
|
movel %d0,%a1@+
|
1998-09-01 23:51:56 +04:00
|
|
|
beqs Lnotable
|
|
|
|
jbsr copy
|
|
|
|
|
|
|
|
| copy string table size
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a0@+,%d0
|
|
|
|
movel %d0,%a1@+
|
1998-09-01 23:51:56 +04:00
|
|
|
beqs Lnotable
|
|
|
|
|
|
|
|
| copy string table
|
2001-06-12 20:57:27 +04:00
|
|
|
subql #4,%d0 | table size is already copied
|
1998-09-01 23:51:56 +04:00
|
|
|
jbsr copy
|
|
|
|
|
|
|
|
Lnotable:
|
|
|
|
|
|
|
|
| stop MFP interrupts (for compatibility)
|
|
|
|
clrb MFP_IERA
|
|
|
|
clrb MFP_IERB
|
|
|
|
clrb MFP_RSR
|
|
|
|
|
|
|
|
|
|
|
|
|
| execute kernel
|
|
|
|
| start(load_addr, mem_max, kernel_end)
|
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a1,%d0
|
|
|
|
addql #3,%d0
|
|
|
|
andib #0xFC,%d0
|
|
|
|
subl %d3,%d0
|
|
|
|
movel %d0,%sp@- | arg #3 (kernel size)
|
|
|
|
movel SRAM_MEMSZ,%sp@- | arg #2 (RAM size from SRAM)
|
|
|
|
movel %d3,%sp@- | arg #1 (load address)
|
1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
#if 0
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%d5 | (reserved)
|
|
|
|
movel %a3@+,%d6 | boot device
|
|
|
|
movel %a3@+,%d7 | boot howto
|
1998-09-01 23:51:56 +04:00
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
movel %a3@+,%a0 | entry address
|
1998-09-01 23:51:56 +04:00
|
|
|
#else /* optimized */
|
2001-06-12 20:57:27 +04:00
|
|
|
moveml %a3@+,%d5-%d7/%a0
|
1998-09-01 23:51:56 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
| clear unused registers
|
2001-06-12 20:57:27 +04:00
|
|
|
moveq #0,%d0
|
|
|
|
moveq #0,%d1
|
|
|
|
moveq #0,%d2
|
|
|
|
moveq #0,%d3
|
|
|
|
moveq #0,%d4
|
|
|
|
moveal %d0,%a1
|
|
|
|
moveal %d0,%a2
|
|
|
|
moveal %d0,%a3
|
|
|
|
moveal %d0,%a4
|
|
|
|
moveal %d0,%a5
|
|
|
|
moveal %d0,%a6
|
|
|
|
|
|
|
|
jsr %a0@ | execute NetBSD kernel
|
1998-09-01 23:51:56 +04:00
|
|
|
| NOTREACHED
|
|
|
|
|
|
|
|
| ??? returned from kernel -- issue software reset
|
2001-06-12 20:57:27 +04:00
|
|
|
subal %a1,%a1
|
|
|
|
moveml 0x00ff0000,#0x0101 | get RESET vectors (%d0: ssp, %a0: pc)
|
|
|
|
moveml #0x0101,%a1@ | put them at 0x00000000 (for Xellent)
|
|
|
|
.long 0x4E7B9801 | movec %a1,%vbr
|
|
|
|
jmp %a0@ | go to reset address
|
1998-09-01 23:51:56 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| utility routines
|
|
|
|
|
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
| copy %d0 bytes from higher (%a0) to lower (%a1) address
|
|
|
|
1: moveb %a0@+,%a1@+
|
|
|
|
copy: subql #1,%d0
|
1998-09-01 23:51:56 +04:00
|
|
|
bpls 1b
|
|
|
|
rts
|
|
|
|
|
2001-06-12 20:57:27 +04:00
|
|
|
| clear %d0 bytes at %a1
|
|
|
|
| do nothing if %d0 is zero
|
|
|
|
1: clrb %a1@+
|
|
|
|
clear: subql #1,%d0
|
1998-09-01 23:51:56 +04:00
|
|
|
bpls 1b
|
|
|
|
rts
|