1 #if (TRY_FLOPPY_FIRST > 0)
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
10 #include "etherboot.h"
12 #define BOOTSECT ((char *)0x7C00)
13 #define BOOTSIG ((unsigned short *)BOOTSECT)[0xFF]
14 #define PARTTAB ((partentry *)(BOOTSECT+0x1BE))
16 typedef struct partentry {
18 unsigned char start_head;
19 unsigned char start_sector;
20 unsigned char start_cylinder;
22 unsigned char end_head;
23 unsigned char end_sector;
24 unsigned char end_cylinder;
29 static unsigned int disk_read_retry(int dev,int c,int h,int s)
33 while (retry-- && (rc = pcbios_disk_read(dev,c,h,s,BOOTSECT)) != 0);
34 if (BOOTSIG != 0xAA55) {
35 printf("not a boot sector");
40 int bootdisk(int dev,int part)
45 if ((rc = disk_read_retry(dev,0,0,1)) != 0) {
48 printf("read error (%#hhX)",rc/256);
55 for (i = 0, ptr = PARTTAB; ptr->type != 5; ptr++)
57 printf("partition not found");
59 if ((rc = disk_read_retry(dev,
62 ptr->start_sector)) != 0)
65 if (!(ptr = PARTTAB-1+part)->type) {
66 printf("empty partition");
68 if ((rc = disk_read_retry(dev,
71 ptr->start_sector)) != 0)
75 /* Set %edx to device number to emulate BIOS
76 Fortunately %edx is not used after this */
77 __asm__("movl %0,%%edx" : : "g" (dev));
78 xstart((unsigned long)BOOTSECT, 0, 0);