Index: bootcd/isolinux/syslinux-6.03/com32/samples/Makefile
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/Makefile	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/Makefile	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,40 @@
+## -----------------------------------------------------------------------
+##
+##   Copyright 2001-2008 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,
+##   Boston MA 02111-1307, USA; either version 2 of the License, or
+##   (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+##
+## samples for syslinux users
+##
+
+LIBS = $(objdir)/com32/libutil/libutil.c32
+
+VPATH = $(SRC)
+include $(MAKEDIR)/elf.mk
+
+all:	hello.c32 resolv.c32 serialinfo.c32 \
+		localboot.c32 \
+		fancyhello.c32 fancyhello.lnx \
+		keytest.c32 keytest.lnx \
+		advdump.c32 entrydump.c32
+
+tidy dist:
+	rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
+
+clean: tidy
+	rm -f *.lnx
+
+spotless: clean
+	rm -f *.lss *.c32 *.com
+	rm -f *~ \#*
+
+install:	# Don't install samples
+
+-include .*.d
Index: bootcd/isolinux/syslinux-6.03/com32/samples/advdump.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/advdump.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/advdump.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,59 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2007-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * advdump.c
+ *
+ * Dump the contents of the syslinux ADV
+ */
+
+#include <stdio.h>
+#include <console.h>
+#include <syslinux/adv.h>
+#include <string.h>
+
+int main(void)
+{
+    uint8_t *p, *ep;
+    size_t s = syslinux_adv_size();
+    char buf[256];
+
+#if 0
+	/* this hangs! */
+    openconsole(&dev_stdcon_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
+
+    p = syslinux_adv_ptr();
+
+    printf("ADV size: %zd bytes at %p\n", s, p);
+
+    ep = p + s;			/* Need at least opcode+len */
+    while (p < ep - 1 && *p) {
+	int t = *p++;
+	int l = *p++;
+
+	if (p + l > ep)
+	    break;
+
+	memcpy(buf, p, l);
+	buf[l] = '\0';
+
+	printf("ADV %3d: \"%s\"\n", t, buf);
+
+	p += l;
+    }
+
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/entrydump.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/entrydump.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/entrydump.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,66 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * entry.c
+ *
+ * Dump the entry point registers
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <console.h>
+#include <syslinux/config.h>
+
+struct stack_frame {
+    uint16_t gs, fs, es, ds;
+    uint32_t edi, esi, ebp, esp;
+    uint32_t ebx, edx, ecx, eax;
+    uint32_t eflags;
+    uint16_t ret_ip, ret_cs;
+    uint16_t pxe_ip, pxe_cs;
+};
+
+int main(void)
+{
+    const union syslinux_derivative_info *di;
+    const struct stack_frame *sf;
+
+#if 0
+	/* this hangs! */
+    openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
+
+    di = syslinux_derivative_info();
+
+    if (di->c.filesystem != SYSLINUX_FS_PXELINUX) {
+	printf("Not running under PXELINUX (fs = %02x)\n", di->c.filesystem);
+	return 1;
+    }
+
+    sf = (const struct stack_frame *)di->pxe.stack;
+
+    printf("EAX: %08x  EBX: %08x  ECX: %08x  EDX: %08x\n"
+	   "ESP: %08x  EBP: %08x  ESI: %08x  EDI: %08x\n"
+	   "SS: %04x   DS: %04x   ES: %04x   FS: %04x   GS:  %04x\n"
+	   "EFLAGS: %08x   RET: %04x:%04x   PXE: %04x:%04x\n",
+	   sf->eax, sf->ebx, sf->ecx, sf->edx,
+	   sf->esp + 4, sf->ebp, sf->esi, sf->edi,
+	   di->rr.r.fs, sf->ds, sf->es, sf->fs, sf->gs,
+	   sf->eflags, sf->ret_cs, sf->ret_ip, sf->pxe_cs, sf->pxe_ip);
+
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/fancyhello.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/fancyhello.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/fancyhello.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,42 @@
+
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * fancyhello.c
+ *
+ * Hello, World! using libcom32 and ANSI console; also possible to compile
+ * as a Linux application for testing.
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+#include <consoles.h>		/* Provided by libutil */
+
+int main(void)
+{
+    char buffer[1024];
+
+    console_ansi_std();
+
+    printf("\033[1;33;44m *** \033[37mHello, World!\033[33m *** \033[0m\n");
+
+    for (;;) {
+	printf("\033[1;36m>\033[0m ");
+	fgets(buffer, sizeof buffer, stdin);
+	if (!strncmp(buffer, "exit", 4))
+	    break;
+	printf("\033[1m:\033[0m %s", buffer);
+    }
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/hello.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/hello.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/hello.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,26 @@
+/*
+ * hello.c - A simple ELF module that sorts a couple of numbers
+ *
+ *  Created on: Aug 11, 2008
+ *      Author: Stefan Bucur <stefanb@zytor.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sort.h"
+
+#define NUM_COUNT		10
+#define MAX_NUM			100
+
+int main(int argc __unused, char **argv __unused)
+{
+    int *nums = NULL;
+
+    nums = malloc(NUM_COUNT * sizeof(int));
+    printf("Hello, world, from 0x%08X! malloc return %p\n", (unsigned int)&main, nums);
+
+    free(nums);
+
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/keytest.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/keytest.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/keytest.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,82 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * keytest.c
+ *
+ * Test the key parsing library
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/times.h>
+
+#include <consoles.h>		/* Provided by libutil */
+#include <getkey.h>
+
+static void cooked_keys(void)
+{
+    int key;
+
+    printf("[cooked]");
+
+    for (;;) {
+	key = get_key(stdin, 0);
+
+	if (key == 0x03) {
+	    printf("[done]\n");
+	    exit(0);
+	} else if (key == '!')
+	    return;
+
+	if (key >= 0x20 && key < 0x100) {
+	    putchar(key);
+	} else {
+	    printf("[%s,%04x]", key_code_to_name(key), key);
+	}
+    }
+}
+
+static void raw_keys(void)
+{
+    int key;
+
+    printf("[raw]");
+
+    for (;;) {
+	key = getc(stdin);
+
+	if (key == 0x03) {
+	    printf("[done]\n");
+	    exit(0);
+	} else if (key == '!')
+	    return;
+
+	if (key != EOF)
+	    printf("<%02x>", key);
+    }
+}
+
+int main(void)
+{
+    console_ansi_raw();
+
+    printf("CLK_TCK = %d\n", (int)CLK_TCK);
+    printf("Press keys, end with Ctrl-C, ! changes from cooked to raw\n");
+
+    for (;;) {
+	cooked_keys();
+	raw_keys();
+    }
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/localboot.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/localboot.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/localboot.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,9 @@
+#include <syslinux/boot.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+    syslinux_local_boot(argc > 1 ? atoi(argv[1]) : 0);
+
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/resolv.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/resolv.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/resolv.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,59 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2004-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * resolv.c
+ *
+ * Resolve an IP address
+ */
+
+#include <syslinux/pxe_api.h>
+#include <string.h>
+#include <stdio.h>
+#include <console.h>
+#include <stdlib.h>
+#include <com32.h>
+
+uint32_t resolv(const char *name)
+{
+    return dns_resolv(name);
+}
+
+int main(int argc, char *argv[])
+{
+    uint32_t ip;
+
+#if 0
+	/* this hangs! */
+    openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
+
+    if (argc < 2) {
+	fputs("Usage: resolv hostname\n", stderr);
+	exit(1);
+    }
+
+    ip = resolv(argv[1]);
+
+    if (ip) {
+	printf("%s = %u.%u.%u.%u\n", argv[1],
+	       (ip & 0xff), (ip >> 8) & 0xff,
+	       (ip >> 16) & 0xff, (ip >> 24) & 0xff);
+    } else {
+	printf("%s not found\n", argv[1]);
+    }
+
+    return 0;
+}
Index: bootcd/isolinux/syslinux-6.03/com32/samples/serialinfo.c
===================================================================
--- bootcd/isolinux/syslinux-6.03/com32/samples/serialinfo.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
+++ bootcd/isolinux/syslinux-6.03/com32/samples/serialinfo.c	(revision e16e8f2a41938d263af54a9fd6b4020d6c0d69fa)
@@ -0,0 +1,45 @@
+/* ----------------------------------------------------------------------- *
+ *
+ *   Copyright 2007-2008 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,
+ *   Boston MA 02111-1307, USA; either version 2 of the License, or
+ *   (at your option) any later version; incorporated herein by reference.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * serialinfo.c
+ *
+ * Print serial port info
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <console.h>
+#include <syslinux/config.h>
+
+int main(void)
+{
+    const struct syslinux_serial_console_info *si;
+
+#if 0
+	/* this hangs! */
+    openconsole(&dev_null_r, &dev_stdcon_w);
+#else
+	/* this works */
+    openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+#endif
+
+    si = syslinux_serial_console_info();
+
+    printf("Serial port base:    %#06x\n", si->iobase);
+    printf("Serial port divisor:  %5d", si->divisor);
+    if (si->divisor)
+	printf(" (%d baud)", 115200 / si->divisor);
+    printf("\n" "Flow control bits:    %#05x\n", si->flowctl);
+
+    return 0;
+}
