Removed excessive traces in loadelf.c
[marionette.git] / kernel / interrupt.h
blob450d2af105bbc391690682765b80f9331ddf7686
1 /*
2 * Copyright (c) 2008 Joshua Phillips. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
15 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef INTERRUPT_H
29 #define INTERRUPT_H
31 #include "stdint.h"
32 #include "cpustruct.h"
34 // This is the stack structure that arises from an interrupt
35 struct interrupt_stack {
36 struct pusha_struct r;
37 uint32_t error_code, eip, cs, eflags, esp, ss;
40 // Interrupt flags (do not correspond to hardware flags)
41 enum {
42 INTR_USER = 0x01, //user can invoke swi
45 typedef void (* isr_t)(int vector, struct interrupt_stack *);
46 extern isr_t interrupt_handlers[];
48 void interrupt_init(void **p_idt);
49 void enable_interrupts(void); // enable interrupts globally
50 void disable_interrupts(void); // disable interrupts globally
51 void set_interrupt(int vector, isr_t handler); // set up an interrupt handler
52 void clear_interrupt(int vector); // remove an interrupt handler
53 void interrupt_flags(int vector, unsigned int flags); // set interrupt flags (INTR_*)
55 int irq_to_int(int irq); // get an interrupt vector of an irq
56 int int_to_irq(int intn); // get the irq number behind an interrupt vector
57 void unmask_irq(int n); // unmask (enable) IRQ n
58 void mask_irq(int n); // mask (disable) IRQ n
59 void ack_irq(int n); // acknowledge IRQ n
61 #endif