refactor: make pci device driver loading passive, pci bus scanner will not load them...
[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 #include <lunaix/isrm.h>
6
7 /*
8  * Macro naming rule:
9  *      HBA_R[xxx]
10  *          HBA Register [xxx]
11  *          e.g. HBA_RPxCLB is Register PxCLB
12  *
13  * All registers offset are 0 based index of a DWORD array
14  */
15
16 #define AHCI_HBA_CLASS 0x10601
17
18 struct ahci_driver
19 {
20     struct llist_header ahci_drvs;
21     struct ahci_hba hba;
22     int id;
23 };
24
25 struct ahci_driver_param
26 {
27     ptr_t mmio_base;
28     size_t mmio_size;
29     int ahci_iv;
30 };
31
32 void
33 ahci_parse_dev_info(struct hba_device* dev_info, u16_t* data);
34
35 void
36 ahci_parsestr(char* str, u16_t* reg_start, int size_word);
37
38 /**
39  * @brief Issue a HBA command (synchronized)
40  *
41  * @param port
42  * @param slot
43  * @return int
44  */
45 int
46 ahci_try_send(struct hba_port* port, int slot);
47
48 /**
49  * @brief Issue a HBA command (asynchronized)
50  *
51  * @param port
52  * @param state
53  * @param slot
54  */
55 void
56 ahci_post(struct hba_port* port, struct hba_cmd_state* state, int slot);
57
58 struct ahci_driver*
59 ahci_driver_init(struct ahci_driver_param* param);
60
61 void
62 ahci_hba_isr(const isr_param* param);
63
64 #endif /* __LUNAIX_AHCI_H */