aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/8042.h1
-rw-r--r--src/utils/multiboot.c39
-rw-r--r--src/utils/multiboot.h32
-rw-r--r--src/utils/pic.c22
-rw-r--r--src/utils/pic.h2
-rw-r--r--src/utils/types.h1
6 files changed, 83 insertions, 14 deletions
diff --git a/src/utils/8042.h b/src/utils/8042.h
index 1fecf2a..068a0ef 100644
--- a/src/utils/8042.h
+++ b/src/utils/8042.h
@@ -58,6 +58,7 @@ void _8042_keypress();
'n',\
',',\
';',\
+ ':',\
}
#endif \ No newline at end of file
diff --git a/src/utils/multiboot.c b/src/utils/multiboot.c
new file mode 100644
index 0000000..891bd57
--- /dev/null
+++ b/src/utils/multiboot.c
@@ -0,0 +1,39 @@
+#include "multiboot.h"
+
+extern u8* MB_INFO;
+
+char mb_load_tag(char **data, char type){
+ char *c_info_size=MB_INFO;
+ char *c_tag_type=c_info_size+8;
+ char *c_tag_size=c_info_size+12;
+
+ for(int i=0;i<10;i++){
+ int tag_type=*((int*)c_tag_type);
+ int tag_size=*((int*)c_tag_size);
+ if(tag_type==type){
+ *data=c_tag_type;
+ return 0;
+ }
+
+ c_tag_type=c_tag_type+tag_size+4;
+ // Skip padding for 64 bits
+ int p=c_tag_type;
+ while((p & 0x7) != 0)
+ p++;
+ // Assign address after padding
+ c_tag_type=p;
+ c_tag_size=c_tag_type+4;
+
+ }
+ return 1;
+}
+char mb_load_bl_name(MBI_TAG_BL_NAME *data){
+ char *to_load;
+ if(!mb_load_tag(&to_load,2)){
+ memcpy(to_load,data,8);
+ to_load+=8;
+ data->name=to_load;
+ return 0;
+ }
+ return 1;
+}
diff --git a/src/utils/multiboot.h b/src/utils/multiboot.h
new file mode 100644
index 0000000..4194d00
--- /dev/null
+++ b/src/utils/multiboot.h
@@ -0,0 +1,32 @@
+#ifndef MULTIBOOT_H
+#define MULTIBOOT_H
+
+#include "types.h"
+
+typedef struct MBI_TAG_HEADER {
+ u32 type;
+ u32 size;
+} __attribute__((packed)) MBI_TAG_HEADER;
+
+typedef struct MBI_TAG_BL_NAME {
+ MBI_TAG_HEADER header;
+ u8 *name;
+} __attribute__((packed)) MBI_TAG_BL_NAME;
+
+
+typedef struct MBI_TAG_FB {
+ MBI_TAG_HEADER header;
+ u64 framebuffer_addr;
+ u32 framebuffer_pitch;
+ u32 framebuffer_width;
+ u32 framebuffer_height;
+ u8 framebuffer_bpp;
+ u8 framebuffer_type;
+ u8 reserved;
+ u8 *color_infos;
+}__attribute__((packed)) MBI_TAG_FB;
+
+
+char mb_load_tag(char **data, char type);
+char mb_load_bl_name(MBI_TAG_BL_NAME *data);
+#endif \ No newline at end of file
diff --git a/src/utils/pic.c b/src/utils/pic.c
index f77eb70..4459f0d 100644
--- a/src/utils/pic.c
+++ b/src/utils/pic.c
@@ -3,8 +3,8 @@
#include "mem.h"
struct IDT_REGISTER IDTR={
- 90*8,
- 0
+ 100*8,
+ 0x0
};
/// Bridge between IDT and functions call
@@ -22,13 +22,12 @@ asm (
extern u32 PIC_IRQ_DEFAULT,PIC_IRQ_PRINT;
-
void pic_enable_interrupt(){
// Map first default 32 entries
- for(int i=0;i<90;i++){
- pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_DEFAULT,IDT_TYPE_1});
+ for(int i=0;i<100;i++){
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_DEFAULT,IDT_TYPE_1},i);
if(i==32)
- pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_PRINT,IDT_TYPE_1});
+ pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_PRINT,IDT_TYPE_1},i);
}
// Now configure 8952A
@@ -39,7 +38,7 @@ void pic_enable_interrupt(){
// ICW2: Map IRQ index to entry into the IDT
outbj(0x21,0x20); // Start interrupt at offset 0x20 in IDT (index 32)
- outbj(0xA1,0x50); // Start interrupt at offset 0x50 in IDT (index 80)
+ 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
@@ -51,15 +50,12 @@ void pic_enable_interrupt(){
asm("lidtl (IDTR)");
asm("sti");
-
}
-void pic_add_idt_entry(IDT_ENTRY entry){
- static int cur_offset=0;
+void pic_add_idt_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+cur_offset),8);
- cur_offset+=8;
-} \ No newline at end of file
+ memcpy((void*)descriptor, (void *)(IDTR.base+(id*8)),8);
+}
diff --git a/src/utils/pic.h b/src/utils/pic.h
index b8f98ac..2734437 100644
--- a/src/utils/pic.h
+++ b/src/utils/pic.h
@@ -17,6 +17,6 @@ struct IDT_REGISTER {
} __attribute__((packed));
void pic_enable_interrupt();
-void pic_add_idt_entry(IDT_ENTRY entry);
+void pic_add_idt_entry(IDT_ENTRY entry,int id);
#endif \ No newline at end of file
diff --git a/src/utils/types.h b/src/utils/types.h
index b06b160..ce49701 100644
--- a/src/utils/types.h
+++ b/src/utils/types.h
@@ -4,5 +4,6 @@
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
+typedef unsigned long long u64;
#endif