Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
Co-Authored-By: Noumi <[email protected]>
  • Loading branch information
wheremyfoodat and noumidev committed Dec 10, 2024
1 parent 4ce0768 commit f539c33
Show file tree
Hide file tree
Showing 20 changed files with 458 additions and 109 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
src/core/services/ir_user.cpp src/core/services/http.cpp src/core/services/soc.cpp
src/core/services/ssl.cpp src/core/services/news_u.cpp src/core/services/amiibo_device.cpp
src/core/services/csnd.cpp src/core/services/nwm_uds.cpp src/core/services/fonts.cpp
src/core/services/ns.cpp
)
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
src/core/PICA/shader_interpreter.cpp src/core/PICA/dynapica/shader_rec.cpp
Expand Down Expand Up @@ -389,7 +390,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
include/align.hpp include/audio/aac_decoder.hpp include/PICA/pica_simd.hpp include/services/fonts.hpp
include/audio/audio_interpolation.hpp include/audio/hle_mixer.hpp include/audio/dsp_simd.hpp
include/services/dsp_firmware_db.hpp include/frontend_settings.hpp include/fs/archive_twl_photo.hpp
include/fs/archive_twl_sound.hpp include/fs/archive_card_spi.hpp
include/fs/archive_twl_sound.hpp include/fs/archive_card_spi.hpp include/services/ns.hpp
)

