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