feat: asynchronized SATA IO
[lunaix-os.git] / lunaix-os / includes / hal / ahci / ahci.h
1 #ifndef __LUNAIX_AHCI_H
2 #define __LUNAIX_AHCI_H
3
4 #include "hba.h"
5
6 /*
7  * Macro naming rule:
8  *      HBA_R[xxx]
9  *          HBA Register [xxx]
10  *          e.g. HBA_RPxCLB is Register PxCLB
11  *
12  * All registers offset are 0 based index of a DWORD array
13  */
14
15 #define AHCI_HBA_CLASS 0x10601
16
17 /**
18  * @brief 初始化AHCI与HBA
19  *
20  */
21 void
22 ahci_init();
23
24 void
25 ahci_list_device();
26
27 unsigned int
28 ahci_get_port_usage();
29
30 struct hba_port*
31 ahci_get_port(unsigned int index);
32
33 void
34 ahci_parse_dev_info(struct hba_device* dev_info, uint16_t* data);
35
36 void
37 ahci_parsestr(char* str, uint16_t* reg_start, int size_word);
38
39 /**
40  * @brief Issue a HBA command (synchronized)
41  *
42  * @param port
43  * @param slot
44  * @return int
45  */
46 int
47 ahci_try_send(struct hba_port* port, int slot);
48
49 /**
50  * @brief Issue a HBA command (asynchronized)
51  *
52  * @param port
53  * @param state
54  * @param slot
55  */
56 void
57 ahci_post(struct hba_port* port, struct hba_cmd_state* state, int slot);
58
59 #endif /* __LUNAIX_AHCI_H */