Magellan Linux

Diff of /trunk/mkinitrd-magellan/isolinux/comboot.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1132 by niro, Sat Sep 1 22:45:15 2007 UTC revision 1133 by niro, Thu Aug 19 09:50:43 2010 UTC
# Line 1  Line 1 
 ;; $Id: comboot.inc,v 1.1 2007-09-01 22:44:04 niro Exp $  
1  ;; -----------------------------------------------------------------------  ;; -----------------------------------------------------------------------
2  ;;    ;;
3  ;;   Copyright 1994-2005 H. Peter Anvin - All Rights Reserved  ;;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
4    ;;   Copyright 2009 Intel Corporation; author: H. Peter Anvin
5  ;;  ;;
6  ;;   This program is free software; you can redistribute it and/or modify  ;;   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  ;;   it under the terms of the GNU General Public License as published by
# Line 13  Line 13 
13    
14  ;;  ;;
15  ;; comboot.inc  ;; comboot.inc
16  ;;  ;;
17  ;; Common code for running a COMBOOT image  ;; Common code for running a COMBOOT image
18  ;;  ;;
19    
# Line 26  Line 26 
26  %define P_FLAGSH byte [bp+45]  %define P_FLAGSH byte [bp+45]
27  %define P_CS word [bp+42]  %define P_CS word [bp+42]
28  %define P_IP word [bp+40]  %define P_IP word [bp+40]
29    %define P_CSIP dword [bp+40]
30  %define P_DS word [bp+38]  %define P_DS word [bp+38]
31  %define P_ES word [bp+36]  %define P_ES word [bp+36]
32  %define P_FS word [bp+34]  %define P_FS word [bp+34]
# Line 62  Line 63 
63    
64  ; Looks like a COMBOOT image but too large  ; Looks like a COMBOOT image but too large
65  comboot_too_large:  comboot_too_large:
66     call close_file
67   mov si,err_comlarge   mov si,err_comlarge
68   call cwritestr   call writestr
69   jmp enter_command   jmp enter_command
70    
71  ;  ;
# Line 72  comboot_too_large: Line 74  comboot_too_large:
74  ; do, however, allow the execution of INT 20h to return to SYSLINUX.  ; do, however, allow the execution of INT 20h to return to SYSLINUX.
75  ;  ;
76  is_comboot_image:  is_comboot_image:
  and dx,dx  
  jnz comboot_too_large  
  cmp ax,0ff00h ; Max size in bytes  
  jae comboot_too_large  
   
77   push si ; Save file handle   push si ; Save file handle
78    
79   call make_plain_cmdline   call make_plain_cmdline
# Line 127  is_comboot_image: Line 124  is_comboot_image:
124   ; Now actually load the file...   ; Now actually load the file...
125   pop si ; File handle   pop si ; File handle
126   mov bx,100h ; Load at <seg>:0100h   mov bx,100h ; Load at <seg>:0100h
127   mov cx,0FF00h >> SECTOR_SHIFT   mov cx,10000h >> SECTOR_SHIFT
128   ; Absolute maximum # of sectors   ; Absolute maximum # of sectors
129   call getfssec   call getfssec
130     cmp ecx,65536-256-2 ; Maximum size
131     ja comboot_too_large
132    
133   ; And invoke the program...   ; And invoke the program...
  mov [SavedSSSP],sp  
  mov [SavedSSSP+2],ss ; Save away SS:SP  
   
