Skip to content

Commit c84807b

Browse files
authored
Merge pull request #328 from GrayJack/load-core
refactor: Update `SceModule` definition
2 parents 787b593 + bd7e850 commit c84807b

File tree

3 files changed

+201
-58
lines changed

3 files changed

+201
-58
lines changed

src/base/psptypes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ typedef struct ScePspDateTime {
427427
unsigned int microsecond;
428428
} ScePspDateTime;
429429

430+
/* Thread entry function type. */
431+
typedef int (*SceKernelThreadEntry)(SceSize args, void *argp);
432+
430433
#ifdef __cplusplus
431434
}
432435
#endif

src/kernel/psploadcore.h

Lines changed: 167 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,174 @@ extern "C" {
2626
/** @addtogroup LoadCore Interface to the LoadCoreForKernel library. */
2727
/**@{*/
2828

29-
/** Describes a module. This structure could change in future firmware revisions. */
29+
30+
/** Reboot preparation functions */
31+
typedef s32 (*SceKernelRebootBeforeForKernel)(void *arg1, s32 arg2, s32 arg3, s32 arg4);
32+
typedef s32 (*SceKernelRebootPhaseForKernel)(s32 arg1, void *arg2, s32 arg3, s32 arg4);
33+
34+
/** Module type attributes. */
35+
enum SceModuleAttribute {
36+
/** No module attributes. */
37+
SCE_MODULE_ATTR_NONE = 0x0000,
38+
/** Resident module - stays in memory. You cannot unload such a module. */
39+
SCE_MODULE_ATTR_CANT_STOP = 0x0001,
40+
/**
41+
* Only one instance of the module (one version) can be loaded into the system. If you want to load another
42+
* version of that module, you have to delete the loaded version first.
43+
*/
44+
SCE_MODULE_ATTR_EXCLUSIVE_LOAD = 0x0002,
45+
/**
46+
* Only one instance of the module (one version) can be started. If you want to start another
47+
* version of that module, you have to stop the currently running version first.
48+
*/
49+
SCE_MODULE_ATTR_EXCLUSIVE_START = 0x0004,
50+
};
51+
52+
/**
53+
* Module Privilege Levels - These levels define the permissions a
54+
* module can have.
55+
*/
56+
enum SceModulePrivilegeLevel {
57+
/** Lowest permission. */
58+
SCE_MODULE_USER = 0x0000,
59+
/** POPS/Demo. */
60+
SCE_MODULE_MS = 0x0200,
61+
/** Module Gamesharing. */
62+
SCE_MODULE_USB_WLAN = 0x0400,
63+
/** Application module. */
64+
SCE_MODULE_APP = 0x0600,
65+
/** VSH module. */
66+
SCE_MODULE_VSH = 0x0800,
67+
/** Highest permission. */
68+
SCE_MODULE_KERNEL = 0x1000,
69+
/** The module uses KIRK's memlmd resident library. */
70+
SCE_MODULE_KIRK_MEMLMD_LIB = 0x2000,
71+
/** The module uses KIRK's semaphore resident library. */
72+
SCE_MODULE_KIRK_SEMAPHORE_LIB = 0x4000,
73+
};
74+
75+
/** Describes a loaded module in memory. This structure could change in future firmware revisions. */
3076
typedef struct SceModule {
31-
struct SceModule *next;
32-
unsigned short attribute;
33-
unsigned char version[2];
34-
char modname[27];
35-
char terminal;
36-
unsigned int unknown1;
37-
unsigned int unknown2;
38-
SceUID modid;
39-
unsigned int unknown3[4];
40-
void * ent_top;
41-
unsigned int ent_size;
42-
void * stub_top;
43-
unsigned int stub_size;
44-
unsigned int unknown4[4];
45-
unsigned int entry_addr;
46-
unsigned int gp_value;
47-
unsigned int text_addr;
48-
unsigned int text_size;
49-
unsigned int data_size;
50-
unsigned int bss_size;
51-
unsigned int nsegment;
52-
unsigned int segmentaddr[4];
53-
unsigned int segmentsize[4];
54-
} __attribute__((packed)) SceModule;
77+
/** Pointer to the next registered module. Modules are connected via a linked list. */
78+
struct SceModule *next;
79+
/** The attributes of a module. One or more of ::SceModuleAttribute and ::SceModulePrivilegeLevel. */
80+
u16 attribute;
81+
/**
82+
* The version of the module. Consists of a major and minor part. There can be several modules
83+
* loaded with the same name and version.
84+
*/
85+
u8 version[2];
86+
/** The module's name. There can be several modules loaded with the same name. */
87+
char modname[27];
88+
/** String terminator (always '\0'). */
89+
char terminal;
90+
/**
91+
* The status of the module. Contains information whether the module has been started, stopped,
92+
* is a user module, etc.
93+
*/
94+
u16 mod_state;
95+
char padding[2];
96+
/** A secondary ID for the module. */
97+
SceUID sec_id;
98+
/** The module's UID. */
99+
SceUID modid;
100+
/** The thread ID of a user module. */
101+
SceUID user_mod_thid;
102+
/** The ID of the memory block belonging to the module. */
103+
SceUID mem_id;
104+
/** The ID of the TEXT segment's memory partition. */
105+
u32 mpid_text;
106+
/** The ID of the DATA segment's memory partition. */
107+
u32 mpid_data;
108+
/** Pointer to the first resident library entry table of the module. */
109+
void * ent_top;
110+
/** The size of all resident library entry tables of the module. */
111+
SceSize ent_size;
112+
/** Pointer to the first stub library entry table of the module. */
113+
void * stub_top;
114+
/** The size of all stub library entry tables of the module. */
115+
SceSize stub_size;
116+
/**
117+
* A pointer to the (required) module's start entry function. This function is executed during
118+
* the module's startup.
119+
*/
120+
SceKernelThreadEntry module_start;
121+
/**
122+
* A pointer to the (required) module's stop entry function. This function is executed during
123+
* the module's stopping phase.
124+
*/
125+
SceKernelThreadEntry module_stop;
126+
/**
127+
* A pointer to a module's Bootstart entry function. This function is probably executed after
128+
* a reboot.
129+
*/
130+
SceKernelThreadEntry module_bootstart;
131+
/**
132+
* A pointer to a module's rebootBefore entry function. This function is probably executed
133+
* before a reboot.
134+
*/
135+
SceKernelRebootBeforeForKernel module_reboot_before;
136+
/**
137+
* A pointer to a module's rebootPhase entry function. This function is probably executed
138+
* during a reboot.
139+
*/
140+
SceKernelRebootPhaseForKernel module_reboot_phase;
141+
/**
142+
* The entry address of the module. It is the offset from the start of the TEXT segment to the
143+
* program's entry point.
144+
*/
145+
u32 entry_addr;
146+
/** Contains the offset from the start of the TEXT segment of the program's GP register value. */
147+
u32 gp_value;
148+
/** The start address of the TEXT segment. */
149+
u32 text_addr;
150+
/** The size of the TEXT segment. */
151+
u32 text_size;
152+
/** The size of the DATA segment. */
153+
u32 data_size;
154+
/** The size of the BSS segment. */
155+
u32 bss_size;
156+
/** The number of segments the module consists of. */
157+
u8 nsegment;
158+
/** Reserved. */
159+
u8 padding2[3];
160+
/** An array containing the start address of each segment. */
161+
u32 segmentaddr[4];
162+
/** An array containing the size of each segment. */
163+
SceSize segmentsize[4];
164+
/** An array containing the alignment information of each segment. */
165+
u32 segmentalign[4];
166+
/** The priority of the module start thread. */
167+
s32 module_start_thread_priority;
168+
/** The stack size of the module start thread. */
169+
SceSize module_start_thread_stacksize;
170+
/** The attributes of the module start thread. */
171+
SceUInt module_start_thread_attr;
172+
/** The priority of the module stop thread. */
173+
s32 module_stop_thread_priority;
174+
/** The stack size of the module stop thread. */
175+
SceSize module_stop_thread_stacksize;
176+
/** The attributes of the module stop thread. */
177+
SceUInt module_stop_thread_attr;
178+
/** The priority of the module reboot before thread. */
179+
s32 module_reboot_before_thread_priority;
180+
/** The stack size of the module reboot before thread. */
181+
SceSize module_reboot_before_thread_stacksize;
182+
/** The attributes of the module reboot before thread. */
183+
SceUInt module_reboot_before_thread_attr;
184+
/** The value of the coprocessor 0's count register when the module is created. */
185+
u32 count_reg_val;
186+
/** The segment checksum of the module's segments. */
187+
u32 segment_checksum;
188+
/** TEXT segment checksum of the module. */
189+
u32 text_segment_checksum;
190+
/**
191+
* Whether to compute the text segment checksum before starting the module (see prologue).
192+
* If non-zero, the text segment checksum will be computed after the module's resident libraries
193+
* have been registered, and its stub libraries have been linked.
194+
*/
195+
u32 compute_text_segment_checksum;
196+
} SceModule;
55197

56198
/** Defines a library and its exported functions and variables. Use the len
57199
member to determine the real size of the table (size = len * 4). */

0 commit comments

Comments
 (0)