Переглянути джерело

Code fixed to operate correctly.

tags/v0.9.3
Michael Brown 19 роки тому
джерело
коміт
7af89ccf33
1 змінених файлів з 26 додано та 23 видалено
  1. 26
    23
      src/arch/i386/drivers/bus/bios_disks.c

+ 26
- 23
src/arch/i386/drivers/bus/bios_disks.c Переглянути файл

@@ -2,10 +2,16 @@
2 2
 
3 3
 #define CF ( 1 << 0 )
4 4
 
5
-/**************************************************************************
6
-DISK_INIT - Initialize the disk system
7
-**************************************************************************/
8
-void disk_init ( void ) {
5
+struct disk_sector {
6
+	char data[512];
7
+};
8
+
9
+/*
10
+ * Reset the disk system using INT 13,0.  Forces both hard disks and
11
+ * floppy disks to seek back to track 0.
12
+ *
13
+ */
14
+static void disk_init ( void ) {
9 15
 	REAL_EXEC ( rm_disk_init,
10 16
 		    "sti\n\t"
11 17
 		    "xorw %%ax,%%ax\n\t"
@@ -19,38 +25,35 @@ void disk_init ( void ) {
19 25
 			      "ebp", "esi", "edi" ) );
20 26
 }
21 27
 
22
-/**************************************************************************
23
-DISK_READ - Read a sector from disk
24
-**************************************************************************/
25
-unsigned int pcbios_disk_read ( int drive, int cylinder, int head, int sector,
26
-				char *fixme_buf ) {
27
-	uint16_t ax, flags, discard_c, discard_d;
28
-	segoff_t buf = SEGOFF ( fixme_buf );
29
-
30
-	/* FIXME: buf should be passed in as a segoff_t rather than a
31
-	 * char *
32
-	 */
28
+/*
29
+ * Read a single sector from a disk using INT 13,2.
30
+ *
31
+ * Returns the BIOS status code (%ah) - 0 indicates success
32
+ *
33
+ */
34
+static unsigned int pcbios_disk_read ( int drive, int cylinder, int head,
35
+				       int sector, struct disk_sector *buf ) {
36
+	uint16_t basemem_buf, status, flags;
37
+	int discard_c, discard_d;
33 38
 
39
+	basemem_buf = BASEMEM_PARAMETER_INIT ( *buf );
34 40
 	REAL_EXEC ( rm_pcbios_disk_read,
35 41
 		    "sti\n\t"
36
-		    "pushl %%ebx\n\t"	   /* Convert %ebx to %es:bx */
37
-		    "popw %%bx\n\t"
38
-		    "popw %%es\n\t"
39
-		    "movb $0x02, %%ah\n\t" /* INT 13,2 - Read disk sector */
40
-		    "movb $0x01, %%al\n\t" /* Read one sector */
42
+		    "movw $0x0201, %%ax\n\t" /* Read a single sector */
41 43
 		    "int $0x13\n\t"
42 44
 		    "pushfw\n\t"
43 45
 		    "popw %%bx\n\t"
44 46
 		    "cli\n\t",
45 47
 		    4,
46
-		    OUT_CONSTRAINTS ( "=a" ( ax ), "=b" ( flags ),
48
+		    OUT_CONSTRAINTS ( "=a" ( status ), "=b" ( flags ),
47 49
 				      "=c" ( discard_c ), "=d" ( discard_d ) ),
48 50
 		    IN_CONSTRAINTS ( "c" ( ( ( cylinder & 0xff ) << 8 ) |
49 51
 					   ( ( cylinder >> 8 ) & 0x3 ) |
50 52
 					   sector ),
51 53
 				     "d" ( ( head << 8 ) | drive ),
52
-				     "b" ( buf ) ),
54
+				     "b" ( basemem_buf ) ),
53 55
 		    CLOBBER ( "ebp", "esi", "edi" ) );
56
+	BASEMEM_PARAMETER_DONE ( *buf );
54 57
 
55
-	return ( flags & CF ) ? ax : 0;
58
+	return ( flags & CF ) ? ( status >> 8 ) : 0;
56 59
 }

Завантаження…
Відмінити
Зберегти