Stratosphere: Fix IServer constructors. SM is fully functional on hardware now.

This commit is contained in:
Michael Scire
2018-04-22 05:13:33 -06:00
parent 674528b246
commit ecf2517bd5
7 changed files with 26 additions and 31 deletions

View File

@@ -48,16 +48,16 @@ void __appExit(void) {
int main(int argc, char **argv)
{
consoleDebugInit(debugDevice_SVC);
/* TODO: What's a good timeout value to use here? */
WaitableManager *server_manager = new WaitableManager(U64_MAX);
/* Create sm:, (and thus allow things to register to it). */
server_manager->add_waitable(new ManagedPortServer<UserService>("dbg:", 0x40));
server_manager->add_waitable(new ManagedPortServer<UserService>("sm:", 0x40));
/* Create sm:m manually. */
Handle smm_h;
if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("dbg:m"), 1, false, &smm_h))) {
if (R_FAILED(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h))) {
/* TODO: Panic. */
}

View File

@@ -36,6 +36,7 @@ Registration::Service *Registration::GetFreeService() {
bool Registration::IsValidForSac(u8 *sac, size_t sac_size, u64 service, bool is_host) {
u8 cur_ctrl;
u64 cur_service;
u64 service_for_compare;
bool cur_is_host;
size_t remaining = sac_size;
while (remaining) {
@@ -51,12 +52,17 @@ bool Registration::IsValidForSac(u8 *sac, size_t sac_size, u64 service, bool is_
cur_service |= ((u64)sac[i]) << (8 * i);
}
/* Check if the last byte is a wildcard ('*') */
service_for_compare = service;
if (sac[cur_size - 1] == '*') {
u64 mask = U64_MAX;
for (unsigned int i = 0; i < 8 - (cur_size - 1); i++) {
mask >>= 8;
}
/* Mask cur_service, service with 0xFF.. up until the wildcard. */
cur_service &= U64_MAX >> (8 * (8 - cur_size - 1));
service &= U64_MAX >> (8 * (8 - cur_size - 1));
cur_service &= mask;
service_for_compare &= mask;
}
if (cur_service == service && (!is_host || cur_is_host)) {
if (cur_service == service_for_compare && (!is_host || cur_is_host)) {
return true;
}
sac += cur_size;
@@ -166,7 +172,7 @@ Result Registration::GetServiceForPid(u64 pid, u64 service, Handle *out) {
return 0xC15;
}
if (pid >= REGISTRATION_PID_BUILTIN_MAX) {
if (pid >= REGISTRATION_PID_BUILTIN_MAX && service != smEncodeName("dbg:m")) {
Registration::Process *proc = GetProcessForPid(pid);
if (proc == NULL) {
return 0x415;