Use main
This commit is contained in:
parent
8a6293dc87
commit
04739004f5
|
@ -4,20 +4,33 @@
|
||||||
|
|
||||||
namespace JabyEngine {
|
namespace JabyEngine {
|
||||||
struct NextRoutine {
|
struct NextRoutine {
|
||||||
typedef NextRoutine (*ExecutionFunction)();
|
static constexpr uintptr_t OverlayBit = (1 << ((sizeof(uintptr_t)*8) - 2));
|
||||||
|
typedef NextRoutine (*MainRoutine)();
|
||||||
|
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
|
|
||||||
static NextRoutine null() {
|
constexpr static NextRoutine null() {
|
||||||
return {.value = 0};
|
return {.value = 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
static NextRoutine from(ExecutionFunction function) {
|
static NextRoutine from(MainRoutine function) {
|
||||||
return {.value = reinterpret_cast<uintptr_t>(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::ExecutionFunction ExecutionFunction;
|
typedef NextRoutine::MainRoutine MainRoutine;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //!__JABYENGINE__H__
|
#endif //!__JABYENGINE__H__
|
|
@ -16,4 +16,8 @@ namespace Setup {
|
||||||
JabyEngine::NextRoutine start();
|
JabyEngine::NextRoutine start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace BootFile {
|
||||||
|
JabyEngine::NextRoutine setup();
|
||||||
|
}
|
||||||
|
|
||||||
#endif //!BOOT_LOADER_HPP
|
#endif //!BOOT_LOADER_HPP
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "../../../include/BootLoader/boot_loader.hpp"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
extern JabyEngine::NextRoutine main();
|
||||||
|
|
||||||
|
namespace BootFile {
|
||||||
|
JabyEngine::NextRoutine setup() {
|
||||||
|
printf("Running main!\n");
|
||||||
|
return JabyEngine::NextRoutine::from(main);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,6 @@ namespace Setup {
|
||||||
//Pause??
|
//Pause??
|
||||||
|
|
||||||
SPU::setup();
|
SPU::setup();
|
||||||
return JabyEngine::NextRoutine::null();
|
return BootFile::setup();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,9 +2,27 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
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() {
|
||||||
printf("Starting Planschbecken\n");
|
NextRoutine next_routine = JabyEngine::NextRoutine::from(Setup::start);
|
||||||
Setup::start();
|
|
||||||
|
printf("Starting Planschbecken 0x%p\n", next_routine.value);
|
||||||
|
while(true) {
|
||||||
|
if(next_routine.is_null()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(next_routine.is_overlay()) {
|
||||||
|
printf("Overlay not supported yet!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
next_routine = execute(next_routine);
|
||||||
|
}
|
||||||
printf("Stop!\n");
|
printf("Stop!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue