I don't really remember what i did but it works so commit
This commit is contained in:
parent
da1c639f9f
commit
de38f1383d
4
makefile
4
makefile
|
|
@ -1,7 +1,7 @@
|
|||
CC := gcc
|
||||
AS := nasm
|
||||
CFLAGS:=-g -c -m32 -fno-pie -mno-sse -O3 -D __bits__=32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types -Wno-address-of-packed-member -Wno-discarded-qualifiers -fno-stack-protector -mno-red-zone -mno-sse -mno-sse2 -ffreestanding -nostdlib -mno-mmx
|
||||
CFLAGS_MODULE:=-g -c -m32 -mno-sse -O3 -D __bits__=32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types -Wno-address-of-packed-member -Wno-discarded-qualifiers -fno-stack-protector -mno-red-zone -mno-sse -mno-sse2 -ffreestanding -nostdlib -mno-mmx
|
||||
CFLAGS_MODULE:=-g -c -m32 -fpie -mno-sse -O3 -D __bits__=32 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-incompatible-pointer-types -Wno-address-of-packed-member -Wno-discarded-qualifiers -fno-stack-protector -mno-red-zone -mno-sse -mno-sse2 -ffreestanding -nostdlib -mno-mmx
|
||||
BL_ASFLAGS := -f bin
|
||||
SRCS := $(wildcard src/kernel/*/*.c)
|
||||
OBJS := $(patsubst src/kernel/%.c, bin/kernel/%.o, $(SRCS))
|
||||
|
|
@ -28,7 +28,7 @@ kernel:
|
|||
# ld -T linker.ld bin/kernel/entry.o bin/kernel/*.o -melf_i386
|
||||
ld -T linker.ld bin/kernel/*.o -melf_i386 -o kernel.elf
|
||||
ld -T linker.ld -o kernel_interface.elf -r -R kernel.elf -melf_i386
|
||||
ld bin/modules/disk_driver.o kernel_interface.elf -o idm.elf -melf_i386
|
||||
ld -pic bin/modules/disk_driver.o kernel_interface.elf -o idm.elf -melf_i386
|
||||
# %.o: $(SRCS)
|
||||
# mkdir -p bin/kernel/$(shell dirname $@)
|
||||
# $(CC) $(CFLAGS) $< -o $@
|
||||
|
|
|
|||
|
|
@ -332,9 +332,11 @@ part_2:
|
|||
je .find_fs_driver_no_disk
|
||||
mov [disk_module_struct.size], edx
|
||||
mov esi, eax
|
||||
and edx, 0xfffffc00
|
||||
add edx, 0x1000
|
||||
and edx, 0xfffff000
|
||||
add edx, 0x2000
|
||||
add [kload_paddr], edx
|
||||
; mov eax, [kload_paddr]
|
||||
; jmp $
|
||||
; debug
|
||||
mov edi, [kload_paddr]
|
||||
mov [disk_module_struct.ptr], edi
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ int pm_init(kernel_info_t *kernel_info){
|
|||
for(uint32_t i = 0; i < mmap_count; i++){
|
||||
pm_map[i] = 0xff;
|
||||
}
|
||||
mlog("KERNEL(MEMORY)", " BASE | LENGTH | TYPE\n", MLOG_PRINT);
|
||||
mlog("KERNEL", " BASE | LENGTH | TYPE\n --------|--------|----\n", MLOG_PRINT);
|
||||
for(uint32_t i = 0; i < kernel_info->mmap_entry_count; i++){
|
||||
for(uint32_t j = 0; j < (mmap[i].entry_length >> 12); j++){
|
||||
if(mmap[i].entry_base + (j << 12) <= mmap[i-1].entry_base + mmap[i-1].entry_length){
|
||||
|
|
@ -55,7 +55,7 @@ int pm_init(kernel_info_t *kernel_info){
|
|||
// printf("%d, %x, %d\n", j >> 3, pm_map[(mmap[i].entry_base >> 12 ) + (j >> 3)], mmap[i].type);
|
||||
// }
|
||||
}
|
||||
mlog("KERNEL(MEMORY)", " %x|%x|%d\n", MLOG_PRINT, (uint32_t)mmap[i].entry_base, (uint32_t)mmap[i].entry_length, mmap[i].type);
|
||||
mlog("KERNEL", " %x|%x|%d\n", MLOG_PRINT, (uint32_t)mmap[i].entry_base, (uint32_t)mmap[i].entry_length, mmap[i].type);
|
||||
// printf("%x", mmap[i].entry_length);
|
||||
// printf("|%d |\n", mmap[i].type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,23 +6,31 @@
|
|||
#include "drivers/pic.h"
|
||||
#include "drivers/cpuio.h"
|
||||
#include "system/scheduler.h"
|
||||
#include "system/modules.h"
|
||||
#include "system/elf.h"
|
||||
|
||||
kernel_info_t *boot_info = 0;
|
||||
|
||||
void pid0(){
|
||||
for(;;);
|
||||
}
|
||||
void sysinit(){
|
||||
|
||||
mlog("KERNEL", "PID 1 Started\n", MLOG_PRINT);
|
||||
init_modules(boot_info);
|
||||
for(;;);
|
||||
}
|
||||
extern void kmain(kernel_info_t *kernel_info){
|
||||
init_serial();
|
||||
pm_init(kernel_info);
|
||||
mlog("KERNEL", "Initializing IDT\n", MLOG_PRINT);
|
||||
init_idt();
|
||||
init_pic(32);
|
||||
pic_disable();
|
||||
pic_setmask(0xfe, PIC1_DATA);
|
||||
//TODO: Map and load filesystem and disk modules
|
||||
//TODO: Start Initial Process
|
||||
mlog("KERNEL", "Initializing Scheduler & starting PID 1\n", MLOG_PRINT);
|
||||
boot_info = kernel_info;
|
||||
init_scheduler();
|
||||
thread_start(pid0);
|
||||
thread_start(sysinit);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
char* log_info_types[] = {
|
||||
"",
|
||||
":DEBUG",
|
||||
"| DEBUG",
|
||||
"",
|
||||
":WARNING",
|
||||
":ERROR"
|
||||
"| WARNING",
|
||||
"| ERROR"
|
||||
};
|
||||
|
||||
void mlog(char *module, char *str, uint32_t type, ...){
|
||||
|
|
@ -15,6 +15,6 @@ void mlog(char *module, char *str, uint32_t type, ...){
|
|||
if(!type || type > 4){
|
||||
return;
|
||||
}
|
||||
printf("[ %s %s]", module, log_info_types[type]);
|
||||
printf("[ %s %s ]", module, log_info_types[type]);
|
||||
vprintf(str, vars);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#include "elf.h"
|
||||
#include "../shared/kstdlib.h"
|
||||
void *load_elf(void *file_data){
|
||||
|
||||
}
|
||||
|
|
@ -1,3 +1,37 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
void *load_elf(char *file_data);
|
||||
|
||||
#define ELF_SIG 0x464c457f
|
||||
#define ELF_BITS_32 1
|
||||
#define ELF_BITS_64 2
|
||||
#define ELF_ENDIAN_LITTLE 1
|
||||
#define ELF_ENDIAN_BIG 2
|
||||
#define ELF_TYPE_RELOC 1
|
||||
#define ELF_TYPE_EXEC 2
|
||||
#define ELF_TYPE_SHARED 3
|
||||
#define ELF_TYPE_CORE 4
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint32_t magic;
|
||||
uint8_t bits;
|
||||
uint8_t endianness;
|
||||
uint8_t elf_head_version;
|
||||
uint8_t abi;
|
||||
uint64_t padding;
|
||||
uint16_t type;
|
||||
uint16_t isa;
|
||||
uint32_t elf_version;
|
||||
uint32_t entry_offset;
|
||||
uint32_t program_header_offset;
|
||||
uint32_t section_table_offset;
|
||||
uint32_t flags;
|
||||
uint16_t elf_header_size;
|
||||
uint16_t program_entry_size;
|
||||
uint16_t program_entry_count;
|
||||
uint16_t section_entry_size;
|
||||
uint16_t section_entry_count;
|
||||
uint16_t section_strtab_index;
|
||||
}__attribute__((packed)) elf_header_t;
|
||||
|
||||
void *load_elf(void *file_data);
|
||||
|
|
@ -1,2 +1,13 @@
|
|||
#include "modules.h"
|
||||
#include "../shared/kstdlib.h"
|
||||
#include "elf.h"
|
||||
|
||||
void init_modules(kernel_info_t *kernel_info){
|
||||
mlog("Module Loader", "Initializing Boot-Time Modules", MLOG_PRINT);
|
||||
kernel_module_t *module = kernel_info->loaded_modules;
|
||||
while(module){
|
||||
// printf("Module Type: %x, Module Size (Bytes): %x, Ptr: %x\n", module->type, module->size, module->ptr);
|
||||
load_elf(module->ptr);
|
||||
module = module->link;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +1,4 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdint.h>
|
||||
#include "../shared/kstdlib.h"
|
||||
void init_modules(kernel_info_t *kernel_info);
|
||||
Loading…
Reference in New Issue