blob: 82df0e3d6834d43fff5417b278ca75ffeb91f2e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <toxic/io.h>
int
ata_read_sector(
int lba,
int total,
void *buf)
{
int i, j;
unsigned short *ptr; /* Get 2 bytes at a time from the controller */
outb(0x1F6, (lba >> 24) | 0xE0);
outb(0x1F2, total);
outb(0x1F3, (unsigned char)(lba & 0xff));
outb(0x1F4, (unsigned char)(lba >> 8));
outb(0x1F5, (unsigned char)(lba >> 16));
outb(0x1F7, 0x20);
ptr = (unsigned short *)buf;
for (i = 0; i < total; i++) {
char c = insb(0x1F7);
/* This should be implemented in interrupts */
while (!(c & 0x08))
c = insb(0x1F7);
for (j = 0; j < 256; j++) {
*ptr = insw(0x1F0);
ptr++;
}
}
return 0;
}
|