-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.h
More file actions
57 lines (53 loc) · 986 Bytes
/
disk.h
File metadata and controls
57 lines (53 loc) · 986 Bytes
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef _DISK_H_
#define _DISK_H_
#ifndef _IO_H_
#include "io.h"
#endif
#define CFLAG_SET 0x01
#define CFLAG_NOT 0x00
/* read_disk: reads sectors from floppy drive (disk 0) */
static char
read_disk(unsigned char start_sector,
unsigned char sector_count, unsigned char drive)
{
unsigned char cf, reset;
cf = 0;
__asm__ __volatile__ (
"int $0x13; \
setc %0;"
: "=r"(cf)
: "a"(0x0200 | sector_count), "b"(0x1000),
"c"(0x0000 | start_sector), "d"(0x0000 | drive)
);
if (cf) {
reset = 1;
print("Could not read the disk"
" sector.\r\n");
while (reset)
__asm__ __volatile__(
"mov $0x00, %%ah;"
"int $0x13;"
"or %%ah, %%ah;"
"mov %%ah, %0;"
: "=r"(reset)
:
);
} else {
print("Sector read.\r\n");
}
return cf;
}
static void
jump_sector(unsigned short sector)
{
__asm__ ("cli");
__asm__ __volatile__ (
"mov %%ss, %%ax;"
"mov %1, %%sp;"
"jmpw $0x0000, %1;"
:
: "a"(0x0000), "g"(sector)
);
__asm__ ("sti");
}
#endif