134   mov ax,es   mov ax,es
135   mov ds,ax   mov ds,ax
136   mov ss,ax   mov ss,ax
# Line 144  is_comboot_image: Line 140  is_comboot_image:
140   jmp comboot_seg:100h ; Run it   jmp comboot_seg:100h ; Run it
141    
142  ; Proper return vector  ; Proper return vector
143  comboot_return: cli ; Don't trust anyone  ; Note: this gets invoked both via INT 21h and directly via INT 20h.
144   xor ax,ax  ; 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   jmp comboot_exit   jmp comboot_exit
149    
150  ;  ;
# Line 153  comboot_return: cli ; Don't trust anyo Line 152  comboot_return: cli ; Don't trust anyo
152  ; by the COM32 code.  ; by the COM32 code.
153  ;  ;
154  comboot_setup_api:  comboot_setup_api:
155   mov di,4*0x20 ; DOS interrupt vectors   mov di,DOSErrTramp ; Error trampolines
156   mov eax,comboot_return ; INT 20h = exit   mov cx,32
157   stosd   push cx
158   mov ax,comboot_int21 ; INT 21h = DOS-compatible syscalls   mov eax,02EB206Ah ; push 20h; jmp $+4
159   stosd  .loop1: stosd
160   mov ax,comboot_int22 ; INT 22h = proprietary syscalls   inc ah
161   stosd   loop .loop1
162   mov ax,comboot_bogus   dec di
163   mov cx,29 ; All remaining DOS vectors   mov byte [di-1],0E9h
164   rep stosd   mov ax,comboot_bogus-2
165   ret   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     ret
180    
181     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  ; INT 21h: generic DOS system call  ; INT 21h: generic DOS system call
225  comboot_int21: cli  comboot_int21: sti
226   push ds   push ds
227   push es   push es
228   push fs   push fs
# Line 191  comboot_int21: cli Line 247  comboot_int21: cli
247   clc   clc
248   call ax ; Call the invoked function   call ax ; Call the invoked function
249  comboot_resume:  comboot_resume:
250     mov bp,sp ; In case the function clobbers BP
251   setc P_FLAGSL ; Propagate CF->error   setc P_FLAGSL ; Propagate CF->error
252   popad   popad
253   pop gs   pop gs
254   pop fs   pop fs
255   pop es   pop es
256   pop ds   pop ds
257    comboot_iret:
258   iret   iret
259    
260  ; Attempted to execute non-21h DOS system call  comboot_bad_int21:
261  comboot_bogus: cli ; Don't trust anyone   mov ax,P_AX
262   mov ax,err_notdos   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  ;  ;
288  ; Generic COMBOOT return to command line code  ; Generic COMBOOT return to command line code
289  ;  AX -> message (if any)  ;  stack -> where to go next
290  ;  BX -> where to go next  ;     CX -> message (for _msg version)
291  ;  ;
292  comboot_exit:  comboot_exit:
293   mov bx,enter_command ; Normal return to command prompt   xor cx,cx
294  comboot_exit_special:  comboot_exit_msg:
295   xor dx,dx   pop bx ; Return address
296   mov ds,dx   RESET_STACK_AND_SEGS SI ; Contains sti, cld
  mov es,dx  
  lss sp,[SavedSSSP]  
  sti  
  cld  
297   call adjust_screen ; The COMBOOT program might have changed the screen   call adjust_screen ; The COMBOOT program might have changed the screen
298   and ax,ax   pusha
299   je .nomsg   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   mov si,KernelCName   mov si,KernelCName
306   call cwritestr   call writestr
307   xchg si,ax   mov si,cx
308   call cwritestr   call writestr
309  .nomsg: jmp bx  .nomsg:
310     jmp bx
311    
312  ;  ;
313  ; INT 21h system calls  ; INT 21h system calls
# Line 298  comboot_getchar: Line 382  comboot_getchar:
382   jmp .done   jmp .done
383    
384  ;  ;
385    ; 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  ; INT 22h - SYSLINUX-specific system calls  ; INT 22h - SYSLINUX-specific system calls
404  ;           System call number in ax  ;           System call number in ax
405  ;  ;
406  comboot_int22:  comboot_int22:
407   cli   sti
408   push ds   push ds
409   push es   push es
410   push fs   push fs
# Line 339  comapi_get_version: Line 441  comapi_get_version:
441   ; Number of API functions supported   ; Number of API functions supported
442   mov P_AX,int22_count   mov P_AX,int22_count
443   ; SYSLINUX version   ; SYSLINUX version
444   mov P_CX,(VER_MAJOR << 8)+VER_MINOR   mov P_CX,(VERSION_MAJOR << 8)+VERSION_MINOR
445   ; SYSLINUX derivative ID byte   ; SYSLINUX derivative ID byte
446   mov P_DX,my_id   mov P_DX,my_id
447   ; For future use   ; For future use
# Line 347  comapi_get_version: Line 449  comapi_get_version:
449    
450   mov P_ES,ds   mov P_ES,ds
451   ; ES:SI -> version banner   ; ES:SI -> version banner
452   mov P_SI,syslinux_banner   mov P_SI,syslinux_banner + 2 ; Skip leading CR LF
453   ; ES:DI -> copyright string   ; ES:DI -> copyright string
454   mov P_DI,copyright_str   mov P_DI,copyright_str + 1 ; Skip leading space
455    
456  comapi_nop:  comapi_nop:
457   clc   clc
# Line 378  comapi_run: Line 480  comapi_run:
480   mov si,P_BX   mov si,P_BX
481   mov di,command_line   mov di,command_line
482   call strcpy   call strcpy
483   xor ax,ax   push load_kernel ; Run a new kernel
484   mov bx,load_kernel ; Run a new kernel   jmp comboot_exit ; Terminate task, clean up
  jmp comboot_exit_special ; Terminate task, clean up  
