diff --git a/.gitignore b/.gitignore index b9a23701..d73a0e99 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ initrd.tar.gz *.log *.img *.iso +*.drv +*.o diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a60142dd..b15db481 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -3,7 +3,7 @@ { "name": "Linux", "includePath": [ - "${workspaceFolder}/include/**" + "${workspaceFolder}/" ], "defines": [ "KERNEL_NAME=\"Fennix\"", @@ -11,7 +11,7 @@ "GIT_COMMIT=\"0000000000000000000000000000000000000000\"", "GIT_COMMIT_SHORT=\"0000000\"" ], - "compilerPath": "/usr/bin/gcc", + "compilerPath": "${workspaceFolder}/tools/cross/bin/amd64-elf-gcc", "cStandard": "c17", "cppStandard": "c++20", "intelliSenseMode": "gcc-x64", diff --git a/Makefile b/Makefile index 14b23e08..2e593c66 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,17 @@ default: # -netdev tap,id=usernet0,ifname=tap0,script=no,downscript=no QEMU = ./$(QEMU_PATH)$(QEMU_ARCH) QEMUFLAGS := -display gtk + +ifeq ($(OSARCH), amd64) QEMUHWACCELERATION = -machine q35 -enable-kvm QEMUMEMORY = -m 4G +else ifeq ($(OSARCH), i686) +QEMUHWACCELERATION = -machine q35 -enable-kvm +QEMUMEMORY = -m 4G +else ifeq ($(OSARCH), aarch64) +QEMUHWACCELERATION = +QEMUMEMORY = -m 1G +endif ifeq ($(OSARCH), amd64) QEMUFLAGS += -device bochs-display -M q35 \ @@ -59,11 +68,10 @@ QEMUFLAGS += -M q35 \ -machine pcspk-audiodev=audio0 \ -device AC97,audiodev=audio0 else ifeq ($(OSARCH), aarch64) -QEMUFLAGS += -M virt \ +QEMUFLAGS += -M raspi3b \ -cpu cortex-a57 \ - -smp $(shell nproc) \ -serial file:serial.log \ - -hda $(OSNAME).iso + -kernel $(OSNAME).img endif doxygen: @@ -86,8 +94,9 @@ tools: make --quiet -C Kernel prepare make --quiet -C Lynx prepare make --quiet -C Userspace prepare + make --quiet -C Drivers prepare -build: build_lynx build_kernel build_userspace build_image +build: build_lynx build_kernel build_userspace build_drivers build_image rebuild: clean build @@ -103,6 +112,10 @@ build_kernel: build_userspace: make --quiet -C Userspace build +build_drivers: + make --quiet -C Drivers build + cp Drivers/out/* initrd/system/drivers/ + build_image: mkdir -p iso_tmp_data tar cf initrd.tar.gz -C initrd/ ./ --format=ustar @@ -131,16 +144,21 @@ ifeq ($(OSARCH), i686) cp tools/grub.cfg iso_tmp_data/boot/grub/ grub-mkrescue -o $(OSNAME).iso iso_tmp_data endif +ifeq ($(OSARCH), aarch64) + $(COMPILER_PATH)/$(COMPILER_ARCH)objcopy Kernel/kernel.fsys -O binary $(OSNAME).img +endif endif -QEMU_UEFI_BIOS := ifeq ($(OSARCH), amd64) -QEMU_UEFI_BIOS += -bios /usr/share/qemu/OVMF.fd +QEMU_UEFI_BIOS = -bios /usr/share/qemu/OVMF.fd endif +# ifeq ($(OSARCH), aarch64) +# QEMU_UEFI_BIOS = -bios -bios /usr/share/AAVMF/AAVMF_CODE.fd +# endif -vscode_debug: build_kernel build_userspace build_image +vscode_debug: build_kernel build_userspace build_drivers build_image rm -f serial.log network.log - $(QEMU) -S -gdb tcp::1234 -d int -no-shutdown $(QEMU_UEFI_BIOS) -m 4G $(QEMUFLAGS) + $(QEMU) -S -gdb tcp::1234 -d int -no-reboot -no-shutdown $(QEMU_UEFI_BIOS) -m 4G $(QEMUFLAGS) qemu: qemu_vdisk rm -f serial.log network.log @@ -153,7 +171,9 @@ qemubios: qemu_vdisk run: build qemu clean: - rm -rf doxygen-doc iso_tmp_data initrd.tar.gz $(OSNAME).iso - make --quiet -C Kernel clean - make --quiet -C Lynx clean - make --quiet -C Userspace clean + rm -rf doxygen-doc iso_tmp_data + rm -f initrd/system/drivers/*.drv initrd.tar.gz $(OSNAME).iso $(OSNAME).img + make -C Kernel clean + make -C Lynx clean + make -C Userspace clean + make -C Drivers clean diff --git a/initrd/system/drivers/.gitkeep b/initrd/system/drivers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tools/ErrorParser.cpp b/tools/ErrorParser.cpp old mode 100644 new mode 100755 diff --git a/tools/Fex.c b/tools/Fex.c new file mode 100644 index 00000000..c7768354 --- /dev/null +++ b/tools/Fex.c @@ -0,0 +1,75 @@ +// FEX is a file format. Right now in development. +#include +#include +#include +#include + +void DumpData(const char *Description, unsigned char *Address, unsigned long Length) +{ + printf("-------------------------------------------------------------------------\n"); + unsigned char Buffer[17]; + unsigned long Iterate; + + if (Description != NULL) + printf("%s:\n", Description); + + for (Iterate = 0; Iterate < Length; Iterate++) + { + if ((Iterate % 16) == 0) + { + if (Iterate != 0) + printf(" %s\n", Buffer); + printf(" %04x ", Iterate); + } + + printf(" %02x", Address[Iterate]); + + if ((Address[Iterate] < 0x20) || (Address[Iterate] > 0x7e)) + Buffer[Iterate % 16] = '.'; + else + Buffer[Iterate % 16] = Address[Iterate]; + + Buffer[(Iterate % 16) + 1] = '\0'; + } + + while ((Iterate % 16) != 0) + { + printf(" "); + Iterate++; + } + + printf(" %s\n", Buffer); + printf("-------------------------------------------------------------------------\n"); +} + +int main() +{ + FILE *FilePointer; + char FileName[20]; + unsigned char *Buffer; + char BufferChar; + struct stat st; + + printf("--- THIS IS NOT A COMPLETE VERSION ---\n\n"); +FileSelection: + printf("File Name: "); + fgets(FileName, 20, stdin); + FileName[strcspn(FileName, "\r\n")] = 0; + FilePointer = fopen(FileName, "r"); + + if (NULL == FilePointer) + { + printf("Error opening file %s. Try again...\n", FileName); + FileName[0] = 0; + goto FileSelection; + } + + stat(FileName, &st); + Buffer = (unsigned char *)malloc(st.st_size); + fread(Buffer, 1, st.st_size, FilePointer); + DumpData(FileName, Buffer, st.st_size); + + fclose(FilePointer); + free(Buffer); + return 0; +} diff --git a/tools/Makefile b/tools/Makefile index b7e00456..9aceab81 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -4,19 +4,23 @@ export PATH := $(CROSS_DIR):$(PATH) QEMU_VERSION = qemu-7.1.0 -all: do_rep do_ep do_limine clone_all do_binutils64 do_binutils32 do_binutilsarm64 do_gcc64 do_gcc32 do_gccarm64 do_qemu +all: do_rep do_ep do_fex do_limine clone_all do_binutils64 do_binutils32 do_binutilsarm64 do_gcc64 do_gcc32 do_gccarm64 do_qemu clean: - rm -f rep ep + rm -f rep ep fex do_rep: gcc -w ReadEthernetPackets.c -o rep chmod +x rep do_ep: - g++ -w e.cpp -o ep + g++ -w ErrorParser.cpp -o ep chmod +x ep +do_fex: + gcc -w Fex.c -o fex + chmod +x fex + do_limine: git clone https://github.com/limine-bootloader/limine.git --branch=v4.x-branch-binary --depth=1 diff --git a/tools/limine.cfg b/tools/limine.cfg index 46a9136f..4a2123b9 100644 --- a/tools/limine.cfg +++ b/tools/limine.cfg @@ -5,7 +5,7 @@ INTERFACE_BRANDING=Fennix # DO NOT EDIT! COMMENT=Boot Fennix using Limine protocol PROTOCOL=limine - KERNEL_CMDLINE=debug + KERNEL_CMDLINE=debug liballoc11 KERNEL_PATH=boot:///kernel.fsys MODULE_PATH=boot:///initrd.tar.gz