Decompile msg.s

This commit is contained in:
kiwi515
2023-06-25 19:07:58 -04:00
parent 6a2aef762b
commit 85118c96ca
12 changed files with 83 additions and 35 deletions
-16
View File
@@ -1,16 +0,0 @@
.include "macros.inc"
.section .text, "ax"
.global TRKMessageSend
TRKMessageSend:
/* 800C1578 000BC478 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 800C157C 000BC47C 7C 08 02 A6 */ mflr r0
/* 800C1580 000BC480 90 01 00 14 */ stw r0, 0x14(r1)
/* 800C1584 000BC484 80 83 00 08 */ lwz r4, 8(r3)
/* 800C1588 000BC488 38 63 00 10 */ addi r3, r3, 0x10
/* 800C158C 000BC48C 48 00 49 21 */ bl TRKWriteUARTN
/* 800C1590 000BC490 80 01 00 14 */ lwz r0, 0x14(r1)
/* 800C1594 000BC494 38 60 00 00 */ li r3, 0
/* 800C1598 000BC498 7C 08 03 A6 */ mtlr r0
/* 800C159C 000BC49C 38 21 00 10 */ addi r1, r1, 0x10
/* 800C15A0 000BC4A0 4E 80 00 20 */ blr
+1
View File
@@ -5,6 +5,7 @@ extern "C" {
#endif
#include <MetroTRK/debugger/Os/dolphin/dolphin_trk.h>
#include <MetroTRK/debugger/Os/dolphin/dolphin_trk_glue.h>
#include <MetroTRK/debugger/Portable/dserror.h>
#include <MetroTRK/debugger/Portable/mem_TRK.h>
#include <MetroTRK/debugger/Portable/msgbuf.h>
@@ -0,0 +1,14 @@
#ifndef METROTRK_DEBUGGER_OS_DOLPHIN_DOLPHIN_TRK_GLUE_H
#define METROTRK_DEBUGGER_OS_DOLPHIN_DOLPHIN_TRK_GLUE_H
#include <MetroTRK/debugger/Portable/UART.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
UARTError TRKWriteUARTN(const void* src, size_t n);
#ifdef __cplusplus
}
#endif
#endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef METROTRK_DEBUGGER_PORTABLE_UART_H
#define METROTRK_DEBUGGER_PORTABLE_UART_H
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
kUARTNoError = 0x0000,
} UARTError;
#ifdef __cplusplus
}
#endif
#endif
+15
View File
@@ -0,0 +1,15 @@
#ifndef METROTRK_DEBUGGER_PORTABLE_MSG_H
#define METROTRK_DEBUGGER_PORTABLE_MSG_H
#include <MetroTRK/debugger/Portable/dserror.h>
#include <MetroTRK/debugger/Portable/msgbuf.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKMessageSend(TRKMessageBuffer* buf);
#ifdef __cplusplus
}
#endif
#endif
+2 -1
View File
@@ -1,5 +1,6 @@
#ifndef METROTRK_DEBUGGER_PORTABLE_MSGBUF_H
#define METROTRK_DEBUGGER_PORTABLE_MSGBUF_H
#include <MetroTRK/debugger/portable/mutex_TRK.h>
#include <types.h>
#ifdef __cplusplus
extern "C" {
@@ -8,7 +9,7 @@ extern "C" {
#define kMessageBufferSize 2048 /* data block */ + 128 /* additional items */
typedef struct TRKMessageBuffer {
unsigned int WORD_0x0;
TRKMutex mutex; // at 0x0
BOOL used; // at 0x4
unsigned int size; // at 0x8
unsigned int pos; // at 0xC
@@ -6,9 +6,14 @@
extern "C" {
#endif
DSError TRKReleaseMutex(void* p);
DSError TRKAcquireMutex(void* p);
DSError TRKInitializeMutex(void* p);
// Unused?
typedef struct TRKMutex {
char dummy[4];
} TRKMutex;
DSError TRKReleaseMutex(TRKMutex* mutex);
DSError TRKAcquireMutex(TRKMutex* mutex);
DSError TRKInitializeMutex(TRKMutex* mutex);
#ifdef __cplusplus
}
+1 -1
View File
@@ -47,7 +47,7 @@ LDFLAGS := -map $(MAP) -mapunused -proc gekko -fp hard -nodefaults -nofail
#
# Compiler flags for the Metrowerks Target Resident Kernel (MetroTRK)
CFLAGS_TRK := -lang c -enum int -inline auto -Cpp_exceptions off -proc gekko -fp hard -O4,p -ir include/MetroTRK -I- -i include -ir include/MSL -nodefaults
CFLAGS_TRK := -lang c -sdata 0 -use_lmw_stmw on -enum int -inline auto -Cpp_exceptions off -proc gekko -fp hard -O4,p -ir include/MetroTRK -I- -i include -ir include/MSL -nodefaults
# Compiler flags for the CodeWarrior runtime library
CFLAGS_RUNTIME := -lang c -enum int -inline auto -rostr -Cpp_exceptions off -proc gekko -fp hard -O4,p -ir include/MetroTRK -I- -i include -ir include/MSL -nodefaults
# Compiler flags for NintendoWare for Revolution
+1 -1
View File
@@ -358,7 +358,7 @@ METROTRK_O_FILES := \
build/asm/MetroTRK/debugger/Portable/mainloop.o \
build/MetroTRK/debugger/Portable/nubevent.o \
build/asm/MetroTRK/debugger/Portable/nubinit.o \
build/asm/MetroTRK/debugger/Portable/msg.o \
build/MetroTRK/debugger/Portable/msg.o \
build/asm/MetroTRK/debugger/Portable/msgbuf.o \
build/asm/MetroTRK/debugger/Portable/serpoll.o \
build/asm/MetroTRK/debugger/Os/usr_put.o \
+6
View File
@@ -0,0 +1,6 @@
#include <MetroTRK.h>
DSError TRKMessageSend(TRKMessageBuffer* buf) {
TRKWriteUARTN(buf->buf, buf->size);
return kNoError;
}
+12 -3
View File
@@ -1,7 +1,16 @@
#include <MetroTRK.h>
DSError TRKReleaseMutex(void* p) { return kNoError; }
DSError TRKReleaseMutex(TRKMutex* mutex) {
#pragma unused(mutex)
return kNoError;
}
DSError TRKAcquireMutex(void* p) { return kNoError; }
DSError TRKAcquireMutex(TRKMutex* mutex) {
#pragma unused(mutex)
return kNoError;
}
DSError TRKInitializeMutex(void* p) { return kNoError; }
DSError TRKInitializeMutex(TRKMutex* mutex) {
#pragma unused(mutex)
return kNoError;
}
+8 -10
View File
@@ -3,7 +3,7 @@
#define QUEUE_CAPACITY 2
typedef struct TRKEventQueue {
char UNK_0x0[0x4];
TRKMutex mutex; // at 0x0
int size; // at 0x4
int front; // at 0x8
TRKEvent queue[QUEUE_CAPACITY]; // at 0xC
@@ -23,8 +23,7 @@ void TRKConstructEvent(TRKEvent* event, TRKEventType type) {
DSError TRKPostEvent(TRKEvent* event) {
s32 id;
DSError err = kNoError;
TRKAcquireMutex(&gTRKEventQueue);
TRKAcquireMutex(&gTRKEventQueue.mutex);
if (gTRKEventQueue.size == QUEUE_CAPACITY) {
err = kMsgQueueFull;
@@ -40,14 +39,13 @@ DSError TRKPostEvent(TRKEvent* event) {
gTRKEventQueue.size++;
}
TRKReleaseMutex(&gTRKEventQueue);
TRKReleaseMutex(&gTRKEventQueue.mutex);
return err;
}
BOOL TRKGetNextEvent(TRKEvent* event) {
BOOL success = FALSE;
TRKAcquireMutex(&gTRKEventQueue);
TRKAcquireMutex(&gTRKEventQueue.mutex);
if (gTRKEventQueue.size > 0) {
TRK_memcpy(event, &gTRKEventQueue.queue[gTRKEventQueue.front],
@@ -62,18 +60,18 @@ BOOL TRKGetNextEvent(TRKEvent* event) {
success = TRUE;
}
TRKReleaseMutex(&gTRKEventQueue);
TRKReleaseMutex(&gTRKEventQueue.mutex);
return success;
}
DSError TRKInitializeEventQueue(TRKEvent* event) {
TRKInitializeMutex(&gTRKEventQueue);
TRKAcquireMutex(&gTRKEventQueue);
TRKInitializeMutex(&gTRKEventQueue.mutex);
TRKAcquireMutex(&gTRKEventQueue.mutex);
gTRKEventQueue.size = 0;
gTRKEventQueue.front = 0;
gTRKEventQueue.uid = 256;
TRKReleaseMutex(&gTRKEventQueue);
TRKReleaseMutex(&gTRKEventQueue.mutex);
return kNoError;
}