Make not working
This commit is contained in:
41
install-crosscompiler.sh
Normal file
41
install-crosscompiler.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
# Install requirements
|
||||
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo
|
||||
|
||||
# Configuration
|
||||
export PREFIX="$HOME/opt/cross"
|
||||
export TARGET=i686-elf
|
||||
export PATH="$PREFIX/bin:$PATH"
|
||||
|
||||
# Create directories
|
||||
mkdir $HOME/src
|
||||
|
||||
# Download binutils + gcc
|
||||
wget https://ftp.nluug.nl/pub/gnu/binutils/binutils-2.31.tar.xz -O $HOME/src/binutils-2.31.tar.xz
|
||||
wget https://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz -O $HOME/src/gcc-8.2.0.tar.xz
|
||||
|
||||
# Decompress
|
||||
cd $HOME/src
|
||||
tar -xf binutils-2.31.tar.xz
|
||||
tar -xf gcc-8.2.0.tar.xz
|
||||
|
||||
# Build binutils
|
||||
cd $HOME/src
|
||||
mkdir build-binutils
|
||||
cd build-binutils
|
||||
../binutils-2.31/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
|
||||
make -j4
|
||||
make install
|
||||
|
||||
# Build GCC
|
||||
cd $HOME/src
|
||||
which -- $TARGET-as || echo $TARGET-as is not in the PATH
|
||||
mkdir build-gcc
|
||||
cd build-gcc
|
||||
../gcc-8.2.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
|
||||
make all-gcc -j4
|
||||
make all-target-libgcc -j4
|
||||
make install-gcc
|
||||
make install-target-libgcc
|
||||
|
||||
export PATH="$HOME/opt/cross/bin:$PATH"
|
||||
echo "Done!"
|
||||
49
kernel.asm
49
kernel.asm
@@ -1,21 +1,34 @@
|
||||
;;kernel.asm
|
||||
bits 32 ; tells nasm to use 32 bit
|
||||
section .text
|
||||
;multiboot spec
|
||||
align 4
|
||||
dd 0x1BADB002 ;magic
|
||||
dd 0x00 ;flags
|
||||
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero
|
||||
/* Declare constants for the multiboot header. */
|
||||
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */
|
||||
.set MEMINFO, 1<<1 /* provide memory map */
|
||||
.set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */
|
||||
.set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
|
||||
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */
|
||||
|
||||
.section .multiboot
|
||||
.align 4
|
||||
.long MAGIC
|
||||
.long FLAGS
|
||||
.long CHECKSUM
|
||||
|
||||
.section .bss
|
||||
.align 16
|
||||
stack_bottom:
|
||||
.skip 16384 ; 16 KiB
|
||||
stack_top:
|
||||
|
||||
global start
|
||||
extern kmain
|
||||
.section .text
|
||||
.global _start
|
||||
.type _start, @function
|
||||
_start:
|
||||
mov $stack_top, %esp
|
||||
call kernel_main
|
||||
cli
|
||||
1: hlt
|
||||
jmp 1b
|
||||
|
||||
start:
|
||||
cli ; blocks interupts i think
|
||||
mov ESP, stack_space ; sets stack pointer
|
||||
call kmain ; calls kmain c++ function
|
||||
hlt ; halts CPU
|
||||
_hang:
|
||||
hlt
|
||||
jmp _hang
|
||||
|
||||
section .bss
|
||||
resb 8192 ; 8 kb stack
|
||||
stack_space:
|
||||
.size _start, . - _start
|
||||
@@ -1,4 +1,4 @@
|
||||
void kmain(void) {
|
||||
int kernel_main(void) {
|
||||
const char* str = "Your mother gay lol";
|
||||
char* videoMemoryPtr = (char*)0xb8000; // Video memory start
|
||||
|
||||
@@ -20,5 +20,5 @@ void kmain(void) {
|
||||
i += 2;
|
||||
}
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
20
makefile
20
makefile
@@ -1,18 +1,19 @@
|
||||
# ThanOS
|
||||
# Copyright Benjamin Kyd (c) 2018
|
||||
|
||||
# CONFIGURATION
|
||||
DELETE = rm -f
|
||||
|
||||
# DIRECTORIES
|
||||
SRC_DIR = ./
|
||||
LIB_DIR = ./libs
|
||||
SHELL_DIR = ./shell
|
||||
OBJ_DIR = ./obj
|
||||
INC_DIR = ./libs/includes
|
||||
|
||||
# C++
|
||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
LIB_FILES = $(wildcard $(LIB_DIR)/*.cpp)
|
||||
SHELL_FILES = $(wildcard $(SHELL_DIR)/*.cpp)
|
||||
CPP_OBJ = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(LIB_FILES)) $(patsubst $(SHELL_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SHELL_FILES))
|
||||
CPP_OBJ = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) $(patsubst $(LIB_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(LIB_FILES))
|
||||
|
||||
# ASSEMBLY
|
||||
ASM_SRC = $(wildcard $(SRC_DIR)/*.asm)
|
||||
@@ -24,12 +25,12 @@ ASM_OBJ = $(patsubst $(SRC_DIR)/%.asm,$(OBJ_DIR)/%.o,$(ASM_SRC)) $(patsubst $(LI
|
||||
GPP_CMD = i686-elf-g++
|
||||
GAS_CMD = i686-elf-as
|
||||
LDFLAGS = -T linker.ld -ffreestanding -O2 -nostdlib -lgcc -Wwrite-strings
|
||||
CPPFLAGS = -I $(INC_DIR) -ffreestanding -O2 -fno-rtti -Wno-write-strings -Wno-unused-variable -Wno-multichar -Wno-unused-parameter -Wno-overflow -Wno-narrowing -fno-exceptions
|
||||
CPPFLAGS = -I $(INC_DIR) -ffreestanding -O2 -fno-rtti -Wno-write-strings -Wno-multichar -Wno-unused-parameter -Wno-overflow -Wno-narrowing -fno-exceptions -Wno-trigraphs
|
||||
CXXFLAGS =
|
||||
GASFLAGS =
|
||||
OBJ_FILES = $(CPP_OBJ) $(ASM_OBJ)
|
||||
OUTPUT = ./bin/MemeOS.bin
|
||||
ISO_OUTPUT = ./bin/MemeOS.iso
|
||||
OUTPUT = ./bin/ThanOS.bin
|
||||
ISO_OUTPUT = ./bin/ThanOS.iso
|
||||
|
||||
all: $(OUTPUT)
|
||||
|
||||
@@ -38,7 +39,7 @@ clean:
|
||||
$(DELETE) ./bin/*
|
||||
|
||||
iso: all
|
||||
cp $(OUTPUT) ./ISO/boot/MemeOS
|
||||
cp $(OUTPUT) ./ISO/boot/ThanOS
|
||||
grub-mkrescue -o $(ISO_OUTPUT) ./ISO
|
||||
|
||||
folders:
|
||||
@@ -53,10 +54,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
|
||||
$(OBJ_DIR)/%.o: $(LIB_DIR)/%.cpp
|
||||
$(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SHELL_DIR)/%.cpp
|
||||
$(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
|
||||
$(GAS_CMD) $(GASFLAGS) -o $@ $<
|
||||
|
||||
|
||||
BIN
obj/kernel.o
Normal file
BIN
obj/kernel.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user