aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/asm.h1
-rw-r--r--src/utils/multiboot.c39
-rw-r--r--src/utils/multiboot.h32
-rw-r--r--src/utils/pic.c14
-rw-r--r--src/utils/print.c18
-rw-r--r--src/utils/print.h1
6 files changed, 32 insertions, 73 deletions
diff --git a/src/utils/asm.h b/src/utils/asm.h
index f92195f..be265d8 100644
--- a/src/utils/asm.h
+++ b/src/utils/asm.h
@@ -9,4 +9,5 @@
#define inb(port,dst) \
asm volatile ("inb %%dx, %%al": "=a" (dst) : "d" (port))
+
#endif \ No newline at end of file
diff --git a/src/utils/multiboot.c b/src/utils/multiboot.c
deleted file mode 100644
index 891bd57..0000000
--- a/src/utils/multiboot.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#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
deleted file mode 100644
index 4194d00..0000000
--- a/src/utils/multiboot.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#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 4459f0d..4806cb9 100644
--- a/src/utils/pic.c
+++ b/src/utils/pic.c
@@ -18,15 +18,22 @@ asm (
"movb $0x20, %al \n\t"
"outb %al, $0x20 \n\t"
"iret \n\t"
+"PIC_IRQ_CLOCK: \n\t"
+ "call clock \n\t"
+ "movb $0x20, %al \n\t"
+ "outb %al, $0x20 \n\t"
+ "iret \n\t"
);
-extern u32 PIC_IRQ_DEFAULT,PIC_IRQ_PRINT;
+extern u32 PIC_IRQ_DEFAULT,PIC_IRQ_PRINT,PIC_IRQ_CLOCK;
void pic_enable_interrupt(){
// Map first default 32 entries
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_CLOCK,IDT_TYPE_1},i);
+ if(i==33)
pic_add_idt_entry((IDT_ENTRY){0x08,(u32)&PIC_IRQ_PRINT,IDT_TYPE_1},i);
}
@@ -48,6 +55,10 @@ void pic_enable_interrupt(){
outbj(0x21,0x01); // Default operating mode
outbj(0xA1,0x01); // Default operating mode
+ // OCW: Masking
+ outbj(0x21,0);
+
+
asm("lidtl (IDTR)");
asm("sti");
}
@@ -56,6 +67,5 @@ 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+(id*8)),8);
}
diff --git a/src/utils/print.c b/src/utils/print.c
index dbed000..c2cdaf1 100644
--- a/src/utils/print.c
+++ b/src/utils/print.c
@@ -20,6 +20,17 @@ VIDEO_STATE VS={
};
void putchar(char c){
+ // Handle newline here
+ if(c=='\n'){
+ VS.col=0;
+ VS.line+=1;
+ if(VS.line>=MAX_LINE){
+ VS.line=MAX_LINE-1;
+ scrollup();
+ }
+ return;
+ }
+
// Print char
VS.mem[VS.col*2+MAX_COL*VS.line*2]=c;
VS.mem[VS.col*2+MAX_COL*VS.line*2+1]=VS.fg|VS.bg<<4;
@@ -44,6 +55,13 @@ void print(char *str){
}
}
+void printc(char* str,VIDEO_COLORS c){
+ VIDEO_COLORS backup=VS.fg;
+ VS.fg=c;
+ print(str);
+ VS.fg=backup;
+}
+
void clear(){
for(char i=0;i<MAX_LINE;i++){
scrollup();
diff --git a/src/utils/print.h b/src/utils/print.h
index d04fed2..163f4ec 100644
--- a/src/utils/print.h
+++ b/src/utils/print.h
@@ -16,6 +16,7 @@ typedef struct VIDEO_STATE VIDEO_STATE;
*/
void putchar(char);
void print(char*);
+void printc(char*,VIDEO_COLORS c);
void scrollup();
void clear();