485    
486  ;  ;
487  ; INT 22h AX=0004h Run default command  ; INT 22h AX=0004h Run default command
488  ;  ;
489  ; Terminates the COMBOOT program and executes the default command line  ; Terminates the COMBOOT program and executes the default command line
490  ; as if a timeout had happened or the user pressed <Enter>.  ; as if a timeout had happened or the user pressed <Enter>.
491  ;  ;
492  comapi_run_default:  comapi_run_default:
493   mov bx,auto_boot   push auto_boot
494   jmp comboot_exit_special   jmp comboot_exit
495    
496  ;  ;
497  ; INT 22h AX=0005h Force text mode  ; INT 22h AX=0005h Force text mode
# Line 406  comapi_textmode: Line 507  comapi_textmode:
507  ; INT 22h AX=0006h Open file  ; INT 22h AX=0006h Open file
508  ;  ;
509  comapi_open:  comapi_open:
510     call reset_idle
511   push ds   push ds
512   mov ds,P_ES   mov ds,P_ES
513   mov si,P_SI   mov si,P_SI
514   mov di,InitRD   mov di,InitRD
  push di  
515   call mangle_name   call mangle_name
  pop di  
516   pop ds   pop ds
517   call searchdir   call searchdir
518   jz comapi_err   jz comapi_err
519   mov P_AX,ax   mov P_EAX,eax
  mov P_HAX,dx  
520   mov P_CX,SECTOR_SIZE   mov P_CX,SECTOR_SIZE
521   mov P_SI,si   mov P_SI,si
522   clc   clc
# Line 427  comapi_open: Line 526  comapi_open:
526  ; INT 22h AX=0007h Read file  ; INT 22h AX=0007h Read file
527  ;  ;
528  comapi_read:  comapi_read:
529     call reset_idle
530   mov es,P_ES   mov es,P_ES
531   mov bx,P_BX   mov bx,P_BX
532   mov si,P_SI   mov si,P_SI
# Line 435  comapi_read: Line 535  comapi_read:
535   jnc .noteof   jnc .noteof
536   xor si,si ; SI <- 0 on EOF, CF <- 0   xor si,si ; SI <- 0 on EOF, CF <- 0
537  .noteof: mov P_SI,si  .noteof: mov P_SI,si
538     mov P_ECX,ecx
539   ret   ret
540    
541  ;  ;
542  ; INT 22h AX=0008h Close file  ; INT 22h AX=0008h Close file
543  ;  ;
544  comapi_close:  comapi_close:
545   ; Do nothing for now.  Eventually implement   mov si,P_SI
546   ; an internal API for this.   call close_file
547   clc   clc
548   ret   ret
549    
# Line 455  comapi_pxecall: Line 556  comapi_pxecall:
556   mov es,P_ES   mov es,P_ES
557   mov di,P_DI   mov di,P_DI
558   call pxenv   call pxenv
559     mov ax,[PXEStatus]
560   mov P_AX,ax   mov P_AX,ax
  clc  
561   ret   ret
562  %else  %else
563  comapi_pxecall equ comapi_err ; Not available  comapi_pxecall equ comapi_err ; Not available
# Line 467  comapi_pxecall equ comapi_err ; Not av Line 568  comapi_pxecall equ comapi_err ; Not av
568  ;  ;
569  comapi_derinfo:  comapi_derinfo:
570   mov P_AL,my_id   mov P_AL,my_id
571  %if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX  %if IS_PXELINUX
  mov al,[DriveNumber]  
  mov P_DL,al  
  mov P_ES,cs  
  mov P_BX,PartInfo  
 %elif IS_PXELINUX  
