sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
imgdrv.c
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Licenced under Academic Free License version 2.0
7
# Review ps2sdk README & LICENSE files for further details.
8
*/
9
15
16
#include <
ioman.h
>
17
#include <
irx.h
>
18
#include <
loadcore.h
>
19
20
#define MODNAME "imgdrv"
21
22
IRX_ID(MODNAME, 1, 1);
23
24
// Function prototypes
25
static
int
imgdrv_read(
iop_file_t
*f,
void
*buf,
int
size);
26
static
int
imgdrv_lseek(
iop_file_t
*f,
int
offset,
int
whence);
27
28
/* The IOMAN operations structure is usually longer than this,
29
but the structure in the original was this short (probably to save space). */
30
typedef
struct
_iop_device_ops_short
31
{
32
int (*init)(iop_device_t *device);
33
int (*deinit)(iop_device_t *device);
34
int (*format)(
iop_file_t
*f);
35
int (*open)(
iop_file_t
*f,
const
char
*name,
int
flags);
36
int (*close)(
iop_file_t
*f);
37
int (*read)(
iop_file_t
*f,
void
*ptr,
int
size);
38
int (*write)(
iop_file_t
*f,
void
*ptr,
int
size);
39
int (*lseek)(
iop_file_t
*f,
int
offset,
int
mode);
40
} iop_device_ops_short_t;
41
42
IOMAN_RETURN_VALUE_IMPL(0);
43
44
static
iop_device_ops_short_t imgdrv_ops = {
45
IOMAN_RETURN_VALUE(0),
// init
46
IOMAN_RETURN_VALUE(0),
// deinit
47
IOMAN_RETURN_VALUE(0),
// format
48
IOMAN_RETURN_VALUE(0),
// open
49
IOMAN_RETURN_VALUE(0),
// close
50
&imgdrv_read,
// read
51
IOMAN_RETURN_VALUE(0),
// write
52
&imgdrv_lseek,
// lseek
53
};
54
55
#define MAX_IMAGES 2
56
// These arrays will be manipulated by the EE-side code before the module is loaded.
57
void
*img[MAX_IMAGES] = {(
void
*)0xDEC1DEC1, 0};
58
int
img_size[MAX_IMAGES] = {0xDEC2DEC2, 0};
59
60
static
iop_device_t img_device = {
61
"img"
,
62
IOP_DT_FS,
63
1,
64
"img"
,
65
(iop_device_ops_t *)&imgdrv_ops,
66
};
67
68
int
_start(
int
argc,
char
*argv[])
69
{
70
return
(AddDrv(&img_device) < 0) ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END;
71
}
72
73
static
int
imgdrv_read(
iop_file_t
*f,
void
*buf,
int
size)
74
{
75
int
i;
76
const
u32 *img_ptr;
77
u32 *img_out;
78
79
img_out = (u32 *)buf;
80
img_ptr = (
const
u32 *)img[f->
unit
];
81
for
(i = size; i > 0; i -= 4, img_ptr++, img_out++)
82
*img_out = *img_ptr;
83
84
return
size;
85
}
86
87
static
int
imgdrv_lseek(
iop_file_t
*f,
int
offset,
int
whence)
88
{
89
return
(whence == SEEK_SET ? 0 : img_size[f->
unit
]);
90
}
ioman.h
iop_file_t
struct _iop_file iop_file_t
irx.h
loadcore.h
_iop_device_ops_short
Definition
imgdrv.c:31
_iop_file::unit
int unit
Definition
ioman.h:58
core
iopreboot
src
imgdrv
imgdrv.c
Generated by
1.18.0