Add test programs.
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?
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
--- /dev/null
+;; $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
+
+
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
xchg eax,edx ; Gotta fix this insanity...
shl eax,16
mov ax,dx
+ pop si ; File handle
call load_high
call crlf
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...
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
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
%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
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
;
%include "comboot.inc"
%include "com32.inc"
+%include "cmdline.inc"
;
; Boot sector loading code
CC = gcc
LD = ld
AR = ar
+NASM = nasm
RANLIB = ranlib
CFLAGS = -march=i386 -O2 -fomit-frame-pointer -I../com32/include
SFLAGS = -march=i386
.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 $@ $<
%.c32: %.elf
$(OBJCOPY) -O binary $< $@
+%.com: %.asm
+ $(NASM) -f bin -o $@ -l $*.lst $<
+
$(LIB): $(LIBOBJS)
rm -f $@
$(AR) cq $@ $^
--- /dev/null
+#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;
+}
--- /dev/null
+;
+; 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