572   mov ax,[APIVer]   mov ax,[APIVer]
573   mov P_DX,ax   mov P_DX,ax
574   mov ax,[StrucPtr]   mov ax,[StrucPtr]
# Line 483  comapi_derinfo: Line 579  comapi_derinfo:
579   mov P_SI,ax   mov P_SI,ax
580   mov ax,[InitStack+2]   mov ax,[InitStack+2]
581   mov P_FS,ax   mov P_FS,ax
582  %elif IS_ISOLINUX   mov eax,[MyIP]
583   mov al,[DriveNo]   mov P_ECX,eax
584    %else
585     ; Physical medium...
586    
587     mov P_CL,SECTOR_SHIFT
588     mov al,[DriveNumber]
589   mov P_DL,al   mov P_DL,al
590     mov P_FS,cs
591     mov P_SI,OrigESDI
592    %if IS_SYSLINUX || IS_EXTLINUX
593     mov P_ES,cs
594     mov P_BX,PartInfo
595    %elif IS_ISOLINUX
596   mov P_ES,cs   mov P_ES,cs
597   mov P_BX,spec_packet   mov P_BX,spec_packet
598     mov ax,[BIOSType]
599     sub ax,bios_cdrom
600     shr ax,2
601     mov P_CH,al ; Mode (el torito/cbios/ebios)
602    %endif
603  %endif  %endif
604   clc   clc
605   ret   ret
# Line 523  comapi_cleanup: Line 635  comapi_cleanup:
635   sub bp,sp ; unload_pxe may move the stack around   sub bp,sp ; unload_pxe may move the stack around
636   call unload_pxe   call unload_pxe
637   add bp,sp ; restore frame pointer...   add bp,sp ; restore frame pointer...
638  %elif IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX  %elif IS_SYSLINUX || IS_EXTLINUX
639   ; Restore original FDC table   ; Restore original FDC table
640   mov eax,[OrigFDCTabPtr]   mov eax,[OrigFDCTabPtr]
641   mov [fdctab],eax   mov [fdctab],eax
642  %endif  %endif
643   ; Reset the floppy disk subsystem   call cleanup_hardware
  xor ax,ax  
  xor dx,dx  
  int 13h  
644   clc   clc
645   ret   ret
646    
# Line 546  comapi_chainboot: Line 655  comapi_chainboot:
655   mov [trackbuf+8],eax ; Total bytes   mov [trackbuf+8],eax ; Total bytes
656   mov eax,7C00h   mov eax,7C00h
657   mov [trackbuf],eax ; Copy to   mov [trackbuf],eax ; Copy to
658   mov [EntryPoint],eax ; CS:IP entry point   push eax ; Entry point on stack
659   mov esi,P_ESI   mov esi,P_ESI
660   mov edx,P_EBX   mov edx,P_EBX
661   mov bx,P_DS   mov bx,P_DS
662   jmp replace_bootstrap_one   jmp replace_bootstrap_one
663    
   
664  ;  ;
665  ; INT 22h AX=000Eh Get configuration file name  ; INT 22h AX=000Eh Get configuration file name
666  ;  ;
# Line 565  comapi_configfile: Line 673  comapi_configfile:
673  ;  ;
674  ; INT 22h AX=000Fh Get IPAPPEND strings  ; INT 22h AX=000Fh Get IPAPPEND strings
675  ;  ;
 %if IS_PXELINUX  
676  comapi_ipappend:  comapi_ipappend:
677   mov P_ES,cs   mov P_ES,cs
678   mov P_CX,numIPAppends   mov P_CX,numIPAppends
# Line 573  comapi_ipappend: Line 680  comapi_ipappend:
680   clc   clc
681   ret   ret
682    
  section .data  
  alignb 2, db 0  
 IPAppends dw IPOption  
  dw BOOTIFStr  
 numIPAppends equ ($-IPAppends)/2  
   
 %else  
 comapi_ipappend equ comapi_err  
 %endif  
   
  section .text  
   
683  ;  ;
684  ; INT 22h AX=0010h Resolve hostname  ; INT 22h AX=0010h Resolve hostname
685  ;  ;
# Line 594  comapi_dnsresolv: Line 689  comapi_dnsresolv:
689   mov si,P_BX   mov si,P_BX
690   call dns_resolv   call dns_resolv
691   mov P_EAX,eax   mov P_EAX,eax
692     clc
693   ret   ret
694  %else  %else
695  comapi_dnsresolv equ comapi_err  comapi_dnsresolv equ comapi_err
696  %endif  %endif
697    
698   section .text   section .text
699    
700  ;  ;
701  ; INT 22h AX=0011h Maximum number of shuffle descriptors  ; INT 22h AX=0011h Obsolete
702  ;  ;
 comapi_maxshuffle:  
  mov P_CX,(2*trackbufsize)/12  
  ret  
