PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
irx.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 __IRX_H__
17
#define __IRX_H__
18
19
#include <types.h>
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
25
#define IRX_VER(major, minor) ((((major) & 0xff) << 8) + ((minor) & 0xff))
26
27
struct
irx_id
{
28
const
char
*n;
29
u16 v;
30
};
31
32
#define IRX_ID(name, major, minor) \
33
struct irx_id _irx_id = { \
34
name, IRX_VER(major, minor) \
35
};
36
37
/*
38
* Module imports
39
*/
40
#define IMPORT_MAGIC 0x41e00000
41
42
struct
irx_import_table
43
{
44
u32 magic;
45
struct
irx_import_table
*next;
46
u16
version
;
47
u16 mode;
48
char
name[8];
49
void
*stubs[];
50
} __attribute ((packed));
51
52
struct
irx_import_stub
53
{
54
u32 jump;
55
u16 fno;
56
u16 ori_zero;
57
} __attribute ((packed));
58
59
/*
60
* Ugly, yet functional.
61
*/
62
#define DECLARE_IMPORT_TABLE(modname, major, minor) \
63
static struct irx_import_table _imp_##modname \
64
__attribute__((section(".text\n\t#"), unused))= { \
65
magic: IMPORT_MAGIC, version: IRX_VER(major, minor), \
66
name: #modname, };
67
68
#define STR(val) #val
69
// .word 0x03e00008 == jr $ra (return immediately), this value will be patched later
70
#define DECLARE_IMPORT(ord, name) \
71
__asm__ (".section\t.text\n\t" \
72
".globl\t"#name"\n\t"#name":\n\t" \
73
".word 0x03e00008\n\t" \
74
".word " STR(0x24000000|ord));
75
76
#define END_IMPORT_TABLE \
77
__asm__ (".section\t.text\n\t.word\t0, 0");
78
79
/*
80
* Module exports
81
*
82
* I'm not sure why GCC won't generate the fptrs initializers, so I fell back
83
* to the above approach to generate the fptrs themselves. Cleaner solutions
84
* requested.
85
*/
86
#define EXPORT_MAGIC 0x41c00000
87
88
void
__attribute__
((unused)) _retonly();
89
90
struct
irx_export_table
{
91
u32 magic;
92
struct
irx_export_table
*next;
93
u16
version
;
94
u16 mode;
95
u8 name[8];
96
void
*fptrs[];
97
};
98
99
#define DECLARE_EXPORT_TABLE(modname, major, minor) \
100
struct irx_export_table _exp_##modname \
101
__attribute__((section(".text\n\t#"), unused)) = { \
102
magic: EXPORT_MAGIC, version: IRX_VER(major, minor), \
103
name: #modname, };
104
105
#define DECLARE_EXPORT(fptr) \
106
__asm__ (".section\t.text\n\t.word\t" STR(fptr));
107
108
#define END_EXPORT_TABLE __asm__ (".section\t.text\n\t.word\t0");
109
110
#ifdef __cplusplus
111
}
112
#endif
113
114
#endif
/* __IRX_H__ */
version
unsigned int version
Definition
fileXio.h:3
irx_export_table
Definition
irx.h:90
irx_id
Definition
irx.h:27
irx_import_stub
Definition
irx.h:53
irx_import_table
Definition
irx.h:43
__attribute__
Definition
gif_registers.h:39
iop
kernel
include
irx.h
Generated on Thu Nov 14 2024 05:25:27 for PS2SDK by
1.9.8