First Commit

This commit is contained in:
2025-02-06 22:24:29 +08:00
parent ed7df4c81e
commit 7539e6a53c
18116 changed files with 6181499 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
*.3dsx
*.elf
*.cxi
*.cia
build/
hide/
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,64 @@
segment p 0000
br 0x0000$0800 always// reset vector
br 0x0000$3000 always
br 0x0000$3000 always
br 0x0000$3000 always // int0
data 0000
data 0000
data 0000
data 0000
data 0000
data 0000
br 0x0000$3000 always // int1
data 0000
data 0000
data 0000
data 0000
data 0000
data 0000
br 0x0000$3000 always // int2
segment p 0800 // pre-write shutdown sequence
load 0x0080u8 page
clr b0 always
mov b0l [page:0x00c8u8] // T_REPLY2
br 0x0000$1000 always // jump to epilogue first to dump the initial register value
segment p 1000 // Main loop
load 0x0000u8 page
mov [page:0x0000u8] b0l // get signal
br 0x0000$1000 eq // loop back if no signal
mov [page:0x0001u8] b0l // get command type
cmpv 0x$0000 b0l
br 0x0000$2000 eq
cmpv 0x$0001 b0l
br 0x0000$3000 eq
br 0x0000$4000 always
segment p 2000 // read
mov [page:0x0002u8] r0
mov [r0] r1
mov r1 [page:0x0003u8]
br 0x0000$4000 always
segment p 3000 // write
mov [page:0x0002u8] r0
mov [page:0x0003u8] r1
mov r1 [r0]
br 0x0000$4000 always
segment p 4000 // end
clr b0 always
mov b0l [page:0x0000u8] // clear signal
br 0x0000$1000 always // loop back
segment d 0000 // signal area
data 0000 // Start signal
data 0000 // Operation type
data 0000 // Address
data 0000 // Data

View File

