Browse Source

kernel: move irq setup later; put level control behind arg

K. Lange 2 years ago
parent
commit
3d34370c80
2 changed files with 9 additions and 4 deletions
  1. 6 2
      kernel/cpu/irq.c
  2. 3 2
      kernel/main.c

+ 6 - 2
kernel/cpu/irq.c

@@ -11,6 +11,7 @@
 #include <kernel/logging.h>
 #include <kernel/module.h>
 #include <kernel/printf.h>
+#include <kernel/args.h>
 
 /* Programmable interrupt controller */
 #define PIC1           0x20
@@ -153,10 +154,13 @@ void irq_install(void) {
 	 * they were set to level triggered in expectation
 	 * of an IO APIC taking over...
 	 */
+	if (!args_present("noelcr")) {
 #if 0
-	outportb(0x4D0, 0x00);
+		outportb(0x4D0, 0x00);
 #endif
-	outportb(0x4D1, (1 << (10-8)) | (1 << (11-8)));
+		uint8_t val = inportb(0x4D1);
+		outportb(0x4D1, val | (1 << (10-8)) | (1 << (11-8)));
+	}
 }
 
 void irq_ack(size_t irq_no) {

+ 3 - 2
kernel/main.c

@@ -94,8 +94,6 @@ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
 	/* Initialize core modules */
 	gdt_install();      /* Global descriptor table */
 	idt_install();      /* IDT */
-	isrs_install();     /* Interrupt service requests */
-	irq_install();      /* Hardware interrupt requests */
 
 	uintptr_t last_mod = (uintptr_t)&end;
 	if (mboot_ptr->flags & MULTIBOOT_FLAG_MODS) {
@@ -168,6 +166,9 @@ int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
 		args_parse(cmdline);
 	}
 
+	isrs_install();     /* Interrupt service requests */
+	irq_install();      /* Hardware interrupt requests */
+
 	vfs_install();
 	tasking_install();  /* Multi-tasking */
 	timer_install();    /* PIC driver */