#include "types.h" // u8
#include "config.h" // CONFIG_*
+#include "farptr.h" // struct segoff_s
#define DISK_RET_SUCCESS 0x00
#define DISK_RET_EPARAM 0x01
u8 size;
u8 reserved;
u16 count;
- u16 offset;
- u16 segment;
+ struct segoff_s data;
u64 lba;
} PACKED;
u8 command;
};
-#define CMD_CDROM_READ 1
-#define CMD_CDEMU_READ 2
+#define CMD_RESET 0x00
+#define CMD_READ 0x02
+#define CMD_WRITE 0x03
+#define CMD_VERIFY 0x04
+#define CMD_FORMAT 0x05
+#define CMD_SEEK 0x07
+#define CMD_ISREADY 0x10
/****************************************************************
u16 spt; // # sectors / track
};
-struct ata_channel_s {
- u16 iobase1; // IO Base 1
- u16 iobase2; // IO Base 2
- u16 pci_bdf;
- u8 irq; // IRQ
-};
-
-struct ata_device_s {
- u8 type; // Detected type of ata (ata/atapi/none/unknown)
- u8 device; // Detected type of attached devices (hd/cd/none)
+struct drive_s {
+ u8 type; // Detected type of drive (ata/atapi/none)
u8 removable; // Removable device flag
u16 blksize; // block size
- u8 version; // ATA/ATAPI version
+ int cntl_id;
+ u8 floppy_type; // Type of floppy (only for floppy drives).
char model[41];
u64 sectors; // Total sectors count
};
-struct ata_s {
- // ATA channels info
- struct ata_channel_s channels[CONFIG_MAX_ATA_INTERFACES];
-
- // ATA devices info
- struct ata_device_s devices[CONFIG_MAX_ATA_DEVICES];
+#define DTYPE_NONE 0x00
+#define DTYPE_FLOPPY 0x01
+#define DTYPE_ATA 0x02
+#define DTYPE_ATAPI 0x03
+#define DTYPE_RAMDISK 0x04
+
+#define TRANSLATION_NONE 0
+#define TRANSLATION_LBA 1
+#define TRANSLATION_LARGE 2
+#define TRANSLATION_RECHS 3
+
+struct drives_s {
+ // info on each internally handled drive
+ struct drive_s drives[CONFIG_MAX_DRIVES];
+ u8 drivecount;
//
- // map between bios hd/cd id and ata channels
+ // map between bios floppy/hd/cd id and driveid index into drives[]
+ u8 floppycount;
u8 cdcount;
- u8 idmap[2][CONFIG_MAX_ATA_DEVICES];
+ u8 idmap[3][CONFIG_MAX_EXTDRIVE];
};
+#define EXTTYPE_FLOPPY 0
+#define EXTTYPE_HD 1
+#define EXTTYPE_CD 2
+
+#define EXTSTART_HD 0x80
+#define EXTSTART_CD 0xE0
+
/****************************************************************
* Function defs
****************************************************************/
-// ata.c
-extern struct ata_s ATA;
-int ata_cmd_data(struct disk_op_s *op);
-int cdrom_read(struct disk_op_s *op);
-int cdrom_read_512(struct disk_op_s *op);
-int ata_cmd_packet(int driveid, u8 *cmdbuf, u8 cmdlen
- , u32 length, void *buf_fl);
-void ata_reset(int driveid);
-void hard_drive_setup();
-void map_drive(int driveid);
+// block.c
+extern struct drives_s Drives;
+void setup_translation(int driveid);
+void map_floppy_drive(int driveid);
+void map_hd_drive(int driveid);
+void map_cd_drive(int driveid);
+int send_disk_op(struct disk_op_s *op);
+void drive_setup();
// floppy.c
-extern u8 FloppyCount;
extern struct floppy_ext_dbt_s diskette_param_table2;
-void floppy_drive_setup();
-void floppy_13(struct bregs *regs, u8 drive);
+void floppy_setup();
+void addFloppy(int floppyid, int ftype, int driver);
+int find_floppy_type(u32 size);
+int process_floppy_op(struct disk_op_s *op);
void floppy_tick();
// disk.c
-void disk_13(struct bregs *regs, u8 device);
-void disk_13XX(struct bregs *regs, u8 device);
+void disk_13(struct bregs *regs, u8 driveid);
+void disk_13XX(struct bregs *regs, u8 driveid);
+void cdemu_access(struct bregs *regs, u8 driveid, u16 command);
// cdrom.c
-void cdrom_13(struct bregs *regs, u8 device);
+void cdrom_13(struct bregs *regs, u8 driveid);
void cdemu_13(struct bregs *regs);
void cdemu_134b(struct bregs *regs);
int cdrom_boot(int cdid);
+// ramdisk.c
+void ramdisk_setup();
+int process_ramdisk_op(struct disk_op_s *op);
+
#endif // disk.h