@@ -0,0 +1,226 @@
BasicInfo:
Title : SVRT
ProductCode : CTR-P-SVRT
Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem
RomFs:
# Specifies the root path of the read only file system to include in the ROM.
#RootPath : romfs
TitleInfo:
Category : Application
UniqueId : 0xff556
Option:
UseOnSD : true # true if App is to be installed to SD
FreeProductCode : true # Removes limitations on ProductCode
MediaFootPadding : false # If true CCI files are created with padding
EnableCrypt : false # Enables encryption for NCCH and CIA
EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
AccessControlInfo:
CoreVersion : 2
# Exheader Format Version
DescVersion : 2
# Minimum Required Kernel Version (below is for 4.5.0)
ReleaseKernelMajor : "02"
ReleaseKernelMinor : "33"
# ExtData
UseExtSaveData : false # enables ExtData
#ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId
# FS:USER Archive Access Permissions
# Uncomment as required
FileSystemAccess:
- CategorySystemApplication
- CategoryHardwareCheck
- CategoryFileSystemTool
- Debug
#- TwlCardBackup
#- TwlNandData
#- Boss
- DirectSdmc
#- Core
#- CtrNandRo
#- CtrNandRw
#- CtrNandRoWrite
#- CategorySystemSettings
#- CardBoard
#- ExportImportIvs
#- DirectSdmcWrite
#- SwitchCleanup
#- SaveDataMove
#- Shop
#- Shell
#- CategoryHomeMenu
# Process Settings
MemoryType : Application # Application/System/Base
SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB
IdealProcessor : 0
AffinityMask : 1
Priority : 16
MaxCpu : 0 # Let system decide
HandleTableSize : 0x200
DisableDebug : false
EnableForceDebug : false
CanWriteSharedPage : false
CanUsePrivilegedPriority : false
CanUseNonAlphabetAndNumber : true
PermitMainFunctionArgument : true
CanShareDeviceMemory : true
RunnableOnSleep : false
SpecialMemoryArrange : false
# New3DS Exclusive Process Settings
SystemModeExt : Legacy # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
CpuSpeed : 268MHz # 268MHz(Default)/804MHz
EnableL2Cache : false # false(default)/true
CanAccessCore2 : false
# Virtual Address Mappings
IORegisterMapping:
- 1ff00000-1ff7ffff # DSP memory
MemoryMapping:
- 1f000000-1f5fffff:r # VRAM
# Accessible SVCs, <Name>:<ID>
SystemCallAccess:
InvalidateProcessDataCache: 82
FlushProcessDataCache: 84
ArbitrateAddress: 34
Break: 60
CancelTimer: 28
ClearEvent: 25
ClearTimer: 29
CloseHandle: 35
ConnectToPort: 45
ControlMemory: 1
CreateAddressArbiter: 33
CreateEvent: 23
CreateMemoryBlock: 30
CreateMutex: 19
CreateSemaphore: 21
CreateThread: 8
CreateTimer: 26
DuplicateHandle: 39
ExitProcess: 3
ExitThread: 9
GetCurrentProcessorNumber: 17
GetHandleInfo: 41
GetProcessId: 53
GetProcessIdOfThread: 54
GetProcessIdealProcessor: 6
GetProcessInfo: 43
GetResourceLimit: 56
GetResourceLimitCurrentValues: 58
GetResourceLimitLimitValues: 57
GetSystemInfo: 42
GetSystemTick: 40
GetThreadContext: 59
GetThreadId: 55
GetThreadIdealProcessor: 15
GetThreadInfo: 44
GetThreadPriority: 11
MapMemoryBlock: 31
OutputDebugString: 61
QueryMemory: 2
ReleaseMutex: 20
ReleaseSemaphore: 22
SendSyncRequest1: 46
SendSyncRequest2: 47
SendSyncRequest3: 48
SendSyncRequest4: 49
SendSyncRequest: 50
SetThreadPriority: 12
SetTimer: 27
SignalEvent: 24
SleepThread: 10
UnmapMemoryBlock: 32
WaitSynchronization1: 36
WaitSynchronizationN: 37
Backdoor: 123
# Service List
# Maximum 34 services (32 if firmware is prior to 9.3.0)
ServiceAccessControl:
- cfg:u
- fs:USER
- gsp::Gpu
- hid:USER
- ndm:u
- pxi:dev
- APT:U
- ac:u
- act:u
- am:net
- boss:U
- cam:u
- cecd:u
- csnd:SND
- frd:u
- http:C
- ir:USER
- ir:u
- ir:rst
- ldr:ro
- mic:u
- news:u
- nfc:u
- nim:aoc
- nwm::UDS
- ptm:u
- qtm:u
- soc:U
- ssl:C
- y2r:u
- ps:ps
SystemControlInfo:
SaveDataSize: 512K
RemasterVersion: 0
StackSize: 0x40000
# Modules that run services listed above should be included below
# Maximum 48 dependencies
# If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves)
# So act, nfc and qtm are commented for 4.x support. Uncomment if you need these.
# <module name>:<module titleid>
Dependency:
ac: 0x0004013000002402
#act: 0x0004013000003802
am: 0x0004013000001502
boss: 0x0004013000003402
camera: 0x0004013000001602
cecd: 0x0004013000002602
cfg: 0x0004013000001702
codec: 0x0004013000001802
csnd: 0x0004013000002702
dlp: 0x0004013000002802
dsp: 0x0004013000001a02
friends: 0x0004013000003202
gpio: 0x0004013000001b02
gsp: 0x0004013000001c02
hid: 0x0004013000001d02
http: 0x0004013000002902
i2c: 0x0004013000001e02
ir: 0x0004013000003302
mcu: 0x0004013000001f02
mic: 0x0004013000002002
ndm: 0x0004013000002b02
news: 0x0004013000003502
#nfc: 0x0004013000004002
nim: 0x0004013000002c02
nwm: 0x0004013000002d02
pdn: 0x0004013000002102
ps: 0x0004013000003102
ptm: 0x0004013000002202
#qtm: 0x0004013020004202
ro: 0x0004013000003702
socket: 0x0004013000002e02
spi: 0x0004013000002302
ssl: 0x0004013000002f02

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import sys
import socket
import struct
for UDP_IP in ["192.168.1.158", "127.0.0.1"]:
UDP_PORT = 8888
MESSAGE = struct.pack('<H', 0xD592)
for i in range(1, len(sys.argv)):
inst = sys.argv[i]
if inst == "r":
MESSAGE += struct.pack('<H', 0)
continue
elif inst == "w":
MESSAGE += struct.pack('<H', 1)
continue
MESSAGE += struct.pack('<H', int(inst, 16))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

