aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2003-11-24 02:44:42 +0000
committerhpa <hpa>2003-11-24 02:44:42 +0000
commit43cf4dda600db1ccd05d9788c7b1da0cde7c0413 (patch)
tree0c69eaa8d2e0f49bc4ea8770762a97d4552771ad
parent4a10396ab1f114fc37fa8f276e047fe3c283671c (diff)
downloadsyslinux.git-43cf4dda600db1ccd05d9788c7b1da0cde7c0413.tar.gz
syslinux.git-43cf4dda600db1ccd05d9788c7b1da0cde7c0413.tar.xz
syslinux.git-43cf4dda600db1ccd05d9788c7b1da0cde7c0413.zip
Fix COMBOOT/COM32 command-line generation.syslinux-2.08-pre1
Add test programs.
-rw-r--r--BUGS2
-rw-r--r--NEWS2
-rw-r--r--cmdline.inc44
-rw-r--r--com32.inc17
-rw-r--r--comboot.doc4
-rw-r--r--comboot.inc34
-rw-r--r--isolinux.asm1
-rw-r--r--ldlinux.asm1
-rw-r--r--pxelinux.asm1
-rw-r--r--sample/Makefile6
-rw-r--r--sample/c32echo.c49
-rw-r--r--sample/comecho.asm35
12 files changed, 178 insertions, 18 deletions
diff --git a/BUGS b/BUGS
index a3ccc7f3..9639da80 100644
--- a/BUGS
+++ b/BUGS
@@ -1,6 +1,4 @@
Known bugs that have not yet been fixed:
-- APPEND doesn't work with COMBOOT/COM32 images.
-
- PXELINUX: Some PXE stacks fail with routing enabled, some with
routing disabled. Try both?
diff --git a/NEWS b/NEWS
index fde4a479..c796e809 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ them.
Changes in 2.08:
* Add "timeoutcmd" to allow timeout to have a different action
than just pressing Enter.
+ * Fix bugs in the COMBOOT/COM32 command-line parsing. APPEND
+ now works with COMBOOT/COM32 images.
Changes in 2.07:
* MEMDISK: Workaround for BIOSes which go into a snit when
diff --git a/cmdline.inc b/cmdline.inc
new file mode 100644
index 00000000..11a81e36
--- /dev/null
+++ b/cmdline.inc
@@ -0,0 +1,44 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;
+;; Copyright 2003 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
+;; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+;; Bostom MA 02111-1307, USA; either version 2 of the License, or
+;; (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; cmdline.inc
+;;
+;; Common routine to assemble [null-terminated] command line into
+;; real_mode_seg:cmd_line_here.
+;; Not used by plain kernel due to BOOT_IMAGE= etc.
+;;
+
+;
+; Assumes DS == CS
+make_plain_cmdline:
+ push es
+ ; ui.inc has already copied the actual command line
+ mov ax,real_mode_seg
+ mov es,ax
+
+ mov si,[CmdOptPtr]
+ mov di,[CmdLinePtr]
+
+.loop: lodsb
+ stosb
+ and al,al
+ jnz .loop
+
+ dec di
+ mov [CmdLinePtr],di
+
+ pop es
+ ret
+
+
diff --git a/com32.inc b/com32.inc
index 59d1cb86..d0bfb3ed 100644
--- a/com32.inc
+++ b/com32.inc
@@ -41,6 +41,19 @@ com32_rmidt:
dd 0 ; Address
is_com32_image:
+ push si ; Save file handle
+
+ call make_plain_cmdline
+ ; Copy the command line into the low cmdline buffer
+ mov ax,real_mode_seg
+ mov fs,ax
+ mov si,cmd_line_here
+ mov di,command_line
+ mov cx,[CmdLinePtr]
+ inc cx ; Include final null
+ sub cx,si
+ fs rep movsb
+
call highmemsize ; We need the high memory size...
call comboot_setup_api ; Set up the COMBOOT-style API
@@ -48,6 +61,7 @@ is_com32_image:
xchg eax,edx ; Gotta fix this insanity...
shl eax,16
mov ax,dx
+ pop si ; File handle
call load_high
call crlf
@@ -146,8 +160,7 @@ com32_call_start:
push dword (1 << 16) ; 64K bounce buffer
push dword (comboot_seg << 4) ; Bounce buffer address
push dword com32_intcall ; Intcall entry point
- movzx esi,word [word CmdOptPtr]
- push esi ; Command line pointer
+ push dword command_line ; Command line pointer
push dword 5 ; Argument count
sti ; Interrupts OK now
call pm_entry ; Run the program...
diff --git a/comboot.doc b/comboot.doc
index 89fe6e43..5d1a9547 100644
--- a/comboot.doc
+++ b/comboot.doc
@@ -179,6 +179,10 @@ INT 21h AH=08h Get Key without Echo
Reads a key fron the console input, without echoing it to the
console output. The read character is returned in AL.
+INT 21h AH=09h Write DOS String to Console
+
+ Writes a DOS $-terminated string in DS:DX to the console.
+
INT 21h AH=0Bh Check Keyboard
Returns AL=FFh if there is a keystroke waiting (which can then
diff --git a/comboot.inc b/comboot.inc
index 454d42c0..c8dbff11 100644
--- a/comboot.inc
+++ b/comboot.inc
@@ -75,16 +75,15 @@ is_comboot_image:
cmp ax,0ff00h ; Max size in bytes
jae comboot_too_large
+ push si ; Save file handle
+
+ call make_plain_cmdline
+
call comboot_setup_api
mov cx,comboot_seg
mov es,cx
- mov bx,100h ; Load at <seg>:0100h
-
- mov cx,[ClustPerMoby] ; Absolute maximum # of clusters
- call getfssec
-
xor di,di
mov cx,64 ; 256 bytes (size of PSP)
xor eax,eax ; Clear PSP
@@ -104,23 +103,32 @@ is_comboot_image:
%endif
%endif
; Copy the command line from high memory
+ mov si,cmd_line_here
mov cx,125 ; Max cmdline len (minus space and CR)
- mov si,[CmdOptPtr]
mov di,081h ; Offset in PSP for command line
mov al,' ' ; DOS command lines begin with a space
stosb
-comboot_cmd_cp: es lodsb
+.loop: es lodsb
and al,al
- jz comboot_end_cmd
+ jz .done
stosb
- loop comboot_cmd_cp
-comboot_end_cmd: mov al,0Dh ; CR after last character
+ loop .loop
+.done:
+
+ mov al,0Dh ; CR after last character
stosb
- mov al,126 ; Include space but not CR
- sub al,cl
- mov [es:80h], al ; Store command line length
+ mov ax,di
+ sub al,82h ; Include space but not CR
+ mov [es:80h],al ; Store command line length
+
+ ; Now actually load the file...
+ pop si ; File handle
+ mov bx,100h ; Load at <seg>:0100h
+ mov cx,[ClustPerMoby] ; Absolute maximum # of clusters
+ call getfssec
+ ; And invoke the program...
mov [SavedSSSP],sp
mov [SavedSSSP+2],ss ; Save away SS:SP
diff --git a/isolinux.asm b/isolinux.asm
index 51d9468e..7b92fd4c 100644
--- a/isolinux.asm
+++ b/isolinux.asm
@@ -860,6 +860,7 @@ load_config:
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
diff --git a/ldlinux.asm b/ldlinux.asm
index c8faa60f..b39c9059 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -1059,6 +1059,7 @@ mkkeymap: stosb
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
diff --git a/pxelinux.asm b/pxelinux.asm
index b8aa92db..fd2877a1 100644
--- a/pxelinux.asm
+++ b/pxelinux.asm
@@ -928,6 +928,7 @@ config_scan:
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
diff --git a/sample/Makefile b/sample/Makefile
index 0d23c98f..373828c3 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -18,6 +18,7 @@
CC = gcc
LD = ld
AR = ar
+NASM = nasm
RANLIB = ranlib
CFLAGS = -march=i386 -O2 -fomit-frame-pointer -I../com32/include
SFLAGS = -march=i386
@@ -30,7 +31,7 @@ LIBOBJS = conio.o
.SUFFIXES: .lss .c .o .elf .c32
-all: syslogo.lss hello.c32 hello2.c32 filetest.c32
+all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32
%.o: %.S
$(CC) $(SFLAGS) -c -o $@ $<
@@ -44,6 +45,9 @@ all: syslogo.lss hello.c32 hello2.c32 filetest.c32
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
+%.com: %.asm
+ $(NASM) -f bin -o $@ -l $*.lst $<
+
$(LIB): $(LIBOBJS)
rm -f $@
$(AR) cq $@ $^
diff --git a/sample/c32echo.c b/sample/c32echo.c
new file mode 100644
index 00000000..9733d41f
--- /dev/null
+++ b/sample/c32echo.c
@@ -0,0 +1,49 @@
+#ident "$Id$"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2002 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
+ * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+ * Bostom MA 02111-1307, USA; either version 2 of the License, or
+ * (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * c32echo.c
+ *
+ * Simple COM32 program which only prints out its own command line
+ */
+
+#include <com32.h>
+
+#define NULL ((void *)0)
+
+static inline void memset(void *buf, int ch, unsigned int len)
+{
+ asm volatile("cld; rep; stosb"
+ : "+D" (buf), "+c" (len) : "a" (ch) : "memory");
+}
+
+int __start(void)
+{
+ com32sys_t inreg, outreg;
+ const char *p;
+
+ memset(&inreg, 0, sizeof inreg);
+ inreg.eax.b[1] = 0x02; /* Write Character */
+
+ for ( p = __com32.cs_cmdline ; *p ; p++ ) {
+ inreg.edx.b[0] = *p;
+ __com32.cs_intcall(0x21, &inreg, NULL);
+ }
+
+ inreg.edx.b[0] = '\r';
+ __com32.cs_intcall(0x21, &inreg, NULL);
+ inreg.edx.b[0] = '\n';
+ __com32.cs_intcall(0x21, &inreg, NULL);
+
+ return 0;
+}
diff --git a/sample/comecho.asm b/sample/comecho.asm
new file mode 100644
index 00000000..3cdf601a
--- /dev/null
+++ b/sample/comecho.asm
@@ -0,0 +1,35 @@
+;
+; Simple COMBOOT program that just prints out its own command line.
+; This also works in DOS.
+;
+
+ org 100h
+
+_start:
+ xor cx,cx
+ mov cl,[80h] ; Command line len
+ mov si,81h ; Command line
+
+ mov dl,"<"
+ mov ah,02h
+ int 21h
+
+.writechar:
+ lodsb
+ mov dl,al
+ mov ah,02h
+ int 21h
+ loop .writechar
+
+ mov dx,end_str
+ mov ah,09h
+ int 21h
+
+ ; Exit with near return, INT 20h, or INT 21h AX=4C00h
+ ret
+
+
+end_str db ">", 0Dh, 0Ah, "$"
+
+
+ \ No newline at end of file