* 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.
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 */
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 ==
CC = gcc
LD = ld
CFLAGS = -march=i386 -O2 -fomit-frame-pointer -I../com32/include
+SFLAGS = -march=i386
LDFLAGS = -s
OBJCOPY = objcopy
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)
$(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
--- /dev/null
+ .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
: "+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;
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;