3ds: 3ds port sources. First set of two

This commit adds changes to the original rockbox sources.

Note: the port files, functions, folders, etc., will be referred
to as 'ctru' to avoid using the Nintendo name elsewhere.

Change-Id: I0e2d3d4d2a75bd45ea67dc3452eb8d5487cf1f5a
This commit is contained in:
Mauricio Garrido 2025-09-29 16:06:04 -06:00 committed by Solomon Peachy
parent 511a38763b
commit a4de1195cd
25 changed files with 227 additions and 23 deletions

View file

@ -25,7 +25,7 @@ target/hosted/rtc.c
#if (CONFIG_PLATFORM & PLATFORM_ANDROID) == 0 && \
!defined(DX50) && !defined(DX90) && \
(defined(DEBUG) || defined(SIMULATOR)) /* sim should define DEBUG instead */
(defined(DEBUG) || defined(SIMULATOR) || defined(CTRU)) /* sim should define DEBUG instead */
target/hosted/debug-hosted.c
#endif
@ -94,12 +94,14 @@ target/hosted/sdl/app/button-application.c
#ifdef WIN32
target/hosted/filesystem-win32.c
#else /* !WIN32 */
#ifndef CTRU
target/hosted/filesystem-unix.c
#endif /* CTRU */
#endif /* WIN32 */
#endif /* APPLICATION */
#endif /* HAVE_SDL */
#ifdef APPLICATION
#if defined(APPLICATION) && !defined(CTRU)
target/hosted/filesystem-app.c
#endif /* APPLICATION */
@ -581,6 +583,8 @@ target/hosted/maemo/pcm-gstreamer.c
target/hosted/sdl/pcm-sdl.c
#endif /* (CONFIG_PLATFORM & PLATFORM_MAEMO) */
#elif defined(CTRU)
drivers/audio/ctru.c
#endif
#endif /* (CONFIG_PLATFORM & PLATFORM_NATIVE) */
@ -2071,6 +2075,28 @@ target/hosted/ibasso/dx90/button-dx90.c
#endif
#endif
#if (CONFIG_PLATFORM & PLATFORM_CTRU)
asm/arm/lcd-as-memframe.S
target/hosted/ctru/backlight-ctru.c
target/hosted/ctru/button-ctru.c
target/hosted/ctru/kernel-ctru.c
target/hosted/ctru/thread-ctru.c
target/hosted/ctru/lcd-bitmap.c
target/hosted/ctru/luminance-ctru.c
target/hosted/ctru/system-ctru.c
target/hosted/ctru/filesystem-ctru.c
target/hosted/ctru/lc-ctru.c
target/hosted/ctru/lc-program-resolver.c
target/hosted/ctru/powermgmt-ctru.c
target/hosted/ctru/timer-ctru.c
target/hosted/ctru/pcm-ctru.c
target/hosted/ctru/lib/sys_file.c
target/hosted/ctru/lib/sys_dir.c
target/hosted/ctru/lib/sys_thread.c
target/hosted/ctru/lib/sys_timer.c
target/hosted/ctru/lib/bfile/bfile.c
#endif
#else /* defined(SIMULATOR) */
#ifdef WIN32
@ -2119,9 +2145,9 @@ kernel/queue.c
#ifdef HAVE_SEMAPHORE_OBJECTS
kernel/semaphore.c
#endif
#if defined(HAVE_SDL_THREADS)
#ifdef HAVE_SDL_THREADS
target/hosted/sdl/thread-sdl.c
#else
#elif !defined(CTRU)
kernel/thread.c
#endif
kernel/thread-common.c

View file

@ -224,7 +224,7 @@ struct sound_settings_info
#elif defined(HAVE_ES9218)
#include "es9218.h"
#elif ((CONFIG_PLATFORM & (PLATFORM_ANDROID | PLATFORM_MAEMO \
| PLATFORM_PANDORA | PLATFORM_SDL )) | defined(RG_NANO))
| PLATFORM_PANDORA | PLATFORM_SDL | PLATFORM_CTRU)) | defined(RG_NANO))
#include "hosted_codec.h"
#elif defined(DX50)
#include "codec-dx50.h"

View file

