Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / src / block.h
1 #ifndef __BLOCK_H
2 #define __BLOCK_H
3
4 #include "types.h" // u32
5
6
7 /****************************************************************
8  * Disk command request
9  ****************************************************************/
10
11 struct disk_op_s {
12     u64 lba;
13     void *buf_fl;
14     struct drive_s *drive_gf;
15     u16 count;
16     u8 command;
17 };
18
19 #define CMD_RESET   0x00
20 #define CMD_READ    0x02
21 #define CMD_WRITE   0x03
22 #define CMD_VERIFY  0x04
23 #define CMD_FORMAT  0x05
24 #define CMD_SEEK    0x07
25 #define CMD_ISREADY 0x10
26
27
28 /****************************************************************
29  * Global storage
30  ****************************************************************/
31
32 struct chs_s {
33     u16 head;
34     u16 cylinder;
35     u16 sector;
36     u16 pad;
37 };
38
39 struct drive_s {
40     u8 type;            // Driver type (DTYPE_*)
41     u8 floppy_type;     // Type of floppy (only for floppy drives).
42     struct chs_s lchs;  // Logical CHS
43     u64 sectors;        // Total sectors count
44     u32 cntl_id;        // Unique id for a given driver type.
45     u8 removable;       // Is media removable (currently unused)
46
47     // Info for EDD calls
48     u8 translation;     // type of translation
49     u16 blksize;        // block size
50     struct chs_s pchs;  // Physical CHS
51 };
52
53 #define DISK_SECTOR_SIZE  512
54 #define CDROM_SECTOR_SIZE 2048
55
56 #define DTYPE_NONE         0x00
57 #define DTYPE_FLOPPY       0x10
58 #define DTYPE_ATA          0x20
59 #define DTYPE_ATA_ATAPI    0x21
60 #define DTYPE_RAMDISK      0x30
61 #define DTYPE_CDEMU        0x40
62 #define DTYPE_AHCI         0x50
63 #define DTYPE_AHCI_ATAPI   0x51
64 #define DTYPE_VIRTIO_SCSI  0x60
65 #define DTYPE_VIRTIO_BLK   0x61
66 #define DTYPE_USB          0x70
67 #define DTYPE_USB_32       0x71
68 #define DTYPE_UAS          0x72
69 #define DTYPE_UAS_32       0x73
70 #define DTYPE_LSI_SCSI     0x80
71 #define DTYPE_ESP_SCSI     0x81
72 #define DTYPE_MEGASAS      0x82
73 #define DTYPE_PVSCSI       0x83
74 #define DTYPE_SDCARD       0x90
75
76 #define MAXDESCSIZE 80
77
78 #define TRANSLATION_NONE  0
79 #define TRANSLATION_LBA   1
80 #define TRANSLATION_LARGE 2
81 #define TRANSLATION_RECHS 3
82
83 #define EXTTYPE_FLOPPY 0
84 #define EXTTYPE_HD 1
85 #define EXTTYPE_CD 2
86
87 #define EXTSTART_HD 0x80
88 #define EXTSTART_CD 0xE0
89
90
91 /****************************************************************
92  * Function defs
93  ****************************************************************/
94
95 // block.c
96 extern u8 FloppyCount, CDCount;
97 extern u8 *bounce_buf_fl;
98 struct drive_s *getDrive(u8 exttype, u8 extdriveoffset);
99 int getDriveId(u8 exttype, struct drive_s *drive);
100 void map_floppy_drive(struct drive_s *drive);
101 void map_hd_drive(struct drive_s *drive);
102 void map_cd_drive(struct drive_s *drive);
103 struct int13dpt_s;
104 int fill_edd(u16 seg, struct int13dpt_s *param_far, struct drive_s *drive_gf);
105 int process_op(struct disk_op_s *op);
106 int send_disk_op(struct disk_op_s *op);
107 int create_bounce_buf(void);
108
109 #endif // block.h