VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/BIOS/ata.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1/* $Id: ata.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * PC BIOS - ???
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 * --------------------------------------------------------------------
27 *
28 * This code is based on:
29 *
30 * ROM BIOS for use with Bochs/Plex86/QEMU emulation environment
31 *
32 * Copyright (C) 2002 MandrakeSoft S.A.
33 *
34 * MandrakeSoft S.A.
35 * 43, rue d'Aboukir
36 * 75002 Paris - France
37 * http://www.linux-mandrake.com/
38 * http://www.mandrakesoft.com/
39 *
40 * This library is free software; you can redistribute it and/or
41 * modify it under the terms of the GNU Lesser General Public
42 * License as published by the Free Software Foundation; either
43 * version 2 of the License, or (at your option) any later version.
44 *
45 * This library is distributed in the hope that it will be useful,
46 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
48 * Lesser General Public License for more details.
49 *
50 * You should have received a copy of the GNU Lesser General Public
51 * License along with this library; if not, write to the Free Software
52 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
53 *
54 */
55
56/*
57 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
58 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
59 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
60 * a choice of LGPL license versions is made available with the language indicating
61 * that LGPLv2 or any later version may be used, or where a choice of which version
62 * of the LGPL is applied is otherwise unspecified.
63 */
64
65#ifndef VBOX_INCLUDED_SRC_PC_BIOS_ata_h
66#define VBOX_INCLUDED_SRC_PC_BIOS_ata_h
67#ifndef RT_WITHOUT_PRAGMA_ONCE
68# pragma once
69#endif
70
71#define ATA_DATA_NO 0x00
72#define ATA_DATA_IN 0x01
73#define ATA_DATA_OUT 0x02
74
75#define ATA_IFACE_NONE 0x00
76#define ATA_IFACE_ISA 0x00
77#define ATA_IFACE_PCI 0x01
78
79#define ATA_MODE_NONE 0x00
80#define ATA_MODE_PIO16 0x00
81#if VBOX_BIOS_CPU >= 80386
82# define ATA_MODE_PIO32 0x01
83#endif
84#define ATA_MODE_ISADMA 0x02
85#define ATA_MODE_PCIDMA 0x03
86#define ATA_MODE_USEIRQ 0x10
87
88// Global defines -- ATA register and register bits.
89// command block & control block regs
90#define ATA_CB_DATA 0 // data reg in/out pio_base_addr1+0
91#define ATA_CB_ERR 1 // error in pio_base_addr1+1
92#define ATA_CB_FR 1 // feature reg out pio_base_addr1+1
93#define ATA_CB_SC 2 // sector count in/out pio_base_addr1+2
94#define ATA_CB_SN 3 // sector number in/out pio_base_addr1+3
95#define ATA_CB_CL 4 // cylinder low in/out pio_base_addr1+4
96#define ATA_CB_CH 5 // cylinder high in/out pio_base_addr1+5
97#define ATA_CB_DH 6 // device head in/out pio_base_addr1+6
98#define ATA_CB_STAT 7 // primary status in pio_base_addr1+7
99#define ATA_CB_CMD 7 // command out pio_base_addr1+7
100#define ATA_CB_ASTAT 6 // alternate status in pio_base_addr2+6
101#define ATA_CB_DC 6 // device control out pio_base_addr2+6
102#define ATA_CB_DA 7 // device address in pio_base_addr2+7
103
104#define ATA_CB_ER_ICRC 0x80 // ATA Ultra DMA bad CRC
105#define ATA_CB_ER_BBK 0x80 // ATA bad block
106#define ATA_CB_ER_UNC 0x40 // ATA uncorrected error
107#define ATA_CB_ER_MC 0x20 // ATA media change
108#define ATA_CB_ER_IDNF 0x10 // ATA id not found
109#define ATA_CB_ER_MCR 0x08 // ATA media change request
110#define ATA_CB_ER_ABRT 0x04 // ATA command aborted
111#define ATA_CB_ER_NTK0 0x02 // ATA track 0 not found
112#define ATA_CB_ER_NDAM 0x01 // ATA address mark not found
113
114#define ATA_CB_ER_P_SNSKEY 0xf0 // ATAPI sense key (mask)
115#define ATA_CB_ER_P_MCR 0x08 // ATAPI Media Change Request
116#define ATA_CB_ER_P_ABRT 0x04 // ATAPI command abort
117#define ATA_CB_ER_P_EOM 0x02 // ATAPI End of Media
118#define ATA_CB_ER_P_ILI 0x01 // ATAPI Illegal Length Indication
119
120// ATAPI Interrupt Reason bits in the Sector Count reg (CB_SC)
121#define ATA_CB_SC_P_TAG 0xf8 // ATAPI tag (mask)
122#define ATA_CB_SC_P_REL 0x04 // ATAPI release
123#define ATA_CB_SC_P_IO 0x02 // ATAPI I/O
124#define ATA_CB_SC_P_CD 0x01 // ATAPI C/D
125
126// bits 7-4 of the device/head (CB_DH) reg
127#define ATA_CB_DH_DEV0 0xa0 // select device 0
128#define ATA_CB_DH_DEV1 0xb0 // select device 1
129
130// status reg (CB_STAT and CB_ASTAT) bits
131#define ATA_CB_STAT_BSY 0x80 // busy
132#define ATA_CB_STAT_RDY 0x40 // ready
133#define ATA_CB_STAT_DF 0x20 // device fault
134#define ATA_CB_STAT_WFT 0x20 // write fault (old name)
135#define ATA_CB_STAT_SKC 0x10 // seek complete
136#define ATA_CB_STAT_SERV 0x10 // service
137#define ATA_CB_STAT_DRQ 0x08 // data request
138#define ATA_CB_STAT_CORR 0x04 // corrected
139#define ATA_CB_STAT_IDX 0x02 // index
140#define ATA_CB_STAT_ERR 0x01 // error (ATA)
141#define ATA_CB_STAT_CHK 0x01 // check (ATAPI)
142
143// device control reg (CB_DC) bits
144#define ATA_CB_DC_HD15 0x08 // bit should always be set to one
145#define ATA_CB_DC_SRST 0x04 // soft reset
146#define ATA_CB_DC_NIEN 0x02 // disable interrupts
147
148// Most mandatory and optional ATA commands (from ATA-3),
149#define ATA_CMD_CFA_ERASE_SECTORS 0xC0
150#define ATA_CMD_CFA_REQUEST_EXT_ERR_CODE 0x03
151#define ATA_CMD_CFA_TRANSLATE_SECTOR 0x87
152#define ATA_CMD_CFA_WRITE_MULTIPLE_WO_ERASE 0xCD
153#define ATA_CMD_CFA_WRITE_SECTORS_WO_ERASE 0x38
154#define ATA_CMD_CHECK_POWER_MODE1 0xE5
155#define ATA_CMD_CHECK_POWER_MODE2 0x98
156#define ATA_CMD_DEVICE_RESET 0x08
157#define ATA_CMD_EXECUTE_DEVICE_DIAGNOSTIC 0x90
158#define ATA_CMD_FLUSH_CACHE 0xE7
159#define ATA_CMD_FORMAT_TRACK 0x50
160#define ATA_CMD_IDENTIFY_DEVICE 0xEC
161#define ATA_CMD_IDENTIFY_PACKET 0xA1
162#define ATA_CMD_IDLE1 0xE3
163#define ATA_CMD_IDLE2 0x97
164#define ATA_CMD_IDLE_IMMEDIATE1 0xE1
165#define ATA_CMD_IDLE_IMMEDIATE2 0x95
166#define ATA_CMD_INITIALIZE_DRIVE_PARAMETERS 0x91
167#define ATA_CMD_INITIALIZE_DEVICE_PARAMETERS 0x91
168#define ATA_CMD_NOP 0x00
169#define ATA_CMD_PACKET 0xA0
170#define ATA_CMD_READ_BUFFER 0xE4
171#define ATA_CMD_READ_DMA 0xC8
172#define ATA_CMD_READ_DMA_QUEUED 0xC7
173#define ATA_CMD_READ_MULTIPLE 0xC4
174#define ATA_CMD_READ_SECTORS 0x20
175#define ATA_CMD_READ_SECTORS_EXT 0x24
176#define ATA_CMD_READ_MULTIPLE_EXT 0x29
177#define ATA_CMD_WRITE_MULTIPLE_EXT 0x39
178#define ATA_CMD_READ_VERIFY_SECTORS 0x40
179#define ATA_CMD_RECALIBRATE 0x10
180#define ATA_CMD_SEEK 0x70
181#define ATA_CMD_SET_FEATURES 0xEF
182#define ATA_CMD_SET_MULTIPLE_MODE 0xC6
183#define ATA_CMD_SLEEP1 0xE6
184#define ATA_CMD_SLEEP2 0x99
185#define ATA_CMD_STANDBY1 0xE2
186#define ATA_CMD_STANDBY2 0x96
187#define ATA_CMD_STANDBY_IMMEDIATE1 0xE0
188#define ATA_CMD_STANDBY_IMMEDIATE2 0x94
189#define ATA_CMD_WRITE_BUFFER 0xE8
190#define ATA_CMD_WRITE_DMA 0xCA
191#define ATA_CMD_WRITE_DMA_QUEUED 0xCC
192#define ATA_CMD_WRITE_MULTIPLE 0xC5
193#define ATA_CMD_WRITE_SECTORS 0x30
194#define ATA_CMD_WRITE_SECTORS_EXT 0x34
195#define ATA_CMD_WRITE_VERIFY 0x3C
196
197extern void ata_reset(uint16_t device);
198
199#endif /* !VBOX_INCLUDED_SRC_PC_BIOS_ata_h */
200
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use