aboutsummaryrefslogtreecommitdiff
path: root/src/userspace/programs
diff options
context:
space:
mode:
authorMarvin Borner2020-05-09 23:50:24 +0200
committerMarvin Borner2020-05-09 23:50:24 +0200
commitc5b0305b3a6e7e6ec6742b99ceb6a1a0b3c6e286 (patch)
tree173965f614435bb9740d05bbc365aba7b76d7e45 /src/userspace/programs
parente350804dc78ab01aaca6aba33792a652535028d9 (diff)
Interrupt analysis - removed many useless cli/sti
Diffstat (limited to 'src/userspace/programs')
-rw-r--r--src/userspace/programs/init.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c
index 64da122..306aee6 100644
--- a/src/userspace/programs/init.c
+++ b/src/userspace/programs/init.c
@@ -5,6 +5,20 @@
#include <syscall.h>
#include <unistd.h>
+u32 cpu_flags()
+{
+ u32 flags;
+ asm volatile("pushf\n"
+ "pop %0\n"
+ : "=rm"(flags)::"memory");
+ return flags;
+}
+
+int interrupts_enabled()
+{
+ return (cpu_flags() & 0x200) == 0x200;
+}
+
void main()
{
if (get_pid() != 1) {
@@ -12,6 +26,11 @@ void main()
exit(1);
}
+ if (interrupts_enabled())
+ printf("INTs enabled :)\n");
+ else
+ printf("INTs disabled :(\n");
+
// TODO: Fix page fault when mallocing
printf("Initializing userspace...\n");
@@ -19,7 +38,10 @@ void main()
// TODO: Fix occasional race conditions with cli/sti
// TODO: Fix scheduler turning off at some point
spawn("/bin/sh");
- printf("AWESOME");
+ if (interrupts_enabled())
+ printf("INTs enabled :)\n");
+ else
+ printf("INTs disabled :(\n");
while (1) {
//printf("B");