1 #ident "$Id: fd.c,v 1.2 2004/12/14 22:46:25 hpa Exp $"
2 /* ----------------------------------------------------------------------- *
4 * Copyright 2003 H. Peter Anvin - All Rights Reserved
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Boston MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
12 * ----------------------------------------------------------------------- */
17 * Chainload a floppy disk (currently rather braindead.)
21 #define NULL ((void *)0)
23 int printf(const char *, ...);
24 unsigned int atou(const char *);
28 int whichfd = atou(__com32.cs_cmdline);
29 static com32sys_t inreg, outreg; /* In bss, so zeroed automatically */
32 for ( retry = 0 ; retry < 6 ; retry++ ) {
34 inreg.eax.w[0] = 0x0201; /* Read one sector */
35 inreg.ecx.w[0] = 0x0001; /* Cyl 0 sector 1 */
36 inreg.edx.b[1] = 0; /* Head 0 */
37 inreg.edx.b[0] = whichfd; /* Drive number */
38 inreg.es = SEG(__com32.cs_bounce); /* Read into the bounce buffer */
39 inreg.ebx.w[0] = OFFS(__com32.cs_bounce);
40 __com32.cs_intcall(0x13, &inreg, &outreg);
42 if ( (outreg.eflags.l & 1) == 0 )
46 if ( (outreg.eflags.l & 1) == 0 ) {
48 inreg.eax.w[0] = 0x000d;
50 inreg.edi.l = (uint32_t) __com32.cs_bounce;
52 inreg.ebx.l = whichfd & 0xff;
53 inreg.esi.l = 0; /* No partitions */
54 inreg.ds = 0; /* No partitions */
55 __com32.cs_intcall(0x22, &inreg, NULL);
58 /* If we get here, badness happened */