2 * Copyright (C) 2002 MandrakeSoft S.A.
7 * http://www.linux-mandrake.com/
8 * http://www.mandrakesoft.com/
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Major modifications made for the V3VEE project
26 * The V3VEE Project is a joint project between Northwestern University
27 * and the University of New Mexico. You can find out more at
28 * http://www.v3vee.org
30 * Copyright (c) 2008, Zheng Cui <cuizheng@cs.unm.edu>
31 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
32 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
33 * All rights reserved for original changes
42 #include <palacios/vmm_types.h>
46 typedef sint32_t ssize_t;
47 typedef unsigned int rd_bool;
48 typedef uchar_t Bit8u;
49 typedef ushort_t Bit16u;
50 typedef uint32_t Bit32u;
51 typedef uint64_t Bit64u;
55 #define MAX_ATA_CHANNEL 4
60 SENSE_ILLEGAL_REQUEST = 5,
61 SENSE_UNIT_ATTENTION = 6
65 ASC_INV_FIELD_IN_CMD_PACKET = 0x24,
66 ASC_MEDIUM_NOT_PRESENT = 0x3a,
67 ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39,
68 ASC_LOGICAL_BLOCK_OOR = 0x21
82 struct interrupt_reason_t {
90 struct controller_status {
94 rd_bool seek_complete;
96 rd_bool corrected_data;
98 unsigned int index_pulse_count;
106 struct sense_info_t {
127 struct error_recovery_t {
128 unsigned char data[8];
135 struct cdrom_ops * cd;
139 int remaining_blocks;
141 struct currentStruct {
142 struct error_recovery_t error_recovery;
150 int total_bytes_remaining;
154 typedef enum { IDE_NONE, IDE_DISK, IDE_CDROM } device_type_t;
156 struct controller_t {
157 struct controller_status status;
158 Bit8u error_register;
163 struct interrupt_reason_t interrupt_reason;
177 Bit8u current_command;
178 Bit8u sectors_per_block;
182 rd_bool reset; // 0=normal, 1=reset controller
183 rd_bool disable_irq; // 0=allow irq, 1=disable irq
186 Bit8u reset_in_progress;
194 device_image_t hard_drive;
195 device_type_t device_type;
196 // 512 byte buffer for ID drive command
197 // These words are stored in native word endian format, as
198 // they are fetched and returned via a return(), so
199 // there's no need to keep them in x86 endian format.
200 Bit16u id_drive[256];
202 struct controller_t controller;
203 struct cdrom_t cdrom;
204 struct sense_info_t sense;
205 struct atapi_t atapi;
215 // For each ATA channel we should have one controller struct
216 // and an array of two drive structs
218 struct drive_t drives[2];
219 unsigned drive_select;
229 struct channel_t channels[MAX_ATA_CHANNEL];
240 #endif // ! __V3VEE__
248 // Open a image. Returns non-negative if successful.
249 //int open (const char* pathname);
251 // Open an image with specific flags. Returns non-negative if successful.
252 int rd_open (const char* pathname, int flags);
257 // Position ourselves. Return the resulting offset from the
258 // beginning of the file.
259 off_t rd_lseek (off_t offset, int whence);
261 // Read count bytes to the buffer buf. Return the number of
262 // bytes read (count).
263 ssize_t rd_read (void* buf, size_t count);
265 // Write count bytes from buf. Return the number of bytes
267 ssize_t rd_write (const void* buf, size_t count);