diff options
author | hpa <hpa> | 2003-11-26 05:42:33 +0000 |
---|---|---|
committer | hpa <hpa> | 2003-11-26 05:42:33 +0000 |
commit | df2322b51c6ffd9e4a05b225c5c4ba44b09d3e75 (patch) | |
tree | 2e837e97013969748192fddd5bac9515e6b2596d /sample | |
parent | 0fab936237d1b5fb713f291dfe6aa7c342c7d246 (diff) | |
download | syslinux-df2322b51c6ffd9e4a05b225c5c4ba44b09d3e75.tar.gz |
Add a bootstrap chainloading API, and include a sample program for it.syslinux-2.08-pre5
Diffstat (limited to 'sample')
-rw-r--r-- | sample/Makefile | 2 | ||||
-rw-r--r-- | sample/fd.c | 63 |
2 files changed, 64 insertions, 1 deletions
diff --git a/sample/Makefile b/sample/Makefile index 0bd4512f..900acbd6 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -31,7 +31,7 @@ LIBOBJS = conio.o .SUFFIXES: .lss .c .o .elf .c32 -all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 +all: syslogo.lss comecho.com hello.c32 hello2.c32 filetest.c32 c32echo.c32 fd.c32 %.o: %.S $(CC) $(SFLAGS) -c -o $@ $< diff --git a/sample/fd.c b/sample/fd.c new file mode 100644 index 00000000..03e13d1a --- /dev/null +++ b/sample/fd.c @@ -0,0 +1,63 @@ +#ident "$Id$" +/* ----------------------------------------------------------------------- * + * + * Copyright 2003 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. + * + * ----------------------------------------------------------------------- */ + +/* + * fd.c + * + * Chainload a floppy disk (currently rather braindead.) + */ + +#include <com32.h> +#define NULL ((void *)0) + +int printf(const char *, ...); +unsigned int atou(const char *); + +int __start(void) +{ + int whichfd = atou(__com32.cs_cmdline); + static com32sys_t inreg, outreg; /* In bss, so zeroed automatically */ + int retry; + + for ( retry = 0 ; retry < 6 ; retry++ ) { + printf(">"); + inreg.eax.w[0] = 0x0201; /* Read one sector */ + inreg.ecx.w[0] = 0x0001; /* Cyl 0 sector 1 */ + inreg.edx.b[1] = 0; /* Head 0 */ + inreg.edx.b[0] = whichfd; /* Drive number */ + inreg.es = SEG(__com32.cs_bounce); /* Read into the bounce buffer */ + inreg.ebx.w[0] = OFFS(__com32.cs_bounce); + __com32.cs_intcall(0x13, &inreg, &outreg); + + if ( (outreg.eflags.l & 1) == 0 ) + break; + } + + if ( (outreg.eflags.l & 1) == 0 ) { + printf("!\n"); + inreg.eax.w[0] = 0x000d; + inreg.edx.w[0] = 0; + inreg.edi.l = (uint32_t) __com32.cs_bounce; + inreg.ecx.l = 512; + inreg.ebx.l = whichfd & 0xff; + inreg.esi.l = 0; /* No partitions */ + inreg.ds = 0; /* No partitions */ + __com32.cs_intcall(0x22, &inreg, NULL); + } + + /* If we get here, badness happened */ + return 255; +} + + + |