Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/modules/BiosDisk/include/BiosDisk.hpp

Source at commit 1079 created 12 years 9 months ago.
By meklort, began implimenting Bios disk changes. Code taken from biosfn.c
1/*
2 * Copyright (c) 2011 Evan Lojewski. All rights reserved.
3 *
4 */
5#ifndef BIOSDISK_H
6#define BIOSDISK_H
7
8#include <IOKit/IOTypes.h>
9#include <Disk.hpp>
10
11
12#define super Disk
13
14/*
15 * BIOS drive information.
16 */
17struct boot_drive_info {
18struct drive_params {
19 UInt16 buf_size;
20 UInt16 info_flags;
21 UInt32 phys_cyls;
22 UInt32 phys_heads;
23 UInt32 phys_spt;
24 UInt64 phys_sectors;
25 UInt16 phys_nbps;
26 UInt16 dpte_offset;
27 UInt16 dpte_segment;
28 /*
29 UInt16 key;
30 UInt8 path_len;
31 UInt8 reserved1;
32 UInt16 reserved2;
33 UInt8 bus_type[4];
34 UInt8 interface_type[8];
35 UInt8 interface_path[8];
36 UInt8 dev_path[8];
37 UInt8 reserved3;
38 UInt8 checksum;
39 */
40} params;
41struct drive_dpte {
42 UInt16 io_port_base;
43 UInt16 control_port_base;
44 UInt8 head_flags;
45 UInt8 vendor_info;
46 UInt8 irq : 4;
47 UInt8 irq_unused : 4;
48 UInt8 block_count;
49 UInt8 dma_channel : 4;
50 UInt8 dma_type : 4;
51 UInt8 pio_type : 4;
52 UInt8 pio_unused : 4;
53 UInt16 option_flags;
54 UInt16 reserved;
55 UInt8 revision;
56 UInt8 checksum;
57} dpte;
58} __attribute__((packed));
59typedef struct boot_drive_info boot_drive_info_t;
60
61
62class BiosDisk : public Disk
63{
64public:
65 BiosDisk(const char* name);
66 ~BiosDisk();
67
68 virtual IOReturn Read(UInt64 sector, UInt64 size, UInt8* buffer);
69 virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer);
70 virtual bool isValid() { return (mValid && (mName != NULL) && (mDiskID & 0x80)); };
71
72protected:
73 UInt8 BIOSRead(UInt16 cylinder, UInt8 head, UInt8 sector, UInt8 count);
74
75 UInt8 EBIOSRead(UInt64 sector, UInt8 count);
76 UInt8 EBIOSWrite(UInt64 sector, UInt8 count);
77
78 UInt8 GetDriveInfo();
79
80private:
81 UInt8 mDiskID;
82
83 UInt8 mUsesEBIOS;
84 bool mNoEmulation;
85 bool mValid;
86
87 boot_drive_info_t mDriveInfo;
88
89};
90
91
92#endif /* BIOSDISK_H */
93

Archive Download this file

Revision: 1079