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