Annotation of qemu/roms/seabios/src/disk.h, revision 1.1.1.4

1.1       root        1: // Definitions for X86 bios disks.
                      2: //
                      3: // Copyright (C) 2008  Kevin O'Connor <[email protected]>
                      4: //
                      5: // This file may be distributed under the terms of the GNU LGPLv3 license.
                      6: #ifndef __DISK_H
                      7: #define __DISK_H
                      8: 
                      9: #include "types.h" // u8
                     10: #include "config.h" // CONFIG_*
                     11: #include "farptr.h" // struct segoff_s
                     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: 
                     30: /****************************************************************
                     31:  * Interface structs
                     32:  ****************************************************************/
                     33: 
                     34: // Bios disk structures.
                     35: struct int13ext_s {
                     36:     u8  size;
                     37:     u8  reserved;
                     38:     u16 count;
                     39:     struct segoff_s data;
                     40:     u64 lba;
                     41: } PACKED;
                     42: 
                     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))
                     47: 
                     48: // Disk Physical Table definition
                     49: struct int13dpt_s {
                     50:     u16 size;
                     51:     u16 infos;
                     52:     u32 cylinders;
                     53:     u32 heads;
                     54:     u32 spt;
                     55:     u64 sector_count;
                     56:     u16 blksize;
                     57:     u16 dpte_offset;
                     58:     u16 dpte_segment;
                     59:     u16 key;
                     60:     u8  dpi_length;
                     61:     u8  reserved1;
                     62:     u16 reserved2;
                     63:     u8  host_bus[4];
                     64:     u8  iface_type[8];
                     65:     u64 iface_path;
1.1.1.4 ! root       66:     union {
        !            67:         struct {
        !            68:             u64 device_path;
        !            69:             u8  reserved3;
        !            70:             u8  checksum;
        !            71:         } phoenix;
        !            72:         struct {
        !            73:             u64 device_path[2];
        !            74:             u8  reserved3;
        !            75:             u8  checksum;
        !            76:         } t13;
        !            77:     };
1.1       root       78: } PACKED;
                     79: 
                     80: #define GET_INT13DPT(regs,var)                                          \
                     81:     GET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var)
                     82: #define SET_INT13DPT(regs,var,val)                                      \
                     83:     SET_FARVAR((regs)->ds, ((struct int13dpt_s*)((regs)->si+0))->var, (val))
                     84: 
                     85: // Floppy "Disk Base Table"
                     86: struct floppy_dbt_s {
                     87:     u8 specify1;
                     88:     u8 specify2;
                     89:     u8 shutoff_ticks;
                     90:     u8 bps_code;
                     91:     u8 sectors;
                     92:     u8 interblock_len;
                     93:     u8 data_len;
                     94:     u8 gap_len;
                     95:     u8 fill_byte;
                     96:     u8 settle_time;
                     97:     u8 startup_time;
                     98: } PACKED;
                     99: 
                    100: struct floppy_ext_dbt_s {
                    101:     struct floppy_dbt_s dbt;
                    102:     // Extra fields
                    103:     u8 max_track;
                    104:     u8 data_rate;
                    105:     u8 drive_type;
                    106: } PACKED;
                    107: 
                    108: // Helper function for setting up a return code.
                    109: struct bregs;
                    110: void __disk_ret(struct bregs *regs, u32 linecode, const char *fname);
                    111: #define disk_ret(regs, code) \
                    112:     __disk_ret((regs), (code) | (__LINE__ << 8), __func__)
                    113: void __disk_ret_unimplemented(struct bregs *regs, u32 linecode
                    114:                               , const char *fname);
                    115: #define disk_ret_unimplemented(regs, code) \
                    116:     __disk_ret_unimplemented((regs), (code) | (__LINE__ << 8), __func__)
                    117: 
                    118: 
                    119: /****************************************************************
                    120:  * Master boot record
                    121:  ****************************************************************/
                    122: 
                    123: struct packed_chs_s {
                    124:     u8 heads;
                    125:     u8 sptcyl;
                    126:     u8 cyllow;
                    127: };
                    128: 
                    129: struct partition_s {
                    130:     u8 status;
                    131:     struct packed_chs_s first;
                    132:     u8 type;
                    133:     struct packed_chs_s last;
                    134:     u32 lba;
                    135:     u32 count;
                    136: } PACKED;
                    137: 
                    138: struct mbr_s {
                    139:     u8 code[440];
                    140:     // 0x01b8
                    141:     u32 diskseg;
                    142:     // 0x01bc
                    143:     u16 null;
                    144:     // 0x01be
                    145:     struct partition_s partitions[4];
                    146:     // 0x01fe
                    147:     u16 signature;
                    148: } PACKED;
                    149: 
                    150: #define MBR_SIGNATURE 0xaa55
                    151: 
                    152: 
                    153: /****************************************************************
                    154:  * Disk command request
                    155:  ****************************************************************/
                    156: 
                    157: struct disk_op_s {
                    158:     u64 lba;
                    159:     void *buf_fl;
                    160:     struct drive_s *drive_g;
                    161:     u16 count;
                    162:     u8 command;
                    163: };
                    164: 
                    165: #define CMD_RESET   0x00
                    166: #define CMD_READ    0x02
                    167: #define CMD_WRITE   0x03
                    168: #define CMD_VERIFY  0x04
                    169: #define CMD_FORMAT  0x05
                    170: #define CMD_SEEK    0x07
                    171: #define CMD_ISREADY 0x10
                    172: 
                    173: 
                    174: /****************************************************************
                    175:  * Global storage
                    176:  ****************************************************************/
                    177: 
                    178: struct chs_s {
                    179:     u16 heads;      // # heads
                    180:     u16 cylinders;  // # cylinders
                    181:     u16 spt;        // # sectors / track
                    182: };
                    183: 
                    184: struct drive_s {
1.1.1.3   root      185:     u8 type;            // Driver type (DTYPE_*)
                    186:     u8 floppy_type;     // Type of floppy (only for floppy drives).
                    187:     struct chs_s lchs;  // Logical CHS
                    188:     u64 sectors;        // Total sectors count
                    189:     u32 cntl_id;        // Unique id for a given driver type.
                    190:     u8 removable;       // Is media removable (currently unused)
                    191: 
                    192:     // Info for EDD calls
                    193:     u8 translation;     // type of translation
                    194:     u16 blksize;        // block size
                    195:     struct chs_s pchs;  // Physical CHS
1.1       root      196: };
                    197: 
                    198: #define DISK_SECTOR_SIZE  512
                    199: #define CDROM_SECTOR_SIZE 2048
                    200: 
                    201: #define DTYPE_NONE     0x00
                    202: #define DTYPE_FLOPPY   0x01
                    203: #define DTYPE_ATA      0x02
                    204: #define DTYPE_ATAPI    0x03
                    205: #define DTYPE_RAMDISK  0x04
                    206: #define DTYPE_CDEMU    0x05
