2 | author: chapuni(webmaster@chapuni.com)
3 | Yasha(itohy@NetBSD.org)
6 | $NetBSD: boot_ustar.S,v 1.4.8.3 2004/09/21 13:24:20 skrll Exp $
10 #include <sys/reboot.h>
11 #include <machine/asm.h>
12 #include <machine/bootinfo.h>
15 #define BOOT_ERROR(s) jbsr boot_error; .asciz s; .even
16 #define SRAM_MEMSIZE (0x00ed0008)
19 ASENTRY_NOPROFILE(start)
20 ASENTRY_NOPROFILE(top)
21 bras _ASM_LABEL(entry0)
24 .word 0x8199,0x94e6,0x82ea,0x82bd
25 .word 0x8e9e,0x82c9,0x82cd,0x8cbb
26 .word 0x8ec0,0x93a6,0x94f0,0x8149
28 ASENTRY_NOPROFILE(entry0)
30 lsll #8,%d0 | clear MSByte
36 | 0xED0000...0xED3FFE SRAM
42 jne boot_dev_unsupported
47 | Since LABELLOFFSET in <machine/disklabel.h> is 0x40,
48 | entry must be after 0x000001d4 (0x000021d4)
53 ASENTRY_NOPROFILE(entry)
60 jne boot_dev_unsupported | boot from SASI?
63 | read first 64KB (XXX: CONSTANT!!)
65 andib #0x03,%d0 | drive # (head=0)
70 orw %d2,%d1 | PDA*256 + MODE
71 movel %d0,%d2 | read position (first sector)
72 movel #65536,%d3 | read bytes
73 moval #(BOOT_TEXTADDR-8192-0x200-32),%a1
74 moval %a1,%a4 | save buffer addr
81 BOOT_ERROR("unsupported boot device")
83 booterr_msg: .ascii "\r\n\n"
86 reboot_msg: .asciz "\r\n[Hit key to reboot]"
89 ASENTRY_NOPROFILE(boot_error)
90 lea %pc@(booterr_msg),%a1
94 lea %pc@(reboot_msg),%a1
97 | wait for a key press (or release of a modifier)
100 | issue software reset
105 lea %a4@(8192),%a1 | USTAR header
106 cmpl #0x55535441,%a1@ | filename `USTA
107 bne error_invalidname
108 cmpl #0x522e766f,%a1@(4) | R.vo...'
109 bne error_invalidname
110 cmpl #0x00757374,%a1@(256) | magic `\0ust'
112 cmpw #0x6172,%a1@(260) | magic `ar'
115 lea %a1@(0x200),%a2 | a.out header
116 movml %a2@+,%d0-%d4/%a5
117 addal #8,%a2 | start of text
119 cmpal #BOOT_TEXTADDR,%a5
120 bne error_invalidboot
122 cmpl #0x00870107,%d0 | a.out magic
123 bne error_invalidmagic
125 addl %d2,%d1 | a_text+a_data
126 movl %d3,%d4 | save a_bss
127 addl %d1,%d3 | a_text+a_data+a_bss
135 /* set args for /boot */
136 pea %a2@(%d3) | esym (unused)
137 movel SRAM_MEMSIZE,%sp@- | lastpa (unused)
138 pea %a2@ | firstpa (unused)
146 andil #3,%d6 | bootdev
148 addil #(B_DEVMAGIC+X68K_MAJOR_FD),%d6
149 movl #RB_SINGLE,%d7 | boothowto (unused)
150 moval %a2,%a0 | entry
151 moval %d0,%a1 | unused
152 moval %d0,%a2 | unused
153 moval %d0,%a3 | unused
154 moval %d0,%a4 | unused
155 moval %d0,%a5 | unused
156 moval %d0,%a6 | unused
158 jmp %a0@ | here we go
161 error_invalidname: BOOT_ERROR("Illegal secondary boot");
163 error_invalidmagic: BOOT_ERROR("Invalid magic")
165 ASGLOBAL(first_kbyte)