boot.S revision 1.18 1 1.3 minoura | file: boot.S
2 1.3 minoura | author: chapuni(webmaster@chapuni.com)
3 1.9 itohy | ITOH Yasufumi
4 1.1 minoura |
5 1.18 isaki | $NetBSD: boot.S,v 1.18 2020/01/28 11:52:21 isaki Exp $
6 1.15 isaki
7 1.15 isaki |
8 1.15 isaki | (1) IPL (or previous stage loader) loads first 1KB of this primary
9 1.15 isaki | bootloader to (*). (*) is 0x2000 (from FD) or 0x2400 (from SASI/SCSI).
10 1.15 isaki |
11 1.15 isaki | (2) The first 1KB loads full primary bootloader (including first 1KB) from
12 1.17 isaki | the boot partition to 0x3000. And jump to there.
13 1.15 isaki |
14 1.15 isaki | (3) The full primary bootloader loads the secondary bootloader known as
15 1.15 isaki | /boot from its filesystem to 0x6000. And jump to there.
16 1.15 isaki |
17 1.15 isaki | Therefore, The first 1KB must be relocatable.
18 1.15 isaki | The first 1KB must be smaller than or equal to 1024 bytes.
19 1.15 isaki |
20 1.15 isaki | (1) -> (2) -> (3)
21 1.15 isaki | +------------+ +------------+ +------------+ 0x000000
22 1.15 isaki | : : : : : :
23 1.15 isaki | +------------+ +------------+ +------------+ (*)
24 1.15 isaki | | first 1KB | | first 1KB | | first 1KB |
25 1.15 isaki | +------------+ +------------+ +------------+ (*)+0x400
26 1.15 isaki | : : : : : :
27 1.17 isaki | : : +------------+ +------------+ 0x003000
28 1.17 isaki | : : |full primary| |full primary|
29 1.17 isaki | : : |boot loader | |boot loader |
30 1.17 isaki | : : +------------+ +------------+
31 1.17 isaki | : : : : : :
32 1.15 isaki | : : : : +------------+ 0x006000
33 1.15 isaki | : : : : | /boot |
34 1.15 isaki | : : : : +------------+
35 1.15 isaki | : : : : : :
36 1.15 isaki | ~ ~ ~ ~ ~ ~
37 1.15 isaki | : : : :<-SP : :<-SP
38 1.17 isaki | + - - - - - -+ + - - - - - -+ + - - - - - -+ 0x100000
39 1.15 isaki | : : : : : :
40 1.15 isaki |
41 1.1 minoura
42 1.1 minoura #include <machine/asm.h>
43 1.1 minoura #include "iocscall.h"
44 1.1 minoura
45 1.1 minoura #define SRAM 0x00ED0000 /* SRAM stat addr */
46 1.1 minoura #define SRAM_MEMSZ (SRAM + 8) /* (L) size of main memory */
47 1.1 minoura #define MINMEM 0x00400000 /* at least 4MB required */
48 1.1 minoura
49 1.1 minoura #define BOOT_ERROR(s) jbsr boot_error; .asciz s; .even
50 1.1 minoura
51 1.1 minoura .globl _C_LABEL(bootufs)
52 1.1 minoura .text
53 1.1 minoura ASENTRY_NOPROFILE(start)
54 1.1 minoura ASENTRY_NOPROFILE(top)
55 1.1 minoura bras _ASM_LABEL(entry0)
56 1.1 minoura .ascii "SHARP/"
57 1.1 minoura .ascii "X680x0"
58 1.1 minoura .word 0x8199,0x94e6,0x82ea,0x82bd
59 1.1 minoura .word 0x8e9e,0x82c9,0x82cd,0x8cbb
60 1.1 minoura .word 0x8ec0,0x93a6,0x94f0,0x8149
61 1.1 minoura .word 0
62 1.1 minoura | d4 SCSI ID
63 1.1 minoura ASENTRY_NOPROFILE(entry0)
64 1.1 minoura moveml %d0-%d7/%a0-%a7,_C_LABEL(startregs)
65 1.17 isaki lea TEXTADDR:W,%a5 | set base ptr
66 1.17 isaki #define _RELOC(adr) %a5@(((adr)-top):W)
67 1.1 minoura #define ASRELOC(var) _RELOC(_ASM_LABEL(var))
68 1.1 minoura #define RELOC(var) _RELOC(_C_LABEL(var))
69 1.1 minoura
70 1.18 isaki lea RELOC(__bss_start),%a1
71 1.1 minoura bra _ASM_LABEL(entry)
72 1.1 minoura
73 1.1 minoura | Disklabel= 404bytes
74 1.11 isaki | Since LABELOFFSET in <machine/disklabel.h> is 0x40,
75 1.1 minoura | entry must be after 0x000001d4 (0x000f01d4)
76 1.13 isaki .org 0x40
77 1.1 minoura disklabel:
78 1.5 isaki .space 404
79 1.1 minoura
80 1.1 minoura ASENTRY_NOPROFILE(entry)
81 1.1 minoura movew #_end-1,%d0 | bss end (low word only)
82 1.1 minoura
83 1.1 minoura | clear out bss (must be <= 64KB)
84 1.1 minoura subw %a1,%d0
85 1.1 minoura clrbss: clrb %a1@+
86 1.1 minoura dbra %d0,clrbss
87 1.1 minoura
88 1.1 minoura movel %d4,RELOC(ID) | SCSI ID (if booted from SCSI)
89 1.1 minoura
90 1.17 isaki lea 0x00100000,%sp | set system stack
91 1.17 isaki lea %a5@,%a1 | set load address
92 1.17 isaki | a1 will be used later for IOCS calls
93 1.1 minoura
94 1.1 minoura | we use 68020 instructions, and check MPU beforehand
95 1.1 minoura |
96 1.10 isaki | here d0.w = -1, and the above "subw a1,d0" = 0x9049, and
97 1.1 minoura | if MPU <= 010 loads 0x49,
98 1.1 minoura | if MPU >= 020 loads 0x90.
99 1.1 minoura | This is a move, not a tst instruction
100 1.16 isaki | because pc-relative tsts are not available on 000/010.
101 1.1 minoura chkmpu: moveb %pc@(clrbss-chkmpu-2:B,%d0:W:2),%d0 | 103B 02xx
102 1.1 minoura jmi mpuok | MC68020 or later
103 1.1 minoura BOOT_ERROR("MPU 68000?")
104 1.1 minoura mpuok: | XXX check for MMU?
105 1.1 minoura
106 1.1 minoura IOCS(__BOOTINF)
107 1.1 minoura lsll #8,%d0 | clear MSByte
108 1.1 minoura lsrl #8,%d0 |
109 1.1 minoura movel %d0,RELOC(BOOT_INFO)
110 1.1 minoura
111 1.1 minoura |
112 1.1 minoura | 0x80...0x8F SASI
113 1.1 minoura | 0x90...0x93 Floppy
114 1.1 minoura | 0xED0000...0xED3FFE SRAM
115 1.1 minoura | others ROM (SCSI?)
116 1.1 minoura |
117 1.1 minoura movel %d0,%d1
118 1.1 minoura clrb %d1
119 1.1 minoura tstl %d1
120 1.1 minoura jne boot_ram_rom
121 1.1 minoura |
122 1.1 minoura | SASI or Floppy
123 1.1 minoura |
124 1.1 minoura movel %d0,%d2
125 1.1 minoura andib #0xFC,%d0
126 1.1 minoura cmpib #0x90,%d0
127 1.1 minoura jne boot_dev_unsupported | boot from SASI?
128 1.1 minoura |
129 1.1 minoura | Floppy
130 1.1 minoura |
131 1.1 minoura moveb %d2,%d0
132 1.1 minoura andib #0x03,%d0 | drive # (head=0)
133 1.1 minoura jbsr check_fd_format
134 1.1 minoura moveml %d0-%d1,RELOC(FDSECMINMAX) | min and max sec #
135 1.1 minoura lslw #8,%d2
136 1.1 minoura moveq #0x70,%d1
137 1.1 minoura orw %d2,%d1 | PDA*256 + MODE
138 1.1 minoura movel %d1,RELOC(FDMODE)
139 1.1 minoura movel %d0,%d2 | read position (first sector)
140 1.1 minoura movel #8192,%d3 | read bytes
141 1.1 minoura IOCS(__B_READ)
142 1.1 minoura jra boot_read_done
143 1.1 minoura
144 1.1 minoura #include "chkfmt.s"
145 1.1 minoura
146 1.1 minoura boot_ram_rom:
147 1.1 minoura movel %d0,%d1
148 1.1 minoura swap %d1
149 1.1 minoura cmpiw #0x00ED,%d1
150 1.1 minoura jne boot_SCSI
151 1.1 minoura | boot from SRAM?
152 1.1 minoura
153 1.1 minoura boot_dev_unsupported:
154 1.1 minoura BOOT_ERROR("unsupported boot device")
155 1.1 minoura
156 1.1 minoura |
157 1.1 minoura | volatile void BOOT_ERROR(const char *msg);
158 1.1 minoura | print error message, wait for key press and reboot
159 1.1 minoura |
160 1.1 minoura booterr_msg: .ascii "\r\n\n"
161 1.1 minoura .ascii BOOT
162 1.1 minoura .asciz ": "
163 1.1 minoura reboot_msg: .asciz "\r\n[Hit key to reboot]"
164 1.1 minoura .even
165 1.1 minoura
166 1.1 minoura ENTRY_NOPROFILE(BOOT_ERROR)
167 1.1 minoura addql #4,%sp
168 1.1 minoura
169 1.1 minoura boot_error: lea %pc@(booterr_msg),%a1
170 1.1 minoura IOCS(__B_PRINT)
171 1.1 minoura moveal %sp@+,%a1
172 1.1 minoura IOCS(__B_PRINT)
173 1.1 minoura lea %pc@(reboot_msg),%a1
174 1.1 minoura IOCS(__B_PRINT)
175 1.1 minoura
176 1.1 minoura | wait for a key press (or release of a modifier)
177 1.1 minoura IOCS(__B_KEYINP)
178 1.1 minoura
179 1.1 minoura | issue software reset
180 1.1 minoura trap #10
181 1.1 minoura | NOTREACHED
182 1.1 minoura
183 1.1 minoura
184 1.1 minoura |
185 1.1 minoura | ROM boot ... probably from SCSI
186 1.1 minoura |
187 1.1 minoura boot_SCSI:
188 1.1 minoura #ifdef SCSI_ADHOC_BOOTPART
189 1.1 minoura |
190 1.1 minoura | Find out boot partition in an ad hoc manner.
191 1.1 minoura |
192 1.1 minoura
193 1.1 minoura | get block length of the SCSI disk
194 1.1 minoura SCSIIOCS(__S_READCAP) | using buffer at a1
195 1.1 minoura tstl %d0
196 1.1 minoura jeq 1f
197 1.1 minoura BOOT_ERROR("READCAP failed")
198 1.1 minoura 1: moveq #0,%d5
199 1.1 minoura moveb %a1@(6),%d5 | 1: 256, 2: 512, 4: 1024
200 1.1 minoura lsrb #1,%d5 | 0: 256, 1: 512, 2: 1024
201 1.1 minoura movel %d5,RELOC(SCSI_BLKLEN)
202 1.1 minoura
203 1.1 minoura | find out the start position of the boot partition
204 1.1 minoura | XXX VERY AD HOC
205 1.1 minoura |
206 1.1 minoura | ROM firmware:
207 1.1 minoura | pass read pos (in block #) in d2
208 1.4 minoura | Human68k-style partition table does not exist
209 1.4 minoura | d2 is 4 at the maximum
210 1.1 minoura | SCSI IPLs (genuine and SxSI):
211 1.1 minoura | pass read pos (in kilobytes) in d2
212 1.4 minoura | d2 is bigger than 0x20
213 1.1 minoura | partition table on the memory is destroyed
214 1.1 minoura | BOOT MENU Ver.2.22:
215 1.1 minoura | passes partition table entry address in a0
216 1.1 minoura | d2 is cleared to zero
217 1.1 minoura | No other IPL is supported. XXX FIXME
218 1.1 minoura tstl %d2
219 1.1 minoura jne sc1
220 1.1 minoura | no information in d2 -- probably from BOOT MENU
221 1.1 minoura | a0 points the partiion table entry
222 1.1 minoura movel %a0@(0x0008),%d2 | in KByte
223 1.1 minoura sc1: cmpl #0x20,%d2
224 1.1 minoura jcs sc2
225 1.1 minoura lsll #8,%d2 | clear MSByte
226 1.1 minoura lsrl #6,%d2 |
227 1.1 minoura lsrl %d5,%d2 | in sector
228 1.4 minoura sc2:
229 1.1 minoura | read entire boot
230 1.1 minoura moveq #8192/256,%d3 | size is 8KB
231 1.1 minoura lsrl %d5,%d3 | in sector
232 1.1 minoura jbsr scsiread | read at %a1
233 1.4 minoura
234 1.4 minoura cmpil #5,%d2
235 1.4 minoura bcc sc3
236 1.4 minoura movql #0,%d2
237 1.4 minoura sc3: movel %d2,RELOC(SCSI_PARTTOP)
238 1.1 minoura #else
239 1.1 minoura moveq #1,%d5 | 512bytes/sec
240 1.1 minoura movel %d5,%sp@-
241 1.1 minoura moveq #8192/512,%d3 |
242 1.1 minoura moveq #0x40,%d2 | (sd*a )
243 1.1 minoura SCSIIOCS(__S_READ)
244 1.1 minoura #endif
245 1.1 minoura
246 1.1 minoura boot_read_done:
247 1.1 minoura jmp first_kbyte
248 1.1 minoura
249 1.1 minoura read_error: BOOT_ERROR("read error")
250 1.1 minoura
251 1.1 minoura #undef RELOC /* base register a5 is no longer available */
252 1.1 minoura #undef ASRELOC
253 1.1 minoura #undef _RELOC
254 1.1 minoura
255 1.1 minoura |
256 1.1 minoura | read SCSI
257 1.1 minoura |
258 1.1 minoura | input: d2.l: pos in sector
259 1.1 minoura | d3.l: len in sector
260 1.1 minoura | d4: target SCSI ID
261 1.1 minoura | d5: sector length (0: 256, 1: 512, 2: 1024)
262 1.1 minoura | a1: buffer address
263 1.1 minoura | destroy:
264 1.1 minoura | d0, d1, a1
265 1.1 minoura |
266 1.1 minoura scsiread:
267 1.1 minoura moveml %d2-%d3/%d6-%d7/%a2,%sp@-
268 1.1 minoura | if (pos >= 0x200000 || (len > 255 && pos + len >= 0x200000))
269 1.1 minoura | use READEXT
270 1.1 minoura | else
271 1.1 minoura | use READ
272 1.1 minoura moveq #0x20,%d0
273 1.1 minoura swap %d0 | d0.l = 0x00200000
274 1.1 minoura moveq #0,%d6
275 1.1 minoura subqb #1,%d6 | d6.l = 255
276 1.1 minoura moveq #8,%d7
277 1.1 minoura addb %d5,%d7 | d7.b = (sector length: 0-2) + 8
278 1.1 minoura cmpl %d0,%d2
279 1.1 minoura jcc scsiread_ext
280 1.1 minoura moveq #__S_READ,%d1
281 1.1 minoura cmpl %d3,%d6
282 1.1 minoura jcc scsiread_noext
283 1.1 minoura subl %d2,%d0 | d0.0 = 0x200000 - pos
284 1.1 minoura cmpl %d0,%d3 | <= len
285 1.1 minoura jcs scsiread_noext | no
286 1.1 minoura
287 1.1 minoura scsiread_ext: | use READEXT
288 1.1 minoura extw %d6 | d6.l = 65535
289 1.1 minoura moveq #__S_READEXT,%d1
290 1.1 minoura
291 1.1 minoura scsiread_noext: | use READ
292 1.1 minoura loop_scsiread:
293 1.1 minoura | d1: SCSI IOCS call #
294 1.1 minoura | d6: max sector count at a time
295 1.1 minoura movel %d3,%a2 | save original len in a2
296 1.1 minoura cmpl %d3,%d6
297 1.1 minoura jcc 1f
298 1.1 minoura movel %d6,%d3
299 1.1 minoura 1: IOCS(__SCSIDRV) | SCSIIOCS(d1)
300 1.1 minoura tstl %d0
301 1.1 minoura jne read_error
302 1.1 minoura movel %d3,%d0 | addr += read count << (8 + sec len)
303 1.1 minoura asll %d7,%d0
304 1.1 minoura addl %d0,%a1
305 1.1 minoura exg %d3,%a2 | restore original len to d3
306 1.1 minoura addl %a2,%d2 | pos += read count
307 1.1 minoura subl %a2,%d3 | len -= read count
308 1.1 minoura jne loop_scsiread
309 1.1 minoura moveml %sp@+,%d2-%d3/%d6-%d7/%a2
310 1.1 minoura rts
311 1.1 minoura
312 1.1 minoura |
313 1.1 minoura | The former part must reside in the first 1KB.
314 1.1 minoura |
315 1.1 minoura .globl first_kbyte
316 1.1 minoura first_kbyte:
317 1.1 minoura |--------------------------------------------------------------------------
318 1.1 minoura |
319 1.1 minoura | The latter text+data part is not accessible at the first boot time.
320 1.1 minoura | PC-relative can be used from here.
321 1.1 minoura |
322 1.14 isaki | Initialize the screen here. Some IPL (060turbo ROM or
323 1.14 isaki | genuine boot selector) don't initialize the screen.
324 1.14 isaki | Such initialization should be done as early as possible
325 1.14 isaki | but it's too severe to place it in first_kbyte area.
326 1.14 isaki | Therefore do it here.
327 1.14 isaki moveq #0x10,%d1
328 1.14 isaki IOCS(__CRTMOD)
329 1.14 isaki
330 1.1 minoura jmp _C_LABEL(bootufs) | 0x0Fxxxx
331 1.1 minoura
332 1.1 minoura .word 0
333 1.1 minoura
334 1.8 christos | int badbaddr __P((void *adr));
335 1.1 minoura | check if the given address is valid for byte read
336 1.1 minoura | return: 0: valid, 1: not valid
337 1.1 minoura
338 1.1 minoura ENTRY_NOPROFILE(badbaddr)
339 1.1 minoura lea 0x0008:W,%a1 | MPU Bus Error vector
340 1.1 minoura moveq #1,%d0
341 1.1 minoura lea %pc@(badr1),%a0
342 1.1 minoura movew %sr,%sp@-
343 1.1 minoura oriw #0x0700,%sr | keep out interrupts
344 1.1 minoura movel %a1@,%sp@-
345 1.1 minoura movel %a0,%a1@ | set bus error vector
346 1.1 minoura movel %sp,%d1 | save sp
347 1.1 minoura moveal %sp@(10),%a0
348 1.1 minoura tstb %a0@ | try read...
349 1.1 minoura moveq #0,%d0 | this is skipped on bus error
350 1.1 minoura badr1: moveal %d1,%sp | restore sp
351 1.1 minoura movel %sp@+,%a1@
352 1.1 minoura movew %sp@+,%sr
353 1.1 minoura rts
354 1.1 minoura
355 1.1 minoura | void RAW_READ __P((void *buf, u_int32_t blkpos, size_t bytelen));
356 1.1 minoura | inputs:
357 1.1 minoura | buf: input buffer address
358 1.1 minoura | blkpos: read start position in the partition in 512byte-blocks
359 1.1 minoura | bytelen: read length in bytes
360 1.1 minoura
361 1.1 minoura Lraw_read_buf=4+(4*11)
362 1.1 minoura Lraw_read_pos_=Lraw_read_buf+4
363 1.1 minoura Lraw_read_len=Lraw_read_buf+8
364 1.1 minoura
365 1.1 minoura #ifdef SCSI_ADHOC_BOOTPART
366 1.1 minoura | RAW_READ of physical disk
367 1.1 minoura ENTRY_NOPROFILE(RAW_READ0)
368 1.1 minoura moveq #0,%d0
369 1.1 minoura jra raw_read1
370 1.1 minoura #endif
371 1.1 minoura
372 1.1 minoura ENTRY_NOPROFILE(RAW_READ)
373 1.1 minoura #ifdef SCSI_ADHOC_BOOTPART
374 1.1 minoura movel _C_LABEL(SCSI_PARTTOP),%d0
375 1.1 minoura raw_read1:
376 1.1 minoura #endif
377 1.1 minoura moveml %d2-%d7/%a2-%a6,%sp@-
378 1.1 minoura moveml %sp@(Lraw_read_buf),%d1-%d3
379 1.1 minoura movel %d1,%a1
380 1.1 minoura | d2.l: pos in 512byte-blocks
381 1.1 minoura | d3.l: length in bytes
382 1.1 minoura | a1 (=d1): buffer address
383 1.1 minoura
384 1.17 isaki lea TEXTADDR:W,%a5 | set base ptr
385 1.17 isaki #define _RELOC(adr) %a5@(((adr)-top):W)
386 1.1 minoura #define ASRELOC(var) _RELOC(_ASM_LABEL(var))
387 1.1 minoura #define RELOC(var) _RELOC(_C_LABEL(var))
388 1.1 minoura
389 1.1 minoura tstb _RELOC(_C_LABEL(BOOT_INFO)+1) | simple check. may be incorrect!
390 1.1 minoura beqs raw_read_floppy
391 1.1 minoura
392 1.1 minoura raw_read_scsi:
393 1.1 minoura movel RELOC(ID),%d4 | SCSI ID
394 1.1 minoura #ifdef SCSI_ADHOC_BOOTPART
395 1.1 minoura movel RELOC(SCSI_BLKLEN),%d5 | sector size: 0-2
396 1.1 minoura | XXX length must be sector aligned
397 1.1 minoura lsrl #8,%d3 | size in 256byte-blocks
398 1.1 minoura lsrl %d5,%d3 | size in sector
399 1.1 minoura bcss read_half | minimal error check
400 1.1 minoura lsll #1,%d2 | X flag and d2: pos in 256byte-blocks
401 1.1 minoura roxrl %d5,%d2 | pos in sector
402 1.1 minoura addl %d0,%d2 | physical pos in sector
403 1.1 minoura #else
404 1.1 minoura moveq #1,%d5 | 512bytes/sec
405 1.1 minoura moveq #9,%d0 | shift count
406 1.1 minoura addl #511,%d3
407 1.1 minoura lsrl %d0,%d3
408 1.1 minoura bcss read_half | minimal error check
409 1.1 minoura
410 1.1 minoura addl #0x40,%d2 | 'a' partition starts here
411 1.1 minoura #endif
412 1.1 minoura | jcc 1f
413 1.1 minoura | BOOT_ERROR("out of seek") | pos exceeds 32bit
414 1.1 minoura |1:
415 1.1 minoura jbsr scsiread
416 1.1 minoura bras raw_read_end
417 1.1 minoura
418 1.1 minoura raw_read_floppy:
419 1.1 minoura |
420 1.1 minoura | Floppy read routine
421 1.1 minoura |
422 1.1 minoura
423 1.1 minoura | convert to seek position
424 1.1 minoura
425 1.1 minoura asll #2,%d2 | size in 128byte-blocks
426 1.1 minoura
427 1.1 minoura | sec = raw_read_pos (d2)
428 1.1 minoura | sec >>= 7 + (sector length: 0-3)
429 1.1 minoura
430 1.1 minoura lea RELOC(FDSECMINMAX),%a0
431 1.1 minoura moveq #0,%d1
432 1.1 minoura moveb %a0@,%d1 | d1: sector length (0-3)
433 1.1 minoura lsrl %d1,%d2 | d2: pos in sector
434 1.1 minoura bcss read_half | error check
435 1.1 minoura
436 1.1 minoura | trk = sec / (# sectors)
437 1.1 minoura | sec = sec % (# sectors)
438 1.1 minoura
439 1.1 minoura moveb %a0@(7),%d1 | d1: max sector #
440 1.1 minoura subb %a0@(3),%d1 | - min sector #
441 1.1 minoura addqb #1,%d1 | d1: # sectors
442 1.1 minoura divu %d1,%d2 | d2: (sec << 16) | track
443 1.1 minoura
444 1.1 minoura | position = (sec length << 24) | (track/2 << 16)
445 1.1 minoura | | (track%2 << 8) | (min sec # + sec)
446 1.1 minoura
447 1.1 minoura movel %a0@,%d0 | d0: (sec len << 24) | min sec #
448 1.1 minoura lsrw #1,%d2 | d2: (sec << 16) | (track / 2)
449 1.1 minoura jcc 1f
450 1.1 minoura bset #8,%d0 | |= (track % 2) << 8
451 1.1 minoura 1: swap %d2 | d2: ((track / 2) << 16) | sec
452 1.1 minoura addl %d0,%d2 | d2: position
453 1.1 minoura
454 1.1 minoura | read
455 1.1 minoura movel RELOC(FDMODE),%d1 | PDA*256 + MODE
456 1.1 minoura
457 1.1 minoura | B_READ (for floppy)
458 1.1 minoura | d1.w: PDA x 256 + MODE
459 1.1 minoura | PDA: 0x90 (drive 0) ... 0x93 (drive 3)
460 1.1 minoura | MODE: bit6: MFM
461 1.1 minoura | bit5: retry
462 1.1 minoura | bit4: seek
463 1.1 minoura | d2.l: position
464 1.1 minoura | bit31-24: sector length (0: 128, 1: 256, 2: 512, 3: 1K)
465 1.1 minoura | bit23-16: track # (0-79)
466 1.1 minoura | bit15-08: side (0 or 1)
467 1.1 minoura | bit07-00: sector # (1-)
468 1.1 minoura | d3.l: read bytes
469 1.1 minoura | a1: read address
470 1.1 minoura | return:
471 1.1 minoura | d0: bit 31-24 ST0
472 1.1 minoura | bit 23-16 ST1
473 1.1 minoura | bit 15- 8 ST2
474 1.1 minoura | bit 7- 0 C
475 1.1 minoura | -1 on parameter error
476 1.1 minoura | destroy: d0, d2, d3, a1
477 1.1 minoura IOCS(__B_READ)
478 1.1 minoura andil #0xf8ffff00,%d0 | check status (must be zero)
479 1.1 minoura jne read_error
480 1.1 minoura
481 1.1 minoura raw_read_end:
482 1.1 minoura moveml %sp@+,%a2-%a6/%d2-%d7
483 1.1 minoura rts
484 1.1 minoura #undef _RELOC /* base register a5 is no longer available */
485 1.1 minoura #undef ASRELOC
486 1.1 minoura #undef RELOC
487 1.1 minoura
488 1.1 minoura read_half: BOOT_ERROR("read half of block")
489 1.1 minoura
490 1.1 minoura
491 1.1 minoura ENTRY_NOPROFILE(B_PUTC)
492 1.1 minoura movel %sp@(4),%d1
493 1.1 minoura IOCS(__B_PUTC)
494 1.1 minoura rts
495 1.1 minoura
496 1.1 minoura ENTRY_NOPROFILE(B_PRINT)
497 1.1 minoura movel %sp@(4),%a1
498 1.1 minoura IOCS(__B_PRINT)
499 1.1 minoura rts
500 1.1 minoura
501 1.1 minoura |
502 1.1 minoura | void memcpy(void *dst, const void *src, size_t count);
503 1.1 minoura | void memmove(void *dst, const void *src, size_t count);
504 1.1 minoura |
505 1.1 minoura | small and slow memcpy...
506 1.1 minoura | THIS FUNCTION DOES NOT CONFORM THE ANSI STANDARD
507 1.1 minoura |
508 1.1 minoura ENTRY_NOPROFILE(memcpy)
509 1.1 minoura ENTRY_NOPROFILE(memmove)
510 1.1 minoura lea %sp@(12),%a1
511 1.1 minoura movel %a1@,%d1 | count
512 1.1 minoura jeq Lmcpret
513 1.1 minoura moveal %a1@-,%a0 | src
514 1.1 minoura moveal %a1@-,%a1 | dest
515 1.1 minoura cmpl %a1,%a0
516 1.1 minoura jcc Lmcpfw
517 1.1 minoura | copy backward
518 1.1 minoura addal %d1,%a0
519 1.1 minoura addal %d1,%a1
520 1.1 minoura 1: moveb %a0@-,%a1@-
521 1.1 minoura subql #1,%d1
522 1.1 minoura jne 1b
523 1.1 minoura jra Lmcpret
524 1.1 minoura Lmcpfw: | copy forward
525 1.1 minoura 1: moveb %a0@+,%a1@+
526 1.1 minoura subql #1,%d1
527 1.1 minoura jne 1b
528 1.1 minoura Lmcpret:
529 1.1 minoura | movel %sp@(8),%d0 | uncomment this to conform ANSI
530 1.1 minoura rts
531 1.1 minoura
532 1.1 minoura
533 1.1 minoura |
534 1.1 minoura | global variables
535 1.1 minoura |
536 1.1 minoura BSS(ID, 4) | SCSI ID
537 1.1 minoura BSS(BOOT_INFO, 4) | result of IOCS(__BOOTINF)
538 1.1 minoura BSS(FDMODE, 4) | Floppy access mode: PDA x 256 + MODE
539 1.1 minoura BSS(FDSECMINMAX, 8) | +0: (min sector) sector length
540 1.1 minoura | +1: (min sector) track #
541 1.1 minoura | +2: (min sector) side
542 1.1 minoura | +3: (min sector) sector #
543 1.1 minoura | +4: (max sector) sector length
544 1.1 minoura | +5: (max sector) track #
545 1.1 minoura | +6: (max sector) side
546 1.1 minoura | +7: (max sector) sector #
547 1.1 minoura #ifdef SCSI_ADHOC_BOOTPART
548 1.1 minoura BSS(SCSI_PARTTOP, 4) | start sector of boot partition
549 1.1 minoura BSS(SCSI_BLKLEN ,4) | sector len 0: 256, 1: 512, 2: 1024
550 1.1 minoura #endif
551