Quellcode durchsuchen

Working with multi-sector reads

tags/v0.9.3
Michael Brown vor 17 Jahren
Ursprung
Commit
a0f078d7f5
1 geänderte Dateien mit 40 neuen und 8 gelöschten Zeilen
  1. 40
    8
      src/arch/i386/prefix/hdprefix.S

+ 40
- 8
src/arch/i386/prefix/hdprefix.S Datei anzeigen

@@ -10,29 +10,61 @@
10 10
 #include "bootpart.S"
11 11
 
12 12
 load_image:
13
-	movw	$_rom_size, %bp
14
-1:	/* Truncate read length to end of track */
15
-	movzwl	%bp, %eax
16
-			movw	$1, %ax
17
-	/* Read sectors */
13
+	/* Get disk geometry */
14
+	pushal
15
+	pushw	%es
16
+	movb	$0x08, %ah
17
+	int	$0x13
18
+	jc	load_failed
19
+	movb	%cl, max_sector
20
+	movb	%dh, max_head
21
+	popw	%es
22
+	popal
23
+	
24
+1:	/* Read to end of current track */
25
+	movb	%cl, %al
26
+	negb	%al
27
+	addb	max_sector, %al
28
+	incb	%al
29
+	andb	$0x3f, %al
30
+	movzbl	%al, %eax
18 31
 	call	*read_sectors
19 32
 	jc	load_failed
33
+	
20 34
 	/* Update %es */
21 35
 	movw	%es, %bx
22 36
 	shll	$5, %eax
23 37
 	addw	%ax, %bx
24 38
 	movw	%bx, %es
25 39
 	shrl	$5, %eax
40
+	
26 41
 	/* Update LBA address */
27 42
 	addl	%eax, %edi
28 43
 	adcl	$0, %esi
44
+	
29 45
 	/* Update CHS address */
30
-			// hmmmm
46
+	andb	$0xc0, %cl
47
+	orb	$0x01, %cl
48
+	incb	%dh
49
+	cmpb	max_head, %dh
50
+	jbe	2f
51
+	xorb	%dh, %dh
52
+	incb	%ch
53
+	jnc	2f
54
+	addb	$0xc0, %cl
55
+2:
31 56
 	/* Loop until whole image is read */
32
-	subw	%ax, %bp
33
-	jne	1b
57
+	subl	%eax, load_length
58
+	ja	1b
34 59
 	ljmp	$BOOT_SEG, $start_image
35 60
 
61
+load_length:
62
+	.long	_rom_size
63
+max_sector:
64
+	.byte	0
65
+max_head:
66
+	.byte	0
67
+
36 68
 load_failed:
37 69
 	movw	$10f, %si
38 70
 	jmp	boot_error

Laden…
Abbrechen
Speichern