MentOS  0.8.0
The Mentoring Operating System
irqflags.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "proc_access.h"
9 #include "stddef.h"
10 #include "stdint.h"
11 
16 inline static void irq_enable(uint8_t flags)
17 {
18  if (flags) {
19  sti();
20  }
21 }
22 
29 inline static uint8_t irq_disable(void)
30 {
31  size_t flags;
32  // We are pushing the entire contents of the EFLAGS register onto the stack,
33  // clearing the interrupt line, and with the pop, getting the current status
34  // of the flags.
35  __asm__ __volatile__("pushf; cli; pop %0;"
36  : "=r"(flags)
37  :
38  : "memory");
39  return flags & (1 << 9);
40 }
41 
44 inline static uint8_t is_irq_enabled(void)
45 {
46  size_t flags;
47  __asm__ __volatile__("pushf; pop %0;"
48  : "=r"(flags)
49  :
50  : "memory");
51  return flags & (1 << 9);
52 }
static uint8_t is_irq_enabled(void)
Determines, if the interrupt flags (IF) is set.
Definition: irqflags.h:44
static void irq_enable(uint8_t flags)
Enable IRQs (nested).
Definition: irqflags.h:16
static uint8_t irq_disable(void)
Disable IRQs (nested).
Definition: irqflags.h:29
Set of functions and flags used to manage processors registers.
static void sti(void)
Set interrupt flag; external, maskable interrupts enabled at the end of the next instruction.
Definition: proc_access.h:291
Define basic data types.
Standard integer data-types.
unsigned char uint8_t
Define the unsigned 8-bit integer.
Definition: stdint.h:30