sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
iomanX.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
17#ifndef __IOMANX_H__
18#define __IOMANX_H__
19
20#include <types.h>
21#ifdef _IOP
22#include <irx.h>
23#endif
24#include <stdarg.h>
25#include <io_common.h>
26#include <iox_stat.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32// Rename prototype names in order to avoid clashes with other standard I/O libraries.
33#ifndef IOMANX_OLD_NAME_COMPATIBILITY
34#ifdef _IOP
35#define IOMANX_OLD_NAME_COMPATIBILITY 1
36#else
37#define IOMANX_OLD_NAME_COMPATIBILITY 0
38#endif /* _IOP */
39#endif /* IOMANX_OLD_NAME_COMPATIBILITY */
40
41// Avoid renaming AddDrv and DelDrv to handle the case where the old ioman AddDrv/DelDrv is linked against.
42#ifndef IOMANX_OLD_NAME_ADDDELDRV
43#ifdef _IOP
44#define IOMANX_OLD_NAME_ADDDELDRV 1
45#else
46#define IOMANX_OLD_NAME_ADDDELDRV 0
47#endif /* _IOP */
48#endif /* IOMANX_OLD_NAME_ADDDELDRV */
49
50#if IOMANX_OLD_NAME_COMPATIBILITY
51#if IOMANX_OLD_NAME_ADDDELDRV
52#define iomanX_AddDrv AddDrv
53#define iomanX_DelDrv DelDrv
54#endif
55#endif
56
57/* Device drivers. */
58
59/* Device types. */
60#define IOP_DT_CHAR 0x01
61#define IOP_DT_CONS 0x02
62#define IOP_DT_BLOCK 0x04
63#define IOP_DT_RAW 0x08
64#define IOP_DT_FS 0x10
65#ifndef IOMAN_NO_EXTENDED
67#define IOP_DT_FSEXT 0x10000000
68#endif
69
81
82typedef struct _iomanX_iop_device {
83 const char *name;
84 unsigned int type;
86 unsigned int version;
87 const char *desc;
88 struct _iomanX_iop_device_ops *ops;
89} iomanX_iop_device_t;
90#define IOMANX_RETURN_VALUE_IMPL(val) \
91 static inline int my_iomanx_retval_##val##_int(void) {return -val;} \
92 static inline signed long long my_iomanx_retval_##val##_s64(void) {return -val;}
93#define IOMANX_RETURN_VALUE(val) ((void*)&my_iomanx_retval_##val##_int)
94#define IOMANX_RETURN_VALUE_S64(val) ((void*)&my_iomanx_retval_##val##_s64)
95
96typedef struct _iomanX_iop_device_ops {
97 int (*init)(iomanX_iop_device_t *device);
98 int (*deinit)(iomanX_iop_device_t *device);
99 int (*format)(iomanX_iop_file_t *f, const char *dev, const char *blockdev, void *arg, int arglen);
100 int (*open)(iomanX_iop_file_t *f, const char *name, int flags, int mode);
101 int (*close)(iomanX_iop_file_t *f);
102 int (*read)(iomanX_iop_file_t *f, void *ptr, int size);
103 int (*write)(iomanX_iop_file_t *f, void *ptr, int size);
104 int (*lseek)(iomanX_iop_file_t *f, int offset, int mode);
105 int (*ioctl)(iomanX_iop_file_t *f, int cmd, void *param);
106 int (*remove)(iomanX_iop_file_t *f, const char *name);
107 int (*mkdir)(iomanX_iop_file_t *f, const char *path, int mode);
108 int (*rmdir)(iomanX_iop_file_t *f, const char *path);
109 int (*dopen)(iomanX_iop_file_t *f, const char *path);
110 int (*dclose)(iomanX_iop_file_t *f);
111 int (*dread)(iomanX_iop_file_t *f, iox_dirent_t *buf);
112 int (*getstat)(iomanX_iop_file_t *f, const char *name, iox_stat_t *stat_);
113 int (*chstat)(iomanX_iop_file_t *f, const char *name, iox_stat_t *stat_, unsigned int statmask);
114
115#ifndef IOMAN_NO_EXTENDED
116 /* Extended ops start here. */
117 int (*rename)(iomanX_iop_file_t *f, const char *old, const char *new_);
118 int (*chdir)(iomanX_iop_file_t *f, const char *name);
119 int (*sync)(iomanX_iop_file_t *f, const char *dev, int flag);
120 int (*mount)(iomanX_iop_file_t *f, const char *fsname, const char *devname, int flag, void *arg, int arglen);
121 int (*umount)(iomanX_iop_file_t *f, const char *fsname);
122 s64 (*lseek64)(iomanX_iop_file_t *f, s64 offset, int whence);
123 int (*devctl)(iomanX_iop_file_t *f, const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
124 int (*symlink)(iomanX_iop_file_t *f, const char *old, const char *new_);
125 int (*readlink)(iomanX_iop_file_t *f, const char *path, char *buf, unsigned int buflen);
126 int (*ioctl2)(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
127#endif /* IOMAN_NO_EXTENDED */
128} iomanX_iop_device_ops_t;
129
130extern iomanX_iop_device_t **iomanX_GetDeviceList(void);
131
132extern int iomanX_open(const char *name, int flags, ...);
133extern int iomanX_close(int fd);
134extern int iomanX_read(int fd, void *ptr, int size);
135extern int iomanX_write(int fd, void *ptr, int size);
136extern int iomanX_lseek(int fd, int offset, int mode);
137
138extern int iomanX_ioctl(int fd, int cmd, void *param);
139extern int iomanX_remove(const char *name);
140
141extern int iomanX_mkdir(const char *path, int mode);
142extern int iomanX_rmdir(const char *path);
143extern int iomanX_dopen(const char *path);
144extern int iomanX_dclose(int fd);
145extern int iomanX_dread(int fd, iox_dirent_t *buf);
146
147extern int iomanX_getstat(const char *name, iox_stat_t *stat);
148extern int iomanX_chstat(const char *name, iox_stat_t *stat, unsigned int statmask);
149
151extern int iomanX_format(const char *dev, const char *blockdev, void *arg, int arglen);
152
153#ifndef IOMAN_NO_EXTENDED
154/* The newer calls - these are NOT supported by the older IOMAN. */
155extern int iomanX_rename(const char *old, const char *new_);
156extern int iomanX_chdir(const char *name);
157extern int iomanX_sync(const char *dev, int flag);
158extern int iomanX_mount(const char *fsname, const char *devname, int flag, void *arg, int arglen);
159extern int iomanX_umount(const char *fsname);
160extern s64 iomanX_lseek64(int fd, s64 offset, int whence);
161extern int iomanX_devctl(const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
162extern int iomanX_symlink(const char *old, const char *new_);
163extern int iomanX_readlink(const char *path, char *buf, unsigned int buflen);
164extern int iomanX_ioctl2(int fd, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
165#endif /* IOMAN_NO_EXTENDED */
166
167extern int iomanX_AddDrv(iomanX_iop_device_t *device);
168extern int iomanX_DelDrv(const char *name);
169
170extern unsigned int iomanX_GetDevType(int fd);
171extern void iomanX_StdioInit(int mode);
172
173#ifdef _IOP
174#define iomanX_IMPORTS_start DECLARE_IMPORT_TABLE(iomanx, 1, 1)
175#define iomanX_IMPORTS_end END_IMPORT_TABLE
176
177#define I_iomanX_GetDeviceList DECLARE_IMPORT(3, iomanX_GetDeviceList)
178#define I_iomanX_open DECLARE_IMPORT(4, iomanX_open)
179#define I_iomanX_close DECLARE_IMPORT(5, iomanX_close)
180#define I_iomanX_read DECLARE_IMPORT(6, iomanX_read)
181#define I_iomanX_write DECLARE_IMPORT(7, iomanX_write)
182#define I_iomanX_lseek DECLARE_IMPORT(8, iomanX_lseek)
183#define I_iomanX_ioctl DECLARE_IMPORT(9, iomanX_ioctl)
184#define I_iomanX_remove DECLARE_IMPORT(10, iomanX_remove)
185#define I_iomanX_mkdir DECLARE_IMPORT(11, iomanX_mkdir)
186#define I_iomanX_rmdir DECLARE_IMPORT(12, iomanX_rmdir)
187#define I_iomanX_dopen DECLARE_IMPORT(13, iomanX_dopen)
188#define I_iomanX_dclose DECLARE_IMPORT(14, iomanX_dclose)
189#define I_iomanX_dread DECLARE_IMPORT(15, iomanX_dread)
190#define I_iomanX_getstat DECLARE_IMPORT(16, iomanX_getstat)
191#define I_iomanX_chstat DECLARE_IMPORT(17, iomanX_chstat)
192#define I_iomanX_format DECLARE_IMPORT(18, iomanX_format)
193#define I_iomanX_rename DECLARE_IMPORT(25, iomanX_rename)
194#define I_iomanX_chdir DECLARE_IMPORT(26, iomanX_chdir)
195#define I_iomanX_sync DECLARE_IMPORT(27, iomanX_sync)
196#define I_iomanX_mount DECLARE_IMPORT(28, iomanX_mount)
197#define I_iomanX_umount DECLARE_IMPORT(29, iomanX_umount)
198#define I_iomanX_lseek64 DECLARE_IMPORT(30, iomanX_lseek64)
199#define I_iomanX_devctl DECLARE_IMPORT(31, iomanX_devctl)
200#define I_iomanX_symlink DECLARE_IMPORT(32, iomanX_symlink)
201#define I_iomanX_readlink DECLARE_IMPORT(33, iomanX_readlink)
202#define I_iomanX_ioctl2 DECLARE_IMPORT(34, iomanX_ioctl2)
203#if IOMANX_OLD_NAME_ADDDELDRV
204#define I_AddDrv DECLARE_IMPORT(20, AddDrv)
205#define I_DelDrv DECLARE_IMPORT(21, DelDrv)
206#else
207#define I_iomanX_AddDrv DECLARE_IMPORT(20, iomanX_AddDrv)
208#define I_iomanX_DelDrv DECLARE_IMPORT(21, iomanX_DelDrv)
209#endif
210#define I_iomanX_GetDevType DECLARE_IMPORT(22, iomanX_GetDevType)
211#define I_iomanX_StdioInit DECLARE_IMPORT(23, iomanX_StdioInit)
212#endif
213
214#if IOMANX_OLD_NAME_COMPATIBILITY
215
217typedef iomanX_iop_device_t iop_device_t;
218typedef iomanX_iop_device_ops_t iop_device_ops_t;
219
220static inline iop_device_t **GetDeviceList(void)
221{
222 return iomanX_GetDeviceList();
223}
224
225static inline int open(const char *name, int flags, ...)
226{
227 va_list alist;
228 int mode;
229
230 va_start(alist, flags);
231 mode = va_arg(alist, int);
232 va_end(alist);
233
234 return iomanX_open(name, flags, mode);
235}
236static inline int close(int fd)
237{
238 return iomanX_close(fd);
239}
240static inline int read(int fd, void *ptr, int size)
241{
242 return iomanX_read(fd, ptr, size);
243}
244static inline int write(int fd, void *ptr, int size)
245{
246 return iomanX_write(fd, ptr, size);
247}
248static inline int lseek(int fd, int offset, int mode)
249{
250 return iomanX_lseek(fd, offset, mode);
251}
252
253static inline int ioctl(int fd, int cmd, void *param)
254{
255 return iomanX_ioctl(fd, cmd, param);
256}
257static inline int remove(const char *name)
258{
259 return iomanX_remove(name);
260}
261
262static inline int mkdir(const char *path, int mode)
263{
264 return iomanX_mkdir(path, mode);
265}
266static inline int rmdir(const char *path)
267{
268 return iomanX_rmdir(path);
269}
270static inline int dopen(const char *path)
271{
272 return iomanX_dopen(path);
273}
274static inline int dclose(int fd)
275{
276 return iomanX_dclose(fd);
277}
278static inline int dread(int fd, iox_dirent_t *buf)
279{
280 return iomanX_dread(fd, buf);
281}
282
283static inline int getstat(const char *name, iox_stat_t *stat)
284{
285 return iomanX_getstat(name, stat);
286}
287static inline int chstat(const char *name, iox_stat_t *stat, unsigned int statmask)
288{
289 return iomanX_chstat(name, stat, statmask);
290}
291
293static inline int format(const char *dev, const char *blockdev, void *arg, int arglen)
294{
295 return iomanX_format(dev, blockdev, arg, arglen);
296}
297
298#ifndef IOMAN_NO_EXTENDED
299/* The newer calls - these are NOT supported by the older IOMAN. */
300static inline int rename(const char *old, const char *new_)
301{
302 return iomanX_rename(old, new_);
303}
304static inline int chdir(const char *name)
305{
306 return iomanX_chdir(name);
307}
308static inline int sync(const char *dev, int flag)
309{
310 return iomanX_sync(dev, flag);
311}
312static inline int mount(const char *fsname, const char *devname, int flag, void *arg, int arglen)
313{
314 return iomanX_mount(fsname, devname, flag, arg, arglen);
315}
316static inline int umount(const char *fsname)
317{
318 return iomanX_umount(fsname);
319}
320static inline s64 lseek64(int fd, s64 offset, int whence)
321{
322 return iomanX_lseek64(fd, offset, whence);
323}
324static inline int devctl(const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
325{
326 return iomanX_devctl(name, cmd, arg, arglen, buf, buflen);
327}
328static inline int symlink(const char *old, const char *new_)
329{
330 return iomanX_symlink(old, new_);
331}
332static inline int readlink(const char *path, char *buf, unsigned int buflen)
333{
334 return iomanX_readlink(path, buf, buflen);
335}
336static inline int ioctl2(int fd, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen)
337{
338 return iomanX_ioctl2(fd, cmd, arg, arglen, buf, buflen);
339}
340#endif /* IOMAN_NO_EXTENDED */
341
342#if !IOMANX_OLD_NAME_ADDDELDRV
343static inline int AddDrv(iop_device_t *device)
344{
345 return iomanX_AddDrv(device);
346}
347static inline int DelDrv(const char *name)
348{
349 return iomanX_DelDrv(name);
350}
351#endif
352
353static inline void StdioInit(int mode)
354{
355 return iomanX_StdioInit(mode);
356}
357
358#ifdef _IOP
359#define I_GetDeviceList I_iomanX_GetDeviceList
360#define I_open I_iomanX_open
361#define I_close I_iomanX_close
362#define I_read I_iomanX_read
363#define I_write I_iomanX_write
364#define I_lseek I_iomanX_lseek
365#define I_ioctl I_iomanX_ioctl
366#define I_remove I_iomanX_remove
367#define I_mkdir I_iomanX_mkdir
368#define I_rmdir I_iomanX_rmdir
369#define I_dopen I_iomanX_dopen
370#define I_dclose I_iomanX_dclose
371#define I_dread I_iomanX_dread
372#define I_getstat I_iomanX_getstat
373#define I_chstat I_iomanX_chstat
374#define I_format I_iomanX_format
375#define I_rename I_iomanX_rename
376#define I_chdir I_iomanX_chdir
377#define I_sync I_iomanX_sync
378#define I_mount I_iomanX_mount
379#define I_umount I_iomanX_umount
380#define I_lseek64 I_iomanX_lseek64
381#define I_devctl I_iomanX_devctl
382#define I_symlink I_iomanX_symlink
383#define I_readlink I_iomanX_readlink
384#define I_ioctl2 I_iomanX_ioctl2
385#if !IOMANX_OLD_NAME_ADDDELDRV
386#define I_AddDrv I_iomanX_AddDrv
387#define I_DelDrv I_iomanX_DelDrv
388#endif
389#define I_StdioInit I_iomanX_StdioInit
390#endif
391
392#endif /* IOMANX_OLD_NAME_COMPATIBILITY */
393
394#ifdef __cplusplus
395}
396#endif
397
398#endif /* __IOMANX_H__ */
int iomanX_format(const char *dev, const char *blockdev, void *arg, int arglen)
Definition iomanX.c:710
struct _iomanX_iop_file iomanX_iop_file_t
struct _iop_file iop_file_t
unsigned int version
Definition iomanX.h:86
struct _iomanX_iop_device * device
Definition iomanX.h:77
void * privdata
Definition iomanX.h:79