703    
704  ;  ;
705  ; INT 22h AX=0012h Cleanup, shuffle and boot  ; INT 22h AX=0012h Obsolete
706  ;  ;
 comapi_shuffle:  
  call comapi_cleanup  
  mov cx,P_CX  
  cmp cx,(2*trackbufsize)/12  
  ja .error  
   
  push cx ; On stack: descriptor count  
   
  lea cx,[ecx+ecx*2] ; CX *= 3  
   
  mov fs,P_ES  
  mov si,P_DI  
  mov di,trackbuf  
  push di ; On stack: descriptor list address  
  fs rep movsd ; Copy the list  
   
  mov eax,P_EBP  
  mov [EntryPoint],eax ; CS:IP entry point  
  mov esi,P_ESI  
  mov edx,P_EBX  
  mov bx,P_DS  
  jmp replace_bootstrap  
 .error:  
  stc  
  ret  
707    
708  ;  ;
709  ; INT 22h AX=0013h Idle call  ; INT 22h AX=0013h Idle call
710  ;  ;
 ;  
 ; *** FIX THIS ***  
 ; The idle call seems to have detrimental effects on some machines when  
 ; called from a COM32 context (WHY?) --  disable it for now.  
 ;  
 %if 0 ; def HAVE_IDLE  
   
711  comapi_idle:  comapi_idle:
712   DO_IDLE   call do_idle
713   clc   clc
714   ret   ret
715    
 %else  
   
 comapi_idle equ comapi_err  
   
 %endif  
   
716  ;  ;
717  ; INT 22h AX=0014h Local boot  ; INT 22h AX=0014h Local boot
718  ;  ;
719  %if IS_PXELINUX || IS_ISOLINUX  %if HAS_LOCALBOOT
720  comapi_localboot:  comapi_localboot:
721   mov ax,P_DX   mov ax,P_DX
722   jmp local_boot   jmp local_boot
723  %else  %else
724  comapi_localboot equ comapi_err  comapi_localboot equ comapi_err
725  %endif  %endif ; HAS_LOCALBOOT
726    
727  ;  ;
728  ; INT 22h AX=0015h Feature flags  ; INT 22h AX=0015h Feature flags
# Line 683  comapi_features: Line 738  comapi_features:
738  ; INT 22h AX=0016h Run kernel image  ; INT 22h AX=0016h Run kernel image
739  ;  ;
740  comapi_runkernel:  comapi_runkernel:
741     mov al,P_DL
742     cmp al,VK_TYPES-1
743     ja .error
744     mov [KernelType],al
745   push ds   push ds
746   mov ds,P_DS   mov ds,P_DS
747   mov si,P_SI   mov si,P_SI
748   mov di,KernelName   mov di,KernelName
  push di  
749   call mangle_name   call mangle_name
  pop di  
750   pop ds   pop ds
751   call searchdir   call searchdir
752   jz comapi_err   jz comapi_err
753    
754   ; The kernel image was found, so we can load it...   ; The kernel image was found, so we can load it...
755   mov [Kernel_SI],si   mov [Kernel_SI],si
756   mov [Kernel_EAX],ax   mov [Kernel_EAX],eax
757   mov [Kernel_EAX+2],dx  
   
758   ; It's not just possible, but quite likely, that ES:BX   ; It's not just possible, but quite likely, that ES:BX
759   ; points into real_mode_seg, so we need to exercise some   ; points into real_mode_seg or xfer_buf_seg, so we
760   ; special care here... use xfer_buf_seg as an intermediary   ; need to exercise some special care here... use
761     ; trackbuf as an intermediary
762   push ds   push ds
  push es  
  mov ax,xfer_buf_seg  
763   mov ds,P_ES   mov ds,P_ES
764   mov si,P_BX   mov si,P_BX
765   mov es,ax   mov di,trackbuf
  xor di,di  
766   call strcpy   call strcpy
  pop es  
767   pop ds   pop ds
768    
769  %if IS_PXELINUX  %if IS_PXELINUX
# Line 718  comapi_runkernel: Line 771  comapi_runkernel:
771   mov [IPAppend],al   mov [IPAppend],al
772  %endif  %endif
773    
774   xor ax,ax   call comboot_exit
  mov bx,.finish  
  jmp comboot_exit_special  
775    
776  .finish:  .finish:
777   ; Copy the command line into its proper place   ; Copy the command line into its proper place
  push ds  
778   push es   push es
  mov ax,xfer_buf_seg  
