Przeglądaj źródła

Extracted from firmware/pcbios/bios.c

tags/v0.9.3
Michael Brown 19 lat temu
rodzic
commit
400fd74897
1 zmienionych plików z 56 dodań i 0 usunięć
  1. 56
    0
      src/arch/i386/drivers/bus/bios_disks.c

+ 56
- 0
src/arch/i386/drivers/bus/bios_disks.c Wyświetl plik

@@ -0,0 +1,56 @@
1
+#include "realmode.h"
2
+
3
+#define CF ( 1 << 0 )
4
+
5
+/**************************************************************************
6
+DISK_INIT - Initialize the disk system
7
+**************************************************************************/
8
+void disk_init ( void ) {
9
+	REAL_EXEC ( rm_disk_init,
10
+		    "sti\n\t"
11
+		    "xorw %%ax,%%ax\n\t"
12
+		    "movb $0x80,%%dl\n\t"
13
+		    "int $0x13\n\t"
14
+		    "cli\n\t",
15
+		    0,
16
+		    OUT_CONSTRAINTS (),
17
+		    IN_CONSTRAINTS (),
18
+   		    CLOBBER ( "eax", "ebx", "ecx", "edx",
19
+			      "ebp", "esi", "edi" ) );
20
+}
21
+
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
+	 */
33
+
34
+	REAL_EXEC ( rm_pcbios_disk_read,
35
+		    "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 */
41
+		    "int $0x13\n\t"
42
+		    "pushfw\n\t"
43
+		    "popw %%bx\n\t"
44
+		    "cli\n\t",
45
+		    4,
46
+		    OUT_CONSTRAINTS ( "=a" ( ax ), "=b" ( flags ),
47
+				      "=c" ( discard_c ), "=d" ( discard_d ) ),
48
+		    IN_CONSTRAINTS ( "c" ( ( ( cylinder & 0xff ) << 8 ) |
49
+					   ( ( cylinder >> 8 ) & 0x3 ) |
50
+					   sector ),
51
+				     "d" ( ( head << 8 ) | drive ),
52
+				     "b" ( buf ) ),
53
+		    CLOBBER ( "ebp", "esi", "edi" ) );
54
+
55
+	return ( flags & CF ) ? ax : 0;
56
+}

Ładowanie…
Anuluj
Zapisz