Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
10 changed files with 131 additions and 133 deletions
Showing only changes of commit c1ff1187f9 - Show all commits

View File

@ -1,6 +1,7 @@
#ifndef __JABYENGINE_HIGH_RES_TIMER_HPP__ #ifndef __JABYENGINE_HIGH_RES_TIMER_HPP__
#define __JABYENGINE_HIGH_RES_TIMER_HPP__ #define __JABYENGINE_HIGH_RES_TIMER_HPP__
#include "../jabyengine_defines.h" #include "../jabyengine_defines.h"
#include <PSX/System/IOPorts/interrupt_io.hpp>
#include <PSX/System/IOPorts/timer_io.hpp> #include <PSX/System/IOPorts/timer_io.hpp>
namespace JabyEngine { namespace JabyEngine {
@ -24,7 +25,6 @@ namespace JabyEngine {
} }
}; };
#ifdef JABYENGINE_USE_HIGH_PERCISION_TIMER
class HighResTime { class HighResTime {
public: public:
class TimeStamp { class TimeStamp {
@ -65,10 +65,17 @@ namespace JabyEngine {
HighResTime() = delete; HighResTime() = delete;
~HighResTime() = delete; ~HighResTime() = delete;
static void enable() {
Interrupt::enable_irq(Interrupt::Timer2);
}
static void disable() {
Interrupt::disable_irq(Interrupt::Timer2);
}
static TimeStamp get_time_stamp() { static TimeStamp get_time_stamp() {
return TimeStamp(HighResTime::global_counter_10ms, Timer_IO::Counter2.get_current_value()); return TimeStamp(HighResTime::global_counter_10ms, Timer_IO::Counter2.get_current_value());
} }
}; };
#endif //JABYENGINE_USE_HIGH_PERCISION_TIMER
} }
#endif //!__JABYENGINE_HIGH_RES_TIMER_HPP__ #endif //!__JABYENGINE_HIGH_RES_TIMER_HPP__

View File

@ -1,8 +0,0 @@
#ifndef __JABYENGINE_CONFIG_HPP__
#define __JABYENGINE_CONFIG_HPP__
#ifdef USE_CUSTOM_CONFIG
#include <jabyengine_custom_config.hpp>
#else
#define JABYENGINE_USE_HIGH_PERCISION_TIMER
#endif //USE_CUSTOM_CONFIG
#endif //!__JABYENGINE_CONFIG_HPP__

View File

@ -1,6 +1,5 @@
#ifndef __JABYENGINE_DEFINES__H__ #ifndef __JABYENGINE_DEFINES__H__
#define __JABYENGINE_DEFINES__H__ #define __JABYENGINE_DEFINES__H__
#include "jabyengine_config.hpp"
#include "../stddef.h" #include "../stddef.h"
#define __used __attribute__((used)) #define __used __attribute__((used))

View File

@ -46,11 +46,7 @@ CCFLAGS_debug += -O0
CXXFLAGS += -fno-exceptions -fno-rtti CXXFLAGS += -fno-exceptions -fno-rtti
USE_FUNCTION_SECTIONS ?= true CCFLAGS += -mno-gpopt -fomit-frame-pointer -ffunction-sections
ifeq ($(USE_FUNCTION_SECTIONS),true)
CCFLAGS += -ffunction-sections
endif
CCFLAGS += -mno-gpopt -fomit-frame-pointer
CCFLAGS += -fno-builtin -fno-strict-aliasing -Wno-attributes CCFLAGS += -fno-builtin -fno-strict-aliasing -Wno-attributes
CCFLAGS += -std=c++20 CCFLAGS += -std=c++20
CCFLAGS += $(ARCHFLAGS) CCFLAGS += $(ARCHFLAGS)
@ -76,11 +72,11 @@ OBJS = $(addprefix $(OUTPUT_DIR)/,$(addsuffix .o, $(subst ..,!super,$(basename $
#Compiling rule #Compiling rule
$(OUTPUT_DIR)/%.o: %.s $(OUTPUT_DIR)/%.o: %.s
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) -c $(DEPS) -o $@ $(CCFLAGS) $(CCFLAGS) $< $(CC) -c $(DEPS) -o $@ $(CCFLAGS) $<
$(OUTPUT_DIR)/%.o: %.c $(OUTPUT_DIR)/%.o: %.c
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) -c $(DEPS) -o $@ $(CCFLAGS) $(CCFLAGS) $< $(CC) -c $(DEPS) -o $@ $(CCFLAGS) $<
$(OUTPUT_DIR)/%.o: %.cpp $(OUTPUT_DIR)/%.o: %.cpp
@mkdir -p $(dir $@) @mkdir -p $(dir $@)

View File

@ -10,8 +10,7 @@ CCFLAGS += -Iinclude -I../../include
CCFLAGS += -save-temps=obj CCFLAGS += -save-temps=obj
include ../../lib/Wildcard.mk include ../../lib/Wildcard.mk
SRCS = $(call rwildcard, src, c cpp) SRCS = $(call rwildcard, src, c cpp s)
SRCS += src/syscall_printf.asm
include ../../lib/Makefile include ../../lib/Makefile
LIB_DIR = ../../lib/$(CONFIG_NAME) LIB_DIR = ../../lib/$(CONFIG_NAME)

View File

@ -21,15 +21,10 @@ namespace JabyEngine {
CD::setup(); CD::setup();
Timer::setup(); Timer::setup();
const auto start = HighResTime::get_time_stamp();
printf("Start...\n");
GPU::setup(); GPU::setup();
GPU::display_logo(); GPU::display_logo();
const auto end = HighResTime::get_time_stamp();
printf("GPU setup took %ims %ius\n", start.milliseconds_to(end), start.microseconds_to(end));
//Pause?? //Pause??
SPU::setup(); SPU::setup();
} }
} }

