Annotation of /trunk/mkinitrd-magellan/isolinux/comboot.inc
Parent Directory | Revision Log
Revision 1133 -
(hide annotations)
(download)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
File size: 21435 byte(s)
Thu Aug 19 09:50:43 2010 UTC (14 years, 1 month ago) by niro
File size: 21435 byte(s)
-updated to isolinux-3.86
1 | niro | 532 | ;; ----------------------------------------------------------------------- |
2 | ;; | ||
3 | niro | 1133 | ;; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved |
4 | ;; Copyright 2009 Intel Corporation; author: H. Peter Anvin | ||
5 | ;; | ||
6 | niro | 532 | ;; This program is free software; you can redistribute it and/or modify |
7 | ;; it under the terms of the GNU General Public License as published by | ||
8 | ;; the Free Software Foundation, Inc., 53 Temple Place Ste 330, | ||
9 | ;; Boston MA 02111-1307, USA; either version 2 of the License, or | ||
10 | ;; (at your option) any later version; incorporated herein by reference. | ||
11 | ;; | ||
12 | ;; ----------------------------------------------------------------------- | ||
13 | |||
14 | ;; | ||
15 | ;; comboot.inc | ||
16 | niro | 1133 | ;; |
17 | niro | 532 | ;; Common code for running a COMBOOT image |
18 | ;; | ||
19 | |||
20 | section .text | ||
21 | |||
22 | ; Parameter registers definition; this is the definition | ||
23 | ; of the stack frame used by INT 21h and INT 22h. | ||
24 | %define P_FLAGS word [bp+44] | ||
25 | %define P_FLAGSL byte [bp+44] | ||
26 | %define P_FLAGSH byte [bp+45] | ||
27 | %define P_CS word [bp+42] | ||
28 | %define P_IP word [bp+40] | ||
29 | niro | 1133 | %define P_CSIP dword [bp+40] |
30 | niro | 532 | %define P_DS word [bp+38] |
31 | %define P_ES word [bp+36] | ||
32 | %define P_FS word [bp+34] | ||
33 | %define P_GS word [bp+32] | ||
34 | %define P_EAX dword [bp+28] | ||
35 | %define P_AX word [bp+28] | ||
36 | %define P_HAX word [bp+30] | ||
37 | %define P_AL byte [bp+28] | ||
38 | %define P_AH byte [bp+29] | ||
39 | %define P_ECX dword [bp+24] | ||
40 | %define P_CX word [bp+24] | ||
41 | %define P_HCX word [bp+26] | ||
42 | %define P_CL byte [bp+24] | ||
43 | %define P_CH byte [bp+25] | ||
44 | %define P_EDX dword [bp+20] | ||
45 | %define P_DX word [bp+20] | ||
46 | %define P_HDX word [bp+22] | ||
47 | %define P_DL byte [bp+20] | ||
48 | %define P_DH byte [bp+21] | ||
49 | %define P_EBX dword [bp+16] | ||
50 | %define P_BX word [bp+16] | ||
51 | %define P_HBX word [bp+18] | ||
52 | %define P_BL byte [bp+16] | ||
53 | %define P_BH byte [bp+17] | ||
54 | %define P_EBP dword [bp+8] | ||
55 | %define P_BP word [bp+8] | ||
56 | %define P_HBP word [bp+10] | ||
57 | %define P_ESI dword [bp+4] | ||
58 | %define P_SI word [bp+4] | ||
59 | %define P_HSI word [bp+6] | ||
60 | %define P_EDI dword [bp] | ||
61 | %define P_DI word [bp] | ||
62 | %define P_HDI word [bp+2] | ||
63 | |||
64 | ; Looks like a COMBOOT image but too large | ||
65 | comboot_too_large: | ||
66 | niro | 1133 | call close_file |
67 | niro | 532 | mov si,err_comlarge |
68 | niro | 1133 | call writestr |
69 | niro | 532 | jmp enter_command |
70 | |||
71 | ; | ||
72 | ; Load a COMBOOT image. A COMBOOT image is basically a DOS .COM file, | ||
73 | ; except that it may, of course, not contain any DOS system calls. We | ||
74 | ; do, however, allow the execution of INT 20h to return to SYSLINUX. | ||
75 | ; | ||
76 | is_comboot_image: | ||
77 | push si ; Save file handle | ||
78 | |||
79 | call make_plain_cmdline | ||
80 | |||
81 | call comboot_setup_api | ||
82 | |||
83 | mov cx,comboot_seg | ||
84 | mov es,cx | ||
85 | |||
86 | xor di,di | ||
87 | mov cx,64 ; 256 bytes (size of PSP) | ||
88 | xor eax,eax ; Clear PSP | ||
89 | rep stosd | ||
90 | |||
91 | mov word [es:0], 020CDh ; INT 20h instruction | ||
92 | ; First non-free paragraph | ||
93 | ; This is valid because comboot_seg == real_mode_seg | ||
94 | ; == the highest segment used by all derivatives | ||
95 | int 12h ; Get DOS memory size | ||
96 | shl ax,6 ; Kilobytes -> paragraphs | ||
97 | mov word [es:02h],ax | ||
98 | |||
99 | %ifndef DEPEND | ||
100 | %if real_mode_seg != comboot_seg | ||
101 | %error "This code assumes real_mode_seg == comboot_seg" | ||
102 | %endif | ||
103 | %endif | ||
104 | ; Copy the command line from high memory | ||
105 | mov si,cmd_line_here | ||
106 | mov cx,125 ; Max cmdline len (minus space and CR) | ||
107 | mov di,081h ; Offset in PSP for command line | ||
108 | mov al,' ' ; DOS command lines begin with a space | ||
109 | stosb | ||
110 | |||
111 | .loop: es lodsb | ||
112 | and al,al | ||
113 | jz .done | ||
114 | stosb | ||
115 | loop .loop | ||
116 | .done: | ||
117 | |||
118 | mov al,0Dh ; CR after last character | ||
119 | stosb | ||
120 | mov ax,di | ||
121 | sub al,82h ; Include space but not CR | ||
122 | mov [es:80h],al ; Store command line length | ||
123 | |||
124 | ; Now actually load the file... | ||
125 | pop si ; File handle | ||
126 | mov bx,100h ; Load at <seg>:0100h | ||
127 | niro | 1133 | mov cx,10000h >> SECTOR_SHIFT |
128 | niro | 532 | ; Absolute maximum # of sectors |
129 | call getfssec | ||
130 | niro | 1133 | cmp ecx,65536-256-2 ; Maximum size |
131 | ja comboot_too_large | ||
132 | niro | 532 | |
133 | ; And invoke the program... | ||
134 | mov ax,es | ||
135 | mov ds,ax | ||
136 | mov ss,ax | ||
137 | xor sp,sp | ||
138 | push word 0 ; Return to address 0 -> exit | ||
139 | |||
140 | jmp comboot_seg:100h ; Run it | ||
141 | |||
142 | ; Proper return vector | ||
143 | niro | 1133 | ; Note: this gets invoked both via INT 21h and directly via INT 20h. |
144 | ; We don't need to cld explicitly here, because comboot_exit does that | ||
145 | ; when invoking RESET_STACK_AND_SEGS. | ||
146 | comboot_return: cli ; May not have a safe stack | ||
147 | push enter_command ; Normal return to command prompt | ||
148 | niro | 532 | jmp comboot_exit |
149 | |||
150 | ; | ||
151 | ; Set up the COMBOOT API interrupt vectors. This is also used | ||
152 | ; by the COM32 code. | ||
153 | ; | ||
154 | comboot_setup_api: | ||
155 | niro | 1133 | mov di,DOSErrTramp ; Error trampolines |
156 | mov cx,32 | ||
157 | push cx | ||
158 | mov eax,02EB206Ah ; push 20h; jmp $+4 | ||
159 | .loop1: stosd | ||
160 | inc ah | ||
161 | loop .loop1 | ||
162 | dec di | ||
163 | mov byte [di-1],0E9h | ||
164 | mov ax,comboot_bogus-2 | ||
165 | sub ax,di | ||
166 | stosw | ||
167 | |||
168 | pop cx ; CX <- 32 | ||
169 | mov si,4*20h ; DOS interrupt vectors | ||
170 | mov bx,comboot_vectors | ||
171 | mov di,DOSSaveVectors | ||
172 | .loop2: | ||
173 | movsd | ||
174 | movzx eax,word [bx] | ||
175 | inc bx | ||
176 | inc bx | ||
177 | mov [si-4],eax | ||
178 | loop .loop2 | ||
179 | niro | 532 | ret |
180 | |||
181 | niro | 1133 | section .bss |
182 | alignb 4 | ||
183 | DOSSaveVectors resd 32 | ||
184 | |||
185 | section .data | ||
186 | %define comboot_err(x) (DOSErrTramp+4*((x)-20h)) | ||
187 | |||
188 | comboot_vectors: | ||
189 | dw comboot_return ; INT 20 = exit | ||
190 | dw comboot_int21 ; INT 21 = DOS-compatible system calls | ||
191 | dw comboot_int22 ; INT 22 = native system calls | ||
192 | dw comboot_err(23h) ; INT 23 = DOS Ctrl-C handler | ||
193 | dw comboot_err(24h) ; INT 24 = DOS critical error handler | ||
194 | dw comboot_err(25h) ; INT 25 = DOS absolute disk read | ||
195 | dw comboot_err(26h) ; INT 26 = DOS absolute disk write | ||
196 | dw comboot_err(27h) ; INT 27 = DOS TSR | ||
197 | dw comboot_int28 ; INT 28 = DOS idle interrupt | ||
198 | dw comboot_int29 ; INT 29 = DOS fast console output | ||
199 | dw comboot_err(2Ah) ; INT 2A = DOS network API (NetBIOS) | ||
200 | dw comboot_err(2Bh) ; INT 2B = DOS reserved | ||
201 | dw comboot_err(2Ch) ; INT 2C = DOS reserved | ||
202 | dw comboot_iret ; INT 2D = DOS reserved, AMIS | ||
203 | dw comboot_err(2Eh) ; INT 2E = DOS run command | ||
204 | dw comboot_iret ; INT 2F = DOS multiplex interrupt | ||
205 | dw comboot_err(30h) ; INT 30 = DOS CP/M system calls | ||
206 | dw comboot_err(31h) ; INT 31 = DPMI | ||
207 | dw comboot_err(32h) ; INT 32 = DOS reserved | ||
208 | dw comboot_iret ; INT 33 = DOS mouse API | ||
209 | dw comboot_err(34h) ; INT 34 = DOS FPU emulation | ||
210 | dw comboot_err(35h) ; INT 35 = DOS FPU emulation | ||
211 | dw comboot_err(36h) ; INT 36 = DOS FPU emulation | ||
212 | dw comboot_err(37h) ; INT 37 = DOS FPU emulation | ||
213 | dw comboot_err(38h) ; INT 38 = DOS FPU emulation | ||
214 | dw comboot_err(39h) ; INT 39 = DOS FPU emulation | ||
215 | dw comboot_err(3Ah) ; INT 3A = DOS FPU emulation | ||
216 | dw comboot_err(3Bh) ; INT 3B = DOS FPU emulation | ||
217 | dw comboot_err(3Ch) ; INT 3C = DOS FPU emulation | ||
218 | dw comboot_err(3Dh) ; INT 3D = DOS FPU emulation | ||
219 | dw comboot_err(3Eh) ; INT 3E = DOS FPU emulation | ||
220 | dw comboot_err(3Fh) ; INT 3F = DOS overlay manager | ||
221 | |||
222 | section .text | ||
223 | |||
224 | niro | 532 | ; INT 21h: generic DOS system call |
225 | niro | 1133 | comboot_int21: sti |
226 | niro | 532 | push ds |
227 | push es | ||
228 | push fs | ||
229 | push gs | ||
230 | pushad | ||
231 | cld | ||
232 | mov bp,cs | ||
233 | mov ds,bp | ||
234 | mov es,bp | ||
235 | mov bp,sp ; Set up stack frame | ||
236 | |||
237 | call adjust_screen ; The COMBOOT program might have changed the screen | ||
238 | |||
239 | mov cx,int21_count | ||
240 | mov si,int21_table | ||
241 | .again: lodsb | ||
242 | cmp al,P_AH | ||
243 | lodsw | ||
244 | loopne .again | ||
245 | ; The last function in the list is the | ||
246 | ; "no such function" function | ||
247 | clc | ||
248 | call ax ; Call the invoked function | ||
249 | comboot_resume: | ||
250 | niro | 1133 | mov bp,sp ; In case the function clobbers BP |
251 | niro | 532 | setc P_FLAGSL ; Propagate CF->error |
252 | popad | ||
253 | pop gs | ||
254 | pop fs | ||
255 | pop es | ||
256 | pop ds | ||
257 | niro | 1133 | comboot_iret: |
258 | niro | 532 | iret |
259 | |||
260 | niro | 1133 | comboot_bad_int21: |
261 | mov ax,P_AX | ||
262 | push P_CSIP | ||
263 | push 21h | ||
264 | ; Fall through | ||
265 | |||
266 | ; Attempted to execute invalid DOS system call | ||
267 | ; The interrupt number is on the stack. | ||
268 | comboot_bogus: pop dx ; Interrupt number | ||
269 | pop edi ; CS:IP | ||
270 | mov cx,err_notdos | ||
271 | push comboot_bogus_tail | ||
272 | jmp comboot_exit_msg | ||
273 | comboot_bogus_tail: | ||
274 | xchg ax,dx | ||
275 | call writehex2 ; Interrupt number | ||
276 | mov al,' ' | ||
277 | call writechr | ||
278 | xchg ax,dx | ||
279 | call writehex4 ; Function number (AX) | ||
280 | mov al,' ' | ||
281 | call writechr | ||
282 | mov eax,edi | ||
283 | call writehex8 ; CS:IP of the origin | ||
284 | call crlf | ||
285 | jmp enter_command | ||
286 | |||
287 | niro | 532 | ; |
288 | ; Generic COMBOOT return to command line code | ||
289 | niro | 1133 | ; stack -> where to go next |
290 | ; CX -> message (for _msg version) | ||
291 | niro | 532 | ; |
292 | comboot_exit: | ||
293 | niro | 1133 | xor cx,cx |
294 | comboot_exit_msg: | ||
295 | pop bx ; Return address | ||
296 | RESET_STACK_AND_SEGS SI ; Contains sti, cld | ||
297 | niro | 532 | call adjust_screen ; The COMBOOT program might have changed the screen |
298 | niro | 1133 | pusha |
299 | mov si,DOSSaveVectors | ||
300 | mov di,4*20h | ||
301 | mov cx,20h | ||
302 | rep movsd ; Restore DOS-range vectors | ||
303 | popa | ||
304 | jcxz .nomsg | ||
305 | niro | 532 | mov si,KernelCName |
306 | niro | 1133 | call writestr |
307 | mov si,cx | ||
308 | call writestr | ||
309 | .nomsg: | ||
310 | jmp bx | ||
311 | niro | 532 | |
312 | ; | ||
313 | ; INT 21h system calls | ||
314 | ; | ||
315 | comboot_getkey: ; 01 = get key with echo | ||
316 | call vgashowcursor | ||
317 | call comboot_getchar | ||
318 | call vgahidecursor | ||
319 | call writechr | ||
320 | clc | ||
321 | ret | ||
322 | |||
323 | comboot_writechr: ; 02 = writechr | ||
324 | mov al,P_DL | ||
325 | call writechr | ||
326 | clc | ||
327 | ret | ||
328 | |||
329 | comboot_writeserial: ; 04 = write serial port | ||
330 | mov al,P_DL | ||
331 | call write_serial | ||
332 | clc | ||
333 | ret | ||
334 | |||
335 | comboot_getkeynoecho: ; 08 = get key w/o echo | ||
336 | call comboot_getchar | ||
337 | clc | ||
338 | ret | ||
339 | |||
340 | comboot_writestr: ; 09 = write DOS string | ||
341 | mov es,P_DS | ||
342 | mov si,P_DX | ||
343 | .loop: es lodsb | ||
344 | cmp al,'$' ; End string with $ - bizarre | ||
345 | je .done | ||
346 | call writechr | ||
347 | jmp short .loop | ||
348 | .done: clc | ||
349 | ret | ||
350 | |||
351 | comboot_checkkey: ; 0B = check keyboard status | ||
352 | cmp byte [APIKeyFlag],00h | ||
353 | jnz .waiting | ||
354 | call pollchar | ||
355 | .waiting: setz al | ||
356 | dec al ; AL = 0FFh if present, 0 if not | ||
357 | mov P_AL,al | ||
358 | clc | ||
359 | ret | ||
360 | |||
361 | comboot_checkver: ; 30 = check DOS version | ||
362 | ; We return 0 in all DOS-compatible version registers, | ||
363 | ; but the high part of eax-ebx-ecx-edx spell "SYSLINUX" | ||
364 | mov P_EAX,'SY' << 16 | ||
365 | mov P_EBX,'SL' << 16 | ||
366 | mov P_ECX,'IN' << 16 | ||
367 | mov P_EDX,'UX' << 16 | ||
368 | ret | ||
369 | |||
370 | comboot_getchar: | ||
371 | cmp byte [APIKeyFlag],00h | ||
372 | jne .queued | ||
373 | call getchar ; If not queued get input | ||
374 | and al,al ; Function key? (CF <- 0) | ||
375 | jnz .done | ||
376 | mov [APIKeyWait],ah ; High part of key | ||
377 | inc byte [APIKeyFlag] ; Set flag | ||
378 | .done: mov P_AL,al | ||
379 | ret | ||
380 | .queued: mov al,[APIKeyWait] | ||
381 | dec byte [APIKeyFlag] | ||
382 | jmp .done | ||
383 | |||
384 | ; | ||
385 | niro | 1133 | ; INT 28h - DOS idle |
386 | ; | ||
387 | comboot_int28: | ||
388 | sti | ||
389 | cld | ||
390 | call do_idle | ||
391 | iret | ||
392 | |||
393 | ; | ||
394 | ; INT 29h - DOS fast write character | ||
395 | ; | ||
396 | comboot_int29: | ||
397 | sti | ||
398 | cld | ||
399 | call writechr ; Preserves registers! | ||
400 | iret | ||
401 | |||
402 | ; | ||
403 | niro | 532 | ; INT 22h - SYSLINUX-specific system calls |
404 | ; System call number in ax | ||
405 | ; | ||
406 | comboot_int22: | ||
407 | niro | 1133 | sti |
408 | niro | 532 | push ds |
409 | push es | ||
410 | push fs | ||
411 | push gs | ||
412 | pushad | ||
413 | cld | ||
414 | mov bp,cs | ||
415 | mov ds,bp | ||
416 | mov es,bp | ||
417 | mov bp,sp ; Set up stack frame | ||
418 | |||
419 | call adjust_screen ; The COMBOOT program might have changed the screen | ||
420 | |||
421 | cmp ax,int22_count | ||
422 | jb .ok | ||
423 | xor ax,ax ; Function 0 -> unimplemented | ||
424 | .ok: | ||
425 | xchg ax,bx | ||
426 | add bx,bx ; CF <- 0 | ||
427 | call [bx+int22_table] | ||
428 | jmp comboot_resume ; On return | ||
429 | |||
430 | ; | ||
431 | ; INT 22h AX=0000h Unimplemented call | ||
432 | ; | ||
433 | comapi_err: | ||
434 | stc | ||
435 | ret | ||
436 | |||
437 | ; | ||
438 | ; INT 22h AX=0001h Get SYSLINUX version | ||
439 | ; | ||
440 | comapi_get_version: | ||
441 | ; Number of API functions supported | ||
442 | mov P_AX,int22_count | ||
443 | ; SYSLINUX version | ||
444 | niro | 1133 | mov P_CX,(VERSION_MAJOR << 8)+VERSION_MINOR |
445 | niro | 532 | ; SYSLINUX derivative ID byte |
446 | mov P_DX,my_id | ||
447 | ; For future use | ||
448 | mov P_BX,cs ; cs == 0 | ||
449 | |||
450 | mov P_ES,ds | ||
451 | ; ES:SI -> version banner | ||
452 | niro | 1133 | mov P_SI,syslinux_banner + 2 ; Skip leading CR LF |
453 | niro | 532 | ; ES:DI -> copyright string |
454 | niro | 1133 | mov P_DI,copyright_str + 1 ; Skip leading space |
455 | niro | 532 | |
456 | comapi_nop: | ||
457 | clc | ||
458 | ret | ||
459 | |||
460 | ; | ||
461 | ; INT 22h AX=0002h Write string | ||
462 | ; | ||
463 | ; Write null-terminated string in ES:BX | ||
464 | ; | ||
465 | comapi_writestr: | ||
466 | mov ds,P_ES | ||
467 | mov si,P_BX | ||
468 | call writestr | ||
469 | clc | ||
470 | ret | ||
471 | |||
472 | ; | ||
473 | ; INT 22h AX=0003h Run command | ||
474 | ; | ||
475 | ; Terminates the COMBOOT program and executes the command line in | ||
476 | ; ES:BX as if it had been entered by the user. | ||
477 | ; | ||
478 | comapi_run: | ||
479 | mov ds,P_ES | ||
480 | mov si,P_BX | ||
481 | mov di,command_line | ||
482 | call strcpy | ||
483 | niro | 1133 | push load_kernel ; Run a new kernel |
484 | jmp comboot_exit ; Terminate task, clean up | ||
485 | niro | 532 | |
486 | ; | ||
487 | niro | 1133 | ; INT 22h AX=0004h Run default command |
488 | niro | 532 | ; |
489 | ; Terminates the COMBOOT program and executes the default command line | ||
490 | ; as if a timeout had happened or the user pressed <Enter>. | ||
491 | ; | ||
492 | comapi_run_default: | ||
493 | niro | 1133 | push auto_boot |
494 | jmp comboot_exit | ||
495 | niro | 532 | |
496 | ; | ||
497 | ; INT 22h AX=0005h Force text mode | ||
498 | ; | ||
499 | ; Puts the video in standard text mode | ||
500 | ; | ||
501 | comapi_textmode: | ||
502 | call vgaclearmode | ||
503 | clc | ||
504 | ret | ||
505 | |||
506 | ; | ||
507 | ; INT 22h AX=0006h Open file | ||
508 | ; | ||
509 | comapi_open: | ||
510 | niro | 1133 | call reset_idle |
511 | niro | 532 | push ds |
512 | mov ds,P_ES | ||
513 | mov si,P_SI | ||
514 | mov di,InitRD | ||
515 | call mangle_name | ||
516 | pop ds | ||
517 | call searchdir | ||
518 | jz comapi_err | ||
519 | niro | 1133 | mov P_EAX,eax |
520 | niro | 532 | mov P_CX,SECTOR_SIZE |
521 | mov P_SI,si | ||
522 | clc | ||
523 | ret | ||
524 | |||
525 | ; | ||
526 | ; INT 22h AX=0007h Read file | ||
527 | ; | ||
528 | comapi_read: | ||
529 | niro | 1133 | call reset_idle |
530 | niro | 532 | mov es,P_ES |
531 | mov bx,P_BX | ||
532 | mov si,P_SI | ||
533 | mov cx,P_CX | ||
534 | call getfssec | ||
535 | jnc .noteof | ||
536 | xor si,si ; SI <- 0 on EOF, CF <- 0 | ||
537 | .noteof: mov P_SI,si | ||
538 | niro | 1133 | mov P_ECX,ecx |
539 | niro | 532 | ret |
540 | |||
541 | ; | ||
542 | ; INT 22h AX=0008h Close file | ||
543 | ; | ||
544 | comapi_close: | ||
545 | niro | 1133 | mov si,P_SI |
546 | call close_file | ||
547 | niro | 532 | clc |
548 | ret | ||
549 | |||
550 | ; | ||
551 | ; INT 22h AX=0009h Call PXE stack | ||
552 | ; | ||
553 | %if IS_PXELINUX | ||
554 | comapi_pxecall: | ||
555 | mov bx,P_BX | ||
556 | mov es,P_ES | ||
557 | mov di,P_DI | ||
558 | call pxenv | ||
559 | niro | 1133 | mov ax,[PXEStatus] |
560 | niro | 532 | mov P_AX,ax |
561 | ret | ||
562 | %else | ||
563 | comapi_pxecall equ comapi_err ; Not available | ||
564 | %endif | ||
565 | |||
566 | ; | ||
567 | ; INT 22h AX=000Ah Get Derivative-Specific Info | ||
568 | ; | ||
569 | comapi_derinfo: | ||
570 | mov P_AL,my_id | ||
571 | niro | 1133 | %if IS_PXELINUX |
572 | niro | 532 | mov ax,[APIVer] |
573 | mov P_DX,ax | ||
574 | mov ax,[StrucPtr] | ||
575 | mov P_BX,ax | ||
576 | mov ax,[StrucPtr+2] | ||
577 | mov P_ES,ax | ||
578 | mov ax,[InitStack] | ||
579 | mov P_SI,ax | ||
580 | mov ax,[InitStack+2] | ||
581 | mov P_FS,ax | ||
582 | niro | 1133 | mov eax,[MyIP] |
583 | mov P_ECX,eax | ||
584 | %else | ||
585 | ; Physical medium... | ||
586 | |||
587 | mov P_CL,SECTOR_SHIFT | ||
588 | mov al,[DriveNumber] | ||
589 | niro | 532 | mov P_DL,al |
590 | niro | 1133 | mov P_FS,cs |
591 | mov P_SI,OrigESDI | ||
592 | %if IS_SYSLINUX || IS_EXTLINUX | ||
593 | niro | 532 | mov P_ES,cs |
594 | niro | 1133 | mov P_BX,PartInfo |
595 | %elif IS_ISOLINUX | ||
596 | mov P_ES,cs | ||
597 | niro | 532 | mov P_BX,spec_packet |
598 | niro | 1133 | mov ax,[BIOSType] |
599 | sub ax,bios_cdrom | ||
600 | shr ax,2 | ||
601 | mov P_CH,al ; Mode (el torito/cbios/ebios) | ||
602 | niro | 532 | %endif |
603 | niro | 1133 | %endif |
604 | niro | 532 | clc |
605 | ret | ||
606 | |||
607 | ; | ||
608 | ; INT 22h AX=000Bh Get Serial Console Configuration | ||
609 | ; | ||
610 | comapi_serialcfg: | ||
611 | mov ax,[SerialPort] | ||
612 | mov P_DX,ax | ||
613 | mov ax,[BaudDivisor] | ||
614 | mov P_CX,ax | ||
615 | mov ax,[FlowControl] | ||
616 | or al,ah | ||
617 | mov ah,[FlowIgnore] | ||
618 | shr ah,4 | ||
619 | test byte [DisplayCon],01h | ||
620 | jnz .normalconsole | ||
621 | or ah,80h | ||
622 | .normalconsole: | ||
623 | mov P_BX,ax | ||
624 | clc | ||
625 | ret | ||
626 | |||
627 | ; | ||
628 | ; INT 22h AX=000Ch Perform final cleanup | ||
629 | ; | ||
630 | comapi_cleanup: | ||
631 | %if IS_PXELINUX | ||
632 | ; Unload PXE if requested | ||
633 | test dl,3 | ||
634 | setnz [KeepPXE] | ||
635 | sub bp,sp ; unload_pxe may move the stack around | ||
636 | call unload_pxe | ||
637 | add bp,sp ; restore frame pointer... | ||
638 | niro | 1133 | %elif IS_SYSLINUX || IS_EXTLINUX |
639 | niro | 532 | ; Restore original FDC table |
640 | mov eax,[OrigFDCTabPtr] | ||
641 | mov [fdctab],eax | ||
642 | %endif | ||
643 | niro | 1133 | call cleanup_hardware |
644 | niro | 532 | clc |
645 | ret | ||
646 | |||
647 | ; | ||
648 | ; INT 22h AX=000Dh Clean up then replace bootstrap | ||
649 | ; | ||
650 | comapi_chainboot: | ||
651 | call comapi_cleanup | ||
652 | mov eax,P_EDI | ||
653 | mov [trackbuf+4],eax ; Copy from | ||
654 | mov eax,P_ECX | ||
655 | mov [trackbuf+8],eax ; Total bytes | ||
656 | mov eax,7C00h | ||
657 | mov [trackbuf],eax ; Copy to | ||
658 | niro | 1133 | push eax ; Entry point on stack |
659 | niro | 532 | mov esi,P_ESI |
660 | mov edx,P_EBX | ||
661 | mov bx,P_DS | ||
662 | jmp replace_bootstrap_one | ||
663 | |||
664 | ; | ||
665 | ; INT 22h AX=000Eh Get configuration file name | ||
666 | ; | ||
667 | comapi_configfile: | ||
668 | mov P_ES,cs | ||
669 | mov P_BX,ConfigName | ||
670 | clc | ||
671 | ret | ||
672 | |||
673 | ; | ||
674 | ; INT 22h AX=000Fh Get IPAPPEND strings | ||
675 | ; | ||
676 | comapi_ipappend: | ||
677 | mov P_ES,cs | ||
678 | mov P_CX,numIPAppends | ||
679 | mov P_BX,IPAppends | ||
680 | clc | ||
681 | ret | ||
682 | |||
683 | ; | ||
684 | ; INT 22h AX=0010h Resolve hostname | ||
685 | ; | ||
686 | %if IS_PXELINUX | ||
687 | comapi_dnsresolv: | ||
688 | mov ds,P_ES | ||
689 | mov si,P_BX | ||
690 | call dns_resolv | ||
691 | mov P_EAX,eax | ||
692 | niro | 1133 | clc |
693 | niro | 532 | ret |
694 | %else | ||
695 | comapi_dnsresolv equ comapi_err | ||
696 | %endif | ||
697 | niro | 1133 | |
698 | niro | 532 | section .text |
699 | |||
700 | ; | ||
701 | niro | 1133 | ; INT 22h AX=0011h Obsolete |
702 | niro | 532 | ; |
703 | |||
704 | ; | ||
705 | niro | 1133 | ; INT 22h AX=0012h Obsolete |
706 | niro | 532 | ; |
707 | |||
708 | ; | ||
709 | ; INT 22h AX=0013h Idle call | ||
710 | ; | ||
711 | comapi_idle: | ||
712 | niro | 1133 | call do_idle |
713 | niro | 532 | clc |
714 | ret | ||
715 | |||
716 | ; | ||
717 | ; INT 22h AX=0014h Local boot | ||
718 | ; | ||
719 | niro | 1133 | %if HAS_LOCALBOOT |
720 | niro | 532 | comapi_localboot: |
721 | mov ax,P_DX | ||
722 | jmp local_boot | ||
723 | %else | ||
724 | comapi_localboot equ comapi_err | ||
725 | niro | 1133 | %endif ; HAS_LOCALBOOT |
726 | niro | 532 | |
727 | ; | ||
728 | ; INT 22h AX=0015h Feature flags | ||
729 | ; | ||
730 | comapi_features: | ||
731 | mov P_ES,cs | ||
732 | mov P_BX,feature_flags | ||
733 | mov P_CX,feature_flags_len | ||
734 | clc | ||
735 | ret | ||
736 | |||
737 | ; | ||
738 | ; INT 22h AX=0016h Run kernel image | ||
739 | ; | ||
740 | comapi_runkernel: | ||
741 | niro | 1133 | mov al,P_DL |
742 | cmp al,VK_TYPES-1 | ||
743 | ja .error | ||
744 | mov [KernelType],al | ||
745 | niro | 532 | push ds |
746 | mov ds,P_DS | ||
747 | mov si,P_SI | ||
748 | mov di,KernelName | ||
749 | call mangle_name | ||
750 | pop ds | ||
751 | call searchdir | ||
752 | jz comapi_err | ||
753 | |||
754 | ; The kernel image was found, so we can load it... | ||
755 | mov [Kernel_SI],si | ||
756 | niro | 1133 | mov [Kernel_EAX],eax |
757 | |||
758 | niro | 532 | ; It's not just possible, but quite likely, that ES:BX |
759 | niro | 1133 | ; points into real_mode_seg or xfer_buf_seg, so we |
760 | ; need to exercise some special care here... use | ||
761 | ; trackbuf as an intermediary | ||
762 | niro | 532 | push ds |
763 | mov ds,P_ES | ||
764 | mov si,P_BX | ||
765 | niro | 1133 | mov di,trackbuf |
766 | niro | 532 | call strcpy |
767 | pop ds | ||
768 | |||
769 | %if IS_PXELINUX | ||
770 | mov al,P_CL | ||
771 | mov [IPAppend],al | ||
772 | %endif | ||
773 | |||
774 | niro | 1133 | call comboot_exit |
775 | niro | 532 | |
776 | .finish: | ||
777 | ; Copy the command line into its proper place | ||
778 | push es | ||
779 | mov dx,real_mode_seg | ||
780 | mov es,dx | ||
781 | niro | 1133 | mov si,trackbuf |
782 | niro | 532 | mov di,cmd_line_here |
783 | call strcpy | ||
784 | mov byte [es:di-1],' ' ; Simulate APPEND | ||
785 | pop es | ||
786 | mov [CmdLinePtr],di | ||
787 | mov word [CmdOptPtr],zero_string | ||
788 | jmp kernel_good_saved | ||
789 | |||
790 | niro | 1133 | .error equ comapi_usingvga.error |
791 | |||
792 | ; | ||
793 | ; INT 22h AX=0017h Report video mode change | ||
794 | ; | ||
795 | comapi_usingvga: | ||
796 | mov ax,P_BX | ||
797 | cmp ax,0Fh ; Unknown flags = failure | ||
798 | ja .error | ||
799 | mov [UsingVGA],al | ||
800 | mov cx,P_CX | ||
801 | mov dx,P_DX | ||
802 | mov [GXPixCols],cx | ||
803 | mov [GXPixRows],dx | ||
804 | test al,08h | ||
805 | jnz .notext | ||
806 | call adjust_screen | ||
807 | .notext: | ||
808 | clc | ||
809 | ret | ||
810 | .error: | ||
811 | stc | ||
812 | ret | ||
813 | |||
814 | ; | ||
815 | ; INT 22h AX=0018h Query custom font | ||
816 | ; | ||
817 | comapi_userfont: | ||
818 | mov al,[UserFont] | ||
819 | and al,al | ||
820 | jz .done | ||
821 | mov al,[VGAFontSize] | ||
822 | mov P_ES,aux_seg | ||
823 | mov P_BX,aux.fontbuf | ||
824 | |||
825 | .done: ; CF=0 here | ||
826 | mov P_AL,al | ||
827 | ret | ||
828 | |||
829 | ; | ||
830 | ; INT 22h AX=0019h Read disk | ||
831 | ; | ||
832 | %if IS_SYSLINUX || IS_ISOLINUX || IS_EXTLINUX | ||
833 | comapi_readdisk: | ||
834 | call reset_idle | ||
835 | mov esi,P_ESI ; Enforce ESI == EDI == 0, these | ||
836 | or esi,P_EDI ; are reserved for future expansion | ||
837 | jnz .err | ||
838 | mov eax,P_EDX | ||
839 | mov es,P_ES | ||
840 | mov bx,P_BX | ||
841 | mov bp,P_CX ; WE CANNOT use P_* after touching bp! | ||
842 | call getlinsec | ||
843 | clc | ||
844 | ret | ||
845 | .err: | ||
846 | stc | ||
847 | ret | ||
848 | %else | ||
849 | comapi_readdisk equ comapi_err | ||
850 | %endif | ||
851 | |||
852 | ; | ||
853 | ; INT 22h AX=001Ah Obsolete | ||
854 | ; | ||
855 | |||
856 | ; | ||
857 | ; INT 22h AX=001Bh Obsolete | ||
858 | ; | ||
859 | |||
860 | ; | ||
861 | ; INT 22h AX=001Ch Get pointer to auxillary data vector | ||
862 | ; | ||
863 | comapi_getadv: | ||
864 | mov P_ES,ds | ||
865 | mov P_BX,adv0.data | ||
866 | mov P_CX,ADV_LEN | ||
867 | ret | ||
868 | |||
869 | ; | ||
870 | ; INT 22h AX=001Dh Write auxillary data vector | ||
871 | ; | ||
872 | comapi_writeadv equ adv_write | ||
873 | |||
874 | ; | ||
875 | ; INT 22h AX=001Eh Keyboard remapping table | ||
876 | comapi_kbdtable: | ||
877 | cmp P_DX,0 | ||
878 | jne .err | ||
879 | mov P_AX,1 ; Version | ||
880 | mov P_CX,256 ; Length | ||
881 | mov P_ES,cs | ||
882 | mov P_BX,KbdMap | ||
883 | ret | ||
884 | .err: | ||
885 | stc | ||
886 | ret | ||
887 | |||
888 | ; | ||
889 | ; INT 22h AX=001Fh Get current working directory | ||
890 | ; | ||
891 | comapi_getcwd: | ||
892 | mov P_ES,cs | ||
893 | mov P_BX,CurrentDirName | ||
894 | clc | ||
895 | ret | ||
896 | |||
897 | ; | ||
898 | ; INT 22h AX=0020h Open directory | ||
899 | ; | ||
900 | %if IS_SYSLINUX | ||
901 | comapi_opendir: | ||
902 | call reset_idle | ||
903 | push ds | ||
904 | mov ds,P_ES | ||
905 | mov si,P_SI | ||
906 | mov di,InitRD | ||
907 | call mangle_name | ||
908 | pop ds | ||
909 | call searchdir | ||
910 | jnz comapi_err ; Didn't find a directory | ||
911 | cmp eax,0 | ||
912 | jz comapi_err ; Found nothing | ||
913 | ;ZF is unset | ||
914 | call alloc_fill_dir | ||
915 | mov P_EAX,eax | ||
916 | mov P_CX,SECTOR_SIZE | ||
917 | mov P_SI,si | ||
918 | clc | ||
919 | ret | ||
920 | %else | ||
921 | comapi_opendir equ comapi_err | ||
922 | %endif | ||
923 | |||
924 | ; | ||
925 | ; INT 22h AX=0021h Read directory | ||
926 | ; | ||
927 | %if IS_SYSLINUX | ||
928 | comapi_readdir: | ||
929 | call reset_idle | ||
930 | mov es,P_ES | ||
931 | mov di,P_DI | ||
932 | mov si,P_SI | ||
933 | call readdir | ||
934 | mov P_EAX,eax | ||
935 | mov P_DL,dl | ||
936 | mov P_EBX,ebx | ||
937 | mov P_SI,si | ||
938 | ret | ||
939 | %else | ||
940 | comapi_readdir equ comapi_err | ||
941 | %endif | ||
942 | |||
943 | ; | ||
944 | ; INT 22h AX=0022h Close directory | ||
945 | ; | ||
946 | %if IS_SYSLINUX | ||
947 | comapi_closedir: | ||
948 | mov si,P_SI | ||
949 | call close_dir | ||
950 | clc | ||
951 | ret | ||
952 | %else | ||
953 | comapi_closedir equ comapi_err | ||
954 | %endif | ||
955 | |||
956 | ; | ||
957 | ; INT 22h AX=0023h Query shuffler size | ||
958 | ; | ||
959 | comapi_shufsize: | ||
960 | mov P_CX,bcopyxx_safe | ||
961 | ret | ||
962 | |||
963 | ; | ||
964 | ; INT 22h AX=0024h Cleanup, shuffle and boot raw | ||
965 | ; | ||
966 | comapi_shufraw: | ||
967 | call comapi_cleanup | ||
968 | mov edi,P_EDI | ||
969 | mov esi,P_ESI | ||
970 | mov ecx,P_ECX | ||
971 | jmp shuffle_and_boot_raw | ||
972 | |||
973 | niro | 532 | section .data |
974 | |||
975 | niro | 1133 | %macro int21 2 |
976 | niro | 532 | db %1 |
977 | dw %2 | ||
978 | %endmacro | ||
979 | |||
980 | int21_table: | ||
981 | int21 00h, comboot_return | ||
982 | int21 01h, comboot_getkey | ||
983 | int21 02h, comboot_writechr | ||
984 | int21 04h, comboot_writeserial | ||
985 | int21 08h, comboot_getkeynoecho | ||
986 | int21 09h, comboot_writestr | ||
987 | int21 0Bh, comboot_checkkey | ||
988 | int21 30h, comboot_checkver | ||
989 | int21 4Ch, comboot_return | ||
990 | niro | 1133 | int21 -1, comboot_bad_int21 |
991 | niro | 532 | int21_count equ ($-int21_table)/3 |
992 | |||
993 | niro | 1133 | alignz 2 |
994 | niro | 532 | int22_table: |
995 | dw comapi_err ; 0000 unimplemented syscall | ||
996 | dw comapi_get_version ; 0001 get SYSLINUX version | ||
997 | dw comapi_writestr ; 0002 write string | ||
998 | dw comapi_run ; 0003 run specified command | ||
999 | dw comapi_run_default ; 0004 run default command | ||
1000 | dw comapi_textmode ; 0005 force text mode | ||
1001 | dw comapi_open ; 0006 open file | ||
1002 | dw comapi_read ; 0007 read file | ||
1003 | dw comapi_close ; 0008 close file | ||
1004 | dw comapi_pxecall ; 0009 call PXE stack | ||
1005 | dw comapi_derinfo ; 000A derivative-specific info | ||
1006 | dw comapi_serialcfg ; 000B get serial port config | ||
1007 | dw comapi_cleanup ; 000C perform final cleanup | ||
1008 | niro | 1133 | dw comapi_err ; 000D clean up then bootstrap |
1009 | niro | 532 | dw comapi_configfile ; 000E get name of config file |
1010 | dw comapi_ipappend ; 000F get ipappend strings | ||
1011 | dw comapi_dnsresolv ; 0010 resolve hostname | ||
1012 | niro | 1133 | dw comapi_err ; 0011 maximum shuffle descriptors |
1013 | dw comapi_err ; 0012 cleanup, shuffle and boot | ||
1014 | niro | 532 | dw comapi_idle ; 0013 idle call |
1015 | dw comapi_localboot ; 0014 local boot | ||
1016 | dw comapi_features ; 0015 feature flags | ||
1017 | dw comapi_runkernel ; 0016 run kernel image | ||
1018 | niro | 1133 | dw comapi_usingvga ; 0017 report video mode change |
1019 | dw comapi_userfont ; 0018 query custom font | ||
1020 | dw comapi_readdisk ; 0019 read disk | ||
1021 | dw comapi_err ; 001A cleanup, shuffle and boot to pm | ||
1022 | dw comapi_err ; 001B cleanup, shuffle and boot to rm | ||
1023 | dw comapi_getadv ; 001C get pointer to ADV | ||
1024 | dw comapi_writeadv ; 001D write ADV to disk | ||
1025 | dw comapi_kbdtable ; 001E keyboard remapping table | ||
1026 | dw comapi_getcwd ; 001F get current working directory | ||
1027 | dw comapi_opendir ; 0020 open directory | ||
1028 | dw comapi_readdir ; 0021 read directory | ||
1029 | dw comapi_closedir ; 0022 close directory | ||
1030 | dw comapi_shufsize ; 0023 query shuffler size | ||
1031 | dw comapi_shufraw ; 0024 cleanup, shuffle and boot raw | ||
1032 | niro | 532 | int22_count equ ($-int22_table)/2 |
1033 | |||
1034 | APIKeyWait db 0 | ||
1035 | APIKeyFlag db 0 | ||
1036 | |||
1037 | zero_string db 0 ; Empty, null-terminated string | ||
1038 | |||
1039 | ; | ||
1040 | ; This is the feature flag array for INT 22h AX=0015h | ||
1041 | niro | 1133 | ; |
1042 | ; Note: PXELINUX clears the idle is noop flag if appropriate | ||
1043 | ; in pxe_detect_nic_type | ||
1044 | ; | ||
1045 | niro | 532 | feature_flags: |
1046 | niro | 1133 | db 1 ; Have local boot, idle is not noop |
1047 | niro | 532 | feature_flags_len equ ($-feature_flags) |
1048 | niro | 1133 | |
1049 | err_notdos db ': attempted DOS system call INT ',0 | ||
1050 | err_comlarge db 'COMBOOT image too large.', CR, LF, 0 | ||
1051 | |||
1052 | section .bss1 | ||
1053 | alignb 4 | ||
1054 | DOSErrTramp resd 33 ; Error trampolines | ||
1055 | ConfigName resb FILENAME_MAX | ||
1056 | CurrentDirName resb FILENAME_MAX |