aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/io')
-rw-r--r--src/kernel/io/io.c16
-rw-r--r--src/kernel/io/io.h10
2 files changed, 18 insertions, 8 deletions
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c
index dfd9efa..fd7cd46 100644
--- a/src/kernel/io/io.c
+++ b/src/kernel/io/io.c
@@ -36,6 +36,14 @@ int interrupts_enabled()
return (cpu_flags() & 0x200) == 0x200;
}
+void interrupts_print()
+{
+ if (interrupts_enabled())
+ log(GRN "Interrupts are enabled!" RES);
+ else
+ log(RED "Interrupts are disabled!" RES);
+}
+
void cli()
{
asm volatile("cli");
@@ -66,14 +74,6 @@ void outl(u16 port, u32 data)
asm volatile("outl %0, %1" ::"a"(data), "Nd"(port));
}
-void spinlock(int *ptr)
-{
- int prev;
- do
- asm volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1));
- while (prev);
-}
-
void init_serial()
{
outb(0x3f8 + 1, 0x00);
diff --git a/src/kernel/io/io.h b/src/kernel/io/io.h
index ba5e7c1..2d078f1 100644
--- a/src/kernel/io/io.h
+++ b/src/kernel/io/io.h
@@ -25,6 +25,7 @@ u16 inw(u16 port);
u32 inl(u16 port);
int interrupts_enabled();
+void interrupts_print();
void cli();
void sti();
void hlt();
@@ -61,4 +62,13 @@ void init_serial();
*/
void serial_put(char ch);
+// Spinlock
+static inline void spinlock(int *ptr)
+{
+ int prev;
+ do
+ asm volatile("lock xchgl %0,%1" : "=a"(prev) : "m"(*ptr), "a"(1));
+ while (prev);
+}
+
#endif \ No newline at end of file