@ -85,6 +85,7 @@
#define RK27XX 2700
#define X1000 1000
#define STM32H743 32743
#define N10480H 10480
/* platforms
* bit fields to allow PLATFORM_HOSTED to be OR'ed e.g. with a
@ -98,6 +99,7 @@
#define PLATFORM_MAEMO5 (1<<5)
#define PLATFORM_MAEMO (PLATFORM_MAEMO4|PLATFORM_MAEMO5)
#define PLATFORM_PANDORA (1<<6)
#define PLATFORM_CTRU (1<<7)
/* CONFIG_KEYPAD */
#define IRIVER_H100_PAD 4
@ -167,6 +169,7 @@
#define ECHO_R1_PAD 75
#define SURFANS_F28_PAD 76
#define RG_NANO_PAD 77
#define CTRU_PAD 78
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@ -623,6 +626,8 @@ Lyre prototype 1 */
#include "config/surfansf28.h"
#elif defined(RG_NANO)
#include "config/rgnano.h"
#elif defined(CTRU)
#include "config/ctru.h"
#else
#error "unknown hardware platform!"
#endif
@ -650,7 +655,7 @@ Lyre prototype 1 */
# define CONFIG_BUFLIB_BACKEND BUFLIB_BACKEND_MEMPOOL
#endif
#ifdef APPLICATION
#if defined(APPLICATION)
#ifndef CONFIG_CPU
#define CONFIG_CPU 0
#endif
@ -1033,7 +1038,8 @@ Lyre prototype 1 */
#if defined(ASSEMBLER_THREADS) \
|| defined(HAVE_WIN32_FIBER_THREADS) \
|| defined(HAVE_SIGALTSTACK_THREADS)
|| defined(HAVE_SIGALTSTACK_THREADS) \
|| defined(CTRU)
#define HAVE_PRIORITY_SCHEDULING
#endif
@ -1104,7 +1110,7 @@ Lyre prototype 1 */
* Older versions of GCC emit assembly in divided syntax with no option
* to enable unified syntax.
*/
#if (__GNUC__ < 8) && defined(CPU_ARM_CLASSIC)
#if (__GNUC__ < 8) && defined(CPU_ARM_CLASSIC) || defined(CTRU)
#define BEGIN_ARM_ASM_SYNTAX_UNIFIED ".syntax unified\n"
#define END_ARM_ASM_SYNTAX_UNIFIED ".syntax divided\n"
#else

View file

@ -35,6 +35,10 @@ extern void ldebugf(const char* file, int line, const char *fmt, ...)
|| (defined(APPLICATION) && defined(DEBUG))
#define DEBUGF debugf
#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
#elif (CONFIG_PLATFORM & PLATFORM_CTRU)
/* let's use second display for debug output */
#define DEBUGF debugf
#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
#elif defined(DEBUG) /* DEBUG on native targets */
#ifdef HAVE_GDB_API

View file

@ -21,8 +21,9 @@
#ifndef HOSTED_CODEC_H
#define HOSTED_CODEC_H
#if defined(HAVE_SDL_AUDIO) \
&& !(CONFIG_PLATFORM & PLATFORM_MAEMO5)
#if (defined(HAVE_SDL_AUDIO) \
&& !(CONFIG_PLATFORM & PLATFORM_MAEMO5)) \
|| (CONFIG_PLATFORM & PLATFORM_CTRU)
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -80, 0, 0)
#else
#define AUDIOHW_CAPS (MONO_VOL_CAP)

View file

@ -41,7 +41,7 @@
/* NOTE: target-specific hosted HOME_DIR resides in filesystem-app.c */
#if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \
defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || \
defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX)
defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX) || defined(CTRU)
#define HOME_DIR "/"
@ -87,7 +87,7 @@
#if defined(APPLICATION) && \
!(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \
defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX))
defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || defined(HIBY_LINUX) || defined(FIIO_M3K_LINUX) || defined(CTRU))
#define PLUGIN_DATA_DIR ROCKBOX_DIR "/rocks.data"
#define PLUGIN_GAMES_DATA_DIR PLUGIN_DATA_DIR

View file

@ -9,8 +9,8 @@
"comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
files aren't affected). */
#ifndef _ANSIDECL_H_
#define _ANSIDECL_H_
#ifndef __ANSIDECL_H__
#define __ANSIDECL_H__
/* First try to figure out whether we really are in an ANSI C environment. */
/* FIXME: This probably needs some work. Perhaps sys/config.h can be
@ -64,4 +64,4 @@
#endif
#endif
#endif /* _ANSIDECL_H_ */
#endif /* __ANSIDECL_H__ */

