# pspmoduleinfo.h

Go to the documentation of this file.

    00001 /*
    00002  * PSP Software Development Kit - http://www.pspdev.org
    00003  * -----------------------------------------------------------------------
    00004  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
    00005  *
    00006  * pspmoduleinfo.h - Definitions for the .rodata.sceModuleInfo ELF section.
    00007  *
    00008  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
    00009  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
    00010  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
    00011  *
    00012  * $Id: pspmoduleinfo.h 1095 2005-09-27 21:02:16Z jim $
    00013  */
    00014 #ifndef PSPMODULEINFO_H
    00015 #define PSPMODULEINFO_H
    00016
    00017 /* Note: Some of the structures and definitions in this file were extrapolated from
    00018    symbolic debugging information found in the Japanese version of Puzzle Bobble. */
    00019
    00020 /* Module info structure.  Used to declare a module (library or executable).  This structure
    00021    is required in all PSP executables. */
    00022 typedef struct _scemoduleinfo {
    00023         unsigned short          modattribute;
    00024         unsigned char           modversion[2];
    00025         char                    modname[27];
    00026         char                    terminal;
    00027         void *                  gp_value;
    00028         void *                  ent_top;
    00029         void *                  ent_end;
    00030         void *                  stub_top;
    00031         void *                  stub_end;
    00032 } _sceModuleInfo;
    00033
    00034 typedef const _sceModuleInfo SceModuleInfo;
    00035
    00036 extern char _gp[];
    00037
    00038 #ifdef __cplusplus
    00039
    00040 /* Declare a module.  This must be specified in the source of a library or executable. */
    00041 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
    00042         __asm__ (                                                       \
    00043         "    .set push\n"                                               \
    00044         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
    00045         "    .align 2\n"                                                \
    00046         "    .word 0\n"                                                 \
    00047         "__lib_ent_top:\n"                                              \
    00048         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
    00049         "    .align 2\n"                                                \
    00050         "__lib_ent_bottom:\n"                                           \
    00051         "    .word 0\n"                                                 \
    00052         "    .section .lib.stub.top, \"a\", @progbits\n"                \
    00053         "    .align 2\n"                                                \
    00054         "    .word 0\n"                                                 \
    00055         "__lib_stub_top:\n"                                             \
    00056         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
    00057         "    .align 2\n"                                                \
    00058         "__lib_stub_bottom:\n"                                          \
    00059         "    .word 0\n"                                                 \
    00060         "    .set pop\n"                                                \
    00061         );                                                              \
    00062         extern char __lib_ent_top[], __lib_ent_bottom[];                \
    00063         extern char __lib_stub_top[], __lib_stub_bottom[];              \
    00064         extern SceModuleInfo module_info                                \
    00065                 __attribute__((section(".rodata.sceModuleInfo"),        \
    00066                                aligned(16), unused)) = {                \
    00067           attributes, { minor_version, major_version }, #name, 0, _gp,  \
    00068           __lib_ent_top, __lib_ent_bottom,                              \
    00069           __lib_stub_top, __lib_stub_bottom                             \
    00070         }
    00071 #else
    00072 /* Declare a module.  This must be specified in the source of a library or executable. */
    00073 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
    00074         __asm__ (                                                       \
    00075         "    .set push\n"                                               \
    00076         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
    00077         "    .align 2\n"                                                \
    00078         "    .word 0\n"                                                 \
    00079         "__lib_ent_top:\n"                                              \
    00080         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
    00081         "    .align 2\n"                                                \
    00082         "__lib_ent_bottom:\n"                                           \
    00083         "    .word 0\n"                                                 \
    00084         "    .section .lib.stub.top, \"a\", @progbits\n"                \
    00085         "    .align 2\n"                                                \
    00086         "    .word 0\n"                                                 \
    00087         "__lib_stub_top:\n"                                             \
    00088         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
    00089         "    .align 2\n"                                                \
    00090         "__lib_stub_bottom:\n"                                          \
    00091         "    .word 0\n"                                                 \
    00092         "    .set pop\n"                                                \
    00093         );                                                              \
    00094         extern char __lib_ent_top[], __lib_ent_bottom[];                \
    00095         extern char __lib_stub_top[], __lib_stub_bottom[];              \
    00096         SceModuleInfo module_info                                       \
    00097                 __attribute__((section(".rodata.sceModuleInfo"),        \
    00098                                aligned(16), unused)) = {                \
    00099           attributes, { minor_version, major_version }, name, 0, _gp,  \
    00100           __lib_ent_top, __lib_ent_bottom,                              \
    00101           __lib_stub_top, __lib_stub_bottom                             \
    00102         }
    00103 #endif
    00104
    00105 /* Define the main thread's initial priority. */
    00106 #define PSP_MAIN_THREAD_PRIORITY(priority) \
    00107         unsigned int sce_newlib_priority = (priority)
    00108 /* Define the main thread's stack size (in KB). */
    00109 #define PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb) \
    00110         unsigned int sce_newlib_stack_kb_size = (size_kb)
    00111 /* Define the main thread's attributes. */
    00112 #define PSP_MAIN_THREAD_ATTR(attr) \
    00113         unsigned int sce_newlib_attribute = (attr)
    00114 #define PSP_MAIN_THREAD_ATTRIBUTE PSP_MAIN_THREAD_ATTR
    00115
    00116 /* Define all main thread parameters. */
    00117 #define PSP_MAIN_THREAD_PARAMS(priority, size_kb, attribute) \
    00118         PSP_MAIN_THREAD_PRIORITY(priority); \
    00119         PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb); \
    00120         PSP_MAIN_THREAD_ATTR(attribute)
    00121
    00122 /* If declared, the runtime code won't create a main thread for the program. */
    00123 #define PSP_NO_CREATE_MAIN_THREAD() \
    00124         int sce_newlib_nocreate_thread_in_start = 1
    00125
    00126 /* Declare the size of the heap (in KB) that the program wants to allocate from. */
    00127 #define PSP_HEAP_SIZE_KB(size_kb) \
    00128         unsigned int sce_newlib_heap_kb_size = (size_kb)
    00129
    00130 #endif /* PSPMODULEINFO_H */