diff --git a/.github/workflows/Linux.yml b/.github/workflows/Linux.yml index a60c05f..e0e4e62 100644 --- a/.github/workflows/Linux.yml +++ b/.github/workflows/Linux.yml @@ -45,9 +45,9 @@ jobs: working-directory: ./ run: | if [ ${{ matrix.arch }} == 'i386' ]; then - cd build32 + cd build32/x86 elif [ ${{ matrix.arch }} == 'x86_64' ]; then - cd build64 + cd build64/x86 elif [ ${{ matrix.arch }} == 'la64' ]; then cd build64/la64 fi @@ -57,9 +57,9 @@ jobs: working-directory: ./ run: | if [ ${{ matrix.arch }} == 'i386' ]; then - cd build32 + cd build32/x86 elif [ ${{ matrix.arch }} == 'x86_64' ]; then - cd build64 + cd build64/x86 elif [ ${{ matrix.arch }} == 'la64' ]; then export PATH=/opt/LoongArch_Toolchains/cross-tools/bin/:$PATH cd build64/la64 diff --git a/app/interrupt.c b/app/x86/interrupt.c similarity index 100% rename from app/interrupt.c rename to app/x86/interrupt.c diff --git a/boot/startup32.S b/boot/x86/startup32.S similarity index 100% rename from boot/startup32.S rename to boot/x86/startup32.S diff --git a/boot/startup64.S b/boot/x86/startup64.S similarity index 100% rename from boot/startup64.S rename to boot/x86/startup64.S diff --git a/build32/Makefile b/build32/x86/Makefile similarity index 80% rename from build32/Makefile rename to build32/x86/Makefile index d69bf06..19334f7 100644 --- a/build32/Makefile +++ b/build32/x86/Makefile @@ -25,38 +25,38 @@ else MS_LDS=ldscripts/memtest_shared.lds endif -INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp +INC_DIRS = -I../../boot -I../../system -I../../system/imc -I../../system/x86 -I../../lib -I../../tests -I../../app -Iapp SYS_OBJS = system/acpi.o \ - system/cpuid.o \ - system/cpuinfo.o \ system/cpulocal.o \ system/ehci.o \ system/font.o \ system/heap.o \ - system/hwctrl.o \ system/hwquirks.o \ system/keyboard.o \ system/ohci.o \ - system/memctrl.o \ system/pci.o \ system/pmem.o \ system/reloc.o \ system/screen.o \ system/serial.o \ system/smbios.o \ - system/i2c_x86.o \ system/spd.o \ system/smp.o \ - system/temperature.o \ system/timers.o \ system/uhci.o \ system/usbhcd.o \ - system/vmem.o \ - system/xhci.o + system/xhci.o \ + system/x86/cpuid.o \ + system/x86/cpuinfo.o \ + system/x86/hwctrl.o \ + system/x86/i2c.o \ + system/x86/memctrl.o \ + system/x86/temperature.o \ + system/x86/vmem.o -IMC_SRCS = $(wildcard ../system/imc/*.c) -IMC_OBJS = $(subst ../,,$(IMC_SRCS:.c=.o)) +IMC_SRCS = $(wildcard ../../system/imc/x86/*.c) +IMC_OBJS = $(subst ../../,,$(IMC_SRCS:.c=.o)) LIB_OBJS = lib/barrier.o \ lib/div64.o \ @@ -80,10 +80,10 @@ APP_OBJS = app/badram.o \ app/config.o \ app/display.o \ app/error.o \ - app/interrupt.o \ - app/main.o + app/main.o \ + app/x86/interrupt.o -OBJS = boot/startup.o boot/efisetup.o $(SYS_OBJS) $(IMC_OBJS) $(LIB_OBJS) $(TST_OBJS) $(APP_OBJS) +OBJS = boot/x86/startup.o boot/efisetup.o $(SYS_OBJS) $(IMC_OBJS) $(LIB_OBJS) $(TST_OBJS) $(APP_OBJS) all: memtest.bin memtest.efi @@ -102,49 +102,57 @@ debug: check memtest.debug memtest.efi -include $(subst .o,.d,$(TST_OBJS)) -include $(subst .o,.d,$(APP_OBJS)) -boot/header.o : | ../boot/sbat.csv +boot/header.o : | ../../boot/sbat.csv -boot/startup.o: ../boot/startup32.S ../boot/boot.h +boot/x86/startup.o: ../../boot/x86/startup32.S ../../boot/boot.h + @mkdir -p boot/x86 + $(CC) -m32 -x assembler-with-cpp -c -I../../boot -o $@ $< + +boot/%.o: ../../boot/%.S ../../boot/boot.h app/build_version.h @mkdir -p boot - $(CC) -m32 -x assembler-with-cpp -c -I../boot -o $@ $< + $(CC) -m32 -x assembler-with-cpp -c -I../../boot -Iapp -o $@ $< -boot/%.o: ../boot/%.S ../boot/boot.h app/build_version.h - @mkdir -p boot - $(CC) -m32 -x assembler-with-cpp -c -I../boot -Iapp -o $@ $< - -boot/efisetup.o: ../boot/efisetup.c +boot/efisetup.o: ../../boot/efisetup.c @mkdir -p boot $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/reloc.o: ../system/reloc32.c +system/reloc.o: ../../system/reloc32.c @mkdir -p system $(CC) -c $(CFLAGS) -fno-strict-aliasing $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/%.o: ../system/%.c +system/%.o: ../../system/%.c @mkdir -p system $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/imc/%.o: ../system/imc/%.c - @mkdir -p system/imc +system/imc/x86/%.o: ../../system/imc/x86/%.c + @mkdir -p system/imc/x86 $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -lib/%.o: ../lib/%.c +system/x86/%.o: ../../system/x86/%.c + @mkdir -p system/x86 + $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) + +lib/%.o: ../../lib/%.c @mkdir -p lib $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -tests/%.o: ../tests/%.c +tests/%.o: ../../tests/%.c @mkdir -p tests $(CC) -c $(CFLAGS) $(OPT_FAST) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -app/%.o: ../app/%.c app/build_version.h +app/%.o: ../../app/%.c app/build_version.h @mkdir -p app $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) +app/x86/%.o: ../../app/x86/%.c app/build_version.h + @mkdir -p app/x86 + $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) + app/build_version.h: FORCE @mkdir -p app @( \ - cp -f ../app/version.h $@.tmp; \ - if $(GIT_AVAILABLE) && test -d ../.git ; then \ + cp -f ../../app/version.h $@.tmp; \ + if $(GIT_AVAILABLE) && test -d ../../.git ; then \ hash=`git rev-parse HEAD | cut -c1-7`; \ sed -i 's/GIT_HASH\s\".*"/GIT_HASH "'$$hash'"/' $@.tmp; \ else \ @@ -239,22 +247,22 @@ grub-eltorito.img: grub-bootia32.efi: $(GRUB_MKIMAGE) --output $@ --prefix /EFI/BOOT/grub --format i386-efi $(GRUB_MODULES) -grub-esp.img: memtest.efi grub-bootia32.efi ../grub/${GRUB_CFG}-efi.cfg +grub-esp.img: memtest.efi grub-bootia32.efi ../../grub/${GRUB_CFG}-efi.cfg @mkdir -p grub-iso/EFI/BOOT/grub/i386-efi grub-iso/EFI/BOOT/grub/fonts cp memtest.efi grub-iso/EFI/BOOT/memtest cp grub-bootia32.efi grub-iso/EFI/BOOT/bootia32.efi - cp ../grub/${GRUB_CFG}-efi.cfg grub-iso/EFI/BOOT/grub/grub.cfg + cp ../../grub/${GRUB_CFG}-efi.cfg grub-iso/EFI/BOOT/grub/grub.cfg cp $(GRUB_FONT_DIR)/unicode.pf2 grub-iso/EFI/BOOT/grub/fonts/ cp $(GRUB_LIB_DIR)/i386-efi/*.mod grub-iso/EFI/BOOT/grub/i386-efi/ @rm -f grub-esp.img /sbin/mkdosfs -n MT86P_ESP -F12 -C grub-esp.img 8192 mcopy -s -i grub-esp.img grub-iso/EFI :: -grub-memtest.iso: memtest.bin grub-eltorito.img ../grub/${GRUB_CFG}-legacy.cfg grub-esp.img +grub-memtest.iso: memtest.bin grub-eltorito.img ../../grub/${GRUB_CFG}-legacy.cfg grub-esp.img @mkdir -p grub-iso/boot/grub/i386-pc grub-iso/boot/grub/fonts cp memtest.bin grub-iso/boot/memtest cp grub-eltorito.img grub-iso/boot/eltorito.img - cp ../grub/${GRUB_CFG}-legacy.cfg grub-iso/boot/grub/grub.cfg + cp ../../grub/${GRUB_CFG}-legacy.cfg grub-iso/boot/grub/grub.cfg cp $(GRUB_FONT_DIR)/unicode.pf2 grub-iso/boot/grub/fonts/ cp $(GRUB_LIB_DIR)/i386-pc/*.mod grub-iso/boot/grub/i386-pc/ xorrisofs -pad -R -J -volid MT86PLUS_32 -graft-points -hide-rr-moved \ diff --git a/build32/ldscripts/memtest_bin.lds b/build32/x86/ldscripts/memtest_bin.lds similarity index 100% rename from build32/ldscripts/memtest_bin.lds rename to build32/x86/ldscripts/memtest_bin.lds diff --git a/build32/ldscripts/memtest_efi.lds b/build32/x86/ldscripts/memtest_efi.lds similarity index 100% rename from build32/ldscripts/memtest_efi.lds rename to build32/x86/ldscripts/memtest_efi.lds diff --git a/build32/ldscripts/memtest_mbr.lds b/build32/x86/ldscripts/memtest_mbr.lds similarity index 100% rename from build32/ldscripts/memtest_mbr.lds rename to build32/x86/ldscripts/memtest_mbr.lds diff --git a/build32/ldscripts/memtest_shared.lds b/build32/x86/ldscripts/memtest_shared.lds similarity index 100% rename from build32/ldscripts/memtest_shared.lds rename to build32/x86/ldscripts/memtest_shared.lds diff --git a/build64/la64/Makefile b/build64/la64/Makefile index e1a9235..4ce5b42 100644 --- a/build64/la64/Makefile +++ b/build64/la64/Makefile @@ -24,7 +24,7 @@ else MS_LDS=ldscripts/memtest_shared.lds endif -INC_DIRS = -I../../boot -I../../system -I../../system/loongarch -I../../lib -I../../tests -I../../app -Iapp +INC_DIRS = -I../../boot -I../../system -I ../../system/imc -I../../system/loongarch -I../../lib -I../../tests -I../../app -Iapp SYS_OBJS = system/acpi.o \ system/cpulocal.o \ diff --git a/build64/Makefile b/build64/x86/Makefile similarity index 80% rename from build64/Makefile rename to build64/x86/Makefile index 5262a5b..878aad8 100644 --- a/build64/Makefile +++ b/build64/x86/Makefile @@ -25,38 +25,38 @@ else MS_LDS=ldscripts/memtest_shared.lds endif -INC_DIRS = -I../boot -I../system -I../lib -I../tests -I../app -Iapp +INC_DIRS = -I../../boot -I../../system -I../../system/imc -I../../system/x86 -I../../lib -I../../tests -I../../app -Iapp SYS_OBJS = system/acpi.o \ - system/cpuid.o \ - system/cpuinfo.o \ system/cpulocal.o \ system/ehci.o \ system/font.o \ - system/hwctrl.o \ system/heap.o \ system/hwquirks.o \ system/keyboard.o \ system/ohci.o \ - system/memctrl.o \ system/pci.o \ system/pmem.o \ system/reloc.o \ system/screen.o \ system/serial.o \ system/smbios.o \ - system/i2c_x86.o \ system/spd.o \ system/smp.o \ - system/temperature.o \ system/timers.o \ system/uhci.o \ system/usbhcd.o \ - system/vmem.o \ - system/xhci.o + system/xhci.o \ + system/x86/cpuid.o \ + system/x86/cpuinfo.o \ + system/x86/hwctrl.o \ + system/x86/i2c.o \ + system/x86/memctrl.o \ + system/x86/temperature.o \ + system/x86/vmem.o -IMC_SRCS = $(wildcard ../system/imc/*.c) -IMC_OBJS = $(subst ../,,$(IMC_SRCS:.c=.o)) +IMC_SRCS = $(wildcard ../../system/imc/x86/*.c) +IMC_OBJS = $(subst ../../,,$(IMC_SRCS:.c=.o)) LIB_OBJS = lib/barrier.o \ lib/print.o \ @@ -79,10 +79,10 @@ APP_OBJS = app/badram.o \ app/config.o \ app/display.o \ app/error.o \ - app/interrupt.o \ - app/main.o + app/main.o \ + app/x86/interrupt.o -OBJS = boot/startup.o boot/efisetup.o $(SYS_OBJS) $(IMC_OBJS) $(LIB_OBJS) $(TST_OBJS) $(APP_OBJS) +OBJS = boot/x86/startup.o boot/efisetup.o $(SYS_OBJS) $(IMC_OBJS) $(LIB_OBJS) $(TST_OBJS) $(APP_OBJS) all: memtest.bin memtest.efi @@ -101,49 +101,57 @@ debug: check memtest.debug memtest.efi -include $(subst .o,.d,$(TST_OBJS)) -include $(subst .o,.d,$(APP_OBJS)) -boot/header.o : | ../boot/sbat.csv +boot/header.o : | ../../boot/sbat.csv -boot/startup.o: ../boot/startup64.S ../boot/boot.h +boot/x86/startup.o: ../../boot/x86/startup64.S ../../boot/boot.h + @mkdir -p boot/x86 + $(CC) -m64 -x assembler-with-cpp -c -I../../boot -o $@ $< + +boot/%.o: ../../boot/%.S ../../boot/boot.h app/build_version.h @mkdir -p boot - $(CC) -m64 -x assembler-with-cpp -c -I../boot -o $@ $< + $(CC) -m64 -x assembler-with-cpp -c -I../../boot -Iapp -o $@ $< -boot/%.o: ../boot/%.S ../boot/boot.h app/build_version.h - @mkdir -p boot - $(CC) -m64 -x assembler-with-cpp -c -I../boot -Iapp -o $@ $< - -boot/efisetup.o: ../boot/efisetup.c +boot/efisetup.o: ../../boot/efisetup.c @mkdir -p boot $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/reloc.o: ../system/reloc64.c +system/reloc.o: ../../system/reloc64.c @mkdir -p system $(CC) -c $(CFLAGS) -fno-strict-aliasing $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/%.o: ../system/%.c +system/%.o: ../../system/%.c @mkdir -p system $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -system/imc/%.o: ../system/imc/%.c - @mkdir -p system/imc +system/imc/x86/%.o: ../../system/imc/x86/%.c + @mkdir -p system/imc/x86 $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -lib/%.o: ../lib/%.c +system/x86/%.o: ../../system/x86/%.c + @mkdir -p system/x86 + $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) + +lib/%.o: ../../lib/%.c @mkdir -p lib $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -tests/%.o: ../tests/%.c +tests/%.o: ../../tests/%.c @mkdir -p tests $(CC) -c $(CFLAGS) $(OPT_FAST) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) -app/%.o: ../app/%.c app/build_version.h +app/%.o: ../../app/%.c app/build_version.h @mkdir -p app $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) +app/x86/%.o: ../../app/x86/%.c app/build_version.h + @mkdir -p app/x86 + $(CC) -c $(CFLAGS) $(OPT_SMALL) $(INC_DIRS) -o $@ $< -MMD -MP -MT $@ -MF $(@:.o=.d) + app/build_version.h: FORCE @mkdir -p app @( \ - cp -f ../app/version.h $@.tmp; \ - if $(GIT_AVAILABLE) && test -d ../.git ; then \ + cp -f ../../app/version.h $@.tmp; \ + if $(GIT_AVAILABLE) && test -d ../../.git ; then \ hash=`git rev-parse HEAD | cut -c1-7`; \ sed -i 's/GIT_HASH\s\".*"/GIT_HASH "'$$hash'"/' $@.tmp; \ else \ @@ -238,22 +246,22 @@ grub-eltorito.img: grub-bootx64.efi: $(GRUB_MKIMAGE) --output $@ --prefix /EFI/BOOT/grub --format x86_64-efi $(GRUB_MODULES) -grub-esp.img: memtest.efi grub-bootx64.efi ../grub/${GRUB_CFG}-efi.cfg +grub-esp.img: memtest.efi grub-bootx64.efi ../../grub/${GRUB_CFG}-efi.cfg @mkdir -p grub-iso/EFI/BOOT/grub/x86_64-efi grub-iso/EFI/BOOT/grub/fonts cp memtest.efi grub-iso/EFI/BOOT/memtest cp grub-bootx64.efi grub-iso/EFI/BOOT/bootx64.efi - cp ../grub/${GRUB_CFG}-efi.cfg grub-iso/EFI/BOOT/grub/grub.cfg + cp ../../grub/${GRUB_CFG}-efi.cfg grub-iso/EFI/BOOT/grub/grub.cfg cp $(GRUB_FONT_DIR)/unicode.pf2 grub-iso/EFI/BOOT/grub/fonts/ cp $(GRUB_LIB_DIR)/x86_64-efi/*.mod grub-iso/EFI/BOOT/grub/x86_64-efi/ @rm -f grub-esp.img /sbin/mkdosfs -n MT86P_ESP -F12 -C grub-esp.img 8192 mcopy -s -i grub-esp.img grub-iso/EFI :: -grub-memtest.iso: memtest.bin grub-eltorito.img ../grub/${GRUB_CFG}-legacy.cfg grub-esp.img +grub-memtest.iso: memtest.bin grub-eltorito.img ../../grub/${GRUB_CFG}-legacy.cfg grub-esp.img @mkdir -p grub-iso/boot/grub/i386-pc grub-iso/boot/grub/fonts cp memtest.bin grub-iso/boot/memtest cp grub-eltorito.img grub-iso/boot/eltorito.img - cp ../grub/${GRUB_CFG}-legacy.cfg grub-iso/boot/grub/grub.cfg + cp ../../grub/${GRUB_CFG}-legacy.cfg grub-iso/boot/grub/grub.cfg cp $(GRUB_FONT_DIR)/unicode.pf2 grub-iso/boot/grub/fonts/ cp $(GRUB_LIB_DIR)/i386-pc/*.mod grub-iso/boot/grub/i386-pc/ xorrisofs -pad -R -J -volid MT86PLUS_64 -graft-points -hide-rr-moved \ diff --git a/build64/ldscripts/memtest_bin.lds b/build64/x86/ldscripts/memtest_bin.lds similarity index 100% rename from build64/ldscripts/memtest_bin.lds rename to build64/x86/ldscripts/memtest_bin.lds diff --git a/build64/ldscripts/memtest_efi.lds b/build64/x86/ldscripts/memtest_efi.lds similarity index 100% rename from build64/ldscripts/memtest_efi.lds rename to build64/x86/ldscripts/memtest_efi.lds diff --git a/build64/ldscripts/memtest_mbr.lds b/build64/x86/ldscripts/memtest_mbr.lds similarity index 100% rename from build64/ldscripts/memtest_mbr.lds rename to build64/x86/ldscripts/memtest_mbr.lds diff --git a/build64/ldscripts/memtest_shared.lds b/build64/x86/ldscripts/memtest_shared.lds similarity index 100% rename from build64/ldscripts/memtest_shared.lds rename to build64/x86/ldscripts/memtest_shared.lds diff --git a/system/imc/amd_zen.c b/system/imc/x86/amd_zen.c similarity index 100% rename from system/imc/amd_zen.c rename to system/imc/x86/amd_zen.c diff --git a/system/imc/intel_adl.c b/system/imc/x86/intel_adl.c similarity index 100% rename from system/imc/intel_adl.c rename to system/imc/x86/intel_adl.c diff --git a/system/imc/intel_hsw.c b/system/imc/x86/intel_hsw.c similarity index 100% rename from system/imc/intel_hsw.c rename to system/imc/x86/intel_hsw.c diff --git a/system/imc/intel_icl.c b/system/imc/x86/intel_icl.c similarity index 100% rename from system/imc/intel_icl.c rename to system/imc/x86/intel_icl.c diff --git a/system/imc/intel_mtl.c b/system/imc/x86/intel_mtl.c similarity index 100% rename from system/imc/intel_mtl.c rename to system/imc/x86/intel_mtl.c diff --git a/system/imc/intel_skl.c b/system/imc/x86/intel_skl.c similarity index 100% rename from system/imc/intel_skl.c rename to system/imc/x86/intel_skl.c diff --git a/system/imc/intel_snb.c b/system/imc/x86/intel_snb.c similarity index 100% rename from system/imc/intel_snb.c rename to system/imc/x86/intel_snb.c diff --git a/system/cpuid.c b/system/x86/cpuid.c similarity index 100% rename from system/cpuid.c rename to system/x86/cpuid.c diff --git a/system/cpuinfo.c b/system/x86/cpuinfo.c similarity index 100% rename from system/cpuinfo.c rename to system/x86/cpuinfo.c diff --git a/system/hwctrl.c b/system/x86/hwctrl.c similarity index 100% rename from system/hwctrl.c rename to system/x86/hwctrl.c diff --git a/system/i2c_x86.c b/system/x86/i2c.c similarity index 100% rename from system/i2c_x86.c rename to system/x86/i2c.c diff --git a/system/memctrl.c b/system/x86/memctrl.c similarity index 100% rename from system/memctrl.c rename to system/x86/memctrl.c diff --git a/system/temperature.c b/system/x86/temperature.c similarity index 100% rename from system/temperature.c rename to system/x86/temperature.c diff --git a/system/vmem.c b/system/x86/vmem.c similarity index 100% rename from system/vmem.c rename to system/x86/vmem.c