XenevaOS
Loading...
Searching...
No Matches
XenevaOS
BaseHdr
ahci.h
Go to the documentation of this file.
1
2
//* BSD 2-Clause License
3
//*
4
//* Copyright (c) 2022-2023, Manas Kamal Choudhury
5
//* All rights reserved.
6
//*
7
//* Redistribution and use in source and binary forms, with or without
8
//* modification, are permitted provided that the following conditions are met:
9
//*
10
//* 1. Redistributions of source code must retain the above copyright notice, this
11
//* list of conditions and the following disclaimer.
12
//*
13
//* 2. Redistributions in binary form must reproduce the above copyright notice,
14
//* this list of conditions and the following disclaimer in the documentation
15
//* and/or other materials provided with the distribution.
16
//*
17
//* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
//* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
//* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
//* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21
//* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
//* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23
//* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24
//* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
//* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
//* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
//*
28
//**/
29
//
30
//#ifndef __AHCI_H__
31
//#define __AHCI_H__
32
//
33
//#include <stdint.h>
34
//
36
//#define PX_CMD_START 1
37
//#define PX_CMD_POD 2
38
//#define PX_CMD_SUD 4
39
//#define PX_CMD_FRE (1<<4)
40
//#define PX_CMD_FR (1<<14)
41
//#define PX_CMD_CR (1<<15)
42
//#define PX_CMD_ATAPI (1<<24)
43
//#define PX_SCTL_NODETECT 0x0
44
//#define PX_SCTL_DETECT 0x1
45
//#define PX_SCTL_NOSPEEDLIM 0x0
46
//#define PX_SCTL_PM_DISABLE (0x7 << 8)
47
//#define PX_TFD_ERR 1
48
//#define PX_TFD_DRQ (1<<3)
49
//#define PX_TFD_BUSY (1<<7)
50
//
51
//
52
//#define GHC_BOHC_OOC (1<<3)
53
//#define GHC_BOHC_OOS (1<<1)
54
//#define GHC_BOHC_SMIE 4
55
//#define GHC_BOHC_BB 0x10
56
//#define GHC_BOHC_BOS 1
57
//
58
//#define GHC_CAP2_BOH 1
59
//
60
//#define FIS_TYPE_REG_H2D 0x27
61
//#define FIS_TYPE_REG_D2H 0x34
62
//#define FIS_TYPE_DMA_ACT 0x39
63
//#define FIS_TYPE_DMA_SETUP 0x41
64
//#define FIS_TYPE_DATA 0x46
65
//#define FIS_TYPE_BIST 0x58
66
//#define FIS_TYPE_PIO_SETUP 0x5F
67
//#define FIS_TYPE_DEV_BITS 0xA1
68
//
70
//#define ATA_CMD_IDENTIFY 0xEC
71
//#define ATA_CMD_READ_DMA 0xC8
72
//#define ATA_CMD_READ_DMA_EXT 0x25
73
//#define ATA_CMD_WRITE_DMA 0xCA
74
//#define ATA_CMD_WRITE_DMA_EXT 0x35
75
//#define ATA_CMD_PACKET 0xA0
76
//
77
//#define FIS_REG_H2D_CTRL_INTERRUPT (1<<7)
78
//
79
//#define HBA_CMD_PRDT_DBC_INTERRUPT (1<<31)
80
//
81
//#define SCTL_PORT_DET_INIT 0x1
82
//#define SCTL_PORT_IPM_NOPART 0x100
83
//#define SCTL_PORT_IPM_NOSLUM 0x200
84
//#define SCTL_PORT_IPM_NODSLP 0x400
85
//#define PX_SCTL_IPM_MASK 0xf << 8
86
//#define PX_SCTL_IPM_ACTIVE 0x1 << 8
87
//#define PX_SCTL_IPM_NONE 0x3 << 8
88
//
89
//#define HBA_PX_SSTS_DET 0xfULL
90
//#define HBA_PX_SSTS_DET_INIT 1
91
//#define HBA_PX_SSTS_DET_PRESENT 3
92
//
93
//#define HBA_PX_IS_TFES (1<<30)
94
//#define HBA_PX_CMD_ICC (0xf << 28)
95
//#define HBA_PX_CMD_ICC_ACTIVE (1<<28)
96
//
97
//#pragma pack(push,1)
98
//typedef struct _hba_port_ {
99
// uint32_t clb;
100
// uint32_t clbu;
101
// uint32_t fb;
102
// uint32_t fbu;
103
// uint32_t is;
104
// uint32_t ie;
105
// uint32_t cmd;
106
// uint32_t rsv0;
107
// uint32_t tfd;
108
// uint32_t sig;
109
// uint32_t ssts;
110
// uint32_t sctl;
111
// uint32_t serr;
112
// uint32_t sact;
113
// uint32_t ci;
114
// uint32_t sntf;
115
// uint32_t fbs;
116
// uint32_t rsv1[11];
117
// uint32_t vendor[4];
118
//}HBA_PORT;
119
//#pragma pack(pop)
120
//
121
//
122
//#pragma pack(push,1)
123
//typedef struct _hba_mem_ {
124
// uint32_t cap;
125
// uint32_t ghc;
126
// uint32_t is;
127
// uint32_t pi;
128
// uint32_t vs;
129
// uint32_t ccc_ctl;
130
// uint32_t ccc_pts;
131
// uint32_t em_loc;
132
// uint32_t em_ctl;
133
// uint32_t cap2;
134
// uint32_t bohc;
135
// uint8_t rsv[0xA0 - 0x2c];
136
// uint8_t vendor[0x100 - 0xA0];
137
// HBA_PORT port[1];
138
//}HBA_MEM;
139
//#pragma pack(pop)
140
//
141
//#pragma pack(push,1)
142
//typedef struct _hba_cmd_prdt_ {
143
// uint32_t data_base_address;
144
// uint32_t dbau;
145
// uint32_t reserved;
146
// uint32_t data_byte_count : 22;
147
// uint32_t rsv1 : 9;
148
// uint32_t i : 1;
149
//}HBA_CMD_PRDT;
150
//#pragma pack(pop)
151
//
152
//#pragma pack(push,1)
153
//typedef struct _hba_cmd_tbl_ {
154
// uint8_t cmd_fis[0x40];
155
// uint8_t atapi_cmd[0x10];
156
// uint8_t reserved[0x30];
157
// HBA_CMD_PRDT prdt[1];
158
//}HBA_CMD_TABLE;
159
//#pragma pack(pop)
160
//
161
//
162
//#pragma pack(push,1)
163
//typedef struct _fis_data_ {
164
// uint8_t fis_type;
165
// uint8_t pm_port;
166
// uint8_t resv1[2];
167
// uint32_t data[1];
168
//}FIS_DATA;
169
//#pragma pack(pop)
170
//
171
//#pragma pack(push,1)
172
//
173
//typedef struct _fis_pio_setup_ {
174
// /*dword 0*/
175
// uint8_t fis_type;
176
// uint8_t ctl_byte;
177
// uint8_t status;
178
// uint8_t error;
179
// /*dword 1 */
180
// uint8_t lba0;
181
// uint8_t lba1;
182
// uint8_t lba2;
183
// uint8_t device;
184
// /*dword 2 */
185
// uint8_t lba3;
186
// uint8_t lba4;
187
// uint8_t lba5;
188
// uint8_t rsv2;
189
// /*dword 3 */
190
// uint8_t countl;
191
// uint8_t counth;
192
// uint8_t rsv3;
193
// uint8_t e_status;
194
// /* dword 4 */
195
// uint16_t tc;
196
// uint8_t rsv4[2];
197
//}FIS_PIO_SETUP;
198
//
199
//typedef struct _fis_reg_h2d_ {
200
// /*dword 0*/
201
// uint8_t fis_type;
202
// uint8_t pmport : 4;
203
// uint8_t rsv0 : 3;
204
// uint8_t c : 1;
205
//
206
// uint8_t command;
207
// uint8_t featurel;
208
//
209
// /*dword 1*/
210
// uint8_t lba0;
211
// uint8_t lba1;
212
// uint8_t lba2;
213
// uint8_t device;
214
//
215
// /* dword 2*/
216
// uint8_t lba3;
217
// uint8_t lba4;
218
// uint8_t lba5;
219
// uint8_t featureh;
220
//
221
// /* dword 3*/
222
// uint8_t countl;
223
// uint8_t counth;
224
// uint8_t icc;
225
// uint8_t control;
226
//
227
// /* dword 4*/
228
// uint8_t rsv1[4];
229
//}FIS_REG_H2D;
230
//
231
//typedef struct _fis_reg_d2h_ {
232
// /* dword 0 */
233
// uint8_t fis_type;
234
// uint8_t ctl_byte;
235
// uint8_t status;
236
// uint8_t error;
237
//
238
// /*dword 1*/
239
// uint8_t lba0;
240
// uint8_t lba1;
241
// uint8_t lba2;
242
// uint8_t device;
243
//
244
// /*dword 2*/
245
// uint8_t lba3;
246
// uint8_t lba4;
247
// uint8_t lba5;
248
// uint8_t rsv2;
249
//
250
// /*dword 3*/
251
// uint8_t countl;
252
// uint8_t counth;
253
// uint8_t rsv3[2];
254
//
255
// /* dword 4 */
256
// uint8_t rsv4[4];
257
//}FIS_REG_D2H;
258
//
259
//
260
//typedef struct _fis_dma_setup_ {
261
// uint8_t fis_type;
262
// uint8_t pm_port : 4;
263
// uint8_t rsv0 : 1;
264
// uint8_t d : 1;
265
// uint8_t i : 1;
266
// uint8_t a : 1;
267
// uint8_t rsved[2];
268
// uint64_t dma_buffer_id;
269
// uint32_t rsvd;
270
// uint32_t dma_buff_offset;
271
// uint32_t transfer_count;
272
// uint32_t resvd;
273
//}FIS_DMA_SETUP;
274
//
275
//
276
//typedef struct _hba_fis_ {
277
// FIS_DMA_SETUP ds_fis;
278
// uint8_t pad0[4];
279
// /* 0x20 */
280
// FIS_PIO_SETUP ps_fis;
281
// uint8_t pad1[12];
282
// /*0x40*/
283
// FIS_REG_D2H rfis;
284
// uint8_t pad2[4];
285
// /*0x58 */
286
// uint64_t sdbfis;
287
// /*0x60 */
288
// uint8_t ufis[64];
289
// /*0xA0*/
290
// uint8_t rsv[0x100 - 0xA0];
291
//} HBA_FIS;
292
//
293
//#pragma pack(pop)
294
//
295
//
296
//#pragma pack(push,1)
297
//typedef struct _cmd_list_hdr_ {
298
// uint8_t cfl : 5;
299
// uint8_t a : 1;
300
// uint8_t w : 1;
301
// uint8_t p : 1; //prefetchable
302
// uint8_t r : 1;
303
// uint8_t b : 1;
304
// uint8_t c : 1;
305
// uint8_t rsv0 : 1;
306
// uint8_t pmp : 4;
307
//
308
// uint16_t prdtl;
309
// uint32_t prdbc;
310
// uint32_t ctba;
311
// uint32_t ctbau;
312
// uint32_t reserved[4];
313
//}HBA_CMD_HEADER;
314
//#pragma pack(pop)
315
//
316
//enum PORT_REGISTERS {
317
// Px_CLB = 0,
318
// Px_CLBU = 4,
319
// Px_FB = 8,
320
// Px_FBU = 0xC,
321
// Px_IS = 0x10,
322
// Px_IE = 0x14,
323
// Px_CMD = 0x18,
324
// Px_TFD = 0x20,
325
// Px_SIG = 0x24,
326
// Px_SSTS = 0x28,
327
// Px_SCTL = 0x2C,
328
// Px_SERR = 0x30,
329
// Px_SACT = 0x34,
330
// Px_CI = 0x38,
331
// Px_SNTF = 0x3C,
332
// Px_FBS = 0x40,
333
// Px_DEVSLP = 0x44
334
//};
335
//
336
//
338
//* AuAHCIInitialise -- initialise the ahci interface
339
//*/
340
//extern void AuAHCIInitialise();
341
//#endif
Generated by
1.9.8