rework external irq system, introduce hierarchical irq
[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 <asm-generic/isrm.h>
6 #include <hal/irq.h>
7
8 /*
9  * Macro naming rule:
10  *      HBA_R[xxx]
11  *          HBA Register [xxx]
12  *          e.g. HBA_RPxCLB is Register PxCLB
13  *
14  * All registers offset are 0 based index of a DWORD array
15  */
16
17 #define AHCI_HBA_CLASS 0x10601
18
19 struct ahci_driver
20 {
21     struct llist_header ahci_drvs;
22     struct ahci_hba hba;
23     int id;
24 };
25
26 struct ahci_driver_param
27 {
28     ptr_t mmio_base;
29     size_t mmio_size;
30     irq_t irq;
31 };
32
33 void
34 ahci_parse_dev_info(struct hba_device* dev_info, u16_t* data);
35
36 void
37 ahci_parsestr(char* str, u16_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 struct ahci_driver*
60 ahci_driver_init(struct ahci_driver_param* param);
61
62 void
63 ahci_hba_isr(irq_t irq, const struct hart_state* hstate);
64
65 #endif /* __LUNAIX_AHCI_H */