Home | History | Annotate | Line # | Download | only in common
execkern.S revision 1.1
      1  1.1  itohy |
      2  1.1  itohy |	execute NetBSD kernel
      3  1.1  itohy |
      4  1.1  itohy |	written by Yasha (ITOH Yasufumi)
      5  1.1  itohy |	public domain
      6  1.1  itohy |
      7  1.1  itohy |	$NetBSD: execkern.S,v 1.1 1998/09/01 19:51:56 itohy Exp $
      8  1.1  itohy 
      9  1.1  itohy /* XXX this value is from <machine/exec_aout.h> */
     10  1.1  itohy #define __LDPGSZ	8192
     11  1.1  itohy 
     12  1.1  itohy #define MFP		0x00E88000	/* MFP */
     13  1.1  itohy #define MFP_IERA	(MFP+0x07)	/* (B) interrupt enable reg A */
     14  1.1  itohy #define MFP_IERB	(MFP+0x09)	/* (B) interrupt enable reg B */
     15  1.1  itohy #define MFP_RSR		(MFP+0x2B)	/* (B) USART receiver status reg */
     16  1.1  itohy 
     17  1.1  itohy #ifndef SRAM_MEMSZ
     18  1.1  itohy #define SRAM		0x00ED0000	/* SRAM start addr */
     19  1.1  itohy #define SRAM_MEMSZ	(SRAM + 8)	/* (L) size of main memory */
     20  1.1  itohy #endif
     21  1.1  itohy 
     22  1.1  itohy |	a3+0	kernel image top address (a.out header is excluded)
     23  1.1  itohy |	a3+4	load address
     24  1.1  itohy |	a3+8	text size
     25  1.1  itohy |	a3+12	data size
     26  1.1  itohy |	a3+16	bss size
     27  1.1  itohy |	a3+20	symbol size
     28  1.1  itohy |	a3+24	(reserved) (d5)
     29  1.1  itohy |	a3+28	bootdev (d6)
     30  1.1  itohy |	a3+32	boothowto (d7)
     31  1.1  itohy |	a3+36	entry address (absolute address)
     32  1.1  itohy 
     33  1.1  itohy #ifndef XK_NO_C_INTERFACE
     34  1.1  itohy 	.text
     35  1.1  itohy 	.even
     36  1.1  itohy 	.globl	_exec_kernel
     37  1.1  itohy _exec_kernel:
     38  1.1  itohy 	addql	#4,sp
     39  1.1  itohy 	moveal	sp@+,a3			| struct execkern_arg *
     40  1.1  itohy #endif
     41  1.1  itohy 
     42  1.1  itohy 	moveal	a3@+,a0			| image address
     43  1.1  itohy 	moveal	a3@+,a1			| load address
     44  1.1  itohy 	movel	a1,d3
     45  1.1  itohy 
     46  1.1  itohy 	|
     47  1.1  itohy 	| copy image
     48  1.1  itohy 	|
     49  1.1  itohy 
     50  1.1  itohy 	| copy text segment
     51  1.1  itohy 	movel	a3@+,d0			| text size
     52  1.1  itohy 	movel	d0,d1
     53  1.1  itohy 	jbsr	copy
     54  1.1  itohy 
     55  1.1  itohy 	| clear gap between text and data
     56  1.1  itohy 	negl	d1
     57  1.1  itohy 	andil	#__LDPGSZ-1,d1
     58  1.1  itohy 	movel	d1,d0			| gap size between text and data
     59  1.1  itohy 	jbsr	clear
     60  1.1  itohy 
     61  1.1  itohy 	| copy data segment
     62  1.1  itohy 	movel	a3@+,d0			| data size
     63  1.1  itohy 	jbsr	copy
     64  1.1  itohy 
     65  1.1  itohy 	| clear bss
     66  1.1  itohy 	movel	a3@+,d0			| bss size
     67  1.1  itohy 	jbsr	clear
     68  1.1  itohy 
     69  1.1  itohy 	| copy symbol table
     70  1.1  itohy 	movel	a3@+,d0			| symbol table size
     71  1.1  itohy 	movel	d0,a1@+
     72  1.1  itohy 	beqs	Lnotable
     73  1.1  itohy 	jbsr	copy
     74  1.1  itohy 
     75  1.1  itohy 	| copy string table size
     76  1.1  itohy 	movel	a0@+,d0
     77  1.1  itohy 	movel	d0,a1@+
     78  1.1  itohy 	beqs	Lnotable
     79  1.1  itohy 
     80  1.1  itohy 	| copy string table
     81  1.1  itohy 	subql	#4,d0			| table size is already copied
     82  1.1  itohy 	jbsr	copy
     83  1.1  itohy 
     84  1.1  itohy Lnotable:
     85  1.1  itohy 
     86  1.1  itohy 	| stop MFP interrupts (for compatibility)
     87  1.1  itohy 	clrb	MFP_IERA
     88  1.1  itohy 	clrb	MFP_IERB
     89  1.1  itohy 	clrb	MFP_RSR
     90  1.1  itohy 
     91  1.1  itohy 	|
     92  1.1  itohy 	| execute kernel
     93  1.1  itohy 	| start(load_addr, mem_max, kernel_end)
     94  1.1  itohy 	|
     95  1.1  itohy 	movel	a1,d0
     96  1.1  itohy 	addql	#3,d0
     97  1.1  itohy 	andib	#0xFC,d0
     98  1.1  itohy 	subl	d3,d0
     99  1.1  itohy 	movel	d0,sp@-			| arg #3 (kernel size)
    100  1.1  itohy 	movel	SRAM_MEMSZ,sp@-		| arg #2 (RAM size from SRAM)
    101  1.1  itohy 	movel	d3,sp@-			| arg #1 (load address)
    102  1.1  itohy 
    103  1.1  itohy #if 0
    104  1.1  itohy 	movel	a3@+,d5			| (reserved)
    105  1.1  itohy 	movel	a3@+,d6			| boot device
    106  1.1  itohy 	movel	a3@+,d7			| boot howto
    107  1.1  itohy 
    108  1.1  itohy 	movel	a3@+,a0			| entry address
    109  1.1  itohy #else	/* optimized */
    110  1.1  itohy 	moveml	a3@+,d5-d7/a0
    111  1.1  itohy #endif
    112  1.1  itohy 
    113  1.1  itohy 	| clear unused registers
    114  1.1  itohy 	moveq	#0,d0
    115  1.1  itohy 	moveq	#0,d1
    116  1.1  itohy 	moveq	#0,d2
    117  1.1  itohy 	moveq	#0,d3
    118  1.1  itohy 	moveq	#0,d4
    119  1.1  itohy 	moveal	d0,a1
    120  1.1  itohy 	moveal	d0,a2
    121  1.1  itohy 	moveal	d0,a3
    122  1.1  itohy 	moveal	d0,a4
    123  1.1  itohy 	moveal	d0,a5
    124  1.1  itohy 	moveal	d0,a6
    125  1.1  itohy 
    126  1.1  itohy 	jsr	a0@			| execute NetBSD kernel
    127  1.1  itohy 	| NOTREACHED
    128  1.1  itohy 
    129  1.1  itohy 	| ??? returned from kernel -- issue software reset
    130  1.1  itohy 	subal	a1,a1
    131  1.1  itohy 	moveml	0x00ff0000,#0x0101	| get RESET vectors (d0: ssp, a0: pc)
    132  1.1  itohy 	moveml	#0x0101,a1@		| put them at 0x00000000 (for Xellent)
    133  1.1  itohy 	.long	0x4E7B9801		| movec	a1,vbr
    134  1.1  itohy 	jmp	a0@			| go to reset address
    135  1.1  itohy 
    136  1.1  itohy 
    137  1.1  itohy |
    138  1.1  itohy | utility routines
    139  1.1  itohy |
    140  1.1  itohy 
    141  1.1  itohy | copy d0 bytes from higher (a0) to lower (a1) address
    142  1.1  itohy 1:	moveb	a0@+,a1@+
    143  1.1  itohy copy:	subql	#1,d0
    144  1.1  itohy 	bpls	1b
    145  1.1  itohy 	rts
    146  1.1  itohy 
    147  1.1  itohy | clear d0 bytes at a1
    148  1.1  itohy | do nothing if d0 is zero
    149  1.1  itohy 1:	clrb	a1@+
    150  1.1  itohy clear:	subql	#1,d0
    151  1.1  itohy 	bpls	1b
    152  1.1  itohy 	rts
    153