This commit is contained in:
Baptiste Wicht 2014-01-08 21:34:01 +01:00
parent d25e567201
commit dfd32786f9
6 changed files with 17 additions and 21 deletions

View File

@ -34,15 +34,16 @@ qemu: default
qemu-kvm -cpu host -hda hdd.img
bochs: default
echo "c" > commands
bochs -qf bochsrc.txt -rc commands
rm commands
bochs -qf bochsrc.txt
debug: default
echo "c" > commands
bochs -qf debug_bochsrc.txt -rc commands
rm commands
gdb: default
bochs -qf gdb_bochsrc.txt
force_look:
true

2
cpp.mk
View File

@ -3,7 +3,7 @@ AS=x86_64-elf-as
OC=x86_64-elf-objcopy
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

5
gdb_bochsrc.txt Normal file
View 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

View File

@ -52,7 +52,7 @@ src/stl/%.cpp.o:
kernel.bin: $(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:
echo $(KERNEL_CPP_STL_FILES)

View File

@ -10,7 +10,7 @@
#include "paging.hpp"
#include "e820.hpp"
namespace {
namespace debugging {
//Used to compile with malloc operations in the console
//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;
malloc_header_chunk* malloc_head = 0;
const e820::mmapentry* current_mmap_entry = nullptr;
uintptr_t current_mmap_entry_position;
const e820::mmapentry* current_mmap_entry = 0;
uintptr_t current_mmap_entry_position = 0;
//All allocated memory is in [min_address, max_address[
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){
return nullptr;
}
auto block = reinterpret_cast<uint64_t*>(current_mmap_entry_position);
paging::identity_map(block, blocks);
@ -212,28 +206,24 @@ void init_head(){
}
void expand_heap(malloc_header_chunk* current){
asm volatile("xchg bx, bx");
//Allocate a new block of memory
uint64_t* block = allocate_block(MIN_BLOCKS);
//Transform it into a malloc chunk
auto header = reinterpret_cast<malloc_header_chunk*>(block);
asm volatile("xchg bx, bx");
//Update the sizes
header->size() = MIN_BLOCKS * BLOCK_SIZE - META_SIZE;
header->footer()->size() = header->size();
asm volatile("xchg bx, bx");
//Insert the new block into the free list
insert_after(current, header);
}
} //end of anonymous namespace
using namespace debugging;
void init_memory_manager(){
//Init the fake head
init_head();

Binary file not shown.