mirror of
https://github.com/LNH-team/dspico-bootloader.git
synced 2026-06-02 09:06:57 +02:00
Initial commit
This commit is contained in:
2
arm7/source/common.h
Normal file
2
arm7/source/common.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include <nds/ndstypes.h>
|
||||
44
arm7/source/main.cpp
Normal file
44
arm7/source/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/rtos/rtosIrq.h>
|
||||
#include <libtwl/rtos/rtosThread.h>
|
||||
#include <libtwl/rtos/rtosEvent.h>
|
||||
#include <libtwl/ipc/ipcSync.h>
|
||||
#include <libtwl/ipc/ipcFifoSystem.h>
|
||||
#include <libtwl/gfx/gfxStatus.h>
|
||||
#include "picoLoaderBootstrap.h"
|
||||
|
||||
static rtos_event_t sVBlankEvent;
|
||||
|
||||
static void vblankIrq(u32 irqMask)
|
||||
{
|
||||
rtos_signalEvent(&sVBlankEvent);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
rtos_initIrq();
|
||||
rtos_startMainThread();
|
||||
ipc_initFifoSystem();
|
||||
|
||||
pload_init();
|
||||
|
||||
rtos_createEvent(&sVBlankEvent);
|
||||
rtos_setIrqFunc(RTOS_IRQ_VBLANK, vblankIrq);
|
||||
rtos_enableIrqMask(RTOS_IRQ_VBLANK);
|
||||
|
||||
gfx_setVBlankIrqEnabled(true);
|
||||
|
||||
ipc_setArm7SyncBits(7);
|
||||
|
||||
while (true)
|
||||
{
|
||||
rtos_waitEvent(&sVBlankEvent, true, true);
|
||||
|
||||
if (pload_shouldStart())
|
||||
{
|
||||
pload_start();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
arm7/source/picoLoaderBootstrap.cpp
Normal file
39
arm7/source/picoLoaderBootstrap.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <libtwl/rtos/rtosIrq.h>
|
||||
#include <libtwl/ipc/ipcFifoSystem.h>
|
||||
#include <libtwl/sound/sound.h>
|
||||
#include "ipcChannels.h"
|
||||
#include "picoLoader7.h"
|
||||
#include "picoLoaderBootstrap.h"
|
||||
|
||||
typedef void (*pico_loader_7_func_t)(void);
|
||||
|
||||
static volatile bool sShouldStart = false;
|
||||
|
||||
static void ipcMessageHandler(u32 channel, u32 data, void* arg)
|
||||
{
|
||||
if (data == 1)
|
||||
{
|
||||
sShouldStart = true;
|
||||
}
|
||||
}
|
||||
|
||||
void pload_init()
|
||||
{
|
||||
ipc_setChannelHandler(IPC_CHANNEL_LOADER, ipcMessageHandler, nullptr);
|
||||
}
|
||||
|
||||
bool pload_shouldStart()
|
||||
{
|
||||
return sShouldStart;
|
||||
}
|
||||
|
||||
void pload_start()
|
||||
{
|
||||
snd_setMasterEnable(false);
|
||||
rtos_disableIrqs();
|
||||
REG_IME = 0;
|
||||
auto header7 = (pload_header7_t*)0x06000000;
|
||||
((pico_loader_7_func_t)header7->entryPoint)();
|
||||
}
|
||||
5
arm7/source/picoLoaderBootstrap.h
Normal file
5
arm7/source/picoLoaderBootstrap.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
void pload_init();
|
||||
bool pload_shouldStart();
|
||||
void pload_start();
|
||||
Reference in New Issue
Block a user