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
|
/* Declare constants for the multiboot header. */
|
||||||
bits 32 ; tells nasm to use 32 bit
|
.set ALIGN, 1<<0 /* align loaded modules on page boundaries */
|
||||||
section .text
|
.set MEMINFO, 1<<1 /* provide memory map */
|
||||||
;multiboot spec
|
.set FLAGS, ALIGN | MEMINFO /* this is the Multiboot 'flag' field */
|
||||||
align 4
|
.set MAGIC, 0x1BADB002 /* 'magic number' lets bootloader find the header */
|
||||||
dd 0x1BADB002 ;magic
|
.set CHECKSUM, -(MAGIC + FLAGS) /* checksum of above, to prove we are multiboot */
|
||||||
dd 0x00 ;flags
|
|
||||||
dd - (0x1BADB002 + 0x00) ;checksum. m+f+c should be zero
|
.section .multiboot
|
||||||
|
.align 4
|
||||||
|
.long MAGIC
|
||||||
|
.long FLAGS
|
||||||
|
.long CHECKSUM
|
||||||
|
|
||||||
|
.section .bss
|
||||||
|
.align 16
|
||||||
|
stack_bottom:
|
||||||
|
.skip 16384 ; 16 KiB
|
||||||
|
stack_top:
|
||||||
|
|
||||||
global start
|
.section .text
|
||||||
extern kmain
|
.global _start
|
||||||
|
.type _start, @function
|
||||||
|
_start:
|
||||||
|
mov $stack_top, %esp
|
||||||
|
call kernel_main
|
||||||
|
cli
|
||||||
|
1: hlt
|
||||||
|
jmp 1b
|
||||||
|
|
||||||
start:
|
_hang:
|
||||||
cli ; blocks interupts i think
|
hlt
|
||||||
mov ESP, stack_space ; sets stack pointer
|
jmp _hang
|
||||||
call kmain ; calls kmain c++ function
|
|
||||||
hlt ; halts CPU
|
|
||||||
|
|
||||||
section .bss
|
.size _start, . - _start
|
||||||
resb 8192 ; 8 kb stack
|
|
||||||
stack_space:
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
void kmain(void) {
|
int kernel_main(void) {
|
||||||
const char* str = "Your mother gay lol";
|
const char* str = "Your mother gay lol";
|
||||||
char* videoMemoryPtr = (char*)0xb8000; // Video memory start
|
char* videoMemoryPtr = (char*)0xb8000; // Video memory start
|
||||||
|
|
||||||
@@ -20,5 +20,5 @@ void kmain(void) {
|
|||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return 1;
|
||||||
}
|
}
|
||||||
20
makefile
20
makefile
@@ -1,18 +1,19 @@
|
|||||||
|
# ThanOS
|
||||||
|
# Copyright Benjamin Kyd (c) 2018
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
DELETE = rm -f
|
DELETE = rm -f
|
||||||
|
|
||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
SRC_DIR = ./
|
SRC_DIR = ./
|
||||||
LIB_DIR = ./libs
|
LIB_DIR = ./libs
|
||||||
SHELL_DIR = ./shell
|
|
||||||
OBJ_DIR = ./obj
|
OBJ_DIR = ./obj
|
||||||
INC_DIR = ./libs/includes
|
INC_DIR = ./libs/includes
|
||||||
|
|
||||||
# C++
|
# C++
|
||||||
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
|
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
|
||||||
LIB_FILES = $(wildcard $(LIB_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))
|
||||||
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))
|
|
||||||
|
|
||||||
# ASSEMBLY
|
# ASSEMBLY
|
||||||
ASM_SRC = $(wildcard $(SRC_DIR)/*.asm)
|
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++
|
GPP_CMD = i686-elf-g++
|
||||||
GAS_CMD = i686-elf-as
|
GAS_CMD = i686-elf-as
|
||||||
LDFLAGS = -T linker.ld -ffreestanding -O2 -nostdlib -lgcc -Wwrite-strings
|
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 =
|
CXXFLAGS =
|
||||||
GASFLAGS =
|
GASFLAGS =
|
||||||
OBJ_FILES = $(CPP_OBJ) $(ASM_OBJ)
|
OBJ_FILES = $(CPP_OBJ) $(ASM_OBJ)
|
||||||
OUTPUT = ./bin/MemeOS.bin
|
OUTPUT = ./bin/ThanOS.bin
|
||||||
ISO_OUTPUT = ./bin/MemeOS.iso
|
ISO_OUTPUT = ./bin/ThanOS.iso
|
||||||
|
|
||||||
all: $(OUTPUT)
|
all: $(OUTPUT)
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ clean:
|
|||||||
$(DELETE) ./bin/*
|
$(DELETE) ./bin/*
|
||||||
|
|
||||||
iso: all
|
iso: all
|
||||||
cp $(OUTPUT) ./ISO/boot/MemeOS
|
cp $(OUTPUT) ./ISO/boot/ThanOS
|
||||||
grub-mkrescue -o $(ISO_OUTPUT) ./ISO
|
grub-mkrescue -o $(ISO_OUTPUT) ./ISO
|
||||||
|
|
||||||
folders:
|
folders:
|
||||||
@@ -53,10 +54,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
|||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(LIB_DIR)/%.cpp
|
$(OBJ_DIR)/%.o: $(LIB_DIR)/%.cpp
|
||||||
$(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
$(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SHELL_DIR)/%.cpp
|
|
||||||
$(GPP_CMD) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
|
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.asm
|
||||||
$(GAS_CMD) $(GASFLAGS) -o $@ $<
|
$(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