aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/fs
diff options
context:
space:
mode:
authorMarvin Borner2020-05-13 21:28:56 +0200
committerMarvin Borner2020-05-13 22:12:41 +0200
commita9c7529dcca845d98192ece62be70f752972216b (patch)
tree666d49ceb411a669abe6191151b2238fd7156c30 /src/kernel/fs
parente1a6ed079303dc7d218f1d5326a13b6755781271 (diff)
Replaced alloc.h with liballoc
And many more adaptions to the lib
Diffstat (limited to 'src/kernel/fs')
-rw-r--r--src/kernel/fs/elf.c14
-rw-r--r--src/kernel/fs/ext2.c10
-rw-r--r--src/kernel/fs/fs.c6
3 files changed, 15 insertions, 15 deletions
diff --git a/src/kernel/fs/elf.c b/src/kernel/fs/elf.c
index c89fd2e..a67ab6a 100644
--- a/src/kernel/fs/elf.c
+++ b/src/kernel/fs/elf.c
@@ -46,23 +46,23 @@ struct process *elf_load(char *path)
proc->registers.eip = header->entry;
paging_switch_directory(proc->cr3);
- u32 stk = (u32)kmalloc_a(PAGE_S);
- proc->registers.useresp = 0x40000000 - (PAGE_S / 2);
+ u32 stk = (u32)malloc(PAGE_SIZE);
+ proc->registers.useresp = 0x40000000 - (PAGE_SIZE / 2);
proc->registers.ebp = proc->registers.useresp;
proc->registers.esp = proc->registers.useresp;
- paging_map_user(proc->cr3, stk, 0x40000000 - PAGE_S);
+ paging_map(stk, 0x40000000 - PAGE_SIZE, PT_USER);
for (int i = 0; i < header->phnum; i++, program_header++) {
switch (program_header->type) {
case 0:
break;
case 1: {
- u32 loc = (u32)kmalloc_a(PAGE_S);
- paging_map_user(proc->cr3, loc, program_header->vaddr);
+ u32 loc = (u32)malloc(PAGE_SIZE);
+ paging_map(loc, program_header->vaddr, PT_USER);
memcpy((void *)program_header->vaddr,
((void *)((u32)file) + program_header->offset),
program_header->filesz);
- if (program_header->filesz > PAGE_S)
+ if (program_header->filesz > PAGE_SIZE)
panic("ELF binary section too large");
break;
}
@@ -71,6 +71,6 @@ struct process *elf_load(char *path)
}
}
- paging_switch_directory(paging_root_directory);
+ paging_switch_directory(paging_kernel_directory);
return proc;
} \ No newline at end of file
diff --git a/src/kernel/fs/ext2.c b/src/kernel/fs/ext2.c
index 3193f87..70c72aa 100644
--- a/src/kernel/fs/ext2.c
+++ b/src/kernel/fs/ext2.c
@@ -78,7 +78,7 @@ static void load_bgdt()
read_abs_sectors(bgdt_lba, bgdt_sectors, buf);
u32 bgdt_size = sizeof(struct bgd) * num_groups;
- bgdt = kmalloc(bgdt_size);
+ bgdt = malloc(bgdt_size);
memcpy(bgdt, buf, bgdt_size);
}
@@ -106,7 +106,7 @@ void ext2_open_inode(u32 inode_num, struct ext2_file *file)
read_inode(&file->inode, inode_num);
file->pos = 0;
file->block_index = 0;
- file->buf = kmalloc(block_size);
+ file->buf = malloc(block_size);
file->curr_block_pos = 0;
read_block(file->inode.dbp[0], file->buf);
@@ -136,7 +136,7 @@ u32 ext2_read(struct ext2_file *file, u8 *buf, u32 count)
file->block_index++;
if (file->block_index >= 12) {
// TODO: Add triple block pointer support
- u32 *tmp = kmalloc(block_size);
+ u32 *tmp = malloc(block_size);
read_block(file->inode.ibp, tmp);
read_block(tmp[file->block_index - 12], file->buf);
} else {
@@ -159,7 +159,7 @@ bool ext2_next_dirent(struct ext2_file *file, struct ext2_dirent *dir)
memcpy(dir, buf, READ_SIZE);
u32 size = dir->name_len + 1;
- u8 *name = kmalloc(size);
+ u8 *name = malloc(size);
if (ext2_read(file, name, size - 1) != size - 1)
return false;
@@ -192,7 +192,7 @@ u32 ext2_find_in_dir(u32 dir_inode, const char *name)
inode = 0;
cleanup:
- kfree(dir.buf);
+ free(dir.buf);
return inode;
}
diff --git a/src/kernel/fs/fs.c b/src/kernel/fs/fs.c
index a23b943..b9bada7 100644
--- a/src/kernel/fs/fs.c
+++ b/src/kernel/fs/fs.c
@@ -25,7 +25,7 @@ u32 read(char *path, u32 offset, u32 count, u8 *buf)
if (inode != 0) {
debug("Reading %s: %dKiB", path, count >> 10);
ext2_read(&file, buf, count);
- kfree(file.buf);
+ free(file.buf);
buf[count - 1] = '\0';
return buf;
} else {
@@ -49,9 +49,9 @@ u8 *read_file(char *path)
if (inode != 0) {
u32 size = file.inode.size;
debug("Reading %s: %dKiB", path, size >> 10);
- u8 *buf = kmalloc(size);
+ u8 *buf = malloc(size);
ext2_read(&file, buf, size);
- kfree(file.buf);
+ free(file.buf);
buf[size - 1] = '\0';
return buf;
} else {