blob: a82857e40d35f76ed4d84acde6eb68f7715fd9b4 [file] [log] [blame]
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05001// 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.
Kevin O'Connor786502d2008-02-27 10:41:41 -05006#ifndef __DISK_H
7#define __DISK_H
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05008
9#include "ioport.h" // outb
Kevin O'Connor786502d2008-02-27 10:41:41 -050010#include "biosvar.h" // struct bregs
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050011
Kevin O'Connore43df9e2008-03-01 22:16:32 -050012#define DISK_RET_SUCCESS 0x00
13#define DISK_RET_EPARAM 0x01
14#define DISK_RET_ECHANGED 0x06
15#define DISK_RET_EBOUNDARY 0x09
16#define DISK_RET_EBADTRACK 0x0c
17#define DISK_RET_ECONTROLLER 0x20
18#define DISK_RET_ETIMEOUT 0x80
19#define DISK_RET_ENOTREMOVABLE 0xb2
20#define DISK_RET_EMEDIA 0xC0
21#define DISK_RET_ENOTREADY 0xAA
22
23// Bios disk structures.
24struct int13ext_s {
25 u8 size;
26 u8 reserved;
27 u16 count;
28 u16 offset;
29 u16 segment;
30 u32 lba1;
31 u32 lba2;
32};
33
34#define GET_INT13EXT(regs,var) \
35 GET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var)
36#define SET_INT13EXT(regs,var,val) \
37 SET_FARVAR((regs)->ds, ((struct int13ext_s*)((regs)->si+0))->var, (val))
38
39// Disk Physical Table definition
40struct int13dpt_s {
41 u16 size;
42 u16 infos;
43 u32 cylinders;
44 u32 heads;
45 u32 spt;
46 u32 sector_count1;
47 u32 sector_count2;
48 u16 blksize;
49 u16 dpte_offset;
50 u16 dpte_segment;
51 u16 key;
52 u8 dpi_length;
53 u8 reserved1;
54 u16 reserved2;
55 u8 host_bus[4];
56 u8 iface_type[8];
57 u8 iface_path[8];
58 u8 device_path[8];
59 u8 reserved3;
60 u8 checksum;
61};
62
63#define GET_INT13DPT(regs,var) \
64 GET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var)
65#define SET_INT13DPT(regs,var,val) \
66 SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val))
67
Kevin O'Connor44c631d2008-03-02 11:24:36 -050068// Floppy "Disk Base Table"
69struct floppy_dbt_s {
70 u8 specify1;
71 u8 specify2;
72 u8 shutoff_ticks;
73 u8 bps_code;
74 u8 sectors;
75 u8 interblock_len;
76 u8 data_len;
77 u8 gap_len;
78 u8 fill_byte;
79 u8 settle_time;
80 u8 startup_time;
81};
82
83struct floppy_ext_dbt_s {
84 struct floppy_dbt_s dbt;
85 // Extra fields
86 u8 max_track;
87 u8 data_rate;
88 u8 drive_type;
89};
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050090
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050091// floppy.c
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050092void floppy_13(struct bregs *regs, u8 drive);
93void floppy_tick();
Kevin O'Connor786502d2008-02-27 10:41:41 -050094
95#endif // disk.h