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

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;
                     66:     u64 device_path;
                     67:     u8  reserved3;
                     68:     u8  checksum;
                     69: } PACKED;
                     70: 
                     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))
                     75: 
                     76: // Floppy "Disk Base Table"
                     77: struct floppy_dbt_s {
                     78:     u8 specify1;
                     79:     u8 specify2;
                     80:     u8 shutoff_ticks;
                     81:     u8 bps_code;
                     82:     u8 sectors;
                     83:     u8 interblock_len;
                     84:     u8 data_len;
                     85:     u8 gap_len;
                     86:     u8 fill_byte;
                     87:     u8 settle_time;
                     88:     u8 startup_time;
                     89: } PACKED;
                     90: 
                     91: struct floppy_ext_dbt_s {
                     92:     struct floppy_dbt_s dbt;
                     93:     // Extra fields
                     94:     u8 max_track;
                     95:     u8 data_rate;
                     96:     u8 drive_type;
                     97: } PACKED;
                     98: 
                     99: // Helper function for setting up a return code.
                    100: struct bregs;
                    101: void __disk_ret(struct bregs *regs, u32 linecode, const char *fname);
                    102: #define disk_ret(regs, code) \
                    103:     __disk_ret((regs), (code) | (__LINE__ << 8), __func__)
                    104: void __disk_ret_unimplemented(struct bregs *regs, u32 linecode
                    105:                               , const char *fname);
                    106: #define disk_ret_unimplemented(regs, code) \
                    107:     __disk_ret_unimplemented((regs), (code) | (__LINE__ << 8), __func__)
                    108: 
                    109: 
                    110: /****************************************************************
                    111:  * Master boot record
                    112:  ****************************************************************/
                    113: 
                    114: struct packed_chs_s {
                    115:     u8 heads;
                    116:     u8 sptcyl;
                    117:     u8 cyllow;
                    118: };
                    119: 
                    120: struct partition_s {
                    121:     u8 status;
                    122:     struct packed_chs_s first;
                    123:     u8 type;
                    124:     struct packed_chs_s last;
                    125:     u32 lba;
                    126:     u32 count;
                    127: } PACKED;
                    128: 
                    129: struct mbr_s {
                    130:     u8 code[440];
                    131:     // 0x01b8
                    132:     u32 diskseg;
                    133:     // 0x01bc
                    134:     u16 null;
                    135:     // 0x01be
                    136:     struct partition_s partitions[4];
                    137:     // 0x01fe
                    138:     u16 signature;
                    139: } PACKED;
                    140: 
                    141: #define MBR_SIGNATURE 0xaa55
                    142: 
                    143: 
                    144: /****************************************************************
                    145:  * Disk command request
                    146:  ****************************************************************/
                    147: 
                    148: struct disk_op_s {
                    149:     u64 lba;
                    150:     void *buf_fl;
                    151:     struct drive_s *drive_g;
                    152:     u16 count;
                    153:     u8 command;
                    154: };
                    155: 
                    156: #define CMD_RESET   0x00
                    157: #define CMD_READ    0x02
                    158: #define CMD_WRITE   0x03
                    159: #define CMD_VERIFY  0x04
                    160: #define CMD_FORMAT  0x05
                    161: #define CMD_SEEK    0x07
                    162: #define CMD_ISREADY 0x10
                    163: 
                    164: 
                    165: /****************************************************************
                    166:  * Global storage
                    167:  ****************************************************************/
                    168: 
                    169: struct chs_s {
                    170:     u16 heads;      // # heads
                    171:     u16 cylinders;  // # cylinders
                    172:     u16 spt;        // # sectors / track
                    173: };
                    174: 
                    175: struct drive_s {
1.1.1.3 ! root      176:     u8 type;            // Driver type (DTYPE_*)
        !           177:     u8 floppy_type;     // Type of floppy (only for floppy drives).
        !           178:     struct chs_s lchs;  // Logical CHS
        !           179:     u64 sectors;        // Total sectors count
        !           180:     char *desc;         // Drive description (only available during POST)
        !           181:     u32 cntl_id;        // Unique id for a given driver type.
        !           182:     u8 removable;       // Is media removable (currently unused)
        !           183: 
        !           184:     // Info for EDD calls
        !           185:     u8 translation;     // type of translation
        !           186:     u16 blksize;        // block size
        !           187:     struct chs_s pchs;  // Physical CHS
1.1       root      188: };
                    189: 
                    190: #define DISK_SECTOR_SIZE  512
                    191: #define CDROM_SECTOR_SIZE 2048
                    192: 
                    193: #define DTYPE_NONE     0x00
                    194: #define DTYPE_FLOPPY   0x01
                    195: #define DTYPE_ATA      0x02
                    196: #define DTYPE_ATAPI    0x03
                    197: #define DTYPE_RAMDISK  0x04
                    198: #define DTYPE_CDEMU    0x05
