aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-05-11 19:14:20 +0200
committerMarvin Borner2020-05-11 19:14:20 +0200
commitd00e6a08ededb16e5d075ce28d7d797763e25c55 (patch)
tree1ab924d955056c342d21e1632251c4899bf8f11c
parent6abd515c051b6dcb545e1033ff129aaaf7293917 (diff)
Some very small fixes in several files
-rwxr-xr-xrun10
-rw-r--r--src/kernel/gdt/gdt.c4
-rw-r--r--src/kernel/interact.asm4
-rw-r--r--src/kernel/interrupts/irq.c16
-rw-r--r--src/kernel/interrupts/isr.c2
-rw-r--r--src/kernel/tasks/process.c2
-rw-r--r--src/userspace/programs/init.c10
-rw-r--r--src/userspace/programs/sh.c23
8 files changed, 39 insertions, 32 deletions
diff --git a/run b/run
index 3c02aea..7ecc464 100755
--- a/run
+++ b/run
@@ -214,12 +214,12 @@ elif [ "${mode}" = "tidy" ]; then
elif [ "${mode}" = "font" ]; then
make_font
make_tidy
-elif [ "${mode}" = "help" ]; then
- echo "Please use the following syntax:"
- echo "The default option is 'test'"
- echo "./run {cross | build | clean | test | debug | image | sync | tidy | font} [-y]"
-else # TODO: Prevent code duplication in build script via functions?
+elif [ "${mode}" = "" ]; then # TODO: Prevent code duplication in build script via functions?
make_cross
make_build
make_test
+else
+ echo "Please use the following syntax:"
+ echo "./run {cross | build | clean | test | debug | image | sync | tidy | font} [-y]"
+ echo "The default option is 'test'"
fi
diff --git a/src/kernel/gdt/gdt.c b/src/kernel/gdt/gdt.c
index 79a52a4..4f98056 100644
--- a/src/kernel/gdt/gdt.c
+++ b/src/kernel/gdt/gdt.c
@@ -61,12 +61,10 @@ void gdt_set_gate(s32 num, u32 base, u32 limit, u8 access, u8 gran)
gdt[num].base_low = (u16)(base & 0xFFFF);
gdt[num].base_middle = (u8)((base >> 16) & 0xFF);
gdt[num].base_high = (u8)((base >> 24) & 0xFF);
-
- // Set descriptor limits
gdt[num].limit_low = (u16)(limit & 0xFFFF);
- gdt[num].granularity = (u8)((limit >> 16) & 0x0F);
// Set granularity and access flags
+ gdt[num].granularity = (u8)((limit >> 16) & 0x0F);
gdt[num].granularity |= (gran & 0xF0);
gdt[num].access = access;
}
diff --git a/src/kernel/interact.asm b/src/kernel/interact.asm
index e7d7e86..00cdbe0 100644
--- a/src/kernel/interact.asm
+++ b/src/kernel/interact.asm
@@ -32,7 +32,7 @@ endstruc
section .text
int32: use32 ; by Napalm
_int32:
- cli ; disable interrupts
+ ;cli ; disable interrupts
pusha ; save register state to 32bit stack
mov esi, reloc ; set source to code below
mov edi, INT32_BASE ; set destination to new base address
@@ -113,7 +113,7 @@ section .text
cld ; clear direction flag (so we copy forward)
rep movsb ; do the actual copy (16bit stack to 32bit stack)
popa ; restore registers
- ; sti ; enable interrupts
+ ;sti ; enable interrupts
ret ; return to caller
resetpic: ; reset's 8259 master and slave pic vectors
diff --git a/src/kernel/interrupts/irq.c b/src/kernel/interrupts/irq.c
index 7c45718..9fd0c31 100644
--- a/src/kernel/interrupts/irq.c
+++ b/src/kernel/interrupts/irq.c
@@ -3,36 +3,22 @@
#include <system.h>
extern void irq0();
-
extern void irq1();
-
extern void irq2();
-
extern void irq3();
-
extern void irq4();
-
extern void irq5();
-
extern void irq6();
-
extern void irq7();
-
extern void irq8();
-
extern void irq9();
-
extern void irq10();
-
extern void irq11();
-
extern void irq12();
-
extern void irq13();
-
extern void irq14();
-
extern void irq15();
+extern void irq128();
// Array to handle custom IRQ handlers
void *irq_routines[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c
index 3bfc2b8..b24529f 100644
--- a/src/kernel/interrupts/isr.c
+++ b/src/kernel/interrupts/isr.c
@@ -47,7 +47,7 @@ void isrs_install()
idt_set_gate(30, (unsigned)isr30, 0x08, 0x8E);
idt_set_gate(31, (unsigned)isr31, 0x08, 0x8E);
- idt_set_gate(0x80, (unsigned)isr128, 0x08, 0xEE);
+ idt_set_gate(0x80, (unsigned)isr128, 0x08, 0x8E);
info("Installed Interrupt Service Routines");
}
diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c
index 0ba3fbe..b86620d 100644
--- a/src/kernel/tasks/process.c
+++ b/src/kernel/tasks/process.c
@@ -21,6 +21,7 @@ extern u32 stack_hold;
void scheduler(struct regs *regs)
{
+ serial_put('+');
memcpy(&current_proc->registers, regs, sizeof(struct regs));
timer_handler(regs);
@@ -32,7 +33,6 @@ void scheduler(struct regs *regs)
/* debug("Max pid: %d", pid); */
/* debug("Task switch to %s with pid %d", current_proc->name, current_proc->pid); */
- serial_put('+');
while (current_proc->state == PROC_ASLEEP) {
current_proc = current_proc->next;
diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c
index 306aee6..019e5c3 100644
--- a/src/userspace/programs/init.c
+++ b/src/userspace/programs/init.c
@@ -21,10 +21,10 @@ int interrupts_enabled()
void main()
{
- if (get_pid() != 1) {
- printf("Wrong PID!\n");
- exit(1);
- }
+ /* if (get_pid() != 1) { */
+ /* printf("Wrong PID!\n"); */
+ /* exit(1); */
+ /* } */
if (interrupts_enabled())
printf("INTs enabled :)\n");
@@ -44,6 +44,6 @@ void main()
printf("INTs disabled :(\n");
while (1) {
- //printf("B");
+ printf("B");
};
} \ No newline at end of file
diff --git a/src/userspace/programs/sh.c b/src/userspace/programs/sh.c
index ba6ba8f..db8543d 100644
--- a/src/userspace/programs/sh.c
+++ b/src/userspace/programs/sh.c
@@ -11,8 +11,31 @@ void test(u8 *data)
printf(".");
}
+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) { */
+ /* printf("Wrong PID!\n"); */
+ /* exit(1); */
+ /* } */
+
+ if (interrupts_enabled())
+ printf("INTs enabled :)\n");
+ else
+ printf("INTs disabled :(\n");
printf("[~] ");
/* while (1) { */