PKUOS - Pintos
Pintos source browser for PKU Operating System course
interrupt.h
Go to the documentation of this file.
1#ifndef THREADS_INTERRUPT_H
2#define THREADS_INTERRUPT_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7/** Interrupts on or off? */
9 {
10 INTR_OFF, /**< Interrupts disabled. */
11 INTR_ON /**< Interrupts enabled. */
12 };
13
14enum intr_level intr_get_level (void);
16enum intr_level intr_enable (void);
17enum intr_level intr_disable (void);
18
19/** Interrupt stack frame. */
21 {
22 /* Pushed by intr_entry in intr-stubs.S.
23 These are the interrupted task's saved registers. */
24 uint32_t edi; /**< Saved EDI. */
25 uint32_t esi; /**< Saved ESI. */
26 uint32_t ebp; /**< Saved EBP. */
27 uint32_t esp_dummy; /**< Not used. */
28 uint32_t ebx; /**< Saved EBX. */
29 uint32_t edx; /**< Saved EDX. */
30 uint32_t ecx; /**< Saved ECX. */
31 uint32_t eax; /**< Saved EAX. */
32 uint16_t gs, :16; /**< Saved GS segment register. */
33 uint16_t fs, :16; /**< Saved FS segment register. */
34 uint16_t es, :16; /**< Saved ES segment register. */
35 uint16_t ds, :16; /**< Saved DS segment register. */
36
37 /* Pushed by intrNN_stub in intr-stubs.S. */
38 uint32_t vec_no; /**< Interrupt vector number. */
39
40 /* Sometimes pushed by the CPU,
41 otherwise for consistency pushed as 0 by intrNN_stub.
42 The CPU puts it just under `eip', but we move it here. */
43 uint32_t error_code; /**< Error code. */
44
45 /* Pushed by intrNN_stub in intr-stubs.S.
46 This frame pointer eases interpretation of backtraces. */
47 void *frame_pointer; /**< Saved EBP (frame pointer). */
48
49 /* Pushed by the CPU.
50 These are the interrupted task's saved registers. */
51 void (*eip) (void); /**< Next instruction to execute. */
52 uint16_t cs, :16; /**< Code segment for eip. */
53 uint32_t eflags; /**< Saved CPU flags. */
54 void *esp; /**< Saved stack pointer. */
55 uint16_t ss, :16; /**< Data segment for esp. */
56 };
57
58typedef void intr_handler_func (struct intr_frame *);
59
60void intr_init (void);
61void intr_register_ext (uint8_t vec, intr_handler_func *, const char *name);
62void intr_register_int (uint8_t vec, int dpl, enum intr_level,
63 intr_handler_func *, const char *name);
64bool intr_context (void);
65void intr_yield_on_return (void);
66
67void intr_dump_frame (const struct intr_frame *);
68const char *intr_name (uint8_t vec);
69
70#endif /**< threads/interrupt.h */
char * name[]
Definition: insult.c:47
enum intr_level intr_set_level(enum intr_level)
Enables or disables interrupts as specified by LEVEL and returns the previous interrupt status.
Definition: interrupt.c:81
void intr_yield_on_return(void)
During processing of an external interrupt, directs the interrupt handler to yield to a new process j...
Definition: interrupt.c:222
void intr_register_ext(uint8_t vec, intr_handler_func *, const char *name)
Registers external interrupt VEC_NO to invoke HANDLER, which is named NAME for debugging purposes.
Definition: interrupt.c:181
enum intr_level intr_enable(void)
Enables interrupts and returns the previous interrupt status.
Definition: interrupt.c:88
const char * intr_name(uint8_t vec)
threads/interrupt.h
Definition: interrupt.c:435
void intr_dump_frame(const struct intr_frame *)
Dumps interrupt frame F to the console, for debugging.
Definition: interrupt.c:411
bool intr_context(void)
Returns true during processing of an external interrupt and false at all other times.
Definition: interrupt.c:212
void intr_init(void)
Initializes the interrupt system.
Definition: interrupt.c:118
enum intr_level intr_disable(void)
Disables interrupts and returns the previous interrupt status.
Definition: interrupt.c:104
void intr_handler_func(struct intr_frame *)
Definition: interrupt.h:58
intr_level
Interrupts on or off?
Definition: interrupt.h:9
@ INTR_ON
Interrupts enabled.
Definition: interrupt.h:11
@ INTR_OFF
Interrupts disabled.
Definition: interrupt.h:10
enum intr_level intr_get_level(void)
Returns the current interrupt status.
Definition: interrupt.c:65
void intr_register_int(uint8_t vec, int dpl, enum intr_level, intr_handler_func *, const char *name)
Registers internal interrupt VEC_NO to invoke HANDLER, which is named NAME for debugging purposes.
Definition: interrupt.c:202
unsigned int uint32_t
Definition: stdint.h:26
unsigned char uint8_t
Definition: stdint.h:20
unsigned short int uint16_t
Definition: stdint.h:23
Interrupt stack frame.
Definition: interrupt.h:21
void * frame_pointer
Saved EBP (frame pointer).
Definition: interrupt.h:47
uint16_t uint32_t eflags
Code segment for eip.
Definition: interrupt.h:52
uint16_t ss
Definition: interrupt.h:55
void(* eip)(void)
Next instruction to execute.
Definition: interrupt.h:51
uint16_t uint16_t fs
Saved GS segment register.
Definition: interrupt.h:32
uint16_t uint16_t uint16_t uint16_t uint32_t vec_no
Saved DS segment register.
Definition: interrupt.h:35
uint32_t esp_dummy
Not used.
Definition: interrupt.h:27
uint32_t error_code
Error code.
Definition: interrupt.h:43
uint32_t ebx
Saved EBX.
Definition: interrupt.h:28
uint16_t uint16_t uint16_t es
Saved FS segment register.
Definition: interrupt.h:33
uint16_t uint16_t uint16_t uint16_t ds
Saved ES segment register.
Definition: interrupt.h:34
uint32_t ecx
Saved ECX.
Definition: interrupt.h:30
uint32_t edx
Saved EDX.
Definition: interrupt.h:29
uint16_t gs
Definition: interrupt.h:32
void * esp
Saved stack pointer.
Definition: interrupt.h:54
uint32_t edi
Saved EDI.
Definition: interrupt.h:24
uint32_t eax
Saved EAX.
Definition: interrupt.h:31
uint32_t ebp
Saved EBP.
Definition: interrupt.h:26
uint16_t cs
Definition: interrupt.h:52
uint32_t esi
Saved ESI.
Definition: interrupt.h:25