Remove BootFiles. Setup code needs improving

This commit is contained in:
Jaby Blubb 2023-04-16 21:39:47 +02:00
parent d1e710a283
commit 74d58a5a50
8 changed files with 13 additions and 102 deletions

View File

@ -3,34 +3,7 @@
#include "../stdint.h" #include "../stdint.h"
namespace JabyEngine { namespace JabyEngine {
struct NextRoutine { typedef void (*MainRoutine)();
static constexpr uintptr_t OverlayBit = (1 << ((sizeof(uintptr_t)*8) - 2));
typedef NextRoutine (*MainRoutine)();
uintptr_t value;
constexpr static NextRoutine null() {
return {.value = 0};
}
static NextRoutine from(MainRoutine function) {
return {.value = reinterpret_cast<uintptr_t>(function)};
}
constexpr bool is_overlay() const {
return (this->value & OverlayBit);
}
constexpr bool is_absolute() const {
return !NextRoutine::is_overlay();
}
constexpr bool is_null() const {
return this->value == 0;
}
};
typedef NextRoutine::MainRoutine MainRoutine;
} }
#endif //!__JABYENGINE__HPP__ #endif //!__JABYENGINE__HPP__

View File

@ -7,10 +7,6 @@ include $(AUTO_OVERLAY_DIR)/Overlays.mk
JABY_ENGINE_LIB_DIR = $(JABY_ENGINE_DIR)/lib/PSX-$(BUILD_PROFILE) JABY_ENGINE_LIB_DIR = $(JABY_ENGINE_DIR)/lib/PSX-$(BUILD_PROFILE)
JABY_ENGINE_LIB_NAME = JabyEngine_$(TV_FORMAT) JABY_ENGINE_LIB_NAME = JabyEngine_$(TV_FORMAT)
#Bind this to the overlay.json file maybe?
BOOT_TYPE = main
OBJS += $(JABY_ENGINE_LIB_DIR)/$(BOOT_TYPE)_boot.o
#Linking rule #Linking rule
$(TARGET).elf: $(OBJS) $(JABY_ENGINE_LIB_DIR)/lib$(JABY_ENGINE_LIB_NAME).a $(AUTO_OVERLAY_DIR)/Overlays.ld $(TARGET).elf: $(OBJS) $(JABY_ENGINE_LIB_DIR)/lib$(JABY_ENGINE_LIB_NAME).a $(AUTO_OVERLAY_DIR)/Overlays.ld
$(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS) $(LD) -o $(TARGET).elf $(LDFLAGS_all) $(LDFLAGS) $(OBJS) -L$(JABY_ENGINE_LIB_DIR) -l$(JABY_ENGINE_LIB_NAME) $(LIBS)

View File

@ -16,9 +16,7 @@ SRCS += src/syscall_printf.asm
include ../../lib/Makefile include ../../lib/Makefile
LIB_DIR = ../../lib/$(CONFIG_NAME) LIB_DIR = ../../lib/$(CONFIG_NAME)
MAIN_BOOT_OBJ = $(filter %/main_boot.o,$(OBJS)) MAIN_LIB_OBJS = $(filter-out $(MAIN_BOOT_OBJ) $(OVERLAY_BOOT_OBJ),$(OBJS))
OVERLAY_BOOT_OBJ = $(filter %/overlay_boot.o,$(OBJS))
MAIN_LIB_OBJS = $(filter-out $(MAIN_BOOT_OBJ) $(OVERLAY_BOOT_OBJ),$(OBJS))
#$(info $$var is [${MAIN_BOOT_OBJ}]) #$(info $$var is [${MAIN_BOOT_OBJ}])
#$(info $$var2 is [${MAIN_LIB_OBJS}]) #$(info $$var2 is [${MAIN_LIB_OBJS}])
@ -33,14 +31,6 @@ $(LIB_DIR)/$(ARTIFACT).a: $(TARGET).a
@mkdir -p $(LIB_DIR) @mkdir -p $(LIB_DIR)
cp $(TARGET).a $(LIB_DIR)/$(ARTIFACT).a cp $(TARGET).a $(LIB_DIR)/$(ARTIFACT).a
$(LIB_DIR)/$(notdir $(MAIN_BOOT_OBJ)): $(MAIN_BOOT_OBJ)
@mkdir -p $(LIB_DIR)
cp $(MAIN_BOOT_OBJ) $(LIB_DIR)/$(notdir $(MAIN_BOOT_OBJ))
$(LIB_DIR)/$(notdir $(OVERLAY_BOOT_OBJ)): $(OVERLAY_BOOT_OBJ)
@mkdir -p $(LIB_DIR)
cp $(OVERLAY_BOOT_OBJ) $(LIB_DIR)/$(notdir $(OVERLAY_BOOT_OBJ))
# Improve later # Improve later
# rule to make the boot image # rule to make the boot image
$(SPLASH_IMAGE): ressources/Splash.png $(SPLASH_IMAGE): ressources/Splash.png
@ -50,7 +40,7 @@ $(SPLASH_IMAGE_NTSC): ressources/Splash_ntsc.png
jaby_engine_fconv --lz4 $< simple-tim full16 | cpp_out --name SplashScreen -o $@ jaby_engine_fconv --lz4 $< simple-tim full16 | cpp_out --name SplashScreen -o $@
#Rules section for default compilation and linking #Rules section for default compilation and linking
all: $(SPLASH_IMAGE) $(SPLASH_IMAGE_NTSC) $(LIB_DIR)/$(ARTIFACT).a $(LIB_DIR)/$(notdir $(MAIN_BOOT_OBJ)) $(LIB_DIR)/$(notdir $(OVERLAY_BOOT_OBJ)) all: $(SPLASH_IMAGE) $(SPLASH_IMAGE_NTSC) $(LIB_DIR)/$(ARTIFACT).a
clean: clean:
rm -fr $(SPLASH_IMAGE) rm -fr $(SPLASH_IMAGE)