1.1.1.3   root      207: #define DTYPE_USB      0x06
                    208: #define DTYPE_VIRTIO   0x07
1.1.1.4 ! root      209: #define DTYPE_AHCI     0x08
1.1.1.3   root      210: 
                    211: #define MAXDESCSIZE 80
1.1       root      212: 
                    213: #define TRANSLATION_NONE  0
                    214: #define TRANSLATION_LBA   1
                    215: #define TRANSLATION_LARGE 2
                    216: #define TRANSLATION_RECHS 3
                    217: 
                    218: #define EXTTYPE_FLOPPY 0
                    219: #define EXTTYPE_HD 1
                    220: #define EXTTYPE_CD 2
                    221: 
                    222: #define EXTSTART_HD 0x80
                    223: #define EXTSTART_CD 0xE0
                    224: 
                    225: 
                    226: /****************************************************************
                    227:  * Function defs
                    228:  ****************************************************************/
                    229: 
                    230: // block.c
1.1.1.4 ! root      231: extern u8 FloppyCount, CDCount;
1.1       root      232: struct drive_s *getDrive(u8 exttype, u8 extdriveoffset);
1.1.1.4 ! root      233: int getDriveId(u8 exttype, struct drive_s *drive_g);
1.1       root      234: void map_floppy_drive(struct drive_s *drive_g);
                    235: void map_hd_drive(struct drive_s *drive_g);
                    236: void map_cd_drive(struct drive_s *drive_g);
                    237: int process_op(struct disk_op_s *op);
                    238: int send_disk_op(struct disk_op_s *op);
                    239: 
                    240: // floppy.c
                    241: extern struct floppy_ext_dbt_s diskette_param_table2;
1.1.1.2   root      242: void floppy_setup(void);
1.1.1.4 ! root      243: struct drive_s *init_floppy(int floppyid, int ftype);
1.1       root      244: int find_floppy_type(u32 size);
                    245: int process_floppy_op(struct disk_op_s *op);
1.1.1.2   root      246: void floppy_tick(void);
1.1       root      247: 
                    248: // cdrom.c
1.1.1.3   root      249: extern struct drive_s *cdemu_drive_gf;
1.1       root      250: int process_cdemu_op(struct disk_op_s *op);
1.1.1.2   root      251: void cdemu_setup(void);
1.1       root      252: void cdemu_134b(struct bregs *regs);
1.1.1.4 ! root      253: int cdrom_boot(struct drive_s *drive_g);
1.1       root      254: 
                    255: // ramdisk.c
1.1.1.2   root      256: void ramdisk_setup(void);
1.1       root      257: int process_ramdisk_op(struct disk_op_s *op);
                    258: 
                    259: #endif // disk.h

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.