mirror of
https://github.com/SMGCommunity/Petari.git
synced 2025-02-21 06:31:00 +00:00
SIBios 100%
This commit is contained in:
parent
3e58b5c7c2
commit
777e52766f
@ -1,12 +1,12 @@
|
||||
Symbol Name, Object File, Library Archive, Matching
|
||||
CompleteTransfer,SIBios.o,si.a,false
|
||||
SIInterruptHandler,SIBios.o,si.a,false
|
||||
SIInit,SIBios.o,si.a,false
|
||||
CompleteTransfer,SIBios.o,si.a,true
|
||||
SIInterruptHandler,SIBios.o,si.a,true
|
||||
SIInit,SIBios.o,si.a,true
|
||||
__SITransfer,SIBios.o,si.a,true
|
||||
SISetXY,SIBios.o,si.a,true
|
||||
AlarmHandler,SIBios.o,si.a,true
|
||||
SITransfer,SIBios.o,si.a,true
|
||||
GetTypeCallback,SIBios.o,si.a,false
|
||||
GetTypeCallback,SIBios.o,si.a,true
|
||||
SIGetType,SIBios.o,si.a,true
|
||||
SISetSamplingRate,SISamplingRate.o,si.a,false
|
||||
SIRefreshSamplingRate,SISamplingRate.o,si.a,false
|
||||
|
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"label": "SDK",
|
||||
"message": "5.364%",
|
||||
"message": "5.775%",
|
||||
"color": "blue"
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
| [pad](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/pad.md) | 0.0% |
|
||||
| [rso](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/rso.md) | 0.0% |
|
||||
| [sc](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/sc.md) | 0.0% |
|
||||
| [si](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/si.md) | 33.826247689463955% |
|
||||
| [si](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/si.md) | 94.82439926062847% |
|
||||
| [thp](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/thp.md) | 0.0% |
|
||||
| [tpl](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/tpl.md) | 100.0% |
|
||||
| [usb](https://github.com/shibbo/Petari/tree/master/libs/RVL_SDK/docs/lib/usb.md) | 0.0% |
|
||||
|
@ -8,21 +8,21 @@
|
||||
|
||||
| Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status
|
||||
| ------------- | ------------- | ------------- | ------------- | -------------
|
||||
| SIBios.o | 35.67251461988304% | 5 / 9 | 55.55555555555556% | :eight_pointed_black_star:
|
||||
| SIBios.o | 100.0% | 9 / 9 | 100.0% | :white_check_mark:
|
||||
| SISamplingRate.o | 0.0% | 0 / 2 | 0.0% | :x:
|
||||
|
||||
|
||||
# SIBios.o
|
||||
| Symbol | Decompiled? |
|
||||
| ------------- | ------------- |
|
||||
| CompleteTransfer | :x: |
|
||||
| SIInterruptHandler | :x: |
|
||||
| SIInit | :x: |
|
||||
| CompleteTransfer | :white_check_mark: |
|
||||
| SIInterruptHandler | :white_check_mark: |
|
||||
| SIInit | :white_check_mark: |
|
||||
| __SITransfer | :white_check_mark: |
|
||||
| SISetXY | :white_check_mark: |
|
||||
| AlarmHandler | :white_check_mark: |
|
||||
| SITransfer | :white_check_mark: |
|
||||
| GetTypeCallback | :x: |
|
||||
| GetTypeCallback | :white_check_mark: |
|
||||
| SIGetType | :white_check_mark: |
|
||||
|
||||
|
||||
|
@ -101,6 +101,7 @@ void __OSGetIOSRev(OSIOSRev *);
|
||||
#include <revolution/os/OSInterrupt.h>
|
||||
#include <revolution/os/OSMessage.h>
|
||||
#include <revolution/os/OSMutex.h>
|
||||
#include <revolution/os/OSRtc.h>
|
||||
#include <revolution/os/OSReset.h>
|
||||
#include <revolution/os/OSTime.h>
|
||||
#include <revolution/os/OSThread.h>
|
||||
|
9
libs/RVL_SDK/include/revolution/os/OSRtc.h
Normal file
9
libs/RVL_SDK/include/revolution/os/OSRtc.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef OSRTC_H
|
||||
#define OSRTC_H
|
||||
|
||||
#include <revolution/types.h>
|
||||
|
||||
u16 OSGetWirelessID(s32);
|
||||
void OSSetWirelessID(s32, u16);
|
||||
|
||||
#endif // OSRTC_H
|
@ -7,7 +7,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (* SICallback )(s32, u32, OSContext *);
|
||||
typedef void (*SICallback)(s32, u32, OSContext *);
|
||||
typedef void (*SITypeAndStatusCallback)(s32, u32);
|
||||
|
||||
typedef struct SIPacket {
|
||||
s32 chan;
|
||||
@ -19,6 +20,11 @@ typedef struct SIPacket {
|
||||
OSTime fire;
|
||||
} SIPacket;
|
||||
|
||||
u32 SIGetType(s32);
|
||||
|
||||
void SISetSamplingRate(u32);
|
||||
void SIRefreshSamplingRate(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -6,4 +6,6 @@
|
||||
|
||||
void VIResetDimmingCount();
|
||||
|
||||
u32 VIGetCurrentLine();
|
||||
|
||||
#endif // VI_H
|
@ -3,6 +3,7 @@
|
||||
#include <private/flipper.h>
|
||||
#include <private/io_reg.h>
|
||||
|
||||
#define OFFSET(n, a) (((u32) (n)) & ((a) - 1))
|
||||
#define ROUND(n, a) (((u32) (n) + (a) - 1) & ~((a) - 1))
|
||||
|
||||
typedef struct SIControl {
|
||||
@ -29,6 +30,224 @@ static u32 Type[4] = {
|
||||
|
||||
static OSTime TypeTime[4];
|
||||
static OSTime XferTime[4];
|
||||
static SITypeAndStatusCallback TypeCallback[4][4];
|
||||
static __OSInterruptHandler RDSTHandler[4];
|
||||
u32 __PADFixBits;
|
||||
|
||||
static BOOL InputBufferValid[4];
|
||||
static u32 InputBuffer[4][2];
|
||||
static vu32 InputBufferVcount[4];
|
||||
|
||||
static const char* __SIVersion = "<< RVL_SDK - SI \trelease build: Aug 8 2007 02:07:10 (0x4199_60831) >>";
|
||||
|
||||
static void GetTypeCallback(s32, u32, OSContext *);
|
||||
|
||||
BOOL SIIsChanBusy(s32 chan) {
|
||||
return Packet[chan].chan != -1 || Si.chan == chan;
|
||||
}
|
||||
|
||||
static void SIClearTCInterrupt(void){
|
||||
u32 reg;
|
||||
reg = __SIRegs[0xD];
|
||||
reg |= 0x80000000;
|
||||
reg &= 0xFFFFFFFE;
|
||||
__SIRegs[0xD] = reg;
|
||||
}
|
||||
|
||||
static u32 CompleteTransfer(void) {
|
||||
u32 sr;
|
||||
u32 i;
|
||||
u32 rLen;
|
||||
u8* input;
|
||||
|
||||
sr = __SIRegs[0xE];
|
||||
SIClearTCInterrupt();
|
||||
|
||||
if (Si.chan != -1) {
|
||||
XferTime[Si.chan] = __OSGetSystemTime();
|
||||
input = Si.input;
|
||||
rLen = Si.inputBytes / 4;
|
||||
|
||||
for (i = 0; i < rLen; i++) {
|
||||
*(u32*)input = __SIRegs[0x20 + i];
|
||||
input += 4;
|
||||
}
|
||||
|
||||
rLen = OFFSET(Si.inputBytes, 4);
|
||||
if (rLen) {
|
||||
u32 temp = __SIRegs[0x20 + i];
|
||||
|
||||
for (i = 0; i < rLen; i++) {
|
||||
*input++ = (u8)((temp >> ((3 - i) * 8)) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
if (__SIRegs[0xD] & 0x20000000) {
|
||||
sr >>= 8 * (3 - Si.chan);
|
||||
sr &= 0xF;
|
||||
|
||||
if ((sr & 8) && !(Type[Si.chan] & 0x80)) {
|
||||
Type[Si.chan] = 8;
|
||||
}
|
||||
|
||||
if (sr == 0) {
|
||||
sr = 4;
|
||||
}
|
||||
}
|
||||
else {
|
||||
TypeTime[Si.chan] = __OSGetSystemTime();
|
||||
sr = 0;
|
||||
}
|
||||
|
||||
Si.chan = -1;
|
||||
}
|
||||
|
||||
return sr;
|
||||
}
|
||||
|
||||
static void SITransferNext(s32 chan) {
|
||||
int i;
|
||||
SIPacket* packet;
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
++chan;
|
||||
chan %= 4;
|
||||
packet = &Packet[chan];
|
||||
|
||||
if (packet->chan != -1 && packet->fire <= __OSGetSystemTime()) {
|
||||
if (__SITransfer(packet->chan, packet->output, packet->outputBytes, packet->input, packet->inputBytes, packet->callback)) {
|
||||
OSCancelAlarm(&Alarm[chan]);
|
||||
packet->chan = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SIInterruptHandler(__OSInterrupt interrupt, OSContext* context) {
|
||||
u32 reg = __SIRegs[0xD];
|
||||
|
||||
if ((reg & 0xC0000000) == 0xC0000000) {
|
||||
s32 chan;
|
||||
u32 sr;
|
||||
SICallback callback;
|
||||
chan = Si.chan;
|
||||
sr = CompleteTransfer();
|
||||
callback = Si.callback;
|
||||
Si.callback = 0;
|
||||
|
||||
SITransferNext(chan);
|
||||
|
||||
if (callback) {
|
||||
callback(chan, sr, context);
|
||||
}
|
||||
|
||||
sr = __SIRegs[0xE];
|
||||
sr &= 0xF000000 >> (8 * chan);
|
||||
__SIRegs[0xE] = sr;
|
||||
|
||||
if (Type[chan] == 0x80 && !SIIsChanBusy(chan)) {
|
||||
static u32 cmdTypeAndStatus = 0;
|
||||
SITransfer(chan, &cmdTypeAndStatus, 1, &Type[chan], 3, GetTypeCallback, (OSTime)OSMicrosecondsToTicks(65));
|
||||
}
|
||||
}
|
||||
|
||||
if ((reg & 0x18000000) == 0x18000000) {
|
||||
int i;
|
||||
u32 vcount;
|
||||
u32 x;
|
||||
|
||||
vcount = VIGetCurrentLine() + 1;
|
||||
x = (Si.poll & 0x03FF0000) >> 16;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (SIGetResponseRaw(i)) {
|
||||
InputBufferVcount[i] = vcount;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!(Si.poll & (0x80000000 >> (31 - 7 + i)))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (InputBufferVcount[i] == 0 || InputBufferVcount[i] + (x / 2) < vcount) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
InputBufferVcount[i] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (RDSTHandler[i]) {
|
||||
RDSTHandler[i](interrupt, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 SIGetStatus(s32 chan) {
|
||||
BOOL enabled;
|
||||
u32 sr;
|
||||
int chanShift;
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
sr = __SIRegs[0xE];
|
||||
chanShift = 8 * (3 - chan);
|
||||
sr >>= chanShift;
|
||||
|
||||
if (sr & 8) {
|
||||
if (!(Type[chan] & 0x80)) {
|
||||
Type[chan] = 8;
|
||||
}
|
||||
}
|
||||
|
||||
OSRestoreInterrupts(enabled);
|
||||
return sr;
|
||||
}
|
||||
|
||||
static BOOL SIGetResponseRaw(s32 chan) {
|
||||
u32 sr;
|
||||
|
||||
sr = SIGetStatus(chan);
|
||||
|
||||
if (sr & 0x20) {
|
||||
InputBuffer[chan][0] = __SIRegs[3 * chan + 1];
|
||||
InputBuffer[chan][1] = __SIRegs[3 * chan + 2];
|
||||
InputBufferValid[chan] = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void SIInit(void) {
|
||||
static BOOL Initialized = FALSE;
|
||||
|
||||
if (Initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
OSRegisterVersion(__SIVersion);
|
||||
Packet[0].chan = Packet[1].chan = Packet[2].chan = Packet[3].chan = -1;
|
||||
Si.poll = 0;
|
||||
SISetSamplingRate(0);
|
||||
|
||||
while (__SIRegs[0xD] & 1) { }
|
||||
|
||||
__SIRegs[0xD] = 0x80000000;
|
||||
__OSSetInterruptHandler(20, SIInterruptHandler);
|
||||
__OSUnmaskInterrupts(0x800);
|
||||
|
||||
SIGetType(0);
|
||||
SIGetType(1);
|
||||
SIGetType(2);
|
||||
SIGetType(3);
|
||||
Initialized = TRUE;
|
||||
}
|
||||
|
||||
BOOL __SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputBytes, SICallback callback) {
|
||||
BOOL enabled;
|
||||
@ -143,8 +362,79 @@ BOOL SITransfer(s32 chan, void* output, u32 outputBytes, void* input, u32 inputB
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CallTypeAndStatusCallback(s32 chan, u32 type) {
|
||||
SITypeAndStatusCallback callback;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
callback = TypeCallback[chan][i];
|
||||
|
||||
if (callback) {
|
||||
TypeCallback[chan][i] = 0;
|
||||
callback(chan, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void GetTypeCallback(s32 chan, u32 error, OSContext* context) {
|
||||
return;
|
||||
static u32 cmdFixDevice[4];
|
||||
u32 type;
|
||||
u32 chanBit;
|
||||
BOOL fix;
|
||||
u32 id;
|
||||
|
||||
Type[chan] &= 0xFFFFFF7F;
|
||||
Type[chan] |= error;
|
||||
TypeTime[chan] = __OSGetSystemTime();
|
||||
type = Type[chan];
|
||||
chanBit = 0x80000000 >> chan;
|
||||
fix = __PADFixBits & chanBit;
|
||||
__PADFixBits &= ~chanBit;
|
||||
|
||||
if ((error & 0xF) || (type & 0x18000000) != 0x08000000 || !(type & 0x80000000) || (type & 0x4000000)) {
|
||||
OSSetWirelessID(chan, 0);
|
||||
CallTypeAndStatusCallback(chan, Type[chan]);
|
||||
return;
|
||||
}
|
||||
|
||||
id = OSGetWirelessID(chan) << 8;
|
||||
|
||||
if (fix && (id & 0x100000)) {
|
||||
cmdFixDevice[chan] = 0x4E << 24 | (id & 0xCFFF00) | 0x4E100000;
|
||||
Type[chan] = 0x80;
|
||||
SITransfer(chan, &cmdFixDevice[chan], 3, &Type[chan], 3, GetTypeCallback, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type & 0x100000) {
|
||||
if ((id & 0xCFFF00) != (type & 0xCFFF00)) {
|
||||
if (!(id & 0x00100000)) {
|
||||
id = type & 0xCFFF00;
|
||||
id |= 0x00100000;
|
||||
OSSetWirelessID(chan, (u16)((id >> 8) & 0xFFFF));
|
||||
}
|
||||
|
||||
cmdFixDevice[chan] = 0x4E << 24 | id;
|
||||
Type[chan] = 0x80;
|
||||
SITransfer(chan, &cmdFixDevice[chan], 3, &Type[chan], 3, GetTypeCallback, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (type & 0x40000000) {
|
||||
id = type & 0xCFFF00;
|
||||
id |= 0x00100000;
|
||||
|
||||
OSSetWirelessID(chan, (u16)((id >> 8) & 0xFFFF));
|
||||
cmdFixDevice[chan] = 0x4E << 24 | id;
|
||||
Type[chan] = 0x80;
|
||||
SITransfer(chan, &cmdFixDevice[chan], 3, &Type[chan], 3, GetTypeCallback, 0);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
OSSetWirelessID(chan, 0);
|
||||
}
|
||||
|
||||
CallTypeAndStatusCallback(chan, Type[chan]);
|
||||
}
|
||||
|
||||
u32 SIGetType(s32 chan) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user