sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
ioman.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 __IOMAN_H__
18#define __IOMAN_H__
19
20#include <types.h>
21#include <irx.h>
22#include <io_common.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28extern int open(const char *name, int mode);
29extern int close(int fd);
30extern int read(int fd, void *ptr, size_t size);
31extern int write(int fd, void *ptr, size_t size);
32extern int lseek(int fd, int pos, int mode);
33extern int ioctl(int fd, int command, void *arg);
34extern int remove(const char *name);
35extern int mkdir(const char *path);
36extern int rmdir(const char *path);
37extern int dopen(const char *path, int mode);
38extern int dclose(int fd);
39extern int dread(int fd, io_dirent_t *buf);
40extern int getstat(const char *name, io_stat_t *stat);
41extern int chstat(const char *name, io_stat_t *stat, unsigned int statmask);
42extern int format(const char *dev);
43
44/* Device drivers. */
45
46/* Device types. */
47#define IOP_DT_CHAR 0x01
48#define IOP_DT_CONS 0x02
49#define IOP_DT_BLOCK 0x04
50#define IOP_DT_RAW 0x08
51#define IOP_DT_FS 0x10
52
54typedef struct _iop_file {
56 int mode;
58 int unit;
62 void *privdata;
64
65typedef struct _iop_device {
66 const char *name;
67 unsigned int type;
69 unsigned int version;
70 const char *desc;
71 struct _iop_device_ops *ops;
72} iop_device_t;
73
74#define IOMAN_RETURN_VALUE_IMPL(val) \
75 static inline int my_ioman_retval_##val##_int(void) {return -val;} \
76 static inline signed long long my_ioman_retval_##val##_s64(void) {return -val;}
77#define IOMAN_RETURN_VALUE(val) ((void*)&my_ioman_retval_##val##_int)
78#define IOMAN_RETURN_VALUE_S64(val) ((void*)&my_ioman_retval_##val##_s64)
79
80typedef struct _iop_device_ops {
81 int (*init)(iop_device_t *device);
82 int (*deinit)(iop_device_t *device);
83 int (*format)(iop_file_t *f);
84 int (*open)(iop_file_t *f, const char *name, int flags);
85 int (*close)(iop_file_t *f);
86 int (*read)(iop_file_t *f, void *ptr, int size);
87 int (*write)(iop_file_t *f, void *ptr, int size);
88 int (*lseek)(iop_file_t *f, int offset, int mode);
89 int (*ioctl)(iop_file_t *f, int cmd, void *param);
90 int (*remove)(iop_file_t *f, const char *name);
91 int (*mkdir)(iop_file_t *f, const char *path);
92 int (*rmdir)(iop_file_t *f, const char *path);
93 int (*dopen)(iop_file_t *f, const char *path);
94 int (*dclose)(iop_file_t *f);
95 int (*dread)(iop_file_t *f, io_dirent_t *buf);
96 int (*getstat)(iop_file_t *f, const char *name, io_stat_t *stat_);
97 int (*chstat)(iop_file_t *f, const char *name, io_stat_t *stat_, unsigned int statmask);
98} iop_device_ops_t;
99
100extern int AddDrv(iop_device_t *device);
101extern int DelDrv(const char *name);
102
103#define ioman_IMPORTS_start DECLARE_IMPORT_TABLE(ioman, 1, 1)
104#define ioman_IMPORTS_end END_IMPORT_TABLE
105
106#define I_open DECLARE_IMPORT(4, open)
107#define I_close DECLARE_IMPORT(5, close)
108#define I_read DECLARE_IMPORT(6, read)
109#define I_write DECLARE_IMPORT(7, write)
110#define I_lseek DECLARE_IMPORT(8, lseek)
111#define I_ioctl DECLARE_IMPORT(9, ioctl)
112#define I_remove DECLARE_IMPORT(10, remove)
113#define I_mkdir DECLARE_IMPORT(11, mkdir)
114#define I_rmdir DECLARE_IMPORT(12, rmdir)
115#define I_dopen DECLARE_IMPORT(13, dopen)
116#define I_dclose DECLARE_IMPORT(14, dclose)
117#define I_dread DECLARE_IMPORT(15, dread)
118#define I_getstat DECLARE_IMPORT(16, getstat)
119#define I_chstat DECLARE_IMPORT(17, chstat)
120#define I_format DECLARE_IMPORT(18, format)
121#define I_AddDrv DECLARE_IMPORT(20, AddDrv);
122#define I_DelDrv DECLARE_IMPORT(21, DelDrv);
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif /* __IOMAN_H__ */
struct _iop_file iop_file_t
unsigned int version
Definition ioman.h:69
struct _iop_device * device
Definition ioman.h:60
void * privdata
Definition ioman.h:62
int unit
Definition ioman.h:58
int mode
Definition ioman.h:56