diff --git a/.gitmodules b/.gitmodules index 2769615..5ae9888 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ [submodule "extern/limine"] path = extern/limine url = https://github.com/limine-bootloader/limine.git - branch = v4.x-branch-binary + branch = v8.x-binary [submodule "extern/terminal"] path = extern/terminal url = https://github.com/limine-bootloader/terminal diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..911efe4 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,7 @@ +{ + "workspace.library": [ + "/Users/frityet/Library/Application Support/Code/User/globalStorage/sumneko.lua/addonManager/addons/xmake/module/library" + ], + "workspace.checkThirdParty": false, + "runtime.version": "LuaJIT" +} diff --git a/Makefile b/Makefile index 38ad9d0..619172b 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ CC = clang LD = ld.lld -LUAJIT= luajit +LUAJIT = luajit GDB := x86_64-elf-gdb @@ -66,7 +66,7 @@ CFLAGS += \ -fms-extensions\ -fblocks -LDFLAGS += \ +LDFLAGS = \ -nostdlib \ -static \ -m elf_x86_64 \ @@ -108,9 +108,11 @@ extern/ovmf-x64: @mkdir -p $@ cd $@ && curl -o OVMF-X64.zip https://efi.akeo.ie/OVMF/OVMF-X64.zip && 7z x OVMF-X64.zip -extern/limine/limine-deploy: +extern/limine/limine: @/usr/bin/printf "[\033[1;35mKernel - extern\033[0m] \033[32mBuilding Limine\n\033[0m" - @$(MAKE) -C extern/limine + @cd extern/limine && git reset +# compiling limine requires that our LDFLAGS are not inherited + @$(MAKE) -C extern/limine LDFLAGS="" extern/LuaJIT/src/lua.h: extern/LuaJIT @@ -118,35 +120,31 @@ user-land: build-userland.lua @/usr/bin/printf "[\033[1;35mUserland\033[0m] \033[32mBuilding userland\n\033[0m" @$(LUAJIT) build-userland.lua - - res/limine.cfg: user-land -build/bin/luaos.iso: extern/limine extern/limine/limine-deploy build/bin/luck.elf res/limine.cfg user-land +build/bin/luaos.iso: extern/limine extern/limine/limine build/bin/luck.elf res/limine.cfg user-land @/usr/bin/printf "[\033[1;35mKernel\033[0m] \033[32mBuilding ISO\n\033[0m" + @rm -rf $(dir $@)/iso @mkdir -p $(dir $@)/iso # All files in Userland/lua_modules/share/lua/5.1/ will be copied to the root of the ISO cp -r Userland/lua_modules/share/lua/5.1/* $(dir $@)/iso - cp \ - build/bin/luck.elf res/powered-by-lua.bmp res/limine.cfg \ - res/font.bin extern/limine/limine-cd.bin extern/limine/limine.sys \ - extern/limine/limine-cd-efi.bin\ - $(dir $@)/iso + cp build/bin/luck.elf $(dir $@)/iso/luck.elf + cp res/powered-by-lua.bmp res/limine.cfg res/font.bin $(dir $@)/iso + cp extern/limine/limine-bios-cd.bin extern/limine/limine-uefi-cd.bin extern/limine/limine-bios.sys extern/limine/BOOTX64.EFI $(dir $@)/iso xorriso -as mkisofs\ - -b limine-cd.bin\ + -b limine-bios-cd.bin\ -no-emul-boot\ -boot-load-size 4\ -boot-info-table\ - --efi-boot limine-cd-efi.bin\ + --efi-boot limine-uefi-cd.bin\ -efi-boot-part\ --efi-boot-image\ --protective-msdos-label\ $(dir $@)/iso -o $@ - rm -rf $(dir $@)/iso - extern/limine/limine-deploy $@ + extern/limine/limine bios-install $@ @/usr/bin/printf "[\033[1;35mKernel\033[0m] \033[32mISO built at \033[33m$@\n\033[0m" build/bin/luck.elf: $(COBJS) $(ASOBJS) extern/LuaJIT/libluajit_luck.o diff --git a/build-userland.lua b/build-userland.lua index 84c240e..b02885c 100644 --- a/build-userland.lua +++ b/build-userland.lua @@ -72,13 +72,13 @@ end ---@generic K, V ---@param array V[] ----@param key K | fun(v: V): K +---@param key fun(v: V): K ---@return { [K]: V } local function map(array, key) local map = {} for _, v in ipairs(array) do - local k = type(key) == "function" and key(v) or v[key] + local k = key(v) map[k] = v end @@ -140,6 +140,8 @@ local config = { } } +config.targets["LuaOS"].modules["limine-bios.sys"] = "limine-bios.sys" + print("[\x1b[1;35mUserland\x1b[0m] \x1b[32mBuilding \x1b[33mres/limine.cfg\n\x1b[0m") -- Dump the config to res/limine.cfg @@ -178,8 +180,6 @@ for name, target in pairs(config.targets) do end end -file:close() - -- Copy over the modules into the `build/iso/ print("[\x1b[1;35mUserland\x1b[0m] \x1b[32mCopying modules to \x1b[33mbuild/iso/boot/\x1b[0m") diff --git a/compile_flags.txt b/compile_flags.txt deleted file mode 100644 index e191d41..0000000 --- a/compile_flags.txt +++ /dev/null @@ -1,6 +0,0 @@ --Iinc --Iextern/ --target -x86_64-elf --ffreestanding --std=gnu2x diff --git a/extern/limine b/extern/limine index 1a17d89..4cf22fe 160000 --- a/extern/limine +++ b/extern/limine @@ -1 +1 @@ -Subproject commit 1a17d8964c0038c1fa6fb213311332ce419a2051 +Subproject commit 4cf22fe6123f0abeb662e3d2c7c800b0913a83c5 diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..081b809 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,99 @@ +add_rules("mode.debug", "mode.release") + +add_cflags ( + "-Wall", + "-Wextra", + "-Werror", + "-Wno-unused", + "-fms-extensions", + "-Wno-microsoft" +) + +add_cflags ( + "-ffreestanding", + "-fno-stack-protector", + "-fno-stack-check", + "-fno-lto", + "-fno-pie", + "-fno-pic", + "-m64", + "-march=x86-64", + "-mabi=sysv", + "-mno-80387", + "-mno-mmx", + "-mno-sse", + "-mno-sse2", + "-mno-red-zone", + "-mcmodel=kernel", + "-target", "x86_64-elf", + "-nostdinc", + "-Wno-unused-command-line-argument", + "-Wanon-enum-enum-conversion", + "-Wassign-enum", + "-Wenum-conversion", + "-Wenum-enum-conversion", + "-Wno-unused-function", + "-Wno-unused-parameter", + "-Wnull-dereference", + "-Wnull-conversion", + "-Wnullability-completeness", + "-Wnullable-to-nonnull-conversion", + "-Wno-missing-field-initializers", + "-fno-omit-frame-pointer", + "-Wno-deprecated-attributes", + "-fms-extensions", + "-fblocks" +) + +add_asflags ( + "-F", "dwarf", + -- "-g" + "-f", "elf64" +) + +add_ldflags ( + "-nostdlib", + "-static", + "-m", "elf_x86_64", + "-z", "max-page-size=0x1000", + "-T", "res/linker.ld", + "-no-pie" +) + +target("terminal") +do + set_kind("static") + add_files("extern/terminal/term.c") + add_files("extern/terminal/backends/framebuffer.c") +end +target_end() + +target("ovmf-x64") +do + +end +target_end() + +--should move to the repo +target("luajit") +do + +end +target_end() + +target("LuaOS") +do + set_kind("binary") + add_deps("terminal") + set_toolchains("clang") --for now just clang, but this project should be able to be compiled with GCC also + set_languages("gnulatest") + + add_sysincludedirs("extern") + add_sysincludedirs("extern/LuaJIT/src") + add_includedirs("inc") + set_arch("x86_64") + + add_files("src/**.c") + add_files("src/**.asm") +end +target_end()