/* Copyright (C) 2021,2022 fef . All rights reserved. */ #pragma once #include #include extern void (*irq_table[NUM_IRQ])(void); /** @brief Return true if you are in IRQ context. */ bool in_irq(void); /** @brief Initialize the IRQ table and interrupt controller. */ void irq_init(void); /** * @brief Enable (unmask) an IRQ. * * @param number IRQ number * @returns 0 on success, or a negative number if there is no associated handler */ int irq_enable(unsigned int number); /** * @brief Disable (mask) an IRQ. * * @param number IRQ number */ void irq_disable(unsigned int number); /** * @brief Attach a handler to a specific IRQ. * * @param number IRQ number * @param handler IRQ handler * @return 0 on success, or `-EEXIST` if the IRQ is already attached * to another handler (use `irq_detach()` to, well, detach handlers * that are no longer in use) */ int irq_attach(unsigned int number, void (*handler)(void)); /** * @brief Detach an IRQ handler that was attached using `irq_attach()`. * * @param number IRQ number */ void irq_detach(unsigned int number);