aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/interrupts.c5
-rw-r--r--src/drivers/keyboard.c2
-rw-r--r--src/features/fs.c24
-rw-r--r--src/inc/fs.h6
-rw-r--r--src/main.c1
5 files changed, 22 insertions, 16 deletions
diff --git a/src/drivers/interrupts.c b/src/drivers/interrupts.c
index edf5837..d65490c 100644
--- a/src/drivers/interrupts.c
+++ b/src/drivers/interrupts.c
@@ -4,6 +4,7 @@
#include <cpu.h>
#include <def.h>
#include <interrupts.h>
+#include <mem.h>
#include <serial.h>
/**
@@ -29,8 +30,8 @@ void idt_install()
idt_ptr.limit = (sizeof(struct idt_entry) * 256) - 1;
idt_ptr.base = &idt;
- // Clear IDT by setting memory cells to 0 // TODO
- //memset(&idt, 0, sizeof(struct idt_entry) * 256);
+ // Clear IDT by setting memory cells to 0
+ memset(&idt, 0, sizeof(struct idt_entry) * 256);
__asm__("lidt %0" : : "m"(idt_ptr));
}
diff --git a/src/drivers/keyboard.c b/src/drivers/keyboard.c
index 3bef356..558563e 100644
--- a/src/drivers/keyboard.c
+++ b/src/drivers/keyboard.c
@@ -9,7 +9,7 @@ u8 scancode;
void keyboard_handler()
{
scancode = inb(0x60);
- serial_print("KEY\n");
+ //serial_print("KEY\n");
//struct keyboard_event *event = malloc(sizeof(struct keyboard_event));
//event->scancode = scancode;
//event_trigger(MAP_KEYBOARD, (u8 *)event);
diff --git a/src/features/fs.c b/src/features/fs.c
index a90aaa9..123a178 100644
--- a/src/features/fs.c
+++ b/src/features/fs.c
@@ -56,20 +56,20 @@ void *read_file(struct inode *in)
int num_blocks = in->blocks / (BLOCK_SIZE / SECTOR_SIZE);
- // assert(num_blocks != 0);
+ //assert(num_blocks != 0);
if (!num_blocks)
return NULL;
u32 sz = BLOCK_SIZE * num_blocks;
void *buf = malloc(sz);
+ printf("Loading %dKiB\n", sz >> 10);
//assert(buf != NULL);
- int indirect = 0;
+ int indirect;
// Single indirect pointer
- if (num_blocks > 12) {
+ if (num_blocks > 12)
indirect = in->block[12];
- }
int blocknum = 0;
char *data;
@@ -77,14 +77,15 @@ void *read_file(struct inode *in)
if (i < 12) {
blocknum = in->block[i];
data = buffer_read(blocknum);
- memcpy((void *)((u32)buf + (i * BLOCK_SIZE)), data, BLOCK_SIZE);
- }
- if (i > 12) {
+ memcpy((u32 *)buf + i * BLOCK_SIZE, data, BLOCK_SIZE);
+ } else {
blocknum = read_indirect(indirect, i - 13);
data = buffer_read(blocknum);
- memcpy((void *)((u32)buf + ((i - 1) * BLOCK_SIZE)), data, BLOCK_SIZE);
+ memcpy((u32 *)buf + (i - 1) * BLOCK_SIZE, data, BLOCK_SIZE);
}
}
+
+ // TODO: Fix space between 1024 and 4096
return buf;
}
@@ -100,7 +101,7 @@ int find_inode(const char *name, int dir_inode)
for (u32 q = 0; q < i->blocks / 2; q++) {
char *data = buffer_read(i->block[q]);
- memcpy((void *)((u32)buf + (q * BLOCK_SIZE)), data, BLOCK_SIZE);
+ memcpy((u32 *)((u32)buf + (q * BLOCK_SIZE)), data, BLOCK_SIZE);
}
struct dirent *d = (struct dirent *)buf;
@@ -129,14 +130,14 @@ void ls_root()
for (u32 q = 0; q < i->blocks / 2; q++) {
char *data = buffer_read(i->block[q]);
- memcpy((void *)((u32)buf + (q * BLOCK_SIZE)), data, BLOCK_SIZE);
+ memcpy((u32 *)((u32)buf + (q * BLOCK_SIZE)), data, BLOCK_SIZE);
}
struct dirent *d = (struct dirent *)buf;
int sum = 0;
int calc = 0;
- printf("Root directory:\n");
+ printf("\nRoot directory:\n");
do {
calc = (sizeof(struct dirent) + d->name_len + 4) & ~0x3;
sum += d->total_len;
@@ -147,4 +148,5 @@ void ls_root()
d = (struct dirent *)((u32)d + d->total_len);
} while (sum < 1024);
+ printf("\n");
}
diff --git a/src/inc/fs.h b/src/inc/fs.h
index e5e1ca7..222939b 100644
--- a/src/inc/fs.h
+++ b/src/inc/fs.h
@@ -91,7 +91,9 @@ struct file {
u32 curr_block_pos;
};
-// DEMO ;)
-void ls_root();
+int find_inode(const char *name, int dir_inode);
+struct inode *get_inode(int i);
+void *read_file(struct inode *in);
+void ls_root(); // DEMO ;)
#endif
diff --git a/src/main.c b/src/main.c
index 7e4c083..a5e5409 100644
--- a/src/main.c
+++ b/src/main.c
@@ -28,6 +28,7 @@ void main(struct mem_info *mem_info, struct vid_info *vid_info)
printf("hello\n");
ls_root();
+ read_file(get_inode(find_inode("font24.bdf", 2)));
while (1) {
};