Skip to content

Commit

Permalink
Version 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryOderNichts committed Apr 1, 2023
1 parent 2d3a0ff commit 7850f4d
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 32 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ in-region titles.
Displays info about several parts of the system.
Including serial number, manufacturing date, console type, regions, memory devices...

### Submit System Data
Allows submitting system information to an online database to collect various statistics about Wii U consoles.
This is entirely optional and personally identifying information will be kept confidential.
[The database can be found here!](https://wiiu.gerbilsoft.com/)

## Building
```bash
# build the docker container
Expand Down
3 changes: 3 additions & 0 deletions ios_kernel/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ int _main(void* arg)
// patch MCP_SetSysProdSettings debug mode check
*(volatile uint32_t*) (0x05024648 - 0x05000000 + 0x081c0000) = 0x20002000; // mov r0, #0; mov r0, #0

// nop out odm log to not spam logs when stopping drive
*(volatile uint32_t*) 0x1073880c = 0xe12fff1e; // bx lr

restore_mmu(control_register);

// invalidate all cache
Expand Down
1 change: 1 addition & 0 deletions ios_mcp/imports.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PROVIDE(strncmp = 0x05055e10);
PROVIDE(usleep = 0x050564e4);

PROVIDE(bspGetHardwareVersion = 0x0503d6e8);
PROVIDE(bspInit = 0x0503d35c);
PROVIDE(bspWrite = 0x0503d460);
PROVIDE(bspRead = 0x0503d550);

Expand Down
2 changes: 1 addition & 1 deletion ios_mcp/source/imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum BSPHardwareVersions {

int bspGetHardwareVersion(uint32_t* version);

int bspInit(const char* entity, uint32_t instance, const char* attribute, uint32_t size, const void* buffer);
int bspWrite(const char* entity, uint32_t instance, const char* attribute, uint32_t size, const void* buffer);
int bspRead(const char* entity, uint32_t instance, const char* attribute, uint32_t size, void* buffer);

Expand Down Expand Up @@ -108,7 +109,6 @@ int IOS_Syscall0x81(int type, uint32_t address, uint32_t value);

// context: 0x70-byte buffer for chaining hash calls together
#define IOSC_HASH_CONTEXT_SIZE 0x70
// NOTE: These flags generate an SHA-256 hash, not SHA-1.
#define IOSC_HASH_FLAGS_SHA1_INIT 0x000
#define IOSC_HASH_FLAGS_SHA1_UPDATE 0x001
#define IOSC_HASH_FLAGS_SHA1_FINALIZE 0x002
Expand Down
21 changes: 11 additions & 10 deletions ios_mcp/source/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int drawMenu(const char* title, const Menu* menu, size_t count,
uint8_t cur_flag = 0;
uint8_t flag = 0;
while (1) {
readSystemEventFlag(&flag);
SMC_ReadSystemEventFlag(&flag);
if (cur_flag != flag) {
if (flag & SYSTEM_EVENT_FLAG_EJECT_BUTTON) {
prev_selected = selected;
Expand Down Expand Up @@ -212,7 +212,7 @@ void waitButtonInput(void)
uint8_t flag = 0;

while (1) {
readSystemEventFlag(&flag);
SMC_ReadSystemEventFlag(&flag);
if (cur_flag != flag) {
if ((flag & SYSTEM_EVENT_FLAG_EJECT_BUTTON) || (flag & SYSTEM_EVENT_FLAG_POWER_BUTTON)) {
return;
Expand Down Expand Up @@ -937,29 +937,30 @@ int menuThread(void* arg)
printf("menuThread running\n");

// set LED to purple-orange blinking
setNotificationLED(NOTIF_LED_RED | NOTIF_LED_RED_BLINKING | NOTIF_LED_BLUE | NOTIF_LED_BLUE_BLINKING | NOTIF_LED_ORANGE);
SMC_SetNotificationLED(NOTIF_LED_RED | NOTIF_LED_RED_BLINKING | NOTIF_LED_BLUE | NOTIF_LED_BLUE_BLINKING | NOTIF_LED_ORANGE);

// stop ppcHeartbeatThread and reset PPC
IOS_CancelThread(ppcHeartBeatThreadId, 0);
resetPPC();

// cut power to the disc drive to not eject a disc every eject press
setDrivePower(0);
SMC_SetODDPower(0);

#ifdef DC_INIT
// (re-)init the graphics subsystem
GFX_SubsystemInit(0);

/* Note: CONFIGURATION_0 is 720p instead of 480p,
but doesn't shut down the GPU properly? The
GamePad just stays connected after calling iOS_Shutdown.
To be safe, let's use CONFIGURATION_1 for now */

// init display output
initDisplay(DC_CONFIGURATION_1);
DISPLAY_DCInit(DC_CONFIGURATION_1);

/* Note about the display configuration struct:
The returned framebuffer address seems to be AV out only?
Writing to the hardcoded addresses in gfx.c works for HDMI though */
//DisplayController_Config dc_config;
//readDCConfig(&dc_config);
DC_Config dc_config;
DISPLAY_ReadDCConfig(&dc_config);
#endif

// initialize the font
Expand All @@ -982,7 +983,7 @@ int menuThread(void* arg)
}

// set LED to purple
setNotificationLED(NOTIF_LED_RED | NOTIF_LED_BLUE);
SMC_SetNotificationLED(NOTIF_LED_RED | NOTIF_LED_BLUE);

int selected = 0;
while (1) {
Expand Down
4 changes: 2 additions & 2 deletions ios_mcp/source/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

#pragma once

#define VERSION_STRING "0.4+"

#include <stddef.h>
#include <stdint.h>

#define VERSION_STRING "0.5"

// FSA handle
// Initialized by menuThread().
extern int fsaHandle;
Expand Down
2 changes: 1 addition & 1 deletion ios_mcp/source/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdint.h>
#include <stdio.h>

#define SOL_SOCKET 0xFFFF
#define SOL_SOCKET -1

#define PF_UNSPEC 0
#define PF_INET 2
Expand Down
25 changes: 15 additions & 10 deletions ios_mcp/source/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ int resetPPC(void)
return 0;
}

int readSystemEventFlag(uint8_t* flag)
{
return bspRead("SMC", 0, "SystemEventFlag", 1, flag);
}

int copy_file(int fsaFd, const char* src, const char* dst)
{
int readHandle;
Expand Down Expand Up @@ -86,22 +81,32 @@ int copy_file(int fsaFd, const char* src, const char* dst)
return (res > 0) ? 0 : res;
}

int initDisplay(uint32_t configuration)
int GFX_SubsystemInit(uint8_t unk)
{
return bspInit("GFX", 0, "subsystem", 1, &unk);
}

int DISPLAY_DCInit(uint32_t configuration)
{
return bspWrite("DISPLAY", 0, "DC_INIT", 4, &configuration);
}

int readDCConfig(DisplayController_Config* config)
int DISPLAY_ReadDCConfig(DC_Config* config)
{
return bspRead("DISPLAY", 0, "DC_CONFIG", 0x14, config);
return bspRead("DISPLAY", 0, "DC_CONFIG", sizeof(DC_Config), config);
}

int SMC_ReadSystemEventFlag(uint8_t* flag)
{
return bspRead("SMC", 0, "SystemEventFlag", 1, flag);
}

int setNotificationLED(uint8_t mask)
int SMC_SetNotificationLED(uint8_t mask)
{
return bspWrite("SMC", 0, "NotificationLED", 1, &mask);
}

int setDrivePower(int power)
int SMC_SetODDPower(int power)
{
return bspWrite("SMC", 0, "ODDPower", 4, &power);
}
20 changes: 12 additions & 8 deletions ios_mcp/source/utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <stdint.h>
#include <assert.h>

/**
* Number of elements in an array.
Expand Down Expand Up @@ -31,13 +32,14 @@ enum {
DC_CONFIGURATION_1,
};

typedef struct DisplayController_Config {
typedef struct DC_Config {
uint32_t id;
uint32_t field_0x4;
int width;
int height;
void* framebuffer;
} DisplayController_Config;
} DC_Config;
static_assert(sizeof(DC_Config) == 0x14);

enum {
NOTIF_LED_OFF = 0,
Expand All @@ -57,14 +59,16 @@ int EEPROM_Read(uint16_t offset, uint16_t num, uint16_t* buf);

int resetPPC(void);

int readSystemEventFlag(uint8_t* flag);

int copy_file(int fsaFd, const char* src, const char* dst);

int initDisplay(uint32_t configuration);
int GFX_SubsystemInit(uint8_t unk);

int DISPLAY_DCInit(uint32_t configuration);

int DISPLAY_ReadDCConfig(DC_Config* config);

int readDCConfig(DisplayController_Config* config);
int SMC_ReadSystemEventFlag(uint8_t* flag);

int setNotificationLED(uint8_t mask);
int SMC_SetNotificationLED(uint8_t mask);

int setDrivePower(int power);
int SMC_SetODDPower(int power);
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7850f4d

Please sign in to comment.