1 // Definitions for X86 bios disks.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU GPLv3 license.
9 #include "types.h" // u8
10 #include "config.h" // CONFIG_*
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
29 /****************************************************************
31 ****************************************************************/
33 // Bios disk structures.
43 #define GET_INT13EXT(regs,var) \
44 GET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var)
45 #define SET_INT13EXT(regs,var,val) \
46 SET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var, (val))
48 // Disk Physical Table definition
71 #define GET_INT13DPT(regs,var) \
72 GET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var)
73 #define SET_INT13DPT(regs,var,val) \
74 SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val))
76 // Floppy "Disk Base Table"
91 struct floppy_ext_dbt_s {
92 struct floppy_dbt_s dbt;
99 // Helper function for setting up a return code.
101 void __disk_ret(const char *fname, int lineno, struct bregs *regs, u8 code);
102 #define disk_ret(regs, code) \
103 __disk_ret(__func__, __LINE__, (regs), (code))
106 /****************************************************************
108 ****************************************************************/
111 u16 heads; // # heads
112 u16 cylinders; // # cylinders
113 u16 spt; // # sectors / track
116 struct ata_channel_s {
117 u16 iobase1; // IO Base 1
118 u16 iobase2; // IO Base 2
123 struct ata_device_s {
124 u8 type; // Detected type of ata (ata/atapi/none/unknown)
125 u8 device; // Detected type of attached devices (hd/cd/none)
126 u8 removable; // Removable device flag
127 u8 mode; // transfer mode : PIO 16/32 bits - IRQ - ISADMA - PCIDMA
128 u16 blksize; // block size
130 u8 translation; // type of translation
131 struct chs_s lchs; // Logical CHS
132 struct chs_s pchs; // Physical CHS
134 u64 sectors; // Total sectors count
139 struct ata_channel_s channels[CONFIG_MAX_ATA_INTERFACES];
142 struct ata_device_s devices[CONFIG_MAX_ATA_DEVICES];
144 // map between bios hd/cd id and ata channels
146 u8 idmap[2][CONFIG_MAX_ATA_DEVICES];
150 /****************************************************************
152 ****************************************************************/
155 extern struct ata_s ATA;
158 extern struct floppy_ext_dbt_s diskette_param_table2;
159 void floppy_drive_setup();
160 void floppy_13(struct bregs *regs, u8 drive);
164 void disk_13(struct bregs *regs, u8 device);
165 void disk_13XX(struct bregs *regs, u8 device);
168 int cdrom_read_emu(u16 device, u32 lba, u32 count, void *far_buffer);
169 void cdrom_13(struct bregs *regs, u8 device);
170 void cdemu_13(struct bregs *regs);
171 void cdemu_134b(struct bregs *regs);