1.1.1.3 ! root      199: #define DTYPE_USB      0x06
        !           200: #define DTYPE_VIRTIO   0x07
        !           201: 
        !           202: #define MAXDESCSIZE 80
1.1       root      203: 
                    204: #define TRANSLATION_NONE  0
                    205: #define TRANSLATION_LBA   1
                    206: #define TRANSLATION_LARGE 2
                    207: #define TRANSLATION_RECHS 3
                    208: 
                    209: struct drives_s {
1.1.1.3 ! root      210:     // map between bios floppy/hd/cd id and drive_s struct
1.1       root      211:     u8 floppycount;
                    212:     u8 cdcount;
1.1.1.3 ! root      213:     struct drive_s *idmap[3][CONFIG_MAX_EXTDRIVE];
1.1       root      214: };
                    215: 
                    216: #define EXTTYPE_FLOPPY 0
                    217: #define EXTTYPE_HD 1
                    218: #define EXTTYPE_CD 2
                    219: 
                    220: #define EXTSTART_HD 0x80
                    221: #define EXTSTART_CD 0xE0
                    222: 
                    223: 
                    224: /****************************************************************
                    225:  * Function defs
                    226:  ****************************************************************/
                    227: 
                    228: // block.c
                    229: extern struct drives_s Drives;
                    230: struct drive_s *getDrive(u8 exttype, u8 extdriveoffset);
                    231: void setup_translation(struct drive_s *drive_g);
                    232: void map_floppy_drive(struct drive_s *drive_g);
                    233: void map_hd_drive(struct drive_s *drive_g);
                    234: void map_cd_drive(struct drive_s *drive_g);
                    235: int process_op(struct disk_op_s *op);
                    236: int send_disk_op(struct disk_op_s *op);
1.1.1.2   root      237: void drive_setup(void);
1.1       root      238: 
                    239: // floppy.c
                    240: extern struct floppy_ext_dbt_s diskette_param_table2;
1.1.1.2   root      241: void floppy_setup(void);
1.1       root      242: struct drive_s *addFloppy(int floppyid, int ftype, int driver);
                    243: int find_floppy_type(u32 size);
                    244: int process_floppy_op(struct disk_op_s *op);
1.1.1.2   root      245: void floppy_tick(void);
1.1       root      246: 
                    247: // cdrom.c
1.1.1.3 ! root      248: extern struct drive_s *cdemu_drive_gf;
1.1       root      249: int process_cdemu_op(struct disk_op_s *op);
1.1.1.2   root      250: void cdemu_setup(void);
1.1       root      251: void cdemu_134b(struct bregs *regs);
                    252: int cdrom_boot(int cdid);
                    253: 
                    254: // ramdisk.c
1.1.1.2   root      255: void ramdisk_setup(void);
1.1       root      256: int process_ramdisk_op(struct disk_op_s *op);
                    257: 
                    258: #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.