1/*
2 * Copyright (c) 2011 ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef _AHCI_SATA_FIS_H
11#define _AHCI_SATA_FIS_H
12
13#define SATA_FIS_TYPE_H2D	0x27 // Register FIS - Host to Device
14#define SATA_FIS_TYPE_D2H	0x34 // Register FIS - Device to Host
15#define SATA_FIS_TYPE_DMAA	0x39 // DMA Activate FIS - Device to Host
16#define SATA_FIS_TYPE_DMAS	0x41 // DMA Setup FIS - Bi-directional
17#define SATA_FIS_TYPE_DATA	0x46 // Data FIS - Bi-directional
18#define SATA_FIS_TYPE_BIST	0x58 // BIST Activate FIS - Bi-directional
19#define SATA_FIS_TYPE_PIO	0x5F // PIO Setup FIS - Device to Host
20#define SATA_FIS_TYPE_SDB	0xA1 // Set Device Bits FIS - Device to Host
21
22struct sata_fis_reg_h2d {
23	unsigned char type;
24	unsigned char specialstuff;
25	unsigned char command;
26	unsigned char feature;
27
28	unsigned char lba0;
29	unsigned char lba1;
30	unsigned char lba2;
31	unsigned char device;
32
33	unsigned char lba3;
34	unsigned char lba4;
35	unsigned char lba5;
36	unsigned char featureh;
37
38	unsigned char countl;
39	unsigned char counth;
40	unsigned char icc;
41	unsigned char control;
42
43	unsigned char reserved[4];
44};
45
46struct sata_fis_reg_d2h {
47	unsigned char type;
48	unsigned char specialstuff;
49	unsigned char status;
50	unsigned char error;
51
52	unsigned char lba0;
53	unsigned char lba1;
54	unsigned char lba2;
55	unsigned char device;
56
57	unsigned char lba3;
58	unsigned char lba4;
59	unsigned char lba5;
60	unsigned char reserved;
61
62	unsigned char countl;
63	unsigned char counth;
64	unsigned char reserved2[2];
65
66	unsigned char reserved3[4];
67};
68
69errval_t sata_alloc_h2d_register_fis(void **fis, size_t *fis_size);
70
71errval_t sata_set_command(void *fis, uint8_t command);
72errval_t sata_set_feature(void *fis, uint8_t feature);
73errval_t sata_set_lba28(void *fis, uint32_t lba);
74errval_t sata_set_lba48(void *fis, uint64_t lba);
75errval_t sata_set_count(void *fis, uint16_t count);
76
77#endif // _AHCI_SATA_FIS_H
78