Subject: Booting a net4501 with a dumb CF card
To: None <current-users@netbsd.org>
From: Quentin Garnier <netbsd-current-users@quatriemek.com>
List: current-users
Date: 07/25/2003 06:20:46
Hi,
I've finally managed to boot my brand new net4501 box from the (poor) CF
card I bought.
First I had some geometry issues, but those were easy to solve.
Then I was hit by the issue (often described in soekris-tech apparently)
of the impossibility of reading more than one sector at a time through INT
13h on the CF card. Thus I had to patch the bootblocks code a little.
My assembly is rather poor but it seems to do the job, so I leave it here
in case someone would need it. Maybe David Laight can work out a
compile-time option for a similar code.
Index: bootxx/pbr.S
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/bootxx/pbr.S,v
retrieving revision 1.3
diff -u -r1.3 pbr.S
--- bootxx/pbr.S 2003/05/15 08:50:53 1.3
+++ bootxx/pbr.S 2003/07/25 04:13:08
@@ -283,9 +283,18 @@
chs_read:
movw $BOOTADDR, %bx /* es:bx is buffer */
- movw $0x200 + BOOTXX_SECTORS, %ax /* command 2, xx sectors */
+ push %di
+ movw $BOOTXX_SECTORS, %di
+read_loop:
+ movw $0x201, %ax /* command 2, sectors one by one */
int $0x13
jc read_err
+ addw $512,%bx
+ inc %cl
+ dec %di
+ jne read_loop
+ movw $BOOTADDR, %bx /* bis repetita */
+ pop %di
ret
Index: lib/bios_disk.S
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/stand/lib/bios_disk.S,v
retrieving revision 1.13
diff -u -r1.13 bios_disk.S
--- lib/bios_disk.S 2003/04/16 12:45:10 1.13
+++ lib/bios_disk.S 2003/07/25 04:13:09
@@ -139,8 +139,18 @@
pop %bx
and $0xf, %bx # and min offset - to avoid overrun
- movb $0x2, %ah # subfunction
+read_loop:
+ pushw %ax
+ movw $0x201, %ax # subfunction
int $0x13
+ jc read_error
+ popw %ax
+ inc %cl
+ addw $512,%bx
+ dec %al
+ jne read_loop
+
+read_error:
setc %al # error code is in %ah
calll _C_LABEL(real_to_prot) # back to protected mode
--
Quentin Garnier - cube@cubidou.net
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.