Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / x68k / stand / boot_ustar / boot_ustar.S
blobb417bfe1228ab3d5316fa57adba2fac94393f4b6
1 | file: boot_ustar.S
2 | author: chapuni(webmaster@chapuni.com)
3 |         Yasha(itohy@NetBSD.org)
4 |         minoura@NetBSD.org
6 | $NetBSD: boot_ustar.S,v 1.4.8.3 2004/09/21 13:24:20 skrll Exp $
8 | supports floppy only
10 #include <sys/reboot.h>
11 #include <machine/asm.h>
12 #include <machine/bootinfo.h>
13 #include "iocscall.h"
15 #define BOOT_ERROR(s)   jbsr boot_error; .asciz s; .even
16 #define SRAM_MEMSIZE    (0x00ed0008)
18         .text
19 ASENTRY_NOPROFILE(start)
20 ASENTRY_NOPROFILE(top)
21                 bras    _ASM_LABEL(entry0)
22                 .ascii  "SHARP/"
23                 .ascii  "X680x0"
24                 .word   0x8199,0x94e6,0x82ea,0x82bd
25                 .word   0x8e9e,0x82c9,0x82cd,0x8cbb
26                 .word   0x8ec0,0x93a6,0x94f0,0x8149
27                 .word   0
28 ASENTRY_NOPROFILE(entry0)
29                 IOCS(__BOOTINF)
30                 lsll    #8,%d0          | clear MSByte
31                 lsrl    #8,%d0          |
33                 |
34                 | 0x80...0x8F           SASI
35                 | 0x90...0x93           Floppy
36                 | 0xED0000...0xED3FFE   SRAM
37                 | others                ROM (SCSI?)
38                 |
39                 movel   %d0,%d1
40                 clrb    %d1
41                 tstl    %d1
42                 jne     boot_dev_unsupported
44                 bra     _ASM_LABEL(entry)
46 |       Disklabel= 404bytes
47 |       Since LABELLOFFSET in <machine/disklabel.h> is 0x40,
48 |       entry must be after 0x000001d4 (0x000021d4)
49                 nop
50 GLOBAL(disklabel)
51                 .space  404
53 ASENTRY_NOPROFILE(entry)
54                 |
55                 | SASI or Floppy
56                 |
57                 movel   %d0,%d6
58                 andib   #0xFC,%d0
59                 cmpib   #0x90,%d0
60                 jne     boot_dev_unsupported    | boot from SASI?
61                 |
62                 | Floppy
63                 |   read first 64KB (XXX: CONSTANT!!)
64                 |
65                 andib   #0x03,%d0       | drive # (head=0)
66                 jbsr    check_fd_format
67                 moveb   %d6,%d2
68                 lslw    #8,%d2
69                 moveq   #0x70,%d1
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
75                 IOCS(__B_READ)
76                 jra     boot_read_done
78 #include "chkfmt.s"
80 boot_dev_unsupported:
81                 BOOT_ERROR("unsupported boot device")
83 booterr_msg:    .ascii  "\r\n\n"
84                 .ascii  BOOT
85                 .asciz  ": "
86 reboot_msg:     .asciz  "\r\n[Hit key to reboot]"
87                 .even
89 ASENTRY_NOPROFILE(boot_error)
90                 lea     %pc@(booterr_msg),%a1
91                 IOCS(__B_PRINT)
92                 moveal  %sp@+,%a1
93                 IOCS(__B_PRINT)
94                 lea     %pc@(reboot_msg),%a1
95                 IOCS(__B_PRINT)
97                 | wait for a key press (or release of a modifier)
98                 IOCS(__B_KEYINP)
100                 | issue software reset
101                 trap    #10
102                 | NOTREACHED
104 boot_read_done:
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'
111                 bne     error_invalidfs
112                 cmpw    #0x6172,%a1@(260)       | magic `ar'
113                 bne     error_invalidfs
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
129         /* clear out bss */
130                 lea     %a2@(%d1),%a3
131 1:              movb    #0,%a3@+
132                 subl    #1,%d4
133                 bne     1b
135         /* set args for /boot */
136                 pea     %a2@(%d3)               | esym (unused)
137                 movel   SRAM_MEMSIZE,%sp@-      | lastpa (unused)
138                 pea     %a2@                    | firstpa (unused)
140                 movq    #0,%d0                  | unused
141                 movq    #0,%d1                  | unused
142                 movq    #0,%d2                  | unused
143                 movq    #0,%d3                  | unused
144                 movq    #0,%d4                  | unused
145                 movq    #0,%d5                  | unused
146                 andil   #3,%d6                  | bootdev
147                 swap    %d6
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
160 error_invalidboot:
161 error_invalidname:      BOOT_ERROR("Illegal secondary boot");
162 error_invalidfs:
163 error_invalidmagic:     BOOT_ERROR("Invalid magic")
165 ASGLOBAL(first_kbyte)