Make several functions non-inline.
[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 #include "util.h" // set_code_fail
12
13 #define DISK_RET_SUCCESS       0x00
14 #define DISK_RET_EPARAM        0x01
15 #define DISK_RET_EADDRNOTFOUND 0x02
16 #define DISK_RET_EWRITEPROTECT 0x03
17 #define DISK_RET_ECHANGED      0x06
18 #define DISK_RET_EBOUNDARY     0x09
19 #define DISK_RET_EBADTRACK     0x0c
20 #define DISK_RET_ECONTROLLER   0x20
21 #define DISK_RET_ETIMEOUT      0x80
22 #define DISK_RET_ENOTLOCKED    0xb0
23 #define DISK_RET_ELOCKED       0xb1
24 #define DISK_RET_ENOTREMOVABLE 0xb2
25 #define DISK_RET_ETOOMANYLOCKS 0xb4
26 #define DISK_RET_EMEDIA        0xC0
27 #define DISK_RET_ENOTREADY     0xAA
28
29 // Bios disk structures.
30 struct int13ext_s {
31     u8  size;
32     u8  reserved;
33     u16 count;
34     u16 offset;
35     u16 segment;
36     u32 lba1;
37     u32 lba2;
38 } PACKED;
39
40 #define GET_INT13EXT(regs,var)                                          \
41     GET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var)
42 #define SET_INT13EXT(regs,var,val)                                      \
43     SET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var, (val))
44
45 // Disk Physical Table definition
46 struct int13dpt_s {
47     u16 size;
48     u16 infos;
49     u32 cylinders;
50     u32 heads;
51     u32 spt;
52     u32 sector_count1;
53     u32 sector_count2;
54     u16 blksize;
55     u16 dpte_offset;
56     u16 dpte_segment;
57     u16 key;
58     u8  dpi_length;
59     u8  reserved1;
60     u16 reserved2;
61     u8  host_bus[4];
62     u8  iface_type[8];
63     u8  iface_path[8];
64     u8  device_path[8];
65     u8  reserved3;
66     u8  checksum;
67 } PACKED;
68
69 #define GET_INT13DPT(regs,var)                                          \
70     GET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var)
71 #define SET_INT13DPT(regs,var,val)                                      \
72     SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val))
73
74 // Floppy "Disk Base Table"
75 struct floppy_dbt_s {
76     u8 specify1;
77     u8 specify2;
78     u8 shutoff_ticks;
79     u8 bps_code;
80     u8 sectors;
81     u8 interblock_len;
82     u8 data_len;
83     u8 gap_len;
84     u8 fill_byte;
85     u8 settle_time;
86     u8 startup_time;
87 } PACKED;
88
89 struct floppy_ext_dbt_s {
90     struct floppy_dbt_s dbt;
91     // Extra fields
92     u8 max_track;
93     u8 data_rate;
94     u8 drive_type;
95 } PACKED;
96
97 // Helper function for setting up a return code.
98 void __disk_ret(const char *fname, struct bregs *regs, u8 code);
99 #define disk_ret(regs, code) \
100     __disk_ret(__func__, (regs), (code))
101
102 // floppy.c
103 extern struct floppy_ext_dbt_s diskette_param_table2;
104 void floppy_13(struct bregs *regs, u8 drive);
105 void floppy_tick();
106
107 // disk.c
108 void disk_13(struct bregs *regs, u8 device);
109 void disk_13XX(struct bregs *regs, u8 device);
110
111 // cdrom.c
112 int cdrom_read_emu(u16 device, u32 lba, u32 count, void *far_buffer);
113 void cdrom_13(struct bregs *regs, u8 device);
114 void cdemu_13(struct bregs *regs);
115 void cdemu_134b(struct bregs *regs);
116 u16 cdrom_boot();
117
118
119 #endif // disk.h