summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--com32/include/com32.h13
-rw-r--r--comboot.doc3
-rw-r--r--sample/Makefile14
-rw-r--r--sample/c32entry.S14
-rw-r--r--sample/hello.c6
6 files changed, 36 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index 42bd36fb..b18f1c57 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Changes in 2.01:
* Update the mkdiskimage script to handle newer mtools
versions, and be able to generate disk images with DOSEMU
headers (controlled by the -d option).
+ * Fix the COM32 sample program.
Changes in 2.00:
* ALL: Add support for "COM32" (32-bit COMBOOT) images.
diff --git a/com32/include/com32.h b/com32/include/com32.h
index 4b7266fd..a56cc698 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -46,11 +46,12 @@ typedef struct {
reg32_t eflags; /* Offset 40 */
} com32sys_t;
-/* The standard prototype for _start() */
-int _start(unsigned int __nargs,
- char *__cmdline,
- void (*__syscall)(uint8_t, com32sys_t *, com32sys_t *),
- void *__bounce_ptr,
- unsigned int __bounce_len);
+extern struct com32_sys_args {
+ uint32_t cs_sysargs;
+ char *cs_cmdline;
+ void (*cs_syscall)(uint8_t, com32sys_t *, com32sys_t *);
+ void *cs_bounce;
+ uint32_t cs_bounce_size;
+} __com32;
#endif /* _COM32_H */
diff --git a/comboot.doc b/comboot.doc
index 43c80f99..f7753138 100644
--- a/comboot.doc
+++ b/comboot.doc
@@ -62,6 +62,9 @@ be possible to create a COM32 execution engine that would run under
something like Linux DOSEMU, it is recommended that the code does not
assume CPL 0 unless absolutely necessary.
+It is highly recommended that every COM32 program begins with the byte
+sequence B8 FF 4C CD 21 (mov eax,21cd4cffh) as a magic number.
+
A COM32 file should have extension ".c32".
On startup, CS will be set up as a flat 32-bit code segment, and DS ==
diff --git a/sample/Makefile b/sample/Makefile
index 58d6d052..54fdb097 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -18,6 +18,7 @@
CC = gcc
LD = ld
CFLAGS = -march=i386 -O2 -fomit-frame-pointer -I../com32/include
+SFLAGS = -march=i386
LDFLAGS = -s
OBJCOPY = objcopy
PPMTOLSS16 = ../ppmtolss16
@@ -26,10 +27,16 @@ PPMTOLSS16 = ../ppmtolss16
all: syslogo.lss hello.c32
-.c.o:
+%.o: %.S
+ $(CC) $(SFLAGS) -c -o $@ $<
+
+%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
-.elf.c32:
+%.elf: c32entry.o %.o
+ $(LD) -Ttext 0x101000 -e _start -o $@ $^
+
+%.c32: %.elf
$(OBJCOPY) -O binary $< $@
syslogo.lss: syslogo.png $(PPMTOLSS16)
@@ -37,9 +44,6 @@ syslogo.lss: syslogo.png $(PPMTOLSS16)
$(PPMTOLSS16) \#000000=0 \#d0d0d0=7 \#f6f6f6=15 \
> syslogo.lss
-hello.elf: hello.o
- $(LD) -Ttext 0x101000 -e _start -o $@ $<
-
clean:
rm -f *.lss *.o *.elf *.c32
diff --git a/sample/c32entry.S b/sample/c32entry.S
new file mode 100644
index 00000000..f1c476ca
--- /dev/null
+++ b/sample/c32entry.S
@@ -0,0 +1,14 @@
+ .section ".text","ax"
+ .globl _start
+_start:
+ movl $0x21cd4cff,%eax
+ leal 4(%esp),%esi
+ movl $__com32,%edi
+ mov $5,%ecx
+ cld
+ rep ; movsl
+ jmp __start
+
+ .section ".bss","a"
+ .globl __com32
+__com32: .space 20
diff --git a/sample/hello.c b/sample/hello.c
index bb8bbfa6..a2b79dde 100644
--- a/sample/hello.c
+++ b/sample/hello.c
@@ -27,9 +27,7 @@ static inline void memset(void *buf, int ch, unsigned int len)
: "+D" (buf), "+c" (len) : "a" (ch) : "memory");
}
-int _start(unsigned int nargs, char *cmdline,
- void (*syscall)(unsigned char, com32sys_t *, com32sys_t *),
- void *bounce_ptr, unsigned int bounce_len)
+int __start(void)
{
const char *msg = "Hello, World!\r\n";
com32sys_t inreg, outreg;
@@ -40,7 +38,7 @@ int _start(unsigned int nargs, char *cmdline,
for ( p = msg ; *p ; p++ ) {
inreg.edx.b[0] = *p;
inreg.eax.b[1] = 0x02; /* Write Character */
- syscall(0x21, &inreg, NULL);
+ __com32.cs_syscall(0x21, &inreg, NULL);
}
return 0;