;; -----------------------------------------------------------------------
;;
-;; Copyright 1994-2006 H. Peter Anvin - All Rights Reserved
+;; Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
clc
call ax ; Call the invoked function
comboot_resume:
+ mov bp,sp ; In case the function clobbers BP
setc P_FLAGSL ; Propagate CF->error
popad
pop gs
mov ds,P_ES
mov si,P_SI
mov di,InitRD
- push di
call mangle_name
- pop di
pop ds
call searchdir
jz comapi_err
; INT 22h AX=0008h Close file
;
comapi_close:
- ; Do nothing for now. Eventually implement
- ; an internal API for this.
+ mov si,P_SI
+ call close_file
clc
ret
;
comapi_derinfo:
mov P_AL,my_id
-%if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX
- mov al,[DriveNumber]
- mov P_DL,al
- mov P_ES,cs
- mov P_BX,PartInfo
-%elif IS_PXELINUX
+%if IS_PXELINUX
mov ax,[APIVer]
mov P_DX,ax
mov ax,[StrucPtr]
mov P_SI,ax
mov ax,[InitStack+2]
mov P_FS,ax
-%elif IS_ISOLINUX
- mov al,[DriveNo]
+%else
+ ; Physical medium...
+
+ mov P_CL,SECTOR_SHIFT
+ mov al,[DriveNumber]
mov P_DL,al
+ mov P_FS,cs
+ mov P_SI,OrigESDI
+%if IS_SYSLINUX || IS_MDSLINUX || IS_EXTLINUX
+ mov P_ES,cs
+ mov P_BX,PartInfo
+%elif IS_ISOLINUX
mov P_ES,cs
mov P_BX,spec_packet
%endif
+%endif
clc
ret
mov si,P_BX
call dns_resolv
mov P_EAX,eax
+ clc
ret
%else
comapi_dnsresolv equ comapi_err
; INT 22h AX=0011h Maximum number of shuffle descriptors
;
comapi_maxshuffle:
- mov P_CX,(2*trackbufsize)/12
+ mov P_CX,trackbufsize/12
ret
;
; INT 22h AX=0012h Cleanup, shuffle and boot
;
comapi_shuffle:
- call comapi_cleanup
- mov cx,P_CX
- cmp cx,(2*trackbufsize)/12
+ cmp P_CX,(2*trackbufsize)/12
ja .error
+ call comapi_cleanup
+
+ mov cx, P_CX
push cx ; On stack: descriptor count
lea cx,[ecx+ecx*2] ; CX *= 3
; INT 22h AX=0016h Run kernel image
;
comapi_runkernel:
+ mov al,P_DL
+ cmp al,VK_TYPES-1
+ ja .error
+ mov [KernelType],al
push ds
mov ds,P_DS
mov si,P_SI
mov di,KernelName
- push di
call mangle_name
- pop di
pop ds
call searchdir
jz comapi_err
mov word [CmdOptPtr],zero_string
jmp kernel_good_saved
+.error equ comapi_shuffle.error
+
;
; INT 22h AX=0017h Report video mode change
;
.done: ; CF=0 here
mov P_AL,al
ret
-
+;
+; INT 22h AX=0019h Read disk
+;
+%if IS_SYSLINUX || IS_MDSLINUX || IS_ISOLINUX || IS_EXTLINUX
+comapi_readdisk:
+ mov esi,P_ESI ; Enforce ESI == EDI == 0, these
+ or esi,P_EDI ; are reserved for future expansion
+ jnz .err
+ mov eax,P_EDX
+ mov es,P_ES
+ mov bx,P_BX
+ mov bp,P_CX ; WE CANNOT use P_* after touching bp!
+ call getlinsec
+ clc
+ ret
+.err:
+ stc
+ ret
+%else
+comapi_readdisk equ comapi_err
+%endif
+
+;
+; INT 22h AX=001Ah Cleanup, shuffle and boot to flat protected mode
+;
+comapi_shufflepm:
+ cmp P_CX,(2*trackbufsize)/12
+ ja .error
+
+ call comapi_cleanup
+
+ mov cx, P_CX
+ 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 fs,P_DS
+ mov si,P_SI
+ mov edi,TrampolineBuf
+ mov al,0B8h ; MOV EAX opcode
+ mov cl,9
+.maketramp:
+ stosb ; MOV opcode
+ inc ax ; Next register opcode
+ fs movsd ; immediate value
+ loop .maketramp
+ mov byte [di-5],0E9h ; Last opcode is JMP
+ sub [di-4],edi ; Make JMP target relative
+
+ mov dword [EntryPoint],trampoline_to_pm
+ xor bx,bx ; DS on entry
+ jmp replace_bootstrap
+.error:
+ stc
+ ret
+
+;
+; INT 22h AX=001Bh Cleanup, shuffle and boot with register setting
+;
+comapi_shufflerm:
+ cmp P_CX,(2*trackbufsize)/12
+ ja .error
+
+ call comapi_cleanup
+
+ mov cx, P_CX
+ 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 fs,P_DS
+ mov si,P_SI
+ mov di,TrampolineBuf
+
+ ; Generate segment-loading instructions
+ mov bx,0C08Eh ; MOV ES,AX
+ mov cl,6 ; 6 segment registers (incl CS)
+.segtramp:
+ mov al,0B8h
+ stosb ; MOV AX,imm16 opcode
+ fs movsw ; imm16
+ mov ax,bx
+ add bh,8
+ stosw ; MOV xS,AX
+ loop .segtramp
+
+ ; Clobber the MOV CS,AX instruction.
+ mov word [di-22], 9090h ; NOP NOP
+
+ ; Generate GPR-loading instructions
+ mov ax,0B866h ; MOV EAX,imm32
+ mov cl,8 ; 8 GPRs
+.gprtramp:
+ stosw ; MOV ExX,imm32 opcode
+ fs movsd ; imm32
+ inc ah
+ loop .gprtramp
+
+ mov al,0EAh ; JMP FAR imm16:imm16 opcode
+ stosb
+ fs movsd ; CS:IP
+
+ mov dword [EntryPoint],TrampolineBuf
+ jmp replace_bootstrap
+.error:
+ stc
+ ret
+
+;
+; INT 22h AX=001Ch Get pointer to auxillary data vector
+;
+comapi_getadv:
+ mov P_ES,ds
+ mov P_BX,adv0.data
+ mov P_CX,ADV_LEN
+ ret
+
+;
+; INT 22h AX=001Dh Write auxillary data vector
+;
+comapi_writeadv equ adv_write
section .data
-%macro int21 2
+%macro int21 2
db %1
dw %2
%endmacro
dw comapi_runkernel ; 0016 run kernel image
dw comapi_usingvga ; 0017 report video mode change
dw comapi_userfont ; 0018 query custom font
+ dw comapi_readdisk ; 0019 read disk
+ dw comapi_shufflepm ; 001A cleanup, shuffle and boot to pm
+ dw comapi_shufflerm ; 001B cleanup, shuffle and boot to rm
+ dw comapi_getadv ; 001C get pointer to ADV
+ dw comapi_writeadv ; 001D write ADV to disk
int22_count equ ($-int22_table)/2
APIKeyWait db 0
db 2 ; No local boot, idle is noop
%endif
feature_flags_len equ ($-feature_flags)
+
+err_notdos db ': attempted DOS system call', CR, LF, 0
+err_comlarge db 'COMBOOT image too large.', CR, LF, 0
+
+ section .bss1
+ConfigName resb FILENAME_MAX