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