Merge remote-tracking branch 'origin/master'

* origin/master: (98 commits)
  rosalina: fix for latest libctru changes
  pm: fix critical bugs where 1.0(?) titles not in the list have scheduling mode misconfigured
  loader: revert to use the NS patch due to a Nintendo bug: https://www.3dbrew.org/wiki/NCCH/Extended_Header#Flag1
  loader: replace NS N3DS CPU patch with exheader override, fix overriding exheader with homebrew
  rosalina: ntp: use PTMSYSM_SetRtcTime
  revert the memory map to the old one (mostly)
  fix module loading
  kext: fix outer memory cacheability on newer versions
  so bascially rosalina's image...
  rosalina: add hidden debug info menu
  rosalina: refactor menu handling
  rosalina: rephrase brightness warning
  rosalina: add brightness control menu
  rosalina/pm: remove fs patch, use pm instead
  rosalina: cleanup variable names
  rosalina: reorder menus
  Fix latest commit
  rosalina menu: add scrolling, cpad and inputredir support (note: no ZL/ZR due to technical reasons)
  stuff
  newlib...
  ...

# Conflicts:
#	k11_extension/source/main.c
#	k11_extension/source/svc/UnmapProcessMemoryEx.c
#	sysmodules/rosalina/Makefile
#	sysmodules/rosalina/include/menu.h
#	sysmodules/rosalina/include/utils.h
#	sysmodules/rosalina/source/errdisp.c
#	sysmodules/rosalina/source/main.c
#	sysmodules/rosalina/source/menu.c
#	sysmodules/rosalina/source/menus.c
This commit is contained in:
Lorenzo Dellacà
2020-07-04 02:43:27 +02:00
266 changed files with 3161 additions and 1525 deletions

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -9,15 +9,15 @@
#include "gdb/net.h"
#include "gdb/debug.h"
extern Handle terminationRequestEvent;
extern bool terminationRequest;
extern Handle preTerminationEvent;
extern bool preTerminationRequested;
void GDB_RunMonitor(GDBServer *server)
{
Handle handles[3 + MAX_DEBUG];
Result r = 0;
handles[0] = terminationRequestEvent;
handles[0] = preTerminationEvent;
handles[1] = server->super.shall_terminate_event;
handles[2] = server->statusUpdated;
@@ -81,5 +81,5 @@ void GDB_RunMonitor(GDBServer *server)
RecursiveLock_Unlock(&ctx->lock);
}
}
while(!terminationRequest && server->super.running);
while(!preTerminationRequested && server->super.running);
}

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -177,7 +177,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
memcpy(backupbuf, ctx->buffer, ctx->latestSentPacketSize);
memset(ctx->buffer, 0, sizeof(ctx->buffer));
int r = soc_recv(ctx->super.sockfd, ctx->buffer, sizeof(ctx->buffer), MSG_PEEK);
int r = socRecv(ctx->super.sockfd, ctx->buffer, sizeof(ctx->buffer), MSG_PEEK);
if(r < 1)
return -1;
if(ctx->buffer[0] == '+') // GDB sometimes acknowleges TCP acknowledgment packets (yes...). IDA does it properly
@@ -186,20 +186,20 @@ int GDB_ReceivePacket(GDBContext *ctx)
return -1;
// Consume it
r = soc_recv(ctx->super.sockfd, ctx->buffer, 1, 0);
r = socRecv(ctx->super.sockfd, ctx->buffer, 1, 0);
if(r != 1)
return -1;
ctx->buffer[0] = 0;
r = soc_recv(ctx->super.sockfd, ctx->buffer, sizeof(ctx->buffer), MSG_PEEK);
r = socRecv(ctx->super.sockfd, ctx->buffer, sizeof(ctx->buffer), MSG_PEEK);
if(r == -1)
goto packet_error;
}
else if(ctx->buffer[0] == '-')
{
soc_send(ctx->super.sockfd, backupbuf, ctx->latestSentPacketSize, 0);
socSend(ctx->super.sockfd, backupbuf, ctx->latestSentPacketSize, 0);
return 0;
}
int maxlen = r > (int)sizeof(ctx->buffer) ? (int)sizeof(ctx->buffer) : r;
@@ -215,7 +215,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
else
{
u8 checksum;
r = soc_recv(ctx->super.sockfd, ctx->buffer, 3 + pos - ctx->buffer, 0);
r = socRecv(ctx->super.sockfd, ctx->buffer, 3 + pos - ctx->buffer, 0);
if(r != 3 + pos - ctx->buffer || GDB_DecodeHex(&checksum, pos + 1, 1) != 1)
goto packet_error;
else if(GDB_ComputeChecksum(ctx->buffer + 1, pos - ctx->buffer - 1) != checksum)
@@ -227,7 +227,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
}
else if(ctx->buffer[0] == '\x03')
{
r = soc_recv(ctx->super.sockfd, ctx->buffer, 1, 0);
r = socRecv(ctx->super.sockfd, ctx->buffer, 1, 0);
if(r != 1)
goto packet_error;
@@ -236,7 +236,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
if(!(ctx->flags & GDB_FLAG_NOACK))
{
int r2 = soc_send(ctx->super.sockfd, "+", 1, 0);
int r2 = socSend(ctx->super.sockfd, "+", 1, 0);
if(r2 != 1)
return -1;
}
@@ -252,7 +252,7 @@ int GDB_ReceivePacket(GDBContext *ctx)
packet_error:
if(!(ctx->flags & GDB_FLAG_NOACK))
{
r = soc_send(ctx->super.sockfd, "-", 1, 0);
r = socSend(ctx->super.sockfd, "-", 1, 0);
if(r != 1)
return -1;
else
@@ -264,7 +264,7 @@ packet_error:
static int GDB_DoSendPacket(GDBContext *ctx, u32 len)
{
int r = soc_send(ctx->super.sockfd, ctx->buffer, len, 0);
int r = socSend(ctx->super.sockfd, ctx->buffer, len, 0);
if(r > 0)
ctx->latestSentPacketSize = r;

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -12,6 +12,8 @@
#include "gdb/breakpoints.h"
#include "utils.h"
#include "../utils.h"
struct
{
const char *name;
@@ -359,81 +361,19 @@ GDB_DECLARE_REMOTE_COMMAND_HANDLER(GetMmuConfig)
return GDB_SendHexPacket(ctx, outbuf, n);
}
static const char *FormatMemPerm(u32 perm)
{
if (perm == MEMPERM_DONTCARE)
return "???";
static char buf[4] = {0};
buf[0] = perm & MEMPERM_READ ? 'r' : '-';
buf[1] = perm & MEMPERM_WRITE ? 'w' : '-';
buf[2] = perm & MEMPERM_EXECUTE ? 'x' : '-';
return buf;
}
static const char *FormatMemState(u32 state)
{
if (state > 11)
return "Unknown";
static const char *states[12] =
{
"Free",
"Reserved",
"IO",
"Static",
"Code",
"Private",
"Shared",
"Continuous",
"Aliased",
"Alias",
"AliasCode",
"Locked"
};
return states[state];
}
GDB_DECLARE_REMOTE_COMMAND_HANDLER(GetMemRegions)
{
u32 address = 0;
u32 posInBuffer = 0;
u32 maxPosInBuffer = GDB_BUF_LEN / 2 - 35; ///< 35 is the maximum length of a formatted region
Handle handle;
MemInfo memi;
PageInfo pagei;
char outbuf[GDB_BUF_LEN / 2 + 1];
if(R_FAILED(svcOpenProcess(&handle, ctx->pid)))
{
posInBuffer = sprintf(outbuf, "Invalid process (wtf?)\n");
goto end;
return GDB_SendHexPacket(ctx, outbuf, posInBuffer);
}
while (address < 0x40000000 ///< Limit to check for regions
&& posInBuffer < maxPosInBuffer
&& R_SUCCEEDED(svcQueryProcessMemory(&memi, &pagei, handle, address)))
{
// Update the address for next region
address = memi.base_addr + memi.size;
// If region isn't FREE then add it to the list
if (memi.state != MEMSTATE_FREE)
{
const char *perm = FormatMemPerm(memi.perm);
const char *state = FormatMemState(memi.state);
posInBuffer += sprintf(outbuf + posInBuffer, "%08lx - %08lx %s %s\n",
memi.base_addr, address, perm, state);
}
}
svcCloseHandle(handle);
end:
posInBuffer = formatMemoryMapOfProcess(outbuf, GDB_BUF_LEN / 2, handle);
return GDB_SendHexPacket(ctx, outbuf, posInBuffer);
}

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -74,13 +74,14 @@ void GDB_DecrementServerReferenceCount(GDBServer *server)
void GDB_RunServer(GDBServer *server)
{
server_bind(&server->super, GDB_PORT_BASE);
server_bind(&server->super, GDB_PORT_BASE + 1);
server_bind(&server->super, GDB_PORT_BASE + 2);
Result res = server_bind(&server->super, GDB_PORT_BASE);
if(R_SUCCEEDED(res)) res = server_bind(&server->super, GDB_PORT_BASE + 1);
if(R_SUCCEEDED(res)) res = server_bind(&server->super, GDB_PORT_BASE + 2);
server_bind(&server->super, GDB_PORT_BASE + 3); // next application
if(R_SUCCEEDED(res)) res = server_bind(&server->super, GDB_PORT_BASE + 3); // next application
server_run(&server->super);
if(R_SUCCEEDED(res))
server_run(&server->super);
}
void GDB_LockAllContexts(GDBServer *server)
@@ -136,9 +137,9 @@ GDBContext *GDB_SelectAvailableContext(GDBServer *server, u16 minPort, u16 maxPo
{
ctx->flags |= GDB_FLAG_SELECTED;
ctx->localPort = port;
ctx->parent = server;
}
ctx->parent = server;
GDB_UnlockAllContexts(server);
return ctx;
}

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -85,38 +85,38 @@
typedef u32 gdbhio_time_t;
typedef int gdbhio_mode_t;
struct gdbhio_stat {
unsigned int st_dev; /* device */
unsigned int st_ino; /* inode */
gdbhio_mode_t st_mode; /* protection */
unsigned int st_nlink; /* number of hard links */
unsigned int st_uid; /* user ID of owner */
unsigned int st_gid; /* group ID of owner */
unsigned int st_rdev; /* device type (if inode device) */
u64 st_size; /* total size, in bytes */
u64 st_blksize; /* blocksize for filesystem I/O */
u64 st_blocks; /* number of blocks allocated */
gdbhio_time_t st_atime; /* time of last access */
gdbhio_time_t st_mtime; /* time of last modification */
gdbhio_time_t st_ctime; /* time of last change */
struct PACKED ALIGN(4) gdbhio_stat {
u32 gst_dev; /* device */
u32 gst_ino; /* inode */
gdbhio_mode_t gst_mode; /* protection */
u32 gst_nlink; /* number of hard links */
u32 gst_uid; /* user ID of owner */
u32 gst_gid; /* group ID of owner */
u32 gst_rdev; /* device type (if inode device) */
u64 gst_size; /* total size, in bytes */
u64 gst_blksize; /* blocksize for filesystem I/O */
u64 gst_blocks; /* number of blocks allocated */
gdbhio_time_t gst_atime; /* time of last access */
gdbhio_time_t gst_mtime; /* time of last modification */
gdbhio_time_t gst_ctime; /* time of last change */
};
static void GDB_TioMakeStructStat(struct gdbhio_stat *out, const struct gdbhio_stat *in)
{
memset(out, 0, sizeof(struct gdbhio_stat));
out->st_dev = __builtin_bswap32(in->st_dev);
out->st_ino = __builtin_bswap32(in->st_ino);
out->st_mode = __builtin_bswap32(in->st_dev);
out->st_nlink = __builtin_bswap32(in->st_nlink);
out->st_uid = __builtin_bswap32(in->st_uid);
out->st_gid = __builtin_bswap32(in->st_gid);
out->st_rdev = __builtin_bswap32(in->st_rdev);
out->st_size = __builtin_bswap64(in->st_size);
out->st_blksize = __builtin_bswap64(in->st_blksize);
out->st_blocks = __builtin_bswap64(in->st_blocks);
out->st_atime = __builtin_bswap32(in->st_atime);
out->st_mtime = __builtin_bswap32(in->st_mtime);
out->st_ctime = __builtin_bswap32(in->st_ctime);
out->gst_dev = __builtin_bswap32(in->gst_dev);
out->gst_ino = __builtin_bswap32(in->gst_ino);
out->gst_mode = __builtin_bswap32(in->gst_dev);
out->gst_nlink = __builtin_bswap32(in->gst_nlink);
out->gst_uid = __builtin_bswap32(in->gst_uid);
out->gst_gid = __builtin_bswap32(in->gst_gid);
out->gst_rdev = __builtin_bswap32(in->gst_rdev);
out->gst_size = __builtin_bswap64(in->gst_size);
out->gst_blksize = __builtin_bswap64(in->gst_blksize);
out->gst_blocks = __builtin_bswap64(in->gst_blocks);
out->gst_atime = __builtin_bswap32(in->gst_atime);
out->gst_mtime = __builtin_bswap32(in->gst_mtime);
out->gst_ctime = __builtin_bswap32(in->gst_ctime);
}
// Inspired from https://github.com/smealum/ctrulib/blob/master/libctru/source/sdmc_dev.c
@@ -408,8 +408,8 @@ GDB_DECLARE_TIO_HANDLER(Stat)
if (err == 0)
{
gdbSt.st_nlink = 1;
gdbSt.st_mode = GDBHIO_S_IFREG | GDBHIO_S_IRUSR | GDBHIO_S_IWUSR |
gdbSt.gst_nlink = 1;
gdbSt.gst_mode = GDBHIO_S_IFREG | GDBHIO_S_IRUSR | GDBHIO_S_IWUSR |
GDBHIO_S_IRGRP | GDBHIO_S_IWGRP | GDBHIO_S_IROTH | GDBHIO_S_IWOTH;
}
}
@@ -419,8 +419,8 @@ GDB_DECLARE_TIO_HANDLER(Stat)
if (err == 0)
{
FSDIR_Close(dirHandle);
gdbSt.st_nlink = 1;
gdbSt.st_mode = GDBHIO_S_IFDIR | GDBHIO_S_IRWXU | GDBHIO_S_IRWXG | GDBHIO_S_IRWXO;
gdbSt.gst_nlink = 1;
gdbSt.gst_mode = GDBHIO_S_IFDIR | GDBHIO_S_IRWXU | GDBHIO_S_IRWXG | GDBHIO_S_IRWXO;
}
}
@@ -524,4 +524,4 @@ GDB_DECLARE_VERBOSE_HANDLER(File)
}
return GDB_HandleUnsupported(ctx); // No handler found!
}
}

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/
@@ -12,7 +12,7 @@
#include <errno.h>
/*
There are only 2 Watchpoint Register Pairs on MPCORE ARM11 CPUs,
There are only 2 Watchpoint Register Pairs on MPCORE Arm11 CPUs,
and only 2 Breakpoint Register Pairs with context ID capabilities (BRP4-5) as well.
We'll reserve and use all 4 of them

View File

@@ -1,6 +1,6 @@
/*
* This file is part of Luma3DS.
* Copyright (C) 2016-2019 Aurora Wright, TuxSH
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
*
* SPDX-License-Identifier: (MIT OR GPL-2.0-or-later)
*/