Quellcode durchsuchen

evx: okay, a set_gate is now okay :-) happy

rain vor 4 Jahren
Ursprung
Commit
3f3536e510

+ 1 - 1
arch/x86/.archcflags

@@ -1 +1 @@
--m64 -I/root/evx/arch/x86/include -I/root/evx/arch/x86/include64 
+-m32 -I/root/evx/arch/x86/include -I/root/evx/arch/x86/include32 

+ 51 - 0
arch/x86/include/arch/int.h

@@ -0,0 +1,51 @@
+/* arch/x86/include32/arch/int.h 
+ * 
+ * This file is part of evx. 
+ * 
+ * evx is free software: you can redistribute it and/or modify 
+ * it under the terms of the GNU General Public License as published by 
+ * the Free Software Foundation, either version 3 of the License, or 
+ * (at your option) any later version. 
+ * 
+ * evx is distributed in the hope that it will be useful, 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with evx. If not, see <https://www.gnu.org/licenses/>
+ */ 
+
+
+
+
+#ifndef __ARCH_INT_H
+#define __ARCH_INT_H
+
+#include <config.h>
+
+
+#ifndef __ASSEMBLER__
+
+struct idt_entry {
+	__uint16_t 	off_0;
+	__uint16_t 	seg;
+
+#if CONFIG_64BIT
+	__uint8_t 	ist;
+#else
+	__uint8_t 	resv;
+#endif
+	__uint8_t 	attr;
+
+	__uint16_t 	off_1;
+#if CONFIG_64BIT
+	__uint32_t 	off_2;
+	__uint32_t 	zero;
+#endif
+} __attribute__ ((packed));
+
+
+#endif
+#endif
+

+ 51 - 0
arch/x86/include32/arch/int.h

@@ -0,0 +1,51 @@
+/* arch/x86/include32/arch/int.h 
+ * 
+ * This file is part of evx. 
+ * 
+ * evx is free software: you can redistribute it and/or modify 
+ * it under the terms of the GNU General Public License as published by 
+ * the Free Software Foundation, either version 3 of the License, or 
+ * (at your option) any later version. 
+ * 
+ * evx is distributed in the hope that it will be useful, 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with evx. If not, see <https://www.gnu.org/licenses/>
+ */ 
+
+
+
+
+#ifndef __ARCH_INT_H
+#define __ARCH_INT_H
+
+#include <config.h>
+
+
+#ifndef __ASSEMBLER__
+
+struct idt_entry {
+	__uint16_t 	off_0;
+	__uint16_t 	seg;
+
+#if CONFIG_64BIT
+	__uint8_t 	ist;
+#else
+	__uint8_t 	resv;
+#endif
+	__uint8_t 	attr;
+
+	__uint16_t 	off_1;
+#if CONFIG_64BIT
+	__uint32_t 	off_2;
+	__uint32_t 	zero;
+#endif
+} __attribute__ ((packed));
+
+
+#endif
+#endif
+

+ 2 - 0
arch/x86/init/head64.S

@@ -170,6 +170,8 @@ gdt_descr:
 
 idt: 	.fill 512, 8, 0
 
+.globl idt_descr 
+
 idt_descr:
 	.word . - idt
 	.quad idt

+ 1 - 1
arch/x86/kernel/Makefile

@@ -2,7 +2,7 @@
 # and we just tell it what objects that he should make. 
 
 # must be the first, as we call it first. 
-obj-i = arch_mm.c 
+obj-i = arch_mm.c arch_int.c 
 
 %.S.o: %.S 
 	@$(AS) $*.S -o $*.o -m$(BITS) 

+ 83 - 0
arch/x86/kernel/arch_int.c

@@ -0,0 +1,83 @@
+/* arch/x86/kernel/arch_int.c 
+ * 
+ * This file is part of evx. 
+ * 
+ * evx is free software: you can redistribute it and/or modify 
+ * it under the terms of the GNU General Public License as published by 
+ * the Free Software Foundation, either version 3 of the License, or 
+ * (at your option) any later version. 
+ * 
+ * evx is distributed in the hope that it will be useful, 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of 
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+ * GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with evx. If not, see <https://www.gnu.org/licenses/>
+ */ 
+
+
+
+
+#include <kernel/init.h>
+#include <kernel/module.h>
+#include <kernel/mm.h>
+#include <kernel/kernel.h>
+#include <kernel/kmlog.h>
+
+#include <arch/archinfo.h>
+#include <arch/mm.h>
+#include <arch/int.h>
+#include <arch/string.h>
+
+#include <sys/types.h>
+#include <config.h>
+
+
+/* head$(BITS).S */
+/* extern struct idt_entry *idt; things interesting.
+ * a struct idt_entry *idt, and that is a pointer. idt, is 
+ * the address.
+ *
+ * a struct idt_entry idt[], and that is an array. */
+
+extern struct idt_entry idt[256];
+
+static int set_gate(struct idt_entry *, void (*) (void), int attr);
+
+/* set the handlers for traps, 0 - 31 */
+
+int __init arch_traps_init(void) {
+	set_gate(idt + 0x80, NULL, 0x8e);
+
+	return 0;
+}
+
+
+static int set_gate(struct idt_entry *entry, void (* handler) (void), int attr) {
+	/* no ist support in long-mode, well, that's not so useful */
+	__archptr_t p = (__archptr_t) handler;
+
+	entry->off_0 = p & 0xffffu;
+	entry->seg = 8;
+#if CONFIG_64BIT
+	entry->ist =
+#else
+	entry->resv = 
+#endif
+		0;
+
+	entry->attr = attr;
+	entry->off_1 = (p >> 16u) & 0xffffu;
+
+#if CONFIG_64BIT
+	entry->off_2 = p >> 32u;
+	entry->zero = 0;
+#endif
+
+	return 0;
+}
+
+
+arch_init(arch_traps_init);
+