779   mov dx,real_mode_seg   mov dx,real_mode_seg
  mov ds,ax  
780   mov es,dx   mov es,dx
781   xor si,si   mov si,trackbuf
782   mov di,cmd_line_here   mov di,cmd_line_here
783   call strcpy   call strcpy
784   mov byte [es:di-1],' ' ; Simulate APPEND   mov byte [es:di-1],' ' ; Simulate APPEND
785   pop es   pop es
  pop ds  
786   mov [CmdLinePtr],di   mov [CmdLinePtr],di
787   mov word [CmdOptPtr],zero_string   mov word [CmdOptPtr],zero_string
788   jmp kernel_good_saved   jmp kernel_good_saved
789    
790    .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   section .data   section .data
974    
975  %macro int21 2  %macro int21 2
976   db %1   db %1
977   dw %2   dw %2
978  %endmacro  %endmacro
# Line 757  int21_table: Line 987  int21_table:
987   int21 0Bh, comboot_checkkey   int21 0Bh, comboot_checkkey
988   int21 30h, comboot_checkver   int21 30h, comboot_checkver
989   int21 4Ch, comboot_return   int21 4Ch, comboot_return
990   int21 -1, comboot_bogus   int21 -1, comboot_bad_int21
991  int21_count equ ($-int21_table)/3  int21_count equ ($-int21_table)/3
992    
993   align 2, db 0   alignz 2
994  int22_table:  int22_table:
995   dw comapi_err ; 0000 unimplemented syscall   dw comapi_err ; 0000 unimplemented syscall
996   dw comapi_get_version ; 0001 get SYSLINUX version   dw comapi_get_version ; 0001 get SYSLINUX version
# Line 775  int22_table: Line 1005  int22_table:
1005   dw comapi_derinfo ; 000A derivative-specific info   dw comapi_derinfo ; 000A derivative-specific info
1006   dw comapi_serialcfg ; 000B get serial port config   dw comapi_serialcfg ; 000B get serial port config
1007   dw comapi_cleanup ; 000C perform final cleanup   dw comapi_cleanup ; 000C perform final cleanup
1008   dw comapi_chainboot ; 000D clean up then bootstrap   dw comapi_err ; 000D clean up then bootstrap
1009   dw comapi_configfile ; 000E get name of config file   dw comapi_configfile ; 000E get name of config file
1010   dw comapi_ipappend ; 000F get ipappend strings   dw comapi_ipappend ; 000F get ipappend strings
1011   dw comapi_dnsresolv ; 0010 resolve hostname   dw comapi_dnsresolv ; 0010 resolve hostname
1012   dw comapi_maxshuffle ; 0011 maximum shuffle descriptors   dw comapi_err ; 0011 maximum shuffle descriptors
1013   dw comapi_shuffle ; 0012 cleanup, shuffle and boot   dw comapi_err ; 0012 cleanup, shuffle and boot
1014   dw comapi_idle ; 0013 idle call   dw comapi_idle ; 0013 idle call
1015   dw comapi_localboot ; 0014 local boot   dw comapi_localboot ; 0014 local boot
1016   dw comapi_features ; 0015 feature flags   dw comapi_features ; 0015 feature flags
1017   dw comapi_runkernel ; 0016 run kernel image   dw comapi_runkernel ; 0016 run kernel image
1018     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  int22_count equ ($-int22_table)/2  int22_count equ ($-int22_table)/2
1033    
1034  APIKeyWait db 0  APIKeyWait db 0
# Line 794  zero_string db 0 ; Empty, null-termina Line 1038  zero_string db 0 ; Empty, null-termina
1038    
1039  ;  ;
1040  ; This is the feature flag array for INT 22h AX=0015h  ; This is the feature flag array for INT 22h AX=0015h
1041    ;
1042    ; Note: PXELINUX clears the idle is noop flag if appropriate
1043    ; in pxe_detect_nic_type
1044    ;
1045  feature_flags:  feature_flags:
1046  %if IS_PXELINUX   db 1 ; Have local boot, idle is not noop
  db 1 ; Have local boot, idle not noop  
 %elif IS_ISOLINUX  
  db 3 ; Have local boot, idle is noop  
 %else  
  db 2 ; No local boot, idle is noop  
 %endif  
1047  feature_flags_len equ ($-feature_flags)  feature_flags_len equ ($-feature_flags)
1048    
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

Legend:
Removed from v.1132  
changed lines
  Added in v.1133