2 ;; -----------------------------------------------------------------------
4 ;; Copyright 1994-2002 H. Peter Anvin - All Rights Reserved
6 ;; 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 ;; Bostom MA 02111-1307, USA; either version 2 of the License, or
10 ;; (at your option) any later version; incorporated herein by reference.
12 ;; -----------------------------------------------------------------------
17 ;; Common code for running a COMBOOT image
20 ; Looks like a COMBOOT image but too large
27 ; Load a COMBOOT image. A COMBOOT image is basically a DOS .COM file,
28 ; except that it may, of course, not contain any DOS system calls. We
29 ; do, however, allow the execution of INT 20h to return to SYSLINUX.
34 cmp ax,0ff00h ; Max size in bytes
37 call comboot_setup_api
42 mov bx,100h ; Load at <seg>:0100h
44 mov cx,[ClustPerMoby] ; Absolute maximum # of clusters
48 mov cx,64 ; 256 bytes (size of PSP)
49 xor eax,eax ; Clear PSP
52 mov word [es:0], 020CDh ; INT 20h instruction
53 ; First non-free paragraph
54 mov word [es:02h], comboot_seg+1000h
56 ; Copy the command line from high memory
57 mov cx,125 ; Max cmdline len (minus space and CR)
59 mov di,081h ; Offset in PSP for command line
60 mov al,' ' ; DOS command lines begin with a space
68 comboot_end_cmd: mov al,0Dh ; CR after last character
70 mov al,126 ; Include space but not CR
72 mov [es:80h], al ; Store command line length
75 mov [SavedSSSP+2],ss ; Save away SS:SP
81 push word 0 ; Return to address 0 -> exit
83 jmp comboot_seg:100h ; Run it
85 ; Proper return vector
86 comboot_return: cli ; Don't trust anyone
91 ; Set up the COMBOOT API interrupt vectors. This is also used
95 mov di,4*0x20 ; DOS interrupt vectors
96 mov eax,comboot_return ; INT 20h = exit
98 mov ax,comboot_int21 ; INT 21h = DOS-compatible syscalls
100 mov ax,comboot_int22 ; INT 22h = proprietary syscalls
103 mov cx,29 ; All remaining DOS vectors
107 ; INT 21h: generic DOS system call
108 comboot_int21: push ds
110 pop ds ; Set DS <- CS
111 and ah,ah ; 00 = return
114 jb comboot_getkeyecho ; 01 = get key with echo
115 je comboot_writechr ; 02 = writechr
116 cmp ah,08h ; 08 = get key w/o echo
118 cmp ah,09h ; 09 = writestr
120 cmp ah,0Bh ; 0B = check keyboard
122 cmp ah,30h ; 30 = check version
124 cmp ah,4Ch ; 4C = return with status
127 ; Otherwise fall through to comboot_bogus
129 ; Attempted to execute non-21h DOS system call
130 comboot_bogus: cli ; Don't trust anyone
133 ; Generic COMBOOT return to command line code
134 ; AX -> message (if any)
135 ; BX -> where to go next
138 mov bx,enter_command ; Normal return to command prompt
139 comboot_exit_special:
155 ; INT 21h system calls
157 comboot_getkeyecho: ; 01 = get key with echo
162 jmp comboot_resume_ok
164 comboot_writechr: ; 02 = writechr
168 jmp comboot_resume_ok
170 comboot_getkey: ; 08 = get key w/o echo
174 jmp comboot_resume_ok
176 comboot_writestr: ; 09 = write string
180 mov es,[bp-20] ; Old DS
183 cmp al,'$' ; End string with $ - bizarre
189 jmp comboot_resume_ok
191 comboot_checkkey: ; 0B = check keyboard status
194 dec al ; AL = 0FFh if present, 0 if not
195 jmp comboot_resume_ok
197 comboot_checkver: ; 30 = check DOS version
198 ; We return 0 in all DOS-compatible version registers,
199 ; but the high part of eax-ebx-ecx-edx spell "SYSLINUX"
204 ;jmp comboot_resume_ok
207 ; Resume comboot execution
220 ; INT 22h - SYSLINUX-specific system calls
221 ; System call number in ax
233 call [bx+int22_table]
234 jmp comboot_resume ; On return
237 ; INT 22h AX=0000h Null system call
238 ; INT 22h AX=0001h Get SYSLINUX version
241 ; Number of API functions supported
244 mov cx,(VER_MAJOR << 8)+VER_MINOR
245 ; SYSLINUX derivative ID byte
252 ; ES:SI -> version banner
253 mov si,syslinux_banner
254 ; ES:DI -> copyright string
262 ; INT 22h AX=0002h Write string
264 ; Write null-terminated string in ES:BX
270 jmp writestr ; Write string from ES:BX
273 ; INT 22h AX=0003h Run command
275 ; Terminates the COMBOOT program and executes the command line in
276 ; ES:BX as if it had been entered by the user.
291 mov bx,load_kernel ; Run a new kernel
292 jmp comboot_exit_special ; Terminate task, clean up
295 ; INT 22h AX=0004h Run default command
297 ; Terminates the COMBOOT program and executes the default command line
298 ; as if a timeout had happened or the user pressed <Enter>.
302 jmp comboot_exit_special
305 ; INT 22h AX=0005h Force text mode
307 ; Puts the video in standard text mode
315 ; INT 22h AX=0006h Open file
342 ; INT 22h AX=0007h Read file
348 xor si,si ; SI <- 0 on EOF, CF <- 0
352 ; INT 22h AX=0008h Close file
355 ; Do nothing for now. Eventually implement
356 ; an internal API for this.
363 dw comapi_nop ; 0000 null syscall
364 dw comapi_get_version ; 0001 get SYSLINUX version
365 dw comapi_writestr ; 0002 write string
366 dw comapi_run ; 0003 run specified command
367 dw comapi_run_default ; 0004 run default command
368 dw comapi_textmode ; 0005 force text mode
369 dw comapi_open ; 0006 open file
370 dw comapi_read ; 0007 read file
371 dw comapi_close ; 0008 close file
372 int22_count equ ($-int22_table)/2