cmrc_add_resource_library(
Expand Down
13 changes: 12 additions & 1 deletion include/ipc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
#include <cstdint>

namespace IPC {
namespace BufferType {
enum : std::uint32_t {
Send = 1,
Receive = 2,
};
}

constexpr std::uint32_t responseHeader(std::uint32_t commandID, std::uint32_t normalResponses, std::uint32_t translateResponses) {
// TODO: Maybe validate the response count stuff fits in 6 bits
return (commandID << 16) | (normalResponses << 6) | translateResponses;
}
}

constexpr std::uint32_t pointerHeader(std::uint32_t index, std::uint32_t size, std::uint32_t type) {
return (size << 14) | (index << 10) | (type << 1);
}
} // namespace IPC
8 changes: 7 additions & 1 deletion include/kernel/config_mem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace ConfigMem {
KernelVersionMajor = 0x1FF80003,
SyscoreVer = 0x1FF80010,
EnvInfo = 0x1FF80014,
PrevFirm = 0x1FF80016,
AppMemAlloc = 0x1FF80040,
FirmUnknown = 0x1FF80060,
FirmRevision = 0x1FF80061,
Expand All @@ -30,6 +31,11 @@ namespace ConfigMem {

// Shows what type of hardware we're running on
namespace HardwareCodes {
enum : u8 { Product = 1, Devboard = 2, Debugger = 3, Capture = 4 };
enum : u8 {
Product = 1,
Devboard = 2,
Debugger = 3,
Capture = 4,
};
}
} // namespace ConfigMem
11 changes: 10 additions & 1 deletion include/kernel/handles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace KernelHandles {
CFG_U, // CFG service (Console & region info)
CFG_I,
CFG_S, // Used by most system apps in lieu of cfg:u
CFG_NOR, // Used by system settings app
CSND, // Plays audio directly from PCM samples
DLP_SRVR, // Download Play: Server. Used for network play.
DSP, // DSP service (Used for audio decoding and output)
Expand All @@ -38,11 +39,14 @@ namespace KernelHandles {
NIM, // Updates, DLC, etc
NDM, // ?????
NS_S, // Nintendo Shell service
NWM_EXT, // ?????
NWM_UDS, // Local multiplayer
NEWS_U, // This service literally has 1 command (AddNotification) and I don't even understand what it does
NEWS_S, // news:u on steroids
NEWS_U, // This service literally has 1 command (AddNotification)
PTM_U, // PTM service (Used for accessing various console info, such as battery, shell and pedometer state)
PTM_SYSM, // PTM system service
PTM_PLAY, // PTM Play service, used for retrieving play history
PTM_GETS, // PTM RTC service (GetSystemTime)
SOC, // Socket service
SSL, // SSL service (Totally didn't expect that)
Y2R, // Also does camera stuff
Expand Down Expand Up @@ -82,6 +86,8 @@ namespace KernelHandles {
case CECD: return "CECD";
case CFG_U: return "CFG:U";
case CFG_I: return "CFG:I";
case CFG_S: return "CFG:S";
case CFG_NOR: return "CFG:NOR";
case CSND: return "CSND";
case DSP: return "DSP";
case DLP_SRVR: return "DLP::SRVR";
Expand All @@ -97,13 +103,16 @@ namespace KernelHandles {
case MCU_HWC: return "MCU::HWC";
case MIC: return "MIC";
case NDM: return "NDM";
case NEWS_S: return "NEWS_S";
case NEWS_U: return "NEWS_U";
case NWM_EXT: return "nwm::EXT";
case NWM_UDS: return "nwm::UDS";
case NFC: return "NFC";
case NIM: return "NIM";
case PTM_U: return "PTM:U";
case PTM_SYSM: return "PTM:SYSM";
case PTM_PLAY: return "PTM:PLAY";
case PTM_GETS: return "PTM:GETS";
case SOC: return "SOC";
case SSL: return "SSL";
case Y2R: return "Y2R";
Expand Down
1 change: 1 addition & 0 deletions include/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace Log {
static Logger<false> nwmUdsLogger;
static Logger<false> nimLogger;
static Logger<false> ndmLogger;
static Logger<false> nsLogger;
static Logger<false> ptmLogger;
static Logger<false> socLogger;
static Logger<false> sslLogger;
Expand Down
1 change: 1 addition & 0 deletions include/services/ac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ACService {
void closeAsync(u32 messagePointer);
void createDefaultConfig(u32 messagePointer);
void getConnectingInfraPriority(u32 messagePointer);
void getNZoneBeaconNotFoundEvent(u32 messagePointer);
void getStatus(u32 messagePointer);
void getLastErrorCode(u32 messagePointer);
void getWifiStatus(u32 messagePointer);
Expand Down
7 changes: 7 additions & 0 deletions include/services/boss.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ class BOSSService {

// Service commands
void cancelTask(u32 messagePointer);
void deleteNsData(u32 messagePointer);
void initializeSession(u32 messagePointer);
void getAppNewFlag(u32 messagePointer);
void getErrorCode(u32 messagePointer);
void getNsDataHeaderInfo(u32 messagePointer);
void getNewArrivalFlag(u32 messagePointer);
void getNsDataIdList(u32 messagePointer, u32 commandWord);
void getNsDataLastUpdated(u32 messagePointer);
void getOptoutFlag(u32 messagePointer);
void getStorageEntryInfo(u32 messagePointer); // Unknown what this is, name taken from Citra
void getTaskIdList(u32 messagePointer);
Expand All @@ -26,12 +30,15 @@ class BOSSService {
void getTaskState(u32 messagePointer);
void getTaskStatus(u32 messagePointer);
void getTaskStorageInfo(u32 messagePointer);
void readNsData(u32 messagePointer);
void receiveProperty(u32 messagePointer);
void registerNewArrivalEvent(u32 messagePointer);
void registerStorageEntry(u32 messagePointer);
void registerTask(u32 messagePointer);
void sendProperty(u32 messagePointer);
void setAppNewFlag(u32 messagePointer);
void setOptoutFlag(u32 messagePointer);
void startBgImmediate(u32 messagePointer);
void startTask(u32 messagePointer);
void unregisterStorage(u32 messagePointer);
void unregisterTask(u32 messagePointer);
Expand Down
9 changes: 8 additions & 1 deletion include/services/cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,22 @@ class CFGService {

// Service functions
void getConfigInfoBlk2(u32 messagePointer);
void getConfigInfoBlk8(u32 messagePointer);
void getConfigInfoBlk8(u32 messagePointer, u32 commandWord);
void getCountryCodeID(u32 messagePointer);
void getLocalFriendCodeSeed(u32 messagePointer);
void getRegionCanadaUSA(u32 messagePointer);
void getSystemModel(u32 messagePointer);
void genUniqueConsoleHash(u32 messagePointer);
void secureInfoGetByte101(u32 messagePointer);
void secureInfoGetRegion(u32 messagePointer);
void setConfigInfoBlk4(u32 messagePointer);
void updateConfigNANDSavegame(u32 messagePointer);
void translateCountryInfo(u32 messagePointer);
void isFangateSupported(u32 messagePointer);

// cfg:nor functions
void norInitialize(u32 messagePointer);
void norReadData(u32 messagePointer);

void getConfigInfo(u32 output, u32 blockID, u32 size, u32 permissionMask);

Expand Down
2 changes: 1 addition & 1 deletion include/services/gsp_gpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ class GPUService {
std::memset(ptr, 0, 0x1000);
}
}
};
};
6 changes: 2 additions & 4 deletions include/services/gsp_lcd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
#include "result/result.hpp"

class LCDService {
using Handle = HorizonHandle;

Handle handle = KernelHandles::LCD;
Memory& mem;
MAKE_LOG_FUNCTION(log, gspLCDLogger)

// Service commands
void setLedForceOff(u32 messagePointer);

public:
public:
LCDService(Memory& mem) : mem(mem) {}
void reset();
void handleSyncRequest(u32 messagePointer);
Expand Down
25 changes: 25 additions & 0 deletions include/services/ns.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "helpers.hpp"
#include "kernel_types.hpp"
#include "logger.hpp"
#include "memory.hpp"
#include "result/result.hpp"

class NSService {
Memory& mem;
MAKE_LOG_FUNCTION(log, nsLogger)

// Service commands
void launchTitle(u32 messagePointer);

public:
enum class Type {
S, // ns:s
P, // ns:p
C, // ns:c
};

NSService(Memory& mem) : mem(mem) {}
void reset();
void handleSyncRequest(u32 messagePointer, Type type);
};
1 change: 1 addition & 0 deletions include/services/ptm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PTMService {

public:
enum class Type {
GETS, // ptm:gets
U, // ptm:u
SYSM, // ptm:sysm
PLAY, // ptm:play
Expand Down
12 changes: 7 additions & 5 deletions include/services/service_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
#include "services/mcu/mcu_hwc.hpp"
#include "services/mic.hpp"
#include "services/ndm.hpp"
#include "services/nwm_uds.hpp"
#include "services/news_u.hpp"
#include "services/nfc.hpp"
#include "services/nim.hpp"
#include "services/ns.hpp"
#include "services/nwm_uds.hpp"
#include "services/ptm.hpp"
#include "services/soc.hpp"
#include "services/ssl.hpp"
Expand All @@ -52,11 +53,11 @@ class ServiceManager {

MAKE_LOG_FUNCTION(log, srvLogger)

ACService ac;
ACService ac;
ACTService act;
AMService am;
AMService am;
APTService apt;
BOSSService boss;
BOSSService boss;
CAMService cam;
CECDService cecd;
CFGService cfg;
Expand All @@ -76,7 +77,8 @@ class ServiceManager {
NewsUService news_u;
NFCService nfc;
NwmUdsService nwm_uds;
NIMService nim;
NIMService nim;
NSService ns;
PTMService ptm;
SOCService soc;
SSLService ssl;
Expand Down
20 changes: 18 additions & 2 deletions src/core/services/ac.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "services/ac.hpp"

#include "ipc.hpp"

namespace ACCommands {
Expand All @@ -10,6 +11,7 @@ namespace ACCommands {
GetStatus = 0x000C0000,
GetWifiStatus = 0x000D0000,
GetConnectingInfraPriority = 0x000F0000,
GetNZoneBeaconNotFoundEvent = 0x002F0004,
RegisterDisconnectEvent = 0x00300004,
IsConnected = 0x003E0042,
SetClientVersion = 0x00400042,
Expand All @@ -29,12 +31,17 @@ void ACService::handleSyncRequest(u32 messagePointer) {
case ACCommands::CreateDefaultConfig: createDefaultConfig(messagePointer); break;
case ACCommands::GetConnectingInfraPriority: getConnectingInfraPriority(messagePointer); break;
case ACCommands::GetLastErrorCode: getLastErrorCode(messagePointer); break;
case ACCommands::GetNZoneBeaconNotFoundEvent: getNZoneBeaconNotFoundEvent(messagePointer); break;
case ACCommands::GetStatus: getStatus(messagePointer); break;
case ACCommands::GetWifiStatus: getWifiStatus(messagePointer); break;
case ACCommands::IsConnected: isConnected(messagePointer); break;
case ACCommands::RegisterDisconnectEvent: registerDisconnectEvent(messagePointer); break;
case ACCommands::SetClientVersion: setClientVersion(messagePointer); break;
default: Helpers::panic("AC service requested. Command: %08X\n", command);

default:
mem.write32(messagePointer + 4, Result::Success);
Helpers::warn("AC service requested. Command: %08X\n", command);
break;
}
}

Expand Down Expand Up @@ -72,7 +79,7 @@ void ACService::getLastErrorCode(u32 messagePointer) {

mem.write32(messagePointer, IPC::responseHeader(0x0A, 2, 0));
mem.write32(messagePointer + 4, Result::Success);
mem.write32(messagePointer + 8, 0); // Hopefully this means no error?
mem.write32(messagePointer + 8, 0); // Hopefully this means no error?
}

void ACService::getConnectingInfraPriority(u32 messagePointer) {
Expand Down Expand Up @@ -136,4 +143,13 @@ void ACService::registerDisconnectEvent(u32 messagePointer) {

mem.write32(messagePointer, IPC::responseHeader(0x30, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
}

void ACService::getNZoneBeaconNotFoundEvent(u32 messagePointer) {
const u32 processID = mem.read32(messagePointer + 8);
const Handle event = mem.read32(messagePointer + 16);
log("AC::GetNZoneBeaconNotFoundEvent (process ID = %X, event = %X) (stubbed)\n", processID, event);

mem.write32(messagePointer, IPC::responseHeader(0x2F, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
}
Loading

0 comments on commit f539c33

Please sign in to comment.