PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
modload.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 __MODLOAD_H__
17#define __MODLOAD_H__
18
19#include <types.h>
20#include <irx.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27{
28 u8 e_ident[16];
29 u16 e_type;
30 u16 e_machine;
31 u32 e_version;
32 u32 e_entry;
33 u32 e_phoff;
34 u32 e_shoff;
35 u32 e_flags;
36 u16 e_ehsize;
37 u16 e_phentsize;
38 u16 e_phnum;
39 u16 e_shentsize;
40 u16 e_shnum;
41 u16 e_shstrndx;
43
45{
46 u32 p_type;
47 u32 p_offset;
48 u32 p_vaddr;
49 u32 p_paddr;
50 u32 p_filesz;
51 u32 p_memsz;
52 u32 p_flags;
53 u32 p_align;
55
57{
58 u32 sh_name;
59 u32 sh_type;
60 u32 sh_flags;
61 u32 sh_addr;
62 u32 sh_offset;
63 u32 sh_size;
64 u32 sh_link;
65 u32 sh_info;
66 u32 sh_addralign;
67 u32 sh_entsize;
69
71{
72 int fd;
73 const char *filename;
74 u8 *section_contents;
75 int unknown_0C;
76 loadfile_elf32_ehdr_t elf_header;
77 loadfile_elf32_phdr_t *program_header;
78 loadfile_elf32_shdr_t *section_headers;
79 int unknown_4C;
81
83{
84 u8 *buffer_base; // 0x00
85 int buffer_offset; // 0x04
86 int buffer_length; // 0x08
87 int dma_handle; // 0x0C
89
91{
92 int read_buffer_length; // 0x00 - Read buffer.
93 int read_buffer_offset; // 0x04 - Read buffer offset into the file.
94 loadfile_ee_elf_ringbuffer_content_t ring_buffer_contents[2];
95 int ring_buffer_index; // 0x28
96 int unknown_2C; // 0x2C
98
99typedef int (*loadfile_read_chunk_callback_t)(int fd, loadfile_allocate_handler_struct_t *allocate_info, void *read_callback_userdata);
100typedef int (*loadfile_elf_load_proc_callback_t)(loadfile_allocate_handler_struct_t *allocate_info, loadfile_file_load_handler_struct_t *flhs, void *read_callback_userdata, loadfile_read_chunk_callback_t read_callback);
101typedef int (*loadfile_check_valid_ee_elf_callback_t)(loadfile_allocate_handler_struct_t *allocate_info, loadfile_file_load_handler_struct_t *flhs);
102typedef int (*loadfile_elf_get_program_header_callback_t)(loadfile_allocate_handler_struct_t *allocate_info, loadfile_file_load_handler_struct_t *flhs);
103typedef void *(*loadfile_elf_load_alloc_buffer_from_heap_callback_t)(u32 size);
104typedef void (*loadfile_elf_load_dealloc_buffer_from_heap_callback_t)(void *buffer);
105typedef int (*loadfile_load_kelf_from_card_callback_t)(loadfile_allocate_handler_struct_t *allocate_info, loadfile_file_load_handler_struct_t *flhs, int port, int slot, int *result_out, int *result_module_out);
106typedef int (*loadfile_load_kelf_from_disk_callback_t)(loadfile_allocate_handler_struct_t *allocate_info, loadfile_file_load_handler_struct_t *flhs, int *result_out, int *result_module_out);
107
109{
110 loadfile_elf_load_proc_callback_t elf_load_proc;
111 loadfile_check_valid_ee_elf_callback_t check_valid_ee_elf;
112 loadfile_elf_get_program_header_callback_t elf_get_program_header;
113 loadfile_elf_load_alloc_buffer_from_heap_callback_t elf_load_alloc_buffer_from_heap;
114 loadfile_elf_load_dealloc_buffer_from_heap_callback_t elf_load_dealloc_buffer_from_heap;
115 loadfile_load_kelf_from_card_callback_t load_kelf_from_card;
116 loadfile_load_kelf_from_disk_callback_t load_kelf_from_disk;
118
119typedef void *(*SecrCardBootFile_callback_t)(int port, int slot, void *buffer);
120typedef void *(*SecrDiskBootFile_callback_t)(void *buffer);
121typedef void (*SetLoadfileCallbacks_callback_t)(SetLoadfileCallbacks_struct_t *callbackinfo);
122typedef int (*CheckKelfPath_callback_t)(const char *filename, int *port, int *slot);
123
124void GetModloadInternalData(void **pInternalData);
125
126int ReBootStart(const char *command, unsigned int flags);
127int LoadModuleAddress(const char *name, void *addr, int offset);
128int LoadModule(const char *name);
129int LoadStartModule(const char *name, int arglen, const char *args, int *result);
130int StartModule(int modid, const char *name, int arglen, const char *args, int *result);
131int LoadModuleBufferAddress(void *buffer, void *addr, int offset);
132int LoadModuleBuffer(void *buffer);
133int LoadStartKelfModule(const char *name, int arglen, const char *args, int *result);
134void SetSecrmanCallbacks(SecrCardBootFile_callback_t SecrCardBootFile_fnc, SecrDiskBootFile_callback_t SecrDiskBootFile_fnc, SetLoadfileCallbacks_callback_t SetLoadfileCallbacks_fnc);
135void SetCheckKelfPathCallback(CheckKelfPath_callback_t CheckKelfPath_fnc);
136void GetLoadfileCallbacks(CheckKelfPath_callback_t *CheckKelfPath_fnc, SetLoadfileCallbacks_callback_t *SetLoadfileCallbacks_fnc);
137int IsIllegalBootDevice(const char *path);
138
139#define modload_IMPORTS_start DECLARE_IMPORT_TABLE(modload, 1, 1)
140#define modload_IMPORTS_end END_IMPORT_TABLE
141
142#define I_GetModloadInternalData DECLARE_IMPORT(3, GetModloadInternalData);
143#define I_ReBootStart DECLARE_IMPORT(4, ReBootStart)
144#define I_LoadModuleAddress DECLARE_IMPORT(5, LoadModuleAddress)
145#define I_LoadModule DECLARE_IMPORT(6, LoadModule)
146#define I_LoadStartModule DECLARE_IMPORT(7, LoadStartModule)
147#define I_StartModule DECLARE_IMPORT(8, StartModule)
148#define I_LoadModuleBufferAddress DECLARE_IMPORT(9, LoadModuleBufferAddress)
149#define I_LoadModuleBuffer DECLARE_IMPORT(10, LoadModuleBuffer)
150#define I_LoadStartKelfModule DECLARE_IMPORT(11, LoadStartKelfModule)
151#define I_SetSecrmanCallbacks DECLARE_IMPORT(12, SetSecrmanCallbacks)
152#define I_SetCheckKelfPathCallback DECLARE_IMPORT(13, SetCheckKelfPathCallback)
153#define I_GetLoadfileCallbacks DECLARE_IMPORT(14, GetLoadfileCallbacks)
154#define I_IsIllegalBootDevice DECLARE_IMPORT(15, IsIllegalBootDevice)
155
156#ifdef __cplusplus
157}
158#endif
159
160#endif /* __MODLOAD_H__ */