4 * @brief ISR Manager, managing the interrupt service routine allocations
8 * @copyright Copyright (c) 2022
11 #ifndef __LUNAIX_ISRM_H
12 #define __LUNAIX_ISRM_H
14 #include <lunaix/types.h>
15 #include <lunaix/hart_state.h>
16 #include <lunaix/device.h>
18 #include <hal/devtree.h>
20 typedef void (*isr_cb)(const struct hart_state*);
27 #define msi_addr(msiv) ((msiv).msi_addr)
28 #define msi_data(msiv) ((msiv).msi_data)
29 #define msi_vect(msiv) ((msiv).mapped_iv)
30 #define check_msiv_invalid(msiv) (msi_vect(msiv) == -1)
31 #define invalid_msi_vector ((msi_vector_t) { (ptr_t)-1, (reg_t)-1, -1 });
33 typedef void* msienv_t;
39 * @brief Release a iv resource
47 * @brief Begin MSI allocation for given device
52 isrm_msi_start(struct device* dev);
55 * @brief Query number of msi avaliable for the device
58 isrm_msi_avaliable(msienv_t msienv);
61 * @brief Allocate a msi resource within defined msi resource list
62 * for the device, indexed by `index`
65 isrm_msi_alloc(msienv_t msienv, cpu_t cpu, int index, isr_cb handler);
68 * @brief Set the sideband information will be used for upcoming
72 isrm_msi_set_sideband(msienv_t msienv, ptr_t sideband);
75 * @brief Done MSI allocation
78 isrm_msi_done(msienv_t msienv);
80 static inline must_inline msi_vector_t
81 isrm_msi_alloc_simple(struct device* dev, cpu_t cpu, isr_cb handler)
86 env = isrm_msi_start(dev);
87 v = isrm_msi_alloc(env, cpu, 0, handler);
94 * @brief Bind the iv according to given device tree node
99 isrm_bind_dtn(struct dt_intr_node* node);
102 * @brief Get the handler associated with the given iv
111 isrm_get_payload(const struct hart_state*);
114 isrm_set_payload(int iv, ptr_t);
117 * @brief Notify end of interrupt event
122 isrm_notify_eoi(cpu_t id, int iv);
125 * @brief Notify end of scheduling event
130 isrm_notify_eos(cpu_t id);
132 #endif /* __LUNAIX_ISRM_H */