mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-18 01:01:57 -04:00
Fix bugs
This commit is contained in:
parent
d25e567201
commit
dfd32786f9
7
Makefile
7
Makefile
@ -34,15 +34,16 @@ qemu: default
|
|||||||
qemu-kvm -cpu host -hda hdd.img
|
qemu-kvm -cpu host -hda hdd.img
|
||||||
|
|
||||||
bochs: default
|
bochs: default
|
||||||
echo "c" > commands
|
bochs -qf bochsrc.txt
|
||||||
bochs -qf bochsrc.txt -rc commands
|
|
||||||
rm commands
|
|
||||||
|
|
||||||
debug: default
|
debug: default
|
||||||
echo "c" > commands
|
echo "c" > commands
|
||||||
bochs -qf debug_bochsrc.txt -rc commands
|
bochs -qf debug_bochsrc.txt -rc commands
|
||||||
rm commands
|
rm commands
|
||||||
|
|
||||||
|
gdb: default
|
||||||
|
bochs -qf gdb_bochsrc.txt
|
||||||
|
|
||||||
force_look:
|
force_look:
|
||||||
true
|
true
|
||||||
|
|
||||||
|
2
cpp.mk
2
cpp.mk
@ -3,7 +3,7 @@ AS=x86_64-elf-as
|
|||||||
OC=x86_64-elf-objcopy
|
OC=x86_64-elf-objcopy
|
||||||
|
|
||||||
WARNING_FLAGS=-Wall -Wextra -pedantic -Wold-style-cast -Wshadow
|
WARNING_FLAGS=-Wall -Wextra -pedantic -Wold-style-cast -Wshadow
|
||||||
COMMON_CPP_FLAGS=-masm=intel -Iinclude/ -nostdlib -Os -std=c++11 -fno-stack-protector -fno-exceptions -funsigned-char -fno-rtti -ffreestanding -fomit-frame-pointer -mno-red-zone -mno-3dnow -mno-mmx -fno-asynchronous-unwind-tables
|
COMMON_CPP_FLAGS=-masm=intel -Iinclude/ -nostdlib -g -Os -std=c++11 -fno-stack-protector -fno-exceptions -funsigned-char -fno-rtti -ffreestanding -fomit-frame-pointer -mno-red-zone -mno-3dnow -mno-mmx -fno-asynchronous-unwind-tables
|
||||||
|
|
||||||
CPP_FLAGS_LOW=-march=i386 -m32 -fno-strict-aliasing -fno-pic -fno-toplevel-reorder -mno-sse -mno-sse2 -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2
|
CPP_FLAGS_LOW=-march=i386 -m32 -fno-strict-aliasing -fno-pic -fno-toplevel-reorder -mno-sse -mno-sse2 -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2
|
||||||
|
|
||||||
|
5
gdb_bochsrc.txt
Normal file
5
gdb_bochsrc.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
display_library: sdl
|
||||||
|
magic_break: enabled=1
|
||||||
|
gdbstub: enabled=1, port=1234
|
||||||
|
ata0-master: type=disk, path="hdd.img", mode=flat, cylinders=1000, heads=16, spt=63
|
||||||
|
boot: disk
|
@ -52,7 +52,7 @@ src/stl/%.cpp.o:
|
|||||||
|
|
||||||
kernel.bin: $(LINK_O_FILES)
|
kernel.bin: $(LINK_O_FILES)
|
||||||
$(CC) $(KERNEL_LINK_FLAGS) $(CPP_FLAGS_64) -o kernel.bin.o $(LINK_O_FILES)
|
$(CC) $(KERNEL_LINK_FLAGS) $(CPP_FLAGS_64) -o kernel.bin.o $(LINK_O_FILES)
|
||||||
$(OC) -R .note -R .comment -S -O binary kernel.bin.o kernel.bin
|
$(OC) -R .note -R .comment -O binary --set-section-flags .bss=alloc,load,contents kernel.bin.o kernel.bin
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
echo $(KERNEL_CPP_STL_FILES)
|
echo $(KERNEL_CPP_STL_FILES)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "paging.hpp"
|
#include "paging.hpp"
|
||||||
#include "e820.hpp"
|
#include "e820.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace debugging {
|
||||||
|
|
||||||
//Used to compile with malloc operations in the console
|
//Used to compile with malloc operations in the console
|
||||||
//can produce a lot of output
|
//can produce a lot of output
|
||||||
@ -98,8 +98,8 @@ static_assert(MIN_SPLIT == aligned_size(MIN_SPLIT), "The size of minimum split m
|
|||||||
fake_head head;
|
fake_head head;
|
||||||
malloc_header_chunk* malloc_head = 0;
|
malloc_header_chunk* malloc_head = 0;
|
||||||
|
|
||||||
const e820::mmapentry* current_mmap_entry = nullptr;
|
const e820::mmapentry* current_mmap_entry = 0;
|
||||||
uintptr_t current_mmap_entry_position;
|
uintptr_t current_mmap_entry_position = 0;
|
||||||
|
|
||||||
//All allocated memory is in [min_address, max_address[
|
//All allocated memory is in [min_address, max_address[
|
||||||
uintptr_t min_address; //Address of the first block being allocated
|
uintptr_t min_address; //Address of the first block being allocated
|
||||||
@ -120,16 +120,10 @@ uint64_t* allocate_block(uint64_t blocks){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asm volatile("xchg bx, bx");
|
|
||||||
|
|
||||||
|
|
||||||
if(!current_mmap_entry){
|
if(!current_mmap_entry){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto block = reinterpret_cast<uint64_t*>(current_mmap_entry_position);
|
auto block = reinterpret_cast<uint64_t*>(current_mmap_entry_position);
|
||||||
|
|
||||||
paging::identity_map(block, blocks);
|
paging::identity_map(block, blocks);
|
||||||
@ -212,28 +206,24 @@ void init_head(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void expand_heap(malloc_header_chunk* current){
|
void expand_heap(malloc_header_chunk* current){
|
||||||
asm volatile("xchg bx, bx");
|
|
||||||
|
|
||||||
//Allocate a new block of memory
|
//Allocate a new block of memory
|
||||||
uint64_t* block = allocate_block(MIN_BLOCKS);
|
uint64_t* block = allocate_block(MIN_BLOCKS);
|
||||||
|
|
||||||
//Transform it into a malloc chunk
|
//Transform it into a malloc chunk
|
||||||
auto header = reinterpret_cast<malloc_header_chunk*>(block);
|
auto header = reinterpret_cast<malloc_header_chunk*>(block);
|
||||||
|
|
||||||
asm volatile("xchg bx, bx");
|
|
||||||
|
|
||||||
//Update the sizes
|
//Update the sizes
|
||||||
header->size() = MIN_BLOCKS * BLOCK_SIZE - META_SIZE;
|
header->size() = MIN_BLOCKS * BLOCK_SIZE - META_SIZE;
|
||||||
header->footer()->size() = header->size();
|
header->footer()->size() = header->size();
|
||||||
|
|
||||||
asm volatile("xchg bx, bx");
|
|
||||||
|
|
||||||
//Insert the new block into the free list
|
//Insert the new block into the free list
|
||||||
insert_after(current, header);
|
insert_after(current, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end of anonymous namespace
|
} //end of anonymous namespace
|
||||||
|
|
||||||
|
using namespace debugging;
|
||||||
|
|
||||||
void init_memory_manager(){
|
void init_memory_manager(){
|
||||||
//Init the fake head
|
//Init the fake head
|
||||||
init_head();
|
init_head();
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user