refactor: one more step towards arch-agnostic design
[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 struct ahci_driver
18 {
19     struct llist_header ahci_drvs;
20     struct ahci_hba hba;
21     int id;
22 };
23
24 void
25 ahci_parse_dev_info(struct hba_device* dev_info, u16_t* data);
26
27 void
28 ahci_parsestr(char* str, u16_t* reg_start, int size_word);
29
30 /**
31  * @brief Issue a HBA command (synchronized)
32  *
33  * @param port
34  * @param slot
35  * @return int
36  */
37 int
38 ahci_try_send(struct hba_port* port, int slot);
39
40 /**
41  * @brief Issue a HBA command (asynchronized)
42  *
43  * @param port
44  * @param state
45  * @param slot
46  */
47 void
48 ahci_post(struct hba_port* port, struct hba_cmd_state* state, int slot);
49
50 #endif /* __LUNAIX_AHCI_H */