Added boots compilation stuff. Although bochs keeps seg faulting (lol wut)

Now makefile generates disasm for debugging
This commit is contained in:
secXsQuared 2016-06-04 16:14:50 -07:00
parent 2139c367d9
commit 32259f3dc7
11 changed files with 1324 additions and 158 deletions

20
bochs_compile/compile_gdb.sh Executable file
View File

@ -0,0 +1,20 @@
cd src
./configure --enable-cpu-level=6 \
--enable-all-optimizations \
--enable-x86-64 \
--enable-pci \
--enable-vmx \
--enable-disasm \
--enable-logging \
--enable-fpu \
--enable-3dnow \
--enable-sb16=dummy \
--enable-cdrom \
--enable-iodebug \
--disable-plugins \
--disable-docbook \
--enable-gdb-stub \
--with-x --with-x11 --with-term --with-sdl
make

23
bochs_compile/compile_idb.sh Executable file
View File

@ -0,0 +1,23 @@
cd src
./configure --enable-smp \
--enable-cpu-level=6 \
--enable-all-optimizations \
--enable-x86-64 \
--enable-pci \
--enable-vmx \
--enable-debugger \
--enable-disasm \
--enable-debugger-gui \
--enable-logging \
--enable-fpu \
--enable-3dnow \
--enable-sb16=dummy \
--enable-cdrom \
--enable-x86-debugger \
--enable-iodebug \
--disable-plugins \
--disable-docbook \
--with-x --with-x11 --with-term --with-sdl
make

