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)
31 typedef void* msienv_t;
37 * @brief Release a iv resource
45 * @brief Begin MSI allocation for given device
50 isrm_msi_start(struct device* dev);
53 * @brief Query number of msi avaliable for the device
56 isrm_msi_avaliable(msienv_t msienv);
59 * @brief Allocate a msi resource within defined msi resource list
60 * for the device, indexed by `index`
63 isrm_msi_alloc(msienv_t msienv, cpu_t cpu, int index, isr_cb handler);
66 * @brief Set the sideband information will be used for upcoming
70 isrm_msi_set_sideband(msienv_t msienv, ptr_t sideband);
73 * @brief Done MSI allocation
76 isrm_msi_done(msienv_t msienv);
78 static inline must_inline msi_vector_t
79 isrm_msi_alloc_simple(struct device* dev, cpu_t cpu, isr_cb handler)
84 env = isrm_msi_start(dev);
85 v = isrm_msi_alloc(env, cpu, 0, handler);
92 * @brief Bind the iv according to given device tree node
97 isrm_bind_dtn(struct dtn_intr* node);
100 * @brief Get the handler associated with the given iv
109 isrm_get_payload(const struct hart_state*);
112 isrm_set_payload(int iv, ptr_t);
115 * @brief Notify end of interrupt event
120 isrm_notify_eoi(cpu_t id, int iv);
123 * @brief Notify end of scheduling event
128 isrm_notify_eos(cpu_t id);
130 #endif /* __LUNAIX_ISRM_H */