summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorhpa <hpa>2002-06-11 05:48:29 +0000
committerhpa <hpa>2002-06-11 05:48:29 +0000
commitabac6f53695c0b99e0235ca3da81ab3cd822f475 (patch)
tree42c9c90abcb685ec654b25e680f6a0e272d1fe52 /sample
parent73d0682dcdd250939e560d333b591d7a5a8299ca (diff)
downloadsyslinux-abac6f53695c0b99e0235ca3da81ab3cd822f475.tar.gz
Add an API for COMBOOT images, and add support for "COM32" -- 32-bit
linear .com files.
Diffstat (limited to 'sample')
-rw-r--r--sample/Makefile18
-rw-r--r--sample/hello.c47
2 files changed, 64 insertions, 1 deletions
diff --git a/sample/Makefile b/sample/Makefile
index f4ad1bcf..e6b648a0 100644
--- a/sample/Makefile
+++ b/sample/Makefile
@@ -15,15 +15,31 @@
## samples for syslinux users
##
+CC = gcc
+LD = ld
+CFLAGS = -O2 -fomit-frame-pointer -I..
+LDFLAGS = -s
+OBJCOPY = objcopy
PPMTOLSS16 = ../ppmtolss16
-all: syslogo.lss
+.SUFFIXES: .lss .c .o .elf .c32
+
+all: syslogo.lss hello.c32
+
+.c.o:
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+.elf.c32:
+ $(OBJCOPY) -O binary $< $@
syslogo.lss: syslogo.png $(PPMTOLSS16)
pngtopnm syslogo.png | \
$(PPMTOLSS16) \#000000=0 \#d0d0d0=7 \#f6f6f6=15 \
> syslogo.lss
+hello.elf: hello.o
+ $(LD) -Ttext 0x101000 -e _start -o $@ $<
+
clean:
rm -f *.lss
diff --git a/sample/hello.c b/sample/hello.c
new file mode 100644
index 00000000..194092e3
--- /dev/null
+++ b/sample/hello.c
@@ -0,0 +1,47 @@
+#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.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * hello.c
+ *
+ * Simple COM32 image
+ */
+
+#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(unsigned int nargs, char *cmdline,
+ void (*syscall)(unsigned char, com32sys_t *, com32sys_t *),
+ void *bounce_ptr, unsigned int bounce_len)
+{
+ const char *msg = "Hello, World!\r\n";
+ com32sys_t inreg, outreg;
+ const char *p;
+
+ memset(&inreg, 0, sizeof inreg);
+
+ for ( p = msg ; *p ; p++ ) {
+ inreg.edx = *p;
+ inreg.eax = 0x0200;
+ syscall(0x21, &inreg, NULL);
+ }
+
+ return 0;
+}