View File

@ -5,10 +5,6 @@
namespace JabyEngine { namespace JabyEngine {
//boot namespace? //boot namespace?
namespace boot { namespace boot {
namespace BootFile {
JabyEngine::NextRoutine setup();
}
namespace CD { namespace CD {
void setup(); void setup();
} }
@ -24,7 +20,7 @@ namespace JabyEngine {
} }
namespace Start { namespace Start {
JabyEngine::NextRoutine setup(); void setup();
} }
namespace Timer { namespace Timer {

View File

@ -1,17 +0,0 @@
#include "../../../internal-include/BootLoader/boot_loader.hpp"
#include <stdio.h>
#include <PSX/File/Processor/cd_file_processor.hpp>
extern JabyEngine::NextRoutine main();
namespace JabyEngine {
namespace boot {
namespace BootFile {
JabyEngine::NextRoutine setup() {
printf("Running main!\n");
return JabyEngine::NextRoutine::from(main);
}
}
}
}

View File

@ -1,13 +0,0 @@
#include "../../../internal-include/BootLoader/boot_loader.hpp"
#include <stdio.h>
namespace JabyEngine {
namespace boot {
namespace BootFile {
JabyEngine::NextRoutine setup() {
printf("Overlay boot not implemented!\n");
return JabyEngine::NextRoutine::null();
}
}
}
}

View File

@ -13,7 +13,7 @@ namespace JabyEngine {
DMA_IO::DPCR = DMA_IO::DPCR_t(DMA_IO::DPCR).set(DMA_IO::DPCR_t::SPUEnable).set(DMA_IO::DPCR_t::GPUEnable).set(DMA_IO::DPCR_t::CDROMEnable); DMA_IO::DPCR = DMA_IO::DPCR_t(DMA_IO::DPCR).set(DMA_IO::DPCR_t::SPUEnable).set(DMA_IO::DPCR_t::GPUEnable).set(DMA_IO::DPCR_t::CDROMEnable);
} }
JabyEngine::NextRoutine setup() { void setup() {
enable_DMA(); enable_DMA();
SPU::stop_voices(); SPU::stop_voices();
@ -31,7 +31,6 @@ namespace JabyEngine {
//Pause?? //Pause??
SPU::setup(); SPU::setup();
return BootFile::setup();
} }
} }
} }

View File

@ -1,29 +1,16 @@
#include "../internal-include/BootLoader/boot_loader.hpp" #include "../internal-include/BootLoader/boot_loader.hpp"
#include <stdio.h> #include <stdio.h>
extern void main();
namespace JabyEngine { namespace JabyEngine {
static NextRoutine execute(NextRoutine routine) {
// Support currently only direct call
return reinterpret_cast<MainRoutine>((routine.value & ~JabyEngine::NextRoutine::OverlayBit))();
}
void start() { void start() {
NextRoutine next_routine = JabyEngine::NextRoutine::from(boot::Start::setup); printf("Starting Planschbecken\n");
boot::Start::setup();
printf("Starting Planschbecken 0x%p\n", next_routine.value);
while(true) { printf("Running main...\n");
if(next_routine.is_null()) { main();
break; printf("Stop!!\n");
}
if(next_routine.is_overlay()) {
printf("Overlay not supported yet!\n");
break;
}
next_routine = execute(next_routine);
}
printf("Stop!\n");
while(true); while(true);
} }
} }