aboutsummaryrefslogtreecommitdiff
path: root/src/int
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-04-12 10:28:04 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-04-12 10:28:04 +0200
commit457a2117706cdaee34f894e67c89da7bf29f6143 (patch)
treee3a1a519c5360abcca95732500594c92af9af51c /src/int
parent39713a3736145483dd3310c3605f940ca34f05c3 (diff)
Refactoring
Diffstat (limited to 'src/int')
-rw-r--r--src/int/8042.c16
-rw-r--r--src/int/8042.h64
-rw-r--r--src/int/idt.c39
-rw-r--r--src/int/idt.h32
-rw-r--r--src/int/int.S72
-rw-r--r--src/int/pic.c28
-rw-r--r--src/int/pic.h9
7 files changed, 0 insertions, 260 deletions
diff --git a/src/int/8042.c b/src/int/8042.c
deleted file mode 100644
index 5446f11..0000000
--- a/src/int/8042.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "8042.h"
-#include "core/framebuffer.h"
-#include "core/asm.h"
-
-DEFINE_AZERTY;
-
-void _8042_keypress(){
- u8 data;
- do {
- inb(0x64,data);
- }
- while((data&0x01) == 0);
- inb(0x60,data);
- if(data<0x80)
- putchar(AZERTY[data]);
-}
diff --git a/src/int/8042.h b/src/int/8042.h
deleted file mode 100644
index 5e61ffd..0000000
--- a/src/int/8042.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef _8042_H
-#define _8042_H
-
-#include "core/types.h"
-
-void _8042_keypress();
-
-#define DEFINE_AZERTY char AZERTY[]={\
- '\0',\
- '\0',\
- '&',\
- '\0',\
- '"',\
- '\'',\
- '(',\
- '-',\
- '\0',\
- '_',/* 10 */\
- '\0',\
- '\0',\
- ')',\
- '=',\
- '\0',\
- '\t',\
- 'a',\
- 'z',\
- 'e',\
- 'r',\
- 't',\
- 'y',\
- 'u',\
- 'i',\
- 'o',\
- 'p',\
- '^',\
- '$',\
- '\0',\
- '\0',\
- 'q',/* 0x1E (30) */\
- 's',\
- 'd',\
- 'f',\
- 'g',\
- 'h',\
- 'j',\
- 'k',\
- 'l',\
- 'm',\
- '\0',\
- '\0',\
- '\0',\
- '*',\
- 'w',\
- 'x',\
- 'c',\
- 'v',\
- 'b',/* 0x30 (48) */\
- 'n',\
- ',',\
- ';',\
- ':',\
-}
-
-#endif \ No newline at end of file
diff --git a/src/int/idt.c b/src/int/idt.c
deleted file mode 100644
index e3e71e8..0000000
--- a/src/int/idt.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "idt.h"
-
-struct IDT_REGISTER IDTR={
- 8*IDT_MAX_ENTRY,
- 0x0
-};
-
-// Interrupt functions (cf int.S)
-extern u32
-INT_DEFAULT,
-INT_PAGE_FAULT,
-INT_CLOCK,
-INT_KEYPRESS,
-INT_SYSCALL;
-
-
-void idt_init(){
- // Map first default 32 entries
- for(int i=0;i<IDT_MAX_ENTRY;i++){
- idt_write_entry((IDT_ENTRY){0x08,(u32)&INT_DEFAULT,IDT_INT_GATE},i);
- if(i==14)
- idt_write_entry((IDT_ENTRY){0x08,(u32)&INT_PAGE_FAULT,IDT_INT_GATE},i);
- if(i==32)
- idt_write_entry((IDT_ENTRY){0x08,(u32)&INT_CLOCK,IDT_INT_GATE},i);
- if(i==33)
- idt_write_entry((IDT_ENTRY){0x08,(u32)&INT_KEYPRESS,IDT_INT_GATE},i);
- if(i==48)
- idt_write_entry((IDT_ENTRY){0x08,(u32)&INT_SYSCALL,IDT_TRAP_GATE},i);
- }
-
- asm("lidtl (IDTR)");
-}
-
-void idt_write_entry(IDT_ENTRY entry, int id){
- int descriptor[2];
- descriptor[0]=entry.offset & 0xFFFF | entry.segment << 16;
- descriptor[1]=entry.type & 0xFFFF | entry.offset & 0xFFFF0000;
- memcpy((void*)descriptor, (void *)(IDTR.base+(id*8)),8);
-} \ No newline at end of file
diff --git a/src/int/idt.h b/src/int/idt.h
deleted file mode 100644
index 17c5cfa..0000000
--- a/src/int/idt.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef IDT_H
-#define IDT_H
-
-#include "core/types.h"
-#include "core/mem.h"
-
-#define IDT_MAX_ENTRY 200
-#define IDT_INT_GATE 0x8E00
-#define IDT_TRAP_GATE 0xEF00
-
-typedef struct IDT_ENTRY {
- u16 segment;
- u32 offset;
- u16 type;
-} IDT_ENTRY;
-
-struct IDT_REGISTER {
- u16 limit;
- u32 base;
-} __attribute__((packed));
-
-/**
- * Copy IDT into memory and load it
- */
-void idt_init();
-
-/**
- * Write an IDT entry into memory
- */
-void idt_write_entry(IDT_ENTRY entry,int id);
-
-#endif \ No newline at end of file
diff --git a/src/int/int.S b/src/int/int.S
deleted file mode 100644
index 8ca8b7a..0000000
--- a/src/int/int.S
+++ /dev/null
@@ -1,72 +0,0 @@
-.macro SAVE_REGS
-pushal
-push %ds
-push %es
-push %fs
-push %gs
-push %ebx
-mov $0x10,%bx
-mov %bx,%ds
-pop %ebx
-.endm
-
-.macro RESTORE_REGS
- pop %gs
- pop %fs
- pop %es
- pop %ds
- popal
-.endm
-
-.globl interrupt_enable
-interrupt_enable:
- call idt_init
- call pic_init
- sti
- ret
-
-.globl INT_DEFAULT
-INT_DEFAULT:
- SAVE_REGS
- movb $0x20, %al
- outb %al, $0x20
- RESTORE_REGS
- iret
-
-.globl INT_KEYPRESS
-INT_KEYPRESS:
- SAVE_REGS
- call _8042_keypress
- movb $0x20, %al
- outb %al, $0x20
- RESTORE_REGS
- iret
-
-.globl INT_CLOCK
-INT_CLOCK:
- SAVE_REGS
- call clock
- movb $0x20, %al
- outb %al, $0x20
- RESTORE_REGS
- iret
-
-.globl INT_SYSCALL
-INT_SYSCALL:
- SAVE_REGS
- call syscall
- movb $0x20, %al
- outb %al, $0x20
- RESTORE_REGS
- iret
-
-.globl INT_PAGE_FAULT
-INT_PAGE_FAULT:
- SAVE_REGS
- call page_fault
- hlt
- movb $0x20, %al
- outb %al, $0x20
- RESTORE_REGS
- iret
-
diff --git a/src/int/pic.c b/src/int/pic.c
deleted file mode 100644
index d509e1d..0000000
--- a/src/int/pic.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "pic.h"
-#include "core/asm.h"
-#include "core/mem.h"
-#include "core/syscall.h"
-
-void pic_init(){
-
- // ICW1: Initialisation
- outbj(0x20,0x11); // Master
- outbj(0xA0,0x11); // Slave
-
- // ICW2: Map IRQ index to entry into the IDT
- outbj(0x21,0x20); // Start interrupt at offset 0x20 in IDT (index 32)
- outbj(0xA1,0x70); // Start interrupt at offset 0x50 in IDT (index 80)
-
- // ICW3: Indicate the connection between master and slave
- outbj(0x21,0x02); // Slave connected to pin 2
- outbj(0xA1,0x01); // Indicate pin id to the slave (2-1)
-
- // ICW4: Operating mode
- outbj(0x21,0x01); // Default operating mode
- outbj(0xA1,0x01); // Default operating mode
-
- // OCW: Masking
- outbj(0x21,0b11111100);
-}
-
-
diff --git a/src/int/pic.h b/src/int/pic.h
deleted file mode 100644
index 19e0f5c..0000000
--- a/src/int/pic.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef PIC_H
-#define PIC_H
-
-/**
- * Configure
- */
-void pic_init();
-
-#endif \ No newline at end of file