summaryrefslogtreecommitdiffstats
path: root/contrib/syslinux-4.02/com32/samples
diff options
context:
space:
mode:
authorSebastian Schmelzer2010-10-25 16:53:54 +0200
committerSebastian Schmelzer2010-10-25 16:53:54 +0200
commit3050a9253437f4a4b5ad4bf3b3efdc3c660a5137 (patch)
tree91ac22153e416aac7ca20916b314b5e2ffa871b1 /contrib/syslinux-4.02/com32/samples
downloadpreboot-3050a9253437f4a4b5ad4bf3b3efdc3c660a5137.tar.gz
preboot-3050a9253437f4a4b5ad4bf3b3efdc3c660a5137.tar.xz
preboot-3050a9253437f4a4b5ad4bf3b3efdc3c660a5137.zip
initial import of sc2010 scripts ..HEADmaster
Diffstat (limited to 'contrib/syslinux-4.02/com32/samples')
-rw-r--r--contrib/syslinux-4.02/com32/samples/Makefile38
-rw-r--r--contrib/syslinux-4.02/com32/samples/advdump.c53
-rw-r--r--contrib/syslinux-4.02/com32/samples/entrydump.c60
-rw-r--r--contrib/syslinux-4.02/com32/samples/fancyhello.c42
-rw-r--r--contrib/syslinux-4.02/com32/samples/hello.c35
-rw-r--r--contrib/syslinux-4.02/com32/samples/keytest.c81
-rw-r--r--contrib/syslinux-4.02/com32/samples/localboot.c9
-rw-r--r--contrib/syslinux-4.02/com32/samples/resolv.c66
-rw-r--r--contrib/syslinux-4.02/com32/samples/serialinfo.c39
9 files changed, 423 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/com32/samples/Makefile b/contrib/syslinux-4.02/com32/samples/Makefile
new file mode 100644
index 0000000..bee2b99
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/Makefile
@@ -0,0 +1,38 @@
+## -----------------------------------------------------------------------
+##
+## 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
+##
+
+topdir = ../..
+include ../MCONFIG
+
+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
diff --git a/contrib/syslinux-4.02/com32/samples/advdump.c b/contrib/syslinux-4.02/com32/samples/advdump.c
new file mode 100644
index 0000000..2c78641
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/advdump.c
@@ -0,0 +1,53 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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];
+
+ openconsole(&dev_stdcon_r, &dev_stdcon_w);
+
+ 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;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/entrydump.c b/contrib/syslinux-4.02/com32/samples/entrydump.c
new file mode 100644
index 0000000..d50859f
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/entrydump.c
@@ -0,0 +1,60 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ 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;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/fancyhello.c b/contrib/syslinux-4.02/com32/samples/fancyhello.c
new file mode 100644
index 0000000..850bff0
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/fancyhello.c
@@ -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;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/hello.c b/contrib/syslinux-4.02/com32/samples/hello.c
new file mode 100644
index 0000000..77e93ac
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/hello.c
@@ -0,0 +1,35 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * hello.c
+ *
+ * Hello, World! using libcom32
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <console.h>
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ openconsole(&dev_stdcon_r, &dev_stdcon_w);
+
+ printf("Hello, World!\n");
+
+ for (i = 1; i < argc; i++)
+ printf("%s%c", argv[i], (i == argc - 1) ? '\n' : ' ');
+
+ return 0;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/keytest.c b/contrib/syslinux-4.02/com32/samples/keytest.c
new file mode 100644
index 0000000..b4f8f5b
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/keytest.c
@@ -0,0 +1,81 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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("[%04x]", 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;
+
+ printf("<%02x>", key);
+ }
+}
+
+int main(void)
+{
+ console_ansi_raw();
+
+ printf("CLK_TCK = %d\n", (int)CLK_TCK);
+ printf("Press keys, end with Ctrl-C...\n");
+
+ for (;;) {
+ cooked_keys();
+ raw_keys();
+ }
+}
diff --git a/contrib/syslinux-4.02/com32/samples/localboot.c b/contrib/syslinux-4.02/com32/samples/localboot.c
new file mode 100644
index 0000000..b6f992d
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/localboot.c
@@ -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;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/resolv.c b/contrib/syslinux-4.02/com32/samples/resolv.c
new file mode 100644
index 0000000..bd49d9f
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/resolv.c
@@ -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.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * resolv.c
+ *
+ * Resolve an IP address
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <console.h>
+#include <stdlib.h>
+#include <com32.h>
+
+uint32_t resolv(const char *name)
+{
+ com32sys_t reg;
+
+ strcpy((char *)__com32.cs_bounce, name);
+
+ memset(&reg, 0, sizeof reg);
+ reg.eax.w[0] = 0x0010;
+ reg.ebx.w[0] = OFFS(__com32.cs_bounce);
+ reg.es = SEG(__com32.cs_bounce);
+
+ __intcall(0x22, &reg, &reg);
+
+ if (reg.eflags.l & EFLAGS_CF)
+ return 0;
+ else
+ return reg.eax.l;
+}
+
+int main(int argc, char *argv[])
+{
+ uint32_t ip;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ 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;
+}
diff --git a/contrib/syslinux-4.02/com32/samples/serialinfo.c b/contrib/syslinux-4.02/com32/samples/serialinfo.c
new file mode 100644
index 0000000..10d0252
--- /dev/null
+++ b/contrib/syslinux-4.02/com32/samples/serialinfo.c
@@ -0,0 +1,39 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * 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;
+
+ openconsole(&dev_null_r, &dev_stdcon_w);
+
+ 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;
+}