]>
Commit | Line | Data |
---|---|---|
57c72a9a | 1 | ; Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved. |
f083c6c3 A |
2 | ; |
3 | ; @APPLE_LICENSE_HEADER_START@ | |
4 | ; | |
57c72a9a | 5 | ; Portions Copyright (c) 2002-2003 Apple Computer, Inc. All Rights |
f083c6c3 A |
6 | ; Reserved. This file contains Original Code and/or Modifications of |
7 | ; Original Code as defined in and that are subject to the Apple Public | |
57c72a9a | 8 | ; Source License Version 2.0 (the "License"). You may not use this file |
f083c6c3 A |
9 | ; except in compliance with the License. Please obtain a copy of the |
10 | ; License at http://www.apple.com/publicsource and read it before using | |
11 | ; this file. | |
12 | ; | |
13 | ; The Original Code and all software distributed under the License are | |
14 | ; distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | ; EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | ; INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | ; FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the | |
18 | ; License for the specific language governing rights and limitations | |
19 | ; under the License. | |
20 | ; | |
21 | ; @APPLE_LICENSE_HEADER_END@ | |
22 | ; | |
23 | ||
24 | kStackAddr EQU 0xFFF0 | |
25 | ||
26 | code16 | |
27 | ORG 0x7c00 | |
28 | ||
29 | SEGMENT .text | |
30 | ||
31 | boot equ $ | |
32 | ||
33 | _start: cli | |
34 | jmp 0:start | |
35 | times 8-($-$$) nop ; Ensure table is at offset 8 | |
36 | ||
37 | ; El Torito boot information table, filled in by the | |
38 | ; mkisofs -boot-info-table option | |
39 | bi_pvd: dd 0 ; LBA of primary volume descriptor | |
40 | bi_file: dd 0 ; LBA of boot file | |
41 | bi_length: dd 0 ; Length of boot file | |
42 | bi_csum: dd 0 ; Checksum of boot file | |
43 | bi_reserved: times 10 dd 0 ; Reserved | |
44 | ||
45 | ||
46 | ||
47 | start: | |
48 | xor ax, ax | |
49 | mov ss, ax | |
50 | mov sp, kStackAddr | |
51 | sti | |
52 | cld | |
53 | mov ds, ax | |
54 | mov es, ax | |
55 | mov [biosdrive], dl | |
56 | ||
57 | mov si, header_str | |
58 | call print_string | |
59 | ||
60 | mov si, drive_str ; print drive number | |
61 | call print_string | |
62 | mov al, dl | |
63 | call print_hex | |
64 | mov si, crnl_str | |
65 | call print_string | |
66 | ||
67 | test1: ; Test 1: El Torito status call | |
68 | mov si, test1_str | |
69 | call print_string | |
70 | ||
71 | mov ax, 0x4b01 | |
72 | mov al, 0x01 | |
73 | ;; dl already contains drive number | |
74 | mov esi, spec | |
75 | int 0x13 | |
76 | ||
77 | jnc test1a ; CF clear? | |
78 | ||
79 | test1_fail: | |
80 | mov si, test1_fail1_str | |
81 | call print_string | |
82 | jmp short test1_end | |
83 | ||
84 | test1a: | |
85 | cmp [spec.drive], dl ; drive in spec packet matches? | |
86 | jne test1a_fail | |
87 | mov si, pass_str | |
88 | call print_string | |
89 | jmp short test1_end | |
90 | ||
91 | test1a_fail: | |
92 | mov si, test1_fail2_str | |
93 | call print_string | |
94 | ||
95 | test1_end: | |
96 | mov si, crnl_str | |
97 | call print_string | |
98 | ||
99 | ||
100 | test2: ; Check for EBIOS support | |
101 | mov si, test2_str | |
102 | call print_string | |
103 | ||
104 | mov cx, 0 | |
105 | mov ah, 0x41 | |
106 | mov bx, 0x55aa | |
107 | mov dl, [biosdrive] | |
108 | int 0x13 | |
109 | ||
110 | jnc test2a ; CF clear? | |
111 | ||
112 | test2_fail: | |
113 | mov si, test2_fail1_str | |
114 | call print_string | |
115 | jmp short test2_end | |
116 | ||
117 | test2a: | |
118 | cmp bx, 0xaa55 | |
119 | je test2b | |
120 | ||
121 | test2a_fail: | |
122 | mov si, test2_fail2_str | |
123 | call print_string | |
124 | jmp short test2_end | |
125 | ||
126 | test2b: | |
127 | mov si, test2_vers_str ; print EDD version | |
128 | call print_string | |
129 | push cx | |
130 | mov al, ah | |
131 | call print_hex | |
132 | mov si, test2_flag_str ; print EDD flags | |
133 | call print_string | |
134 | mov al, cl | |
135 | call print_hex | |
136 | mov al, ' ' | |
137 | call putc | |
138 | pop cx | |
139 | and cl, 0x01 ; EDD drive access? | |
140 | jnz test2_pass | |
141 | ||
142 | test2b_fail: | |
143 | mov si, test2_fail3_str | |
144 | call print_string | |
145 | jmp short test2_end | |
146 | ||
147 | test2_pass | |
148 | mov si, pass_str | |
149 | call print_string | |
150 | ||
151 | test2_end: | |
152 | mov si, crnl_str | |
153 | call print_string | |
154 | ||
155 | test3: ; Disk geometry | |
156 | mov si, test3_str | |
157 | call print_string | |
158 | ||
159 | mov ah, 0x48 | |
160 | mov dl, [biosdrive] | |
161 | mov si, disk_params | |
162 | int 0x13 | |
163 | ||
164 | jnc test3a | |
165 | ||
166 | test3_fail: | |
167 | mov si, test3_fail1_str | |
168 | call print_string | |
169 | jmp test3_end | |
170 | ||
171 | test3a: | |
172 | cmp word [disk_params.nbps], 0x0800 | |
173 | je test3_pass | |
174 | ||
175 | test3a_fail: | |
176 | mov al, [disk_params.nbps+1] | |
177 | call print_hex | |
178 | mov al, [disk_params.nbps] | |
179 | call print_hex | |
180 | mov al, ' ' | |
181 | call putc | |
182 | mov si, test3_fail2_str | |
183 | call print_string | |
184 | jmp test3_end | |
185 | ||
186 | test3_pass: | |
187 | mov si, pass_str | |
188 | call print_string | |
189 | ||
190 | test3_end: | |
191 | mov si, crnl_str | |
192 | call print_string | |
193 | ||
194 | ||
195 | finished: | |
196 | mov si, finished_str | |
197 | call print_string | |
198 | ||
199 | halt: hlt | |
200 | jmp short halt | |
201 | ||
202 | ||
203 | ||
204 | ;; ----- Helper functions ----- | |
205 | ||
206 | ;; putc(ch) | |
207 | ;; character in AL | |
208 | ;; clobbers AX, BX | |
209 | putc: mov bx, 0x000f | |
210 | mov ah, 0x0e | |
211 | int 0x10 | |
212 | ret | |
213 | ||
214 | ;; getc() | |
215 | ;; clobbers AH | |
216 | ;; returns character in AL | |
217 | getc: mov ah, 0 | |
218 | int 0x16 | |
219 | ret | |
220 | ||
221 | ;-------------------------------------------------------------------------- | |
222 | ; Write the byte value to the console in hex. | |
223 | ; | |
224 | ; Arguments: | |
225 | ; AL = Value to be displayed in hex. | |
226 | ; | |
227 | print_hex: | |
228 | push ax | |
229 | ror al, 4 | |
230 | call print_nibble ; display upper nibble | |
231 | pop ax | |
232 | call print_nibble ; display lower nibble | |
233 | ret | |
234 | ||
235 | print_nibble: | |
236 | and al, 0x0f | |
237 | add al, '0' | |
238 | cmp al, '9' | |
239 | jna .print_ascii | |
240 | add al, 'A' - '9' - 1 | |
241 | .print_ascii: | |
242 | call putc | |
243 | ret | |
244 | ||
245 | ;-------------------------------------------------------------------------- | |
246 | ; Write a string to the console. | |
247 | ; | |
248 | ; Arguments: | |
249 | ; DS:SI pointer to a NULL terminated string. | |
250 | ; | |
251 | ; Clobber list: | |
252 | ; none | |
253 | ; | |
254 | print_string: | |
255 | pushad | |
256 | mov bx, 1 ; BH=0, BL=1 (blue) | |
257 | .loop | |
258 | lodsb ; load a byte from DS:SI into AL | |
259 | cmp al, 0 ; Is it a NULL? | |
260 | je .exit ; yes, all done | |
261 | mov ah, 0xE ; INT10 Func 0xE | |
262 | int 0x10 ; display byte in tty mode | |
263 | jmp short .loop | |
264 | .exit | |
265 | popad | |
266 | ret | |
267 | ||
268 | ||
269 | SEGMENT .data | |
270 | ||
271 | ;; Strings | |
272 | ||
273 | header_str: db "BIOS test v0.3", 10,13, 0 | |
274 | finished_str: db "Tests completed.", 10,13,0 | |
275 | drive_str: db "Boot drive: ", 0 | |
276 | pass_str: db "pass", 0 | |
277 | fail_str: db "FAIL", 0 | |
278 | crnl_str: db 10,13, 0 | |
279 | test1_str: db "Test 1: El Torito status: ", 0 | |
280 | test1_fail1_str: db "FAIL (CF=1)", 0 | |
281 | test1_fail2_str: db "FAIL (spec drive)", 0 | |
282 | test2_str: db "Test 2: EBIOS check: ", 0 | |
283 | test2_vers_str: db "vers. ", 0 | |
284 | test2_flag_str: db " flags ", 0 | |
285 | test2_fail1_str: db "FAIL (CF=1)", 0 | |
286 | test2_fail2_str: db "FAIL (BX != AA55)", 0 | |
287 | test2_fail3_str: db "FAIL (CL & 1 == 0)", 0 | |
288 | test3_str: db "Test 3: Geometry check: ", 0 | |
289 | test3_fail1_str: db "FAIL (CF=1)", 0 | |
290 | test3_fail2_str: db "FAIL (nbps != 0x200)", 0 | |
291 | ||
292 | ;; Other variables | |
293 | ||
294 | biosdrive: db 0 | |
295 | ||
296 | ;; El Torito spec packet | |
297 | spec: | |
298 | .size: db 0x13 | |
299 | .type: db 0 | |
300 | .drive: db 0 | |
301 | .index: db 0 | |
302 | .lba: dd 0 | |
303 | .spec: dw 0 | |
304 | .userseg: dw 0 | |
305 | .loadseg: dw 0 | |
306 | .seccnt: dw 0 | |
307 | .cylcnt: db 0 | |
308 | .ccl: db 0 | |
309 | .hdcnt: db 0 | |
310 | ||
311 | ;; Disk parameter packet | |
312 | disk_params: | |
313 | .size: dw 66 | |
314 | .flags: dw 0 | |
315 | .cyls: dd 0 | |
316 | .heads: dd 0 | |
317 | .spt: dd 0 | |
318 | .sectors: dd 0,0 | |
319 | .nbps: dw 0 | |
320 | .dpte_offset: dw 0 | |
321 | .dpte_segment: dw 0 | |
322 | .key: dw 0 | |
323 | .ignored: times 34 db 0 | |
324 | ||
325 |