Added an unfinished PMM. Breaks build
This commit is contained in:
parent
0e73954ea4
commit
e1203d8271
7 changed files with 74 additions and 14 deletions
|
@ -1,12 +1,11 @@
|
|||
CROSSPATH=$HOME/opt # You can change it to whatever you want
|
||||
CROSSPATH=/usr/local # You can change it to whatever you want
|
||||
export PATH=$CROSSPATH/bin:$PATH
|
||||
function buildscript() {
|
||||
date "[+%c] " | tr -d '\n' | tee buildlog
|
||||
echo "Building binutils for $1" | tee buildlog
|
||||
echo "[$(date +%c)] Building binutils for $1" | tee buildlog
|
||||
mkdir build-binutils
|
||||
cd build-binutils
|
||||
../binutils-2.26/configure --prefix=$CROSSPATH --target=$1 --with-sysroot --disable-nls --disable-werror
|
||||
make -j2
|
||||
make -j8
|
||||
make install
|
||||
cd ..
|
||||
rm -rf build-binutils
|
||||
|
@ -15,8 +14,8 @@ function buildscript() {
|
|||
mkdir build-gcc
|
||||
cd build-gcc
|
||||
../gcc-5.3.0/configure --prefix=$CROSSPATH --target=$1 --disable-nls --enable-languages=c,c++ --without-headers
|
||||
make all-gcc
|
||||
make all-target-libgcc
|
||||
make all-gcc -j8
|
||||
make all-target-libgcc -j8
|
||||
make install-gcc
|
||||
make install-target-libgcc
|
||||
cd ..
|
||||
|
@ -33,11 +32,11 @@ echo "Untaring..."
|
|||
tar -xf gcc-5.3.0.tar.bz2
|
||||
tar -xf binutils-2.26.tar.bz2
|
||||
cd gcc-5.3.0
|
||||
tar -xf mpc-1.0.3.tar.gz
|
||||
tar -xf ../mpc-1.0.3.tar.gz
|
||||
mv mpc-1.0.3 mpc
|
||||
tar -xf mpfr-3.1.3.tar.xz
|
||||
tar -xf ../mpfr-3.1.3.tar.xz
|
||||
mv mpfr-3.1.3 mpfr
|
||||
tar -xf gmp-6.1.0.tar.xz
|
||||
tar -xf ../gmp-6.1.0.tar.xz
|
||||
mv gmp-6.1.0 gmp
|
||||
cd ..
|
||||
echo "Preperation done. Beginning the compilation now."
|
||||
|
@ -45,5 +44,6 @@ buildscript i686-elf #x86 port
|
|||
buildscript arm-none-eabi #ARM ports (3DS, pi)
|
||||
buildscript armeb-eabi #Wii port
|
||||
buildscript ppc-elf #Wii port
|
||||
buildscript x86_64-elf #x86_64 port
|
||||
rm -rf gcc* binutils* mpc* mpfr* gmp*
|
||||
echo "Done! Have fun with your cross compilers!"
|
||||
echo "Done! Have fun with your cross compilers!"
|
||||
|
|
|
@ -5,8 +5,8 @@ OBJS = $(addsuffix .o,$(basename $(SRCS)))
|
|||
CPP = $(PREFIX)g++
|
||||
CC = $(PREFIX)gcc
|
||||
ASFLAGS = -m32
|
||||
CFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -ffreestanding -march=native -std=c11 -fno-builtin -Werror -nostdlib -g
|
||||
CPPFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -march=native -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g
|
||||
CFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -ffreestanding -march=native -std=c11 -fno-builtin -Werror -nostdlib -g -fpie
|
||||
CPPFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -fno-rtti -fno-exceptions -ffreestanding -march=native -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie
|
||||
LDFLAGS = -r -melf_i386
|
||||
|
||||
|
||||
|
|
17
kernel/hal/x86/include/pmm.hpp
Normal file
17
kernel/hal/x86/include/pmm.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef _PMM_HPP
|
||||
#define _PMM_HPP
|
||||
#include <stdint.h>
|
||||
#include <multiboot.h>
|
||||
class PMM {
|
||||
private:
|
||||
uint32_t bitmap[0x8000]; //Enough for 4 GB
|
||||
PMM() {}
|
||||
auto markUsed(void * addr) -> void;
|
||||
public:
|
||||
PMM(struct multiboot_info*);
|
||||
auto operator >> (void * &addr) -> PMM &; //alloc
|
||||
auto operator << (const void * addr) -> PMM &; //free
|
||||
auto operator()(int pages) -> void*; //alloc_multipage
|
||||
|
||||
};
|
||||
#endif
|
|
@ -44,12 +44,17 @@ namespace MTGosHAL {
|
|||
}
|
||||
}
|
||||
typedef void (*constructor)();
|
||||
typedef void (*destructor)();
|
||||
extern "C" constructor start_ctors;
|
||||
extern "C" constructor end_ctors;
|
||||
extern "C" destructor start_dtors;
|
||||
extern "C" destructor end_dtors;
|
||||
extern "C" void init(int eax, struct multiboot_info* ebx) {
|
||||
for(constructor* i = &start_ctors; i != &end_ctors; ++i)
|
||||
(*i)();
|
||||
MTGosHAL::main(eax, ebx);
|
||||
for(destructor* i = &start_dtors; i != &end_dtors; i++)
|
||||
(*i)();
|
||||
}
|
||||
extern "C" void __cxa_pure_virtual() {
|
||||
MTGosHAL::debug << "A pure virtual function just got called.\n";
|
||||
|
|
35
kernel/hal/x86/mm/pmm.cpp
Normal file
35
kernel/hal/x86/mm/pmm.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <pmm.hpp>
|
||||
#include <multiboot.h>
|
||||
extern "C" const int kernel_start;
|
||||
extern "C" const int kernel_end; //those are voids actually
|
||||
PMM::PMM(struct multiboot_info * mb_info) {
|
||||
for(int i=0;i<0x8000;i++)
|
||||
bitmap[i]=0;
|
||||
struct multiboot_mmap_entry* mmap = (struct multiboot_mmap_entry*) mb_info->mmap_addr;
|
||||
struct multiboot_mmap_entry* mmap_end = (struct multiboot_mmap_entry*) ((unsigned int) mb_info->mmap_addr + mb_info->mmap_length);
|
||||
while (mmap < mmap_end) {
|
||||
if (mmap->type == 1) {
|
||||
// Der Speicherbereich ist frei, entsprechend markieren
|
||||
uintptr_t addr = mmap->addr;
|
||||
uintptr_t end_addr = addr + mmap->len;
|
||||
while (addr < end_addr) {
|
||||
*this << (void*) addr;
|
||||
addr += 0x1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
mmap++;
|
||||
unsigned int addr = (unsigned int) &kernel_start;
|
||||
while(addr < (unsigned int) &kernel_end) {
|
||||
markUsed((void*)addr);
|
||||
addr+=0x1000;
|
||||
}
|
||||
}
|
||||
auto PMM::markUsed(void * addr) -> void {
|
||||
unsigned int address=(unsigned int)addr;
|
||||
address>>=12;
|
||||
int index=address>>5;
|
||||
int bit=1<<(address&0x1F);
|
||||
bitmap[index]&=~bit;
|
||||
}
|
||||
//auto PMM::operator >> (void * &addr) -> PMM &;
|
|
@ -4,6 +4,7 @@ OUTPUT_ARCH(i386:i386)
|
|||
SECTIONS
|
||||
{
|
||||
. = 0x100000;
|
||||
kernel_start = .;
|
||||
.text : {
|
||||
*(multiboot)
|
||||
*(.text)
|
||||
|
@ -25,4 +26,6 @@ SECTIONS
|
|||
.bss ALIGN(4096) : {
|
||||
*(.bss)
|
||||
}
|
||||
. = ALIGN(4096);
|
||||
kernel_end = .;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ OBJS = $(addsuffix .o,$(basename $(SRCS)))
|
|||
CPP = $(PREFIX)g++
|
||||
CC = $(PREFIX)gcc
|
||||
ASFLAGS = -m32
|
||||
CFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../hal/dummy/c_include -ffreestanding -march=native -std=c11 -fno-builtin -Werror -nostdlib -g
|
||||
CPPFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../hal/dummy/include -I../hal/dummy/c_include -fno-rtti -fno-exceptions -ffreestanding -march=native -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g
|
||||
CFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../hal/dummy/c_include -ffreestanding -march=native -std=c11 -fno-builtin -Werror -nostdlib -g -fpie
|
||||
CPPFLAGS = -m32 -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../hal/dummy/include -I../hal/dummy/c_include -fno-rtti -fno-exceptions -ffreestanding -march=native -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpie
|
||||
all: $(OBJS)
|
||||
|
||||
%.o: %.cpp
|
||||
|
|
Loading…
Reference in a new issue