PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
loadcore.h
Go to the documentation of this file.
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
16#ifndef __LOADCORE_H__
17#define __LOADCORE_H__
18
19#include <types.h>
20#include <irx.h>
21
22#define MODULE_RESIDENT_END 0
23#define MODULE_NO_RESIDENT_END 1
24#define MODULE_REMOVABLE_END 2 // Only for 'modload' > v1.2
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
31typedef struct _ModuleInfo {
32 struct _ModuleInfo *next;
33 char *name;
34 u16 version;
37 u16 id;
39 u16 flags;
41 u32 entry;
42 u32 gp;
43 u32 text_start;
44 u32 text_size;
45 u32 data_size;
46 u32 bss_size;
47 u32 unused1;
48 u32 unused2;
50
51typedef struct _IopModuleID {
52 const char *name;
53 unsigned short int version;
55
56typedef struct _FileInfo {
57 u32 ModuleType;
58 void *EntryPoint;
59 void *gp;
60 void *text_start;
61 u32 text_size;
62 u32 data_size;
63 u32 bss_size;
64 u32 MemSize;
65 IopModuleID_t *mod_id;
67
68typedef struct _iop_library {
69 struct _iop_library *prev;
70 struct irx_import_table *caller;
71 u16 version;
72 u16 flags;
73 char name[8];
74 void *exports[];
76
78typedef struct tag_LC_internals {
79 iop_library_t* let_next, *let_prev; //let_next = tail, let_prev = head. I don't know what "let" and "mda" stand for.
80 iop_library_t* mda_next, *mda_prev;
83 int module_count;
84 int module_index;
85 /* The following members may change depending on the version of the module. */
86 void *reboot_handlers;
87 void *intr_suspend_tbl;
88 int bootmodes[16];
89 int bootmodes_size;
91
92typedef struct {
93 u16 value;
94 u8 id;
95 u8 len;
96 u32 data[];
98
99
100typedef struct{ //FIXME: Incomplete structure definition. Provided only for compatibility, as I don't know what the full structure is like.
101 void *callback;
103
104typedef int (*BootupCallback_t)(iop_init_entry_t* next, int delayed);
105
109typedef struct {
110 struct _iop_library *tail;
111 struct _iop_library *head;
112} iop_library_table_t __attribute__ ((deprecated));
113
118lc_internals_t *GetLoadcoreInternalData(void);
119
120void FlushIcache(void);
121void FlushDcache(void);
122
123int RegisterLibraryEntries(struct irx_export_table *exports);
124int ReleaseLibraryEntries(struct irx_export_table *exports);
125
126// In liberx, the following is LinkLibraryClients
127int LinkLibraryEntries(void* addr, int size);
128// In liberx, the following is UnLinkLibraryClients
129int UnLinkLibraryEntries(void* addr, int size);
130
131int RegisterNonAutoLinkEntries(struct irx_export_table *exports);
132
133// In liberx, the following is SearchLibraryEntries
134void *QueryLibraryEntryTable(iop_library_t *library);
135int * QueryBootMode(int mode);
136void RegisterBootMode(iop_bootmode_t *b);
137
138void LockLibraryClient(struct irx_export_table *export);
139void UnLockLibraryClient(struct irx_export_table *export);
140
141void RegisterModule(ModuleInfo_t *mi);
142void ReleaseModule(ModuleInfo_t *mi);
143
144int AddRebootNotifyHandler(BootupCallback_t func, int priority, int *stat);
145
146void SetCacheCtrl(u32 val);
147
148int ProbeExecutableObject(void* image, FileInfo_t *result);
149int LoadExecutableObject(void* image, FileInfo_t *fi);
150ModuleInfo_t *SearchModuleCBByAddr(void* addr);
151
152#define loadcore_IMPORTS \
153 loadcore_IMPORTS_start \
154 \
155 I_GetLibraryEntryTable \
156 \
157 I_FlushIcache \
158 I_FlushDcache \
159 \
160 I_RegisterLibraryEntries \
161 I_ReleaseLibraryEntries \
162 \
163 I_QueryLibraryEntryTable \
164 I_QueryBootMode \
165 \
166 loadcore_IMPORTS_end
167
168#define loadcore_IMPORTS_start DECLARE_IMPORT_TABLE(loadcore, 1, 1)
169#define loadcore_IMPORTS_end END_IMPORT_TABLE
170
171#define I_GetLibraryEntryTable DECLARE_IMPORT(3, GetLibraryEntryTable)
172#define I_GetLoadcoreInternalData DECLARE_IMPORT(3, GetLoadcoreInternalData)
173#define I_FlushIcache DECLARE_IMPORT(4, FlushIcache)
174#define I_FlushDcache DECLARE_IMPORT(5, FlushDcache)
175#define I_RegisterLibraryEntries DECLARE_IMPORT(6, RegisterLibraryEntries)
176#define I_ReleaseLibraryEntries DECLARE_IMPORT(7, ReleaseLibraryEntries)
177#define I_LinkLibraryEntries DECLARE_IMPORT(8, LinkLibraryEntries)
178#define I_UnLinkLibraryEntries DECLARE_IMPORT(9, UnLinkLibraryEntries)
179#define I_RegisterNonAutoLinkEntries DECLARE_IMPORT(10, RegisterNonAutoLinkEntries)
180#define I_QueryLibraryEntryTable DECLARE_IMPORT(11, QueryLibraryEntryTable)
181#define I_QueryBootMode DECLARE_IMPORT(12, QueryBootMode)
182#define I_RegisterBootMode DECLARE_IMPORT(13, RegisterBootMode)
183#define I_LockLibraryClient DECLARE_IMPORT(14, LockLibraryClient)
184#define I_UnLockLibraryClient DECLARE_IMPORT(15, UnLockLibraryClient)
185#define I_RegisterModule DECLARE_IMPORT(16, RegisterModule)
186#define I_ReleaseModule DECLARE_IMPORT(17, ReleaseModule)
187#define I_AddRebootNotifyHandler DECLARE_IMPORT(20, AddRebootNotifyHandler)
188#define I_SetCacheCtrl DECLARE_IMPORT(21, SetCacheCtrl)
189#define I_ProbeExecutableObject DECLARE_IMPORT(22, ProbeExecutableObject)
190#define I_LoadExecutableObject DECLARE_IMPORT(23, LoadExecutableObject)
191#define I_SearchModuleCBByAddr DECLARE_IMPORT(24, SearchModuleCBByAddr)
192
193// For backwards compatibility
194#define LinkImports(...) LinkLibraryEntries(__VA_ARGS__)
195#define UnlinkImports(...) UnLinkLibraryEntries(__VA_ARGS__)
196#define SetNonAutoLinkFlag(...) LockLibraryClient(__VA_ARGS__)
197#define UnsetNonAutoLinkFlag(...) UnLockLibraryClient(__VA_ARGS__)
198#define LinkModule(...) RegisterModule(__VA_ARGS__)
199#define UnlinkModule(...) ReleaseModule(__VA_ARGS__)
200#define RegisterPostBootCallback(...) AddRebootNotifyHandler(__VA_ARGS__)
201#define ReadModuleHeader(...) ProbeExecutableObject(__VA_ARGS__)
202#define LoadModuleImage(...) LoadExecutableObject(__VA_ARGS__)
203#define FindImageInfo(...) SearchModuleCBByAddr(__VA_ARGS__)
204#define I_LinkImports I_LinkLibraryEntries
205#define I_UnlinkImports I_UnLinkLibraryEntries
206#define I_SetNonAutoLinkFlag I_LockLibraryClient
207#define I_UnsetNonAutoLinkFlag I_UnLockLibraryClient
208#define I_LinkModule I_RegisterModule
209#define I_UnlinkModule I_ReleaseModule
210#define I_RegisterPostBootCallback I_AddRebootNotifyHandler
211#define I_ReadModuleHeader I_ProbeExecutableObject
212#define I_LoadModuleImage I_LoadExecutableObject
213#define I_FindImageInfo I_SearchModuleCBByAddr
214
215#ifdef __cplusplus
216}
217#endif
218
219#endif /* __LOADCORE_H__ */
unsigned int version
Definition fileXio.h:3
ModuleInfo_t * image_info
Definition loadcore.h:82
struct _ModuleInfo ModuleInfo_t
u16 newflags
Definition loadcore.h:36
struct tag_LC_internals lc_internals_t
iop_library_table_t * GetLibraryEntryTable(void) __attribute__((deprecated))
Definition loadcore.h:100