Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


added header files
[palacios.git] / palacios / include / devices / ide.h
1 #ifndef __IDE_H__
2 #define __IDE_H__
3
4
5 #ifdef __V3VEE__
6 #include <palacios/vmm_types.h>
7
8 #ifdef __V3_32BIT__
9 typedef long off_t;
10 typedef sint32_t ssize_t;
11 typedef unsigned int rd_bool;
12 typedef uchar_t Bit8u;
13 typedef ushort_t Bit16u;
14 typedef uint32_t Bit32u;
15 typedef uint64_t Bit64u;
16 #endif
17
18
19 typedef enum _sense {
20       SENSE_NONE = 0, 
21       SENSE_NOT_READY = 2, 
22       SENSE_ILLEGAL_REQUEST = 5,
23       SENSE_UNIT_ATTENTION = 6
24 } sense_t ;
25
26 typedef enum _asc {
27       ASC_INV_FIELD_IN_CMD_PACKET = 0x24,
28       ASC_MEDIUM_NOT_PRESENT = 0x3a,
29       ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39,
30       ASC_LOGICAL_BLOCK_OOR = 0x21
31 } asc_t ;
32
33
34
35 typedef struct  {
36   unsigned cylinders;
37   unsigned heads;
38   unsigned sectors;
39 } device_image_t;
40
41
42
43
44 struct interrupt_reason_t {
45   unsigned  c_d : 1; 
46   unsigned  i_o : 1; 
47   unsigned  rel : 1; 
48   unsigned  tag : 5; 
49 };
50
51
52 struct controller_status {
53   rd_bool busy;
54   rd_bool drive_ready;
55   rd_bool write_fault;
56   rd_bool seek_complete;
57   rd_bool drq;
58   rd_bool corrected_data;
59   rd_bool index_pulse;
60   unsigned int index_pulse_count;
61   rd_bool err;
62 };
63
64
65
66
67
68 struct  sense_info_t {
69   sense_t sense_key;
70
71   struct  {
72     Bit8u arr[4];
73   } information;
74
75   struct  {
76     Bit8u arr[4];
77   } specific_inf;
78
79   struct  {
80     Bit8u arr[3];
81   } key_spec;
82
83   Bit8u fruc;
84   Bit8u asc;
85   Bit8u ascq;
86 };
87
88
89 struct  error_recovery_t {
90   unsigned char data[8];
91 };
92
93 struct  cdrom_t {
94   rd_bool ready;
95   rd_bool locked;
96
97   struct cdrom_interface * cd;
98
99   uint32_t capacity;
100   int next_lba;
101   int remaining_blocks;
102
103   struct  currentStruct {
104     struct error_recovery_t error_recovery;
105   } current;
106
107 };
108
109 struct  atapi_t {
110   uint8_t command;
111   int drq_bytes;
112   int total_bytes_remaining;
113 };
114
115
116 typedef enum { IDE_NONE, IDE_DISK, IDE_CDROM } device_type_t;
117
118 struct controller_t  {
119   struct controller_status status;
120   Bit8u    error_register;
121   Bit8u    head_no;
122
123   union {
124     Bit8u    sector_count;
125     struct interrupt_reason_t interrupt_reason;
126   };
127
128
129   Bit8u    sector_no;
130
131   union  {
132     Bit16u   cylinder_no;
133     Bit16u   byte_count;
134   };
135
136   Bit8u    buffer[2048]; 
137   Bit32u   buffer_index;
138   Bit32u   drq_index;
139   Bit8u    current_command;
140   Bit8u    sectors_per_block;
141   Bit8u    lba_mode;
142
143   struct  {
144     rd_bool reset;       // 0=normal, 1=reset controller
145     rd_bool disable_irq;     // 0=allow irq, 1=disable irq
146   } control;
147
148   Bit8u    reset_in_progress;
149   Bit8u    features;
150 };
151
152
153
154
155 struct  drive_t {
156   device_image_t  hard_drive;
157   device_type_t device_type;
158   // 512 byte buffer for ID drive command
159   // These words are stored in native word endian format, as
160   // they are fetched and returned via a return(), so
161   // there's no need to keep them in x86 endian format.
162   Bit16u id_drive[256];
163   
164   struct controller_t controller;
165   struct cdrom_t cdrom;
166   struct sense_info_t sense;
167   struct atapi_t atapi;
168   
169   Bit8u model_no[41];
170 };
171
172
173 // FIXME:
174 // For each ATA channel we should have one controller struct
175 // and an array of two drive structs
176 struct  channel_t {
177   struct drive_t drives[2];
178   unsigned drive_select;
179   
180   Bit16u ioaddr1;
181   Bit16u ioaddr2;
182   Bit8u  irq;
183 };
184
185
186
187
188
189 struct ramdisk_t;
190
191
192
193
194
195
196 #endif // ! __V3VEE__
197
198
199 #endif
200