瀏覽代碼

Working with multi-sector reads

tags/v0.9.3
Michael Brown 17 年之前
父節點
當前提交
a0f078d7f5
共有 1 個檔案被更改,包括 40 行新增8 行删除
  1. 40
    8
      src/arch/i386/prefix/hdprefix.S

+ 40
- 8
src/arch/i386/prefix/hdprefix.S 查看文件

@@ -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

Loading…
取消
儲存