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 2188 2007-02-20 23:15:37Z tyranid $
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 enum PspModuleInfoAttr
00039 {
00040         PSP_MODULE_USER   = 0,
00041         PSP_MODULE_KERNEL = 0x1000,
00042 };
00043 
00044 #ifdef __cplusplus
00045 
00046 /* Declare a module.  This must be specified in the source of a library or executable. */
00047 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
00048         __asm__ (                                                       \
00049         "    .set push\n"                                               \
00050         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
00051         "    .align 2\n"                                                \
00052         "    .word 0\n"                                                 \
00053         "__lib_ent_top:\n"                                              \
00054         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
00055         "    .align 2\n"                                                \
00056         "__lib_ent_bottom:\n"                                           \
00057         "    .word 0\n"                                                 \
00058         "    .section .lib.stub.top, \"a\", @progbits\n"                \
00059         "    .align 2\n"                                                \
00060         "    .word 0\n"                                                 \
00061         "__lib_stub_top:\n"                                             \
00062         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
00063         "    .align 2\n"                                                \
00064         "__lib_stub_bottom:\n"                                          \
00065         "    .word 0\n"                                                 \
00066         "    .set pop\n"                                                \
00067         "    .text\n"                                                                                                   \
00068         );                                                              \
00069         extern char __lib_ent_top[], __lib_ent_bottom[];                \
00070         extern char __lib_stub_top[], __lib_stub_bottom[];              \
00071         extern SceModuleInfo module_info                                \
00072                 __attribute__((section(".rodata.sceModuleInfo"),        \
00073                                aligned(16), unused)) = {                \
00074           attributes, { minor_version, major_version }, #name, 0, _gp,  \
00075           __lib_ent_top, __lib_ent_bottom,                              \
00076           __lib_stub_top, __lib_stub_bottom                             \
00077         }
00078 #else
00079 /* Declare a module.  This must be specified in the source of a library or executable. */
00080 #define PSP_MODULE_INFO(name, attributes, major_version, minor_version) \
00081         __asm__ (                                                       \
00082         "    .set push\n"                                               \
00083         "    .section .lib.ent.top, \"a\", @progbits\n"                 \
00084         "    .align 2\n"                                                \
00085         "    .word 0\n"                                                 \
00086         "__lib_ent_top:\n"                                              \
00087         "    .section .lib.ent.btm, \"a\", @progbits\n"                 \
00088         "    .align 2\n"                                                \
00089         "__lib_ent_bottom:\n"                                           \
00090         "    .word 0\n"                                                 \
00091         "    .section .lib.stub.top, \"a\", @progbits\n"                \
00092         "    .align 2\n"                                                \
00093         "    .word 0\n"                                                 \
00094         "__lib_stub_top:\n"                                             \
00095         "    .section .lib.stub.btm, \"a\", @progbits\n"                \
00096         "    .align 2\n"                                                \
00097         "__lib_stub_bottom:\n"                                          \
00098         "    .word 0\n"                                                 \
00099         "    .set pop\n"                                                \
00100         "    .text\n"                                                                                                   \
00101         );                                                              \
00102         extern char __lib_ent_top[], __lib_ent_bottom[];                \
00103         extern char __lib_stub_top[], __lib_stub_bottom[];              \
00104         SceModuleInfo module_info                                       \
00105                 __attribute__((section(".rodata.sceModuleInfo"),        \
00106                                aligned(16), unused)) = {                \
00107           attributes, { minor_version, major_version }, name, 0, _gp,  \
00108           __lib_ent_top, __lib_ent_bottom,                              \
00109           __lib_stub_top, __lib_stub_bottom                             \
00110         }
00111 #endif
00112 
00113 /* Define the main thread's initial priority. */
00114 #define PSP_MAIN_THREAD_PRIORITY(priority) \
00115         unsigned int sce_newlib_priority = (priority)
00116 /* Define the main thread's stack size (in KB). */
00117 #define PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb) \
00118         unsigned int sce_newlib_stack_kb_size = (size_kb)
00119 /* Define the main thread's attributes. */
00120 #define PSP_MAIN_THREAD_ATTR(attr) \
00121         unsigned int sce_newlib_attribute = (attr)
00122 #define PSP_MAIN_THREAD_ATTRIBUTE PSP_MAIN_THREAD_ATTR
00123 
00124 /* Define all main thread parameters. */
00125 #define PSP_MAIN_THREAD_PARAMS(priority, size_kb, attribute) \
00126         PSP_MAIN_THREAD_PRIORITY(priority); \
00127         PSP_MAIN_THREAD_STACK_SIZE_KB(size_kb); \
00128         PSP_MAIN_THREAD_ATTR(attribute)
00129 
00130 /* If declared, the runtime code won't create a main thread for the program. */
00131 #define PSP_NO_CREATE_MAIN_THREAD() \
00132         int sce_newlib_nocreate_thread_in_start = 1
00133 
00134 /* Declare the size of the heap (in KB) that the program wants to allocate from. */
00135 #define PSP_HEAP_SIZE_KB(size_kb) \
00136         unsigned int sce_newlib_heap_kb_size = (size_kb)
00137 
00138 /* Declare the name of the main thread */
00139 #define PSP_MAIN_THREAD_NAME(s) const char* sce_newlib_main_thread_name = (s)
00140 
00141 #endif /* PSPMODULEINFO_H */

Generated on Tue Jul 24 15:21:23 2007 for PSPSDK-Rev2272 by  doxygen 1.5.2