From cd78fb05cb1e0b952e3cdab74f5b9d640a0c8924 Mon Sep 17 00:00:00 2001 From: TuxSH <1922548+TuxSH@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:17:59 +0000 Subject: [PATCH] Change arg types of svcCreateCodeSet and improve documentation Since kernel doesn't directly access the LMA, but just does memory management on them instead, they should be passed as u32 (uptr) instead of void *. Also change CodeSetInfo to CodeSetHeader to avoid confusion with ExHeader types. --- libctru/include/3ds/svc.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libctru/include/3ds/svc.h b/libctru/include/3ds/svc.h index 2a43ffa..4d29671 100644 --- a/libctru/include/3ds/svc.h +++ b/libctru/include/3ds/svc.h @@ -497,9 +497,8 @@ typedef enum { /// Information on address space for process. All sizes are in pages (0x1000 bytes) typedef struct { u8 name[8]; ///< ASCII name of codeset - u16 unk1; - u16 unk2; - u32 unk3; + u16 version; ///< Version field of codeset (unused) + u16 padding[3]; ///< Padding u32 text_addr; ///< .text start address u32 text_size; ///< .text number of pages u32 ro_addr; ///< .rodata start address @@ -509,9 +508,9 @@ typedef struct { u32 text_size_total; ///< total pages for .text (aligned) u32 ro_size_total; ///< total pages for .rodata (aligned) u32 rw_size_total; ///< total pages for .data, .bss (aligned) - u32 unk4; + u32 padding2; ///< Padding u64 program_id; ///< Program ID -} CodeSetInfo; +} CodeSetHeader; /// Information for the main thread of a process. typedef struct @@ -756,23 +755,24 @@ Result svcCreatePort(Handle* portServer, Handle* portClient, const char* name, s Result svcConnectToPort(volatile Handle* out, const char* portName); /** - * @brief Sets up virtual address space for a new process - * @param[out] out Pointer to output the code set handle to. - * @param info Description for setting up the addresses - * @param code_ptr Pointer to .text in shared memory - * @param ro_ptr Pointer to .rodata in shared memory - * @param data_ptr Pointer to .data in shared memory + * @brief Sets up virtual address space for a new process. + * @param[out] out Pointer to output the codeset handle to. + * @param info Codeset header, contains process name, titleId and segment info. + * @param textSegmentLma Address of executable segment in caller's address space. + * @param roSegmentLma Address of read-only segment in caller's address space. + * @param dataSegmentLma Address of read-write segment in caller's address space. + * @note On success, the provided segments are unmapped from the caller's address space. */ -Result svcCreateCodeSet(Handle* out, const CodeSetInfo *info, void* code_ptr, void* ro_ptr, void* data_ptr); +Result svcCreateCodeSet(Handle* out, const CodeSetHeader* info, u32 textSegmentLma, u32 roSegmentLma, u32 dataSegmentLma); /** - * @brief Sets up virtual address space for a new process + * @brief Create a new process. * @param[out] out Pointer to output the process handle to. - * @param codeset Codeset created for this process - * @param arm11kernelcaps ARM11 Kernel Capabilities from exheader - * @param arm11kernelcaps_num Number of kernel capabilities + * @param codeset Codeset created for this process. + * @param arm11KernelCaps Arm11 Kernel Capabilities from exheader. + * @param numArm11KernelCaps Number of kernel capabilities. */ -Result svcCreateProcess(Handle* out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num); +Result svcCreateProcess(Handle* out, Handle codeset, const u32* arm11KernelCaps, s32 numArm11KernelCaps); /** * @brief Gets a process's affinity mask.