A Total Overhaul on the Lunaix's Virtual Memory Model (#26)
[lunaix-os.git] / lunaix-os / includes / hal / ahci / scsi.h
1 #ifndef __LUNAIX_SCSI_H
2 #define __LUNAIX_SCSI_H
3
4 #include <stdint.h>
5
6 #define SCSI_FLIP(val)                                                         \
7     ((((val)&0x000000ff) << 24) | (((val)&0x0000ff00) << 8) |                  \
8      (((val)&0x00ff0000) >> 8) | (((val)&0xff000000) >> 24))
9
10 #define SCSI_READ_CAPACITY_16 0x9e
11 #define SCSI_READ_CAPACITY_10 0x25
12 #define SCSI_READ_BLOCKS_16 0x88
13 #define SCSI_READ_BLOCKS_12 0xa8
14 #define SCSI_WRITE_BLOCKS_16 0x8a
15 #define SCSI_WRITE_BLOCKS_12 0xaa
16
17 #define SCSI_CDB16 16
18 #define SCSI_CDB12 12
19
20 struct scsi_cdb12
21 {
22     u8_t opcode;
23     u8_t misc1;
24     u32_t lba_be;
25     u32_t length;
26     u8_t misc2;
27     u8_t ctrl;
28 } __attribute__((packed));
29
30 struct scsi_cdb16
31 {
32     u8_t opcode;
33     u8_t misc1;
34     u32_t lba_be_hi;
35     u32_t lba_be_lo;
36     u32_t length;
37     u8_t misc2;
38     u8_t ctrl;
39 } __attribute__((packed));
40
41 void
42 scsi_create_packet12(struct scsi_cdb12* cdb,
43                      u8_t opcode,
44                      u32_t lba,
45                      u32_t alloc_size);
46
47 void
48 scsi_create_packet16(struct scsi_cdb16* cdb,
49                      u8_t opcode,
50                      lba_t lba,
51                      u32_t alloc_size);
52
53 void
54 scsi_submit(struct hba_device* dev, struct blkio_req* io_req);
55
56 void
57 scsi_parse_capacity(struct hba_device* device, u32_t* parameter);
58
59 #endif /* __LUNAIX_ATAPI_H */