Initial cdrom support.
[seabios.git] / src / disk.h
1 // Definitions for X86 bios disks.
2 //
3 // Copyright (C) 2008  Kevin O'Connor <kevin@koconnor.net>
4 //
5 // This file may be distributed under the terms of the GNU GPLv3 license.
6 #ifndef __DISK_H
7 #define __DISK_H
8
9 #include "ioport.h" // outb
10 #include "biosvar.h" // struct bregs
11
12 #define DISK_RET_SUCCESS       0x00
13 #define DISK_RET_EPARAM        0x01
14 #define DISK_RET_EADDRNOTFOUND 0x02
15 #define DISK_RET_EWRITEPROTECT 0x03
16 #define DISK_RET_ECHANGED      0x06
17 #define DISK_RET_EBOUNDARY     0x09
18 #define DISK_RET_EBADTRACK     0x0c
19 #define DISK_RET_ECONTROLLER   0x20
20 #define DISK_RET_ETIMEOUT      0x80
21 #define DISK_RET_ENOTLOCKED    0xb0
22 #define DISK_RET_ELOCKED       0xb1
23 #define DISK_RET_ENOTREMOVABLE 0xb2
24 #define DISK_RET_ETOOMANYLOCKS 0xb4
25 #define DISK_RET_EMEDIA        0xC0
26 #define DISK_RET_ENOTREADY     0xAA
27
28 // Bios disk structures.
29 struct int13ext_s {
30     u8  size;
31     u8  reserved;
32     u16 count;
33     u16 offset;
34     u16 segment;
35     u32 lba1;
36     u32 lba2;
37 };
38
39 #define GET_INT13EXT(regs,var)                                          \
40     GET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var)
41 #define SET_INT13EXT(regs,var,val)                                      \
42     SET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var, (val))
43
44 // Disk Physical Table definition
45 struct int13dpt_s {
46     u16 size;
47     u16 infos;
48     u32 cylinders;
49     u32 heads;
50     u32 spt;
51     u32 sector_count1;
52     u32 sector_count2;
53     u16 blksize;
54     u16 dpte_offset;
55     u16 dpte_segment;
56     u16 key;
57     u8  dpi_length;
58     u8  reserved1;
59     u16 reserved2;
60     u8  host_bus[4];
61     u8  iface_type[8];
62     u8  iface_path[8];
63     u8  device_path[8];
64     u8  reserved3;
65     u8  checksum;
66 };
67
68 #define GET_INT13DPT(regs,var)                                          \
69     GET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var)
70 #define SET_INT13DPT(regs,var,val)                                      \
71     SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val))
72
73 // Floppy "Disk Base Table"
74 struct floppy_dbt_s {
75     u8 specify1;
76     u8 specify2;
77     u8 shutoff_ticks;
78     u8 bps_code;
79     u8 sectors;
80     u8 interblock_len;
81     u8 data_len;
82     u8 gap_len;
83     u8 fill_byte;
84     u8 settle_time;
85     u8 startup_time;
86 };
87
88 struct floppy_ext_dbt_s {
89     struct floppy_dbt_s dbt;
90     // Extra fields
91     u8 max_track;
92     u8 data_rate;
93     u8 drive_type;
94 };
95
96 // floppy.c
97 void floppy_13(struct bregs *regs, u8 drive);
98 void floppy_tick();
99
100 #endif // disk.h