23
x64/CMakeLists.txt Normal file
View File

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 2.8.4)
project(Workspace)
MACRO(HEADER_DIRECTORIES return_list)
FILE(GLOB_RECURSE new_list ./*.h)
SET(dir_list "")
FOREACH(file_path ${new_list})
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
SET(dir_list ${dir_list} ${dir_path})
ENDFOREACH()
LIST(REMOVE_DUPLICATES dir_list)
SET(${return_list} ${dir_list})
ENDMACRO()
HEADER_DIRECTORIES(header_dirs)
include_directories(${header_dirs})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
file(GLOB_RECURSE SOURCE_FILES ./*.h ./*.c)
add_executable(Workspace ${SOURCE_FILES})

1226
x64/bochs.bxrc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, gameport=1
config_interface: win32config
display_library: win32
memory: host=256, guest=256
romimage: file="bochs/BIOS-bochs-latest"
vgaromimage: file="bochs/VGABIOS-lgpl-latest"
boot: cdrom
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="HOS.iso", status=inserted, model="Generic 1234", biosdetect=auto
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5
cpu: count=1, ips=4000000, model=bx_generic, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, x86_64=1, 1g_pages=1, pcid=0, fsgsbase=1
cpuid: smep=0, smap=0, mwait=1, vmx=1
print_timestamps: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
sound: driver="default", waveout=none, wavein=none
speaker: enabled=1, mode=sound
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0

View File

@ -1,55 +0,0 @@
# configuration file generated by Bochs
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, gameport=1, pci_ide=1, acpi=1, ioapic=1
config_interface: textconfig
display_library: sdl
magic_break: enabled=1
memory: host=128, guest=128
romimage: file="/usr/share/bochs/BIOS-bochs-latest"
vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest"
boot: cdrom
floppy_bootsig_check: disabled=0
# no floppya
# no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="secX.iso", status=inserted, biosdetect=auto, model="HOS"
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0
ata3: enabled=0
parport1: enabled=1, file=""
parport2: enabled=0
com1: enabled=1, mode=null, dev=""
com2: enabled=0
com3: enabled=0
com4: enabled=0
usb_uhci: enabled=0
usb_ohci: enabled=0
i440fxsupport: enabled=1
vga_update_interval: 50000
vga: extension=vbe
cpu: count=1, ips=4000000, reset_on_triple_fault=1, ignore_bad_msrs=1
cpuid: cpuid_limit_winnt=0, mmx=1, sse=sse2, xapic=1, sep=1, aes=0, xsave=0, movbe=0, 1g_pages=1, pcid=0 fsgsbase=0
cpuid: stepping=3, vendor_string="GenuineIntel", brand_string=" Intel(R) Pentium(R) 4 CPU "
print_timestamps: enabled=0
# no gdb stub
port_e9_hack: enabled=0
text_snapshot_check: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local
# no cmosimage
ne2k: enabled=0
pnic: enabled=0
sb16: enabled=0
# no loader
log: -
logprefix: %t%e%d
panic: action=ask
error: action=report
info: action=report
debug: action=ignore
pass: action=fatal
keyboard_type: mf
keyboard_serial_delay: 250
keyboard_paste_delay: 100000
keyboard_mapping: enabled=0, map=
user_shortcut: keys=none
mouse: enabled=0, type=ps2, toggle=ctrl+mbutton

View File

@ -1,3 +0,0 @@
menuentry "secX x64 [Dev]" {
multiboot2 /secX/kernel.bin
}

View File

@ -1,29 +0,0 @@
OUTPUT_FORMAT(binary)
SECTIONS
{
. = 0x1000000;
kernel_start = .;
.entry : ALIGN(0x1000)
{
*(.entry)
}
.text : ALIGN(0x1000)
{
*(.text)
}
.data : ALIGN(0x1000)
{
*(.data)
*(.rodata)
}
.bss : ALIGN(0x1000)
{
*(.bss)
}
kernel_end = .;
}

View File

@ -8,15 +8,15 @@ rdircard=$(sort $(dir $(call rwildcard,$1,*)))
rdircardex=$(sort $(dir $(call rwildcard,$1,$2)))
#x64 vars
LD_SCRIPT := linker.ld
GRUB_CFG := grub.cfg
LD_SCRIPT := build/linker.ld
GRUB_CFG := build/grub.cfg
OUTPUT_DIR := out
TEMP_DIR := tmp
HEADER_DIRS := $(call rdircardex, *,*.h)
ALL_OUTPUT_DIRS := $(addprefix $(OUTPUT_DIR)/,$(call rdircard,*))
ALL_TEMP_DIRS := $(addprefix $(TEMP_DIR)/,$(call rdircard,*))
C_FLAGS := -m64 -std=c11 -g -c $(addprefix -I, $(HEADER_DIRS)) -fno-stack-protector -fno-builtin -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -masm=intel -Wall -Wextra -Wno-comment
ASM_FLAGS := -f elf64 -I $(ASM_SRC_PATH_64)/
ASM_FLAGS := -g -f elf64 -I $(ASM_SRC_PATH_64)/
LD_FLAGS := -melf_x86_64
C_SRC := $(call rwildcard, ./, *.c)
@ -24,41 +24,50 @@ ASM_SRC := $(call rwildcard, ./, *.asm)
KERNEL_BIN := kernel.bin
KERNEL_ELF := kernel.elf
KERNEL_DASM := kernel.dasm
#Object files
C_OBJ := $(C_SRC:.c=.o)
ASM_OBJ := $(ASM_SRC:.asm=.oasm)
ALL_OBJ := $(addprefix $(OUTPUT_DIR)/,$(C_OBJ)) $(addprefix $(OUTPUT_DIR)/,$(ASM_OBJ))
ALL_OBJ := $(addprefix $(TEMP_DIR)/,$(C_OBJ)) $(addprefix $(TEMP_DIR)/,$(ASM_OBJ))
#Commands
all: init compile link buildiso clean
all: init compile link buildiso disasm clean_temp
init:
mkdir -p $(ALL_OUTPUT_DIRS)
mkdir -p $(ALL_TEMP_DIRS)
compile: $(C_OBJ) $(ASM_OBJ)
link: $(KERNEL_BIN)
link: $(KERNEL_BIN) $(KERNEL_ELF)
buildiso:
mkdir -p $(OUTPUT_DIR)/temp_iso/secX
mkdir -p $(OUTPUT_DIR)/temp_iso/boot
mkdir -p $(OUTPUT_DIR)/temp_iso/boot/grub
mv $(OUTPUT_DIR)/$(KERNEL_BIN) $(OUTPUT_DIR)/temp_iso/secX/$(KERNEL_BIN)
cp $(GRUB_CFG) $(OUTPUT_DIR)/temp_iso/boot/grub/
grub-mkrescue -o secX.iso $(OUTPUT_DIR)/temp_iso
rm -rf $(OUTPUT_DIR)/temp_iso
mkdir -p $(TEMP_DIR)/temp_iso/secX
mkdir -p $(TEMP_DIR)/temp_iso/boot
mkdir -p $(TEMP_DIR)/temp_iso/boot/grub
cp $(TEMP_DIR)/$(KERNEL_BIN) $(TEMP_DIR)/temp_iso/secX/$(KERNEL_BIN)
cp $(GRUB_CFG) $(TEMP_DIR)/temp_iso/boot/grub/
grub-mkrescue -o secX.iso $(TEMP_DIR)/temp_iso
clean:
rm -rf $(OUTPUT_DIR)
clean_temp:
rm -rf $(TEMP_DIR)
clean: clean_temp
rm -rf $(KERNEL_DASM)
rm -rf secX.iso
%.o: %.c
$(CC) $(C_FLAGS) -o $(OUTPUT_DIR)/$@ $^
$(CC) $(C_FLAGS) -o $(TEMP_DIR)/$@ $^
%.oasm: %.asm
$(ASM) $(ASM_FLAGS) -o $(OUTPUT_DIR)/$@ $^
$(ASM) $(ASM_FLAGS) -o $(TEMP_DIR)/$@ $^
$(KERNEL_BIN): $(ALL_OBJ)
$(LD) $(LD_FLAGS) -T $(LD_SCRIPT) -o $(OUTPUT_DIR)/$(KERNEL_BIN) $(ALL_OBJ)
$(LD) $(LD_FLAGS) -T $(LD_SCRIPT) --oformat binary -o $(TEMP_DIR)/$(KERNEL_BIN) $(ALL_OBJ)
$(KERNEL_ELF): $(ALL_OBJ)
$(LD) $(LD_FLAGS) -T $(LD_SCRIPT) --oformat elf64-x86-64 -o $(TEMP_DIR)/$(KERNEL_ELF) $(ALL_OBJ)
disasm:
objdump -M intel -D $(TEMP_DIR)/$(KERNEL_ELF) > $(KERNEL_DASM)

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.4)
project(Workspace)
MACRO(HEADER_DIRECTORIES return_list)
FILE(GLOB_RECURSE new_list ./x64/*.h)
FILE(GLOB_RECURSE new_list ./*.h)
SET(dir_list "")
FOREACH(file_path ${new_list})
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
@ -18,6 +18,6 @@ include_directories(${header_dirs})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
file(GLOB_RECURSE SOURCE_FILES ./x64/*.h ./x64/*.c)
file(GLOB_RECURSE SOURCE_FILES ./*.h ./*.c)
add_executable(Workspace ${SOURCE_FILES})