View File

@ -1,12 +1,10 @@
#include <PSX/jabyengine_config.hpp> #include <PSX/System/IOPorts/interrupt_io.hpp>
#ifdef JABYENGINE_USE_HIGH_PERCISION_TIMER #include <PSX/System/syscalls.h>
#include <PSX/System/IOPorts/interrupt_io.hpp> #define private public
#include <PSX/System/syscalls.h> #include <PSX/Timer/high_res_timer.hpp>
#define private public #undef private
#include <PSX/Timer/high_res_timer.hpp>
#undef private
namespace JabyEngine { namespace JabyEngine {
namespace Timer { namespace Timer {
extern InterrupCallback IRQCallback; extern InterrupCallback IRQCallback;
} }
@ -20,6 +18,8 @@
static constexpr auto Mode = CounterMode_t::from(CounterMode_t::FreeRun, Counter2_v::SyncMode::FreeRun, CounterMode_t::ResetAfterTarget, CounterMode_t::IRQAtTarget, CounterMode_t::IRQEveryTime, CounterMode_t::IRQPulse, Counter2_v::Source::System_Clock_Div_8); static constexpr auto Mode = CounterMode_t::from(CounterMode_t::FreeRun, Counter2_v::SyncMode::FreeRun, CounterMode_t::ResetAfterTarget, CounterMode_t::IRQAtTarget, CounterMode_t::IRQEveryTime, CounterMode_t::IRQPulse, Counter2_v::Source::System_Clock_Div_8);
// We disable the IRQ here so it can be enabled by user demand later
// Having the interrupt fire every 10ms will slow us down slightly so we only do it on demand
Interrupt::disable_irq(Interrupt::Timer2); Interrupt::disable_irq(Interrupt::Timer2);
__syscall_EnterCriticalSection(); __syscall_EnterCriticalSection();
@ -28,19 +28,7 @@
Counter2.set_target_value(HighResTime::TicksFor10ms); Counter2.set_target_value(HighResTime::TicksFor10ms);
Counter2.set_mode(Mode); Counter2.set_mode(Mode);
Interrupt::enable_irq(Interrupt::Timer2);
} }
} }
} }
} }
#else
namespace JabyEngine {
namespace boot {
namespace Timer {
void setup() {
}
}
}
}
#endif //JABYENGINE_USE_HIGH_PERCISION_TIMER

View File

@ -1,13 +1,10 @@
#include <PSX/jabyengine_config.hpp> #define private public
#ifdef JABYENGINE_USE_HIGH_PERCISION_TIMER #include <PSX/System/IOPorts/timer_io.hpp>
#define private public #include <PSX/System/syscalls.h>
#include <PSX/System/IOPorts/interrupt_io.hpp> #include <PSX/Timer/high_res_timer.hpp>
#include <PSX/System/IOPorts/timer_io.hpp> #undef private
#include <PSX/System/syscalls.h>
#include <PSX/Timer/high_res_timer.hpp>
#undef private
namespace JabyEngine { namespace JabyEngine {
volatile uint16_t HighResTime :: global_counter_10ms = 0; volatile uint16_t HighResTime :: global_counter_10ms = 0;
namespace Timer { namespace Timer {
@ -34,5 +31,4 @@
.verifier_function = interrupt_verifier .verifier_function = interrupt_verifier
}; };
} }
} }
#endif //JABYENGINE_USE_HIGH_PERCISION_TIMER

View File

@ -0,0 +1,26 @@
.set noreorder
.section .text, "ax", @progbits
.align 2
.global busy_loop
.type busy_loop, @function
busy_loop:
sw $a0, 0($sp)
lw $v0, 0($sp)
lw $v1, 0($sp)
nop
addiu $v1, -1
beqz $v0, early_exit
sw $v1, 0($sp)
busy_loop_loop:
lw $v0, 0($sp)
lw $v1, 0($sp)
nop
addiu $v1, -1
bnez $v0, busy_loop_loop
sw $v1, 0($sp)
early_exit:
jr $ra
nop

View File

@ -1,6 +1,6 @@
.set push .set push
.set noreorder .set noreorder
#.section .ramtext, "ax", @progbits .section .text, "ax", @progbits
.align 2 .align 2
.global __syscall_printf .global __syscall_printf
.type __syscall_printf, @function .type __syscall_printf, @function