PSPSDK 2024-10-31
Loading...
Searching...
No Matches
pspmoduleinfo.h
Go to the documentation of this file.
1/*
2 * PSP Software Development Kit - https://github.com/pspdev
3 * -----------------------------------------------------------------------
4 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
5 *
6 * pspmoduleinfo.h - Definitions for the .rodata.sceModuleInfo ELF section.
7 *
8 * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
9 * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
10 * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
11 *
12 */
13#ifndef PSPMODULEINFO_H
14#define PSPMODULEINFO_H
15
16/* Note: Some of the structures and definitions in this file were extrapolated from
17 symbolic debugging information found in the Japanese version of Puzzle Bobble. */
18
19/* Module info structure. Used to declare a module (library or executable). This structure
20 is required in all PSP executables. */
21typedef struct _scemoduleinfo {
22 unsigned short modattribute;
23 unsigned char modversion[2];
24 char modname[27];
26 void * gp_value;
27 void * ent_top;
28 void * ent_end;
29 void * stub_top;
30 void * stub_end;
32
34
35extern char _gp[];
36
45
46#ifdef __cplusplus
47
48/* Declare a module. This must be specified in the source of a library or executable. */
49#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
50 extern char __lib_ent_top[], __lib_ent_bottom[]; \
51 extern char __lib_stub_top[], __lib_stub_bottom[]; \
52 extern SceModuleInfo module_info \
53 __attribute__((section(".rodata.sceModuleInfo"), \
54 aligned(16), unused)) = { \
55 attributes, { minor_version, major_version }, #name, 0, _gp, \
56 __lib_ent_top, __lib_ent_bottom, \
57 __lib_stub_top, __lib_stub_bottom \
58 }
59#else
60/* Declare a module. This must be specified in the source of a library or executable. */
61#define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
62 extern char __lib_ent_top[], __lib_ent_bottom[]; \
63 extern char __lib_stub_top[], __lib_stub_bottom[]; \
64 SceModuleInfo module_info \
65 __attribute__((section(".rodata.sceModuleInfo"), \
66 aligned(16), unused)) = { \
67 attributes, { minor_version, major_version }, name, 0, _gp, \
68 __lib_ent_top, __lib_ent_bottom, \
69 __lib_stub_top, __lib_stub_bottom \
70 }
71#endif
72
73/* Define the main thread's initial priority. */
74#define PSP_MAIN_THREAD_PRIORITY(priority) \
75 unsigned int sce_newlib_priority = (priority)
76/* Define the main thread's stack size (in KB). */
77#define PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb) \
78 unsigned int sce_newlib_stack_kb_size = (size_kb)
79/* Define the main thread's attributes. */
80#define PSP_MAIN_THREAD_ATTR(attr) \
81 unsigned int sce_newlib_attribute = (attr)
82#define PSP_MAIN_THREAD_ATTRIBUTE PSP_MAIN_THREAD_ATTR
83
84/* Define all main thread parameters. */
85#define PSP_MAIN_THREAD_PARAMS(priority, size_kb, attribute) \
86 PSP_MAIN_THREAD_PRIORITY(priority); \
87 PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb); \
88 PSP_MAIN_THREAD_ATTR(attribute)
89
90/* If declared, the runtime code won't create a main thread for the program. */
91#define PSP_NO_CREATE_MAIN_THREAD() \
92 int sce_newlib_nocreate_thread_in_start = 1
93
94/* Declare the size of the heap (in KB) that the program wants to allocate from. */
95#define PSP_HEAP_SIZE_KB(size_kb) \
96 int sce_newlib_heap_kb_size = (size_kb)
97
98/* Declare the threshold of the heap (in KB) that the program wants to keep for external allocation. */
99#define PSP_HEAP_THRESHOLD_SIZE_KB(size_kb) \
100 int sce_newlib_heap_threshold_kb_size = (size_kb)
101
102/* Declare the name of the main thread */
103#define PSP_MAIN_THREAD_NAME(s) const char* sce_newlib_main_thread_name = (s)
104
105/* Disable the use of newlib, getting a minimal binary. */
106#define PSP_DISABLE_NEWLIB() \
107 void __libcglue_init(int argc, char *argv[]) {} \
108 void __libcglue_deinit() {}
109
110/* Disable the auto start of pthread on init for reducing binary size if not used. */
111#define PSP_DISABLE_AUTOSTART_PTHREAD() \
112 void __libpthreadglue_init() {}
113
114#endif /* PSPMODULEINFO_H */
char _gp[]
struct _scemoduleinfo _sceModuleInfo
const _sceModuleInfo SceModuleInfo
Definition pspmoduleinfo.h:33
PspModuleInfoAttr
Definition pspmoduleinfo.h:38
@ PSP_MODULE_NO_STOP
Definition pspmoduleinfo.h:40
@ PSP_MODULE_KERNEL
Definition pspmoduleinfo.h:43
@ PSP_MODULE_SINGLE_LOAD
Definition pspmoduleinfo.h:41
@ PSP_MODULE_USER
Definition pspmoduleinfo.h:39
@ PSP_MODULE_SINGLE_START
Definition pspmoduleinfo.h:42
Definition pspmoduleinfo.h:21
void * stub_top
Definition pspmoduleinfo.h:29
unsigned short modattribute
Definition pspmoduleinfo.h:22
unsigned char modversion[2]
Definition pspmoduleinfo.h:23
void * ent_top
Definition pspmoduleinfo.h:27
char modname[27]
Definition pspmoduleinfo.h:24
void * ent_end
Definition pspmoduleinfo.h:28
void * stub_end
Definition pspmoduleinfo.h:30
char terminal
Definition pspmoduleinfo.h:25
void * gp_value
Definition pspmoduleinfo.h:26