aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2005-08-21 06:18:54 +0000
committerhpa <hpa>2005-08-21 06:18:54 +0000
commit2ea32f4e7f26c44fcfcddcb26ae529b23babf7e3 (patch)
tree0157970f0ad6b097765f3e5f2c74e8477c234461
parent87575da8034373b0bf9ea147329b6d24dc5a825a (diff)
downloadsyslinux-2ea32f4e7f26c44fcfcddcb26ae529b23babf7e3.tar.gz
syslinux-2ea32f4e7f26c44fcfcddcb26ae529b23babf7e3.tar.xz
syslinux-2ea32f4e7f26c44fcfcddcb26ae529b23babf7e3.zip
Correct the code related to the run kernel image API function.
-rw-r--r--cmdline.inc7
-rw-r--r--com32/modules/menu.c46
-rw-r--r--comboot.inc48
3 files changed, 59 insertions, 42 deletions
diff --git a/cmdline.inc b/cmdline.inc
index 9b636e38..d1cb2610 100644
--- a/cmdline.inc
+++ b/cmdline.inc
@@ -23,17 +23,14 @@
; Assumes DS == CS
make_plain_cmdline:
push es
- ; ui.inc has already copied the actual command line
+ ; ui.inc has already copied any APPEND options
mov ax,real_mode_seg
mov es,ax
mov si,[CmdOptPtr]
mov di,[CmdLinePtr]
-.loop: lodsb
- stosb
- and al,al
- jnz .loop
+ call strcpy
dec di
mov [CmdLinePtr],di
diff --git a/com32/modules/menu.c b/com32/modules/menu.c
index d67f5b55..40270c1d 100644
--- a/com32/modules/menu.c
+++ b/com32/modules/menu.c
@@ -588,40 +588,38 @@ run_menu(void)
static void
-execute(char *cmdline)
+execute(const char *cmdline)
{
#ifdef __COM32__
com32sys_t ireg;
+ const char *p;
+ char *q = __com32.cs_bounce;
+ const char *kernel, *args;
+
memset(&ireg, 0, sizeof ireg);
- if ( !strncmp(cmdline, ".localboot", 10) && isspace(cmdline[10]) ) {
- unsigned long localboot = strtoul(cmdline+10, NULL, 0);
-
+ kernel = q;
+ p = cmdline;
+ while ( *p && !isspace(*p) ) {
+ *q++ = *p++;
+ }
+ *q++ = '\0';
+
+ args = q;
+ while ( *p && isspace(*p) )
+ p++;
+
+ strcpy(q, p);
+
+ if ( !strcmp(kernel, ".localboot") ) {
ireg.eax.w[0] = 0x0014; /* Local boot */
- ireg.edx.w[0] = localboot;
+ ireg.edx.w[0] = strtoul(args, NULL, 0);
} else {
- const char *p;
- char *q = __com32.cs_bounce;
- const char *kernel, *args;
-
- kernel = q;
- p = cmdline;
- while ( *p && !isspace(*p) ) {
- *p++ = *q++;
- }
- *q++ = '\0';
-
- args = q;
- while ( *p && isspace(*p) )
- p++;
-
- strcpy(q, p);
-
- ireg.eax.w[0] = 0x0016;
+ ireg.eax.w[0] = 0x0016; /* Run kernel image */
ireg.esi.w[0] = OFFS(kernel);
ireg.ds = SEG(kernel);
ireg.ebx.w[0] = OFFS(args);
- ireg.es = SEG(kernel);
+ ireg.es = SEG(args);
/* ireg.ecx.l = 0; */ /* We do ipappend "manually" */
/* ireg.edx.l = 0; */
}
diff --git a/comboot.inc b/comboot.inc
index 91e260a0..6cab6c4a 100644
--- a/comboot.inc
+++ b/comboot.inc
@@ -415,17 +415,13 @@ comapi_open:
pop di
pop ds
call searchdir
- jz .err
+ jz comapi_err
mov P_AX,ax
mov P_HAX,dx
mov P_CX,SECTOR_SIZE
mov P_SI,si
clc
ret
-.err:
- stc
- ret
-
;
; INT 22h AX=0007h Read file
@@ -694,30 +690,53 @@ comapi_runkernel:
pop di
pop ds
call searchdir
- jz comapi_err ; Kernel doesn't exist
+ jz comapi_err
; The kernel image was found, so we can load it...
mov [Kernel_SI],si
mov [Kernel_EAX],ax
mov [Kernel_EAX+2],dx
+ ; It's not just possible, but quite likely, that ES:BX
+ ; points into real_mode_seg, so we need to exercise some
+ ; special care here... use xfer_buf_seg as an intermediary
+ push ds
push es
+ mov ax,xfer_buf_seg
mov ds,P_ES
mov si,P_BX
- push word real_mode_seg
- pop es
- mov di,cmd_line_here
+ mov es,ax
+ xor di,di
call strcpy
- dec di
- mov [CmdLinePtr],di
pop es
-
+ pop ds
+
%if IS_PXELINUX
mov al,P_CL
mov [IPAppend],al
%endif
- mov bx,kernel_good_saved
+ xor ax,ax
+ mov bx,.finish
+ jmp comboot_exit_special
+
+.finish:
+ ; Copy the command line into its proper place
+ push ds
+ push es
+ mov ax,xfer_buf_seg
+ mov dx,real_mode_seg
+ mov ds,ax
+ mov es,dx
+ xor si,si
+ mov di,cmd_line_here
+ call strcpy
+ mov byte [es:di-1],' ' ; Simulate APPEND
+ pop es
+ pop ds
+ mov [CmdLinePtr],di
+ mov word [CmdOptPtr],zero_string
+ jmp kernel_good_saved
section .data
int21_table:
@@ -757,11 +776,14 @@ int22_table:
dw comapi_idle ; 0013 idle call
dw comapi_localboot ; 0014 local boot
dw comapi_features ; 0015 feature flags
+ dw comapi_runkernel ; 0016 run kernel image
int22_count equ ($-int22_table)/2
APIKeyWait db 0
APIKeyFlag db 0
+zero_string db 0 ; Empty, null-terminated string
+
;
; This is the feature flag array for INT 22h AX=0015h
feature_flags: