You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB
C

/* Copyright (C) 2021,2022 fef <owo@fef.moe>. All rights reserved. */
#pragma once
#include <arch/irq.h>
#include <gay/types.h>
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);