View File

@@ -0,0 +1,291 @@
#include <string>
#include <unordered_map>
#include <vector>
#include <3ds.h>
#include <arpa/inet.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include "cdc_bin.h"
PrintConsole topScreen, bottomScreen;
void MoveCursor(unsigned row, unsigned col) {
printf("\x1b[%u;%uH", row + 1, col + 1);
}
enum Color {
Reset = 0,
Black = 30,
Red = 31,
Green = 32,
Yellow = 33,
Blue = 34,
Magnenta = 35,
Cyan = 36,
White = 37,
};
void SetColor(Color color, Color background) {
printf("\x1b[%dm\x1b[%dm", (int)color, (int)background + 10);
}
void FlushCache(void* ptr, u32 size) {
svcFlushProcessDataCache(CUR_PROCESS_HANDLE, ptr, size);
}
void InvalidateCache(void* ptr, u32 size) {
svcInvalidateProcessDataCache(CUR_PROCESS_HANDLE, ptr, size);
}
vu16* dspP = (vu16*)0x1FF00000;
vu16* dspD = (vu16*)0x1FF40000;
u32 playground_size = 0x80;
vu8* dsp_playground = (vu8*)(dspD + 0x1000); // note: address = 0x1000 in dsp space
vu8* fcram_playground;
void PrintAll() {
consoleSelect(&topScreen);
MoveCursor(0, 0);
printf("DSP @ 0x1000:\n");
InvalidateCache((void*)dsp_playground, playground_size);
for (u32 i = 0; i < playground_size; ++i) {
u8 v = dsp_playground[i];
if (v != i) {
SetColor(Green, Black);
}
printf("%02X", v);
SetColor(Reset, Reset);
if (i % 16 == 15) {
printf("\n");
} else {
printf(" ");
}
}
u32 addr = (u32)fcram_playground;
if (addr < 0x1C000000) {
addr = addr - 0x14000000 + 0x20000000;
} else {
addr = addr - 0x30000000 + 0x20000000;
}
printf("\nFCRAM @ 0x%08lX:\n", addr);
InvalidateCache((void*)fcram_playground, playground_size);
for (u32 i = 0; i < playground_size; ++i) {
u8 v = fcram_playground[i];
if (v != (i | 0x80)) {
SetColor(Green, Black);
}
printf("%02X", v);
SetColor(Reset, Reset);
if (i % 16 == 15) {
printf("\n");
} else {
printf(" ");
}
}
consoleSelect(&bottomScreen);
}
void ResetDspPlayground() {
InvalidateCache((void*)dsp_playground, playground_size);
for (u32 i = 0; i < playground_size; ++i) {
dsp_playground[i] = i;
}
FlushCache((void*)dsp_playground, playground_size);
}
void ResetFcramPlayground() {
InvalidateCache((void*)fcram_playground, playground_size);
for (u32 i = 0; i < playground_size; ++i) {
fcram_playground[i] = i | 0x80;
}
FlushCache((void*)fcram_playground, playground_size);
}
int udp_s;
int udp_s_broadcast;
void UdpInit() {
#define SOC_ALIGN 0x1000
#define SOC_BUFFERSIZE 0x100000
static u32* SOC_buffer;
// allocate buffer for SOC service
SOC_buffer = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE);
if (SOC_buffer == NULL) {
printf("memalign: failed to allocate\n");
return;
}
Result ret;
if ((ret = socInit(SOC_buffer, SOC_BUFFERSIZE)) != 0) {
printf("socInit: 0x%08lX\n", ret);
return;
}
sockaddr_in si_me;
// create a UDP socket
if ((udp_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
printf("socket() failed\n");
return;
}
// zero out the structure
memset(&si_me, 0, sizeof(si_me));
si_me.sin_family = AF_INET;
si_me.sin_port = htons(8888);
si_me.sin_addr.s_addr = htonl(INADDR_ANY);
// bind socket to port
if (bind(udp_s, (sockaddr*)&si_me, sizeof(si_me)) == -1) {
printf("bind() failed\n");
return;
}
// create a UDP broadcast socket
if ((udp_s_broadcast = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
printf("socket()(broadcast) failed\n");
return;
}
}
constexpr unsigned BUFLEN = 512;
char buf[BUFLEN];
void Fire() {
dspD[0] = 1;
FlushCache((void*)dspD, 8);
while(true) {
InvalidateCache((void*)dspD, 8);
if (dspD[0] == 0)
break;
}
}
void CheckPackage() {
sockaddr_in si_other;
socklen_t slen = sizeof(si_other);
int recv_len;
if ((recv_len = recvfrom(udp_s, buf, BUFLEN, MSG_DONTWAIT, (sockaddr*)&si_other, &slen)) < 4)
return;
u16 magic;
memcpy(&magic, buf, 2);
if (magic == 0xD592) {
std::vector<u16> command_package((recv_len - 2) / 2);
printf("Command received\n");
memcpy(command_package.data(), buf + 2, command_package.size() * 2);
switch (command_package[0]) {
case 0: {
if (command_package.size() != 2) {
printf("Wrong length for Read\n");
break;
}
u16 addr = command_package[1];
printf("Read [%04X] -> ", addr);
dspD[1] = 0;
dspD[2] = addr;
dspD[3] = 0xCCCC;
Fire();
printf("%04X\n", dspD[3]);
break;
}
case 1: {
if (command_package.size() != 3) {
printf("Wrong length for Write\n");
break;
}
u16 addr = command_package[1];
u16 value = command_package[2];
printf("Write [%04X] <- %04X", addr, value);
dspD[1] = 1;
dspD[2] = addr;
dspD[3] = value;
Fire();
printf(" OK\n");
break;
}
}
}
}
int main() {
fcram_playground = (vu8*)linearAlloc(playground_size);
ResetDspPlayground();
ResetFcramPlayground();
aptInit();
gfxInitDefault();
consoleInit(GFX_TOP, &topScreen);
consoleInit(GFX_BOTTOM, &bottomScreen);
consoleSelect(&bottomScreen);
printf("Hello!\n");
UdpInit();
printf("dspInit: %08lX\n", dspInit());
bool loaded = false;
printf("DSP_LoadComponent: %08lX\n",
DSP_LoadComponent(cdc_bin, cdc_bin_size, 0xFF, 0xFF, &loaded));
printf("loaded = %d\n", loaded);
svcSleepThread(1000000000);
char hostname[100];
gethostname(hostname, 100);
printf("IP: %s port: 8888\n", hostname);
// Main loop
while (aptMainLoop()) {
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break;
if (kDown & KEY_A) {
ResetDspPlayground();
printf("Reset DSP playground\n");
}
if (kDown & KEY_B) {
ResetFcramPlayground();
printf("Reset FCRAM playground\n");
}
CheckPackage();
PrintAll();
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
// Wait for VBlank
gspWaitForVBlank();
}
socExit();
dspExit();
gfxExit();
aptExit();
return 0;
}