Browse Source

Working with multi-sector reads

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
a0f078d7f5
1 changed files with 40 additions and 8 deletions
  1. 40
    8
      src/arch/i386/prefix/hdprefix.S

+ 40
- 8
src/arch/i386/prefix/hdprefix.S View File

10
 #include "bootpart.S"
10
 #include "bootpart.S"
11
 
11
 
12
 load_image:
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
 	call	*read_sectors
31
 	call	*read_sectors
19
 	jc	load_failed
32
 	jc	load_failed
33
+	
20
 	/* Update %es */
34
 	/* Update %es */
21
 	movw	%es, %bx
35
 	movw	%es, %bx
22
 	shll	$5, %eax
36
 	shll	$5, %eax
23
 	addw	%ax, %bx
37
 	addw	%ax, %bx
24
 	movw	%bx, %es
38
 	movw	%bx, %es
25
 	shrl	$5, %eax
39
 	shrl	$5, %eax
40
+	
26
 	/* Update LBA address */
41
 	/* Update LBA address */
27
 	addl	%eax, %edi
42
 	addl	%eax, %edi
28
 	adcl	$0, %esi
43
 	adcl	$0, %esi
44
+	
29
 	/* Update CHS address */
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
 	/* Loop until whole image is read */
56
 	/* Loop until whole image is read */
32
-	subw	%ax, %bp
33
-	jne	1b
57
+	subl	%eax, load_length
58
+	ja	1b
34
 	ljmp	$BOOT_SEG, $start_image
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
 load_failed:
68
 load_failed:
37
 	movw	$10f, %si
69
 	movw	$10f, %si
38
 	jmp	boot_error
70
 	jmp	boot_error

Loading…
Cancel
Save