summaryrefslogtreecommitdiffstats
path: root/sys/i386/boot/netboot
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-11-02 14:46:27 +0000
committerphk <phk@FreeBSD.org>1996-11-02 14:46:27 +0000
commitfb5536deb2892e2ceb3246ced782de38ee5e4f22 (patch)
treed952fa0570d8511ddaf08925dd21b322ab00b3d4 /sys/i386/boot/netboot
parent223875ec7d51de4b686f9069a84494af29734cf6 (diff)
downloadFreeBSD-src-fb5536deb2892e2ceb3246ced782de38ee5e4f22.zip
FreeBSD-src-fb5536deb2892e2ceb3246ced782de38ee5e4f22.tar.gz
Fill in the bios-geometry array in struct bootinfo.
2.2 candidate.
Diffstat (limited to 'sys/i386/boot/netboot')
-rw-r--r--sys/i386/boot/netboot/main.c5
-rw-r--r--sys/i386/boot/netboot/start2.S74
2 files changed, 79 insertions, 0 deletions
diff --git a/sys/i386/boot/netboot/main.c b/sys/i386/boot/netboot/main.c
index 6b429a4..fc5943d 100644
--- a/sys/i386/boot/netboot/main.c
+++ b/sys/i386/boot/netboot/main.c
@@ -54,6 +54,11 @@ main()
printf(" - bad response\n\r");
}
#endif
+
+ /* get the bios's idea about the disks geometry */
+ for(c = 0; c < N_BIOS_GEOM; c ++)
+ bootinfo.bi_bios_geom[c] = get_diskinfo(c + 0x80);
+
gateA20();
printf("\r\nBOOTP/TFTP/NFS bootstrap loader ESC for menu\n\r");
printf("\r\nSearching for adapter...");
diff --git a/sys/i386/boot/netboot/start2.S b/sys/i386/boot/netboot/start2.S
index 5bbc96c..00a37a3 100644
--- a/sys/i386/boot/netboot/start2.S
+++ b/sys/i386/boot/netboot/start2.S
@@ -324,6 +324,80 @@ _prot_to_real:
ret
/**************************************************************************
+GET DISK GEOMETRY INFO
+**************************************************************************/
+
+/*
+ *
+ * get_diskinfo(): return a word that represents the
+ * max number of sectors and heads and drives for this device
+ *
+ */
+
+ .globl _get_diskinfo
+_get_diskinfo:
+ push %ebp
+ mov %esp, %ebp
+ push %es
+ push %ebx
+ push %ecx
+ push %edx
+
+ movb 0x8(%ebp), %dl /* diskinfo(drive #) */
+ call _prot_to_real /* enter real mode */
+
+ movb $0x8, %ah /* ask for disk info */
+
+ sti
+ int $0x13
+ cli
+
+ jnc ok
+ /*
+ * Urk. Call failed. It is not supported for floppies by old BIOS's.
+ * Guess it's a 15-sector floppy.
+ */
+ subb %ah, %ah /* %ax = 0 */
+ movb %al, %al
+ movb %ah, %bh /* %bh = 0 */
+ movb $2, %bl /* %bl bits 0-3 = drive type,
+ bit 2 = 1.2M */
+ movb $79, %ch /* max track */
+ movb $15, %cl /* max sector */
+ movb $1, %dh /* max head */
+ movb $1, %dl /* # floppy drives installed */
+ /* es:di = parameter table */
+ /* carry = 0 */
+ok:
+
+ opsize
+ call _real_to_prot /* back to protected mode */
+
+ /*
+ * form a longword representing all this gunk:
+ * 6 bit zero
+ * 10 bit max cylinder (0 based)
+ * 8 bit max head (0 based)
+ * 8 bit zero
+ * 6 bit max sector (1 based) = # sectors
+ */
+ movb %cl, %al /* Upper two bits of cylinder count */
+ andl $192,%eax
+ leal 0(,%eax,4),%eax /* << 2 */
+ movb %ch, %al /* Lower 8 bits */
+ sall $16,%eax /* << 16 */
+ movb %dh, %ah /* max head */
+ andb $0x3f, %cl /* mask of cylinder gunk */
+ movb %cl, %al /* max sector (and # sectors) */
+
+ pop %edx
+ pop %ecx
+ pop %ebx
+ pop %es
+ pop %ebp
+ ret
+
+/**************************************************************************
GLOBAL DESCRIPTOR TABLE
**************************************************************************/
.align 4
OpenPOWER on IntegriCloud