View file

@ -28,7 +28,9 @@
#include "fs_attr.h"
#include "fs_defines.h"
#if defined (APPLICATION) || defined(CHECKWPS)
#if defined(CTRU) && !defined(SIMULATOR)
#include "filesystem-ctru.h"
#elif defined (APPLICATION) || defined(CHECKWPS)
#include "filesystem-app.h"
#elif defined(SIMULATOR) || defined(DBTOOL)
#include "../../uisimulator/common/filesystem-sim.h"

View file

@ -40,7 +40,9 @@ enum relate_result
RELATE_PREFIX, /* the path2 contains path1 as a prefix */
};
#if defined(APPLICATION) || defined(CHECKWPS)
#if defined(CTRU) && !defined(SIMULATOR)
#include "filesystem-ctru.h"
#elif defined(APPLICATION) || defined(CHECKWPS)
#include "filesystem-app.h"
#elif defined(SIMULATOR) || defined(DBTOOL)
#include "../../uisimulator/common/filesystem-sim.h"

View file

@ -28,7 +28,7 @@
#endif
#ifndef __MINGW32__
#ifdef __APPLE__
#if defined(__APPLE__) || defined(CTRU)
#include <sys/types.h>
#else
#include <endian.h>

View file

@ -89,7 +89,7 @@ struct thread_entry;
*
* simulator (possibly) doesn't simulate stack usage anyway but well ... */
#if defined(HAVE_SDL_THREADS) || defined(__PCTOOL__)
#if defined(HAVE_SDL_THREADS) || defined(__PCTOOL__) || defined(CTRU)
#define DEFAULT_STACK_SIZE 0x100 /* tiny, ignored anyway */
#else
#include "asm/thread.h"

View file

@ -75,11 +75,15 @@ void mutex_lock(struct mutex *m)
/* Release ownership of a mutex object - only owning thread must call this */
void mutex_unlock(struct mutex *m)
{
#ifndef CTRU
/* FIXME: synchronization primitives does not behave
correctly between different cores */
/* unlocker not being the owner is an unlocking violation */
KERNEL_ASSERT(m->blocker.thread == __running_self_entry(),
"mutex_unlock->wrong thread (%s != %s)\n",
m->blocker.thread->name,
__running_self_entry()->name);
#endif
if(m->recursion > 0)
{

View file

@ -304,7 +304,7 @@ int thread_get_debug_info(unsigned int thread_id,
#ifdef HAVE_SCHEDULER_BOOSTCTRL
cpu_boost = thread->cpu_boost;
#endif
#ifndef HAVE_SDL_THREADS
#if !defined(HAVE_SDL_THREADS) && !defined(CTRU)
infop->stack_usage = stack_usage(thread->stack, thread->stack_size);
size_t stack_used_current =

View file

@ -32,7 +32,7 @@
*
* simulator (possibly) doesn't simulate stack usage anyway but well ... */
#if defined(HAVE_SDL_THREADS) || defined(__PCTOOL__)
#if defined(HAVE_SDL_THREADS) || defined(__PCTOOL__) || defined(CTRU)
struct regs
{
void *t; /* OS thread */

View file

@ -58,7 +58,11 @@ const char * handle_special_dirs(const char *dir, unsigned flags,
#ifdef WIN32
#include "filesystem-win32.h"
#else /* !WIN32 */
#if defined(CTRU) && !defined(SIMULATOR)
#include "filesystem-ctru.h"
#else
#include "filesystem-unix.h"
#endif
#endif /* WIN32 */
#include "filesystem-hosted.h"

View file

@ -24,7 +24,7 @@
#include <sys/time.h>
#if !defined(WIN32)
#include <sys/ioctl.h>
#if !defined(__APPLE__)
#if !defined(__APPLE__) && !defined(CTRU)
#include <linux/rtc.h>
#endif
#include <fcntl.h>
@ -49,7 +49,7 @@ int rtc_read_datetime(struct tm *tm)
int rtc_write_datetime(const struct tm *tm)
{
#if !defined(WIN32) && !defined(__APPLE__)
#if !defined(WIN32) && !defined(__APPLE__) && !defined(CTRU)
struct timeval tv;
struct tm *tm_time;