PS2SDK
PS2 Homebrew Libraries
devfs: PS2 Device Filing System

Macros

#define DEVFS_MAX_SUBDEVS   16
 
#define DEVFS_MAX_DEVNAME_LENGTH   32
 
#define DEVFS_MAX_DESC_LENGTH   256
 
#define DEVFS_IOCTL_TYPE_1   1
 
#define DEVFS_IOCTL_TYPE_2   2
 
#define DEVFS_IOCTL_GETDESC   0
 
#define INVALID_HDEV   -1
 
#define devfs_IMPORTS_start   DECLARE_IMPORT_TABLE(devfs, 1, 1)
 
#define devfs_IMPORTS_end   END_IMPORT_TABLE
 
#define I_DevFSAddDevice   DECLARE_IMPORT(4, DevFSAddDevice)
 
#define I_DevFSDelDevice   DECLARE_IMPORT(5, DevFSDelDevice)
 
#define I_DevFSAddSubDevice   DECLARE_IMPORT(6, DevFSAddSubDevice)
 
#define I_DevFSDelSubDevice   DECLARE_IMPORT(7, DevFSDelSubDevice)
 

Typedefs

typedef s32 HDEV
 
typedef s32(* read_handler) (const devfs_info_t *dev, u8 *buf, s32 len)
 
typedef s32(* write_handler) (const devfs_info_t *dev, u8 *buf, s32 len)
 
typedef s32(* ioctl_handler) (const devfs_info_t *dev, int ioctl_type, int cmd, void *arg, size_t arglen, void *buf, size_t buflen)
 

Enumerations

enum  devfs_subdev_modes { DEVFS_MODE_EX = (1 << 0), DEVFS_MODE_W = (1 << 1), DEVFS_MODE_R = (1 << 2), DEVFS_MODE_RW = (DEVFS_MODE_R | DEVFS_MODE_W) }
 
enum  devfs_devtypes { DEVFS_DEVTYPE_CHAR = 1, DEVFS_DEVTYPE_BLOCK = 2, DEVFS_DEVTYPE_STREAM = 3 }
 

Functions

HDEV DevFSAddDevice (const devfs_node_t *node)
 
int DevFSDelDevice (HDEV hDev)
 
int DevFSAddSubDevice (HDEV hDev, u32 subdev_no, s32 mode, devfs_loc_t extent, void *data)
 
int DevFSDelSubDevice (HDEV hDev, u32 subdev_no)
 

Detailed Description

Macro Definition Documentation

◆ DEVFS_MAX_SUBDEVS

#define DEVFS_MAX_SUBDEVS   16

#include <iop/fs/devfs/include/devfs.h>

Maximum number of sub devices per device

Definition at line 28 of file devfs.h.

◆ DEVFS_MAX_DEVNAME_LENGTH

#define DEVFS_MAX_DEVNAME_LENGTH   32

#include <iop/fs/devfs/include/devfs.h>

Maximum size of a device name

Definition at line 30 of file devfs.h.

◆ DEVFS_MAX_DESC_LENGTH

#define DEVFS_MAX_DESC_LENGTH   256

#include <iop/fs/devfs/include/devfs.h>

Maximum length of a description string

Definition at line 32 of file devfs.h.

◆ DEVFS_IOCTL_TYPE_1

#define DEVFS_IOCTL_TYPE_1   1

#include <iop/fs/devfs/include/devfs.h>

Specifies ioctl was called. No return value and the lengths are invalid

Definition at line 61 of file devfs.h.

◆ DEVFS_IOCTL_TYPE_2

#define DEVFS_IOCTL_TYPE_2   2

#include <iop/fs/devfs/include/devfs.h>

ioctl2 was called. Parameters should all be valid

Definition at line 63 of file devfs.h.

◆ DEVFS_IOCTL_GETDESC

#define DEVFS_IOCTL_GETDESC   0

#include <iop/fs/devfs/include/devfs.h>

ioctl command to return the description associated with a device

Definition at line 66 of file devfs.h.

◆ INVALID_HDEV

#define INVALID_HDEV   -1

#include <iop/fs/devfs/include/devfs.h>

Defines an invalid HDEV value

Definition at line 152 of file devfs.h.

Typedef Documentation

◆ HDEV

typedef s32 HDEV

#include <iop/fs/devfs/include/devfs.h>

Type to hold a handle to a device

Definition at line 26 of file devfs.h.

◆ read_handler

typedef s32(* read_handler) (const devfs_info_t *dev, u8 *buf, s32 len)

#include <iop/fs/devfs/include/devfs.h>

Typedef of the read event handler

Definition at line 95 of file devfs.h.

◆ write_handler

typedef s32(* write_handler) (const devfs_info_t *dev, u8 *buf, s32 len)

#include <iop/fs/devfs/include/devfs.h>

Typedef of the write event handler

Definition at line 97 of file devfs.h.

◆ ioctl_handler

typedef s32(* ioctl_handler) (const devfs_info_t *dev, int ioctl_type, int cmd, void *arg, size_t arglen, void *buf, size_t buflen)

#include <iop/fs/devfs/include/devfs.h>

Typedef of the ioctl handler

Definition at line 99 of file devfs.h.

Enumeration Type Documentation

◆ devfs_subdev_modes

#include <iop/fs/devfs/include/devfs.h>

Enumeration of sub device access modes

Enumerator
DEVFS_MODE_EX 

Indicates a sub device can only be opened by one application at a time

DEVFS_MODE_W 

Indicates a sub device can be opened for reading

DEVFS_MODE_R 

Indicates a sub device can be opened for writing

DEVFS_MODE_RW 

Indicates a sub device can be opened for reading and writing

Definition at line 35 of file devfs.h.

◆ devfs_devtypes

#include <iop/fs/devfs/include/devfs.h>

Enumeration of device type.

Note
These are currently not used
Enumerator
DEVFS_DEVTYPE_CHAR 

Indicates a device is character device

DEVFS_DEVTYPE_BLOCK 

Indicates a device is a block device

DEVFS_DEVTYPE_STREAM 

Indicates a device is a stream device (no seek)

Definition at line 50 of file devfs.h.

Function Documentation

◆ DevFSAddDevice()

HDEV DevFSAddDevice ( const devfs_node_t node)

#include <iop/fs/devfs/include/devfs.h>

Adds a new device to the filing system

Parameters
nodePointer to a devfs_node_t structure
Returns
A device handle is returned if the device was added. On error INVALID_HDEV is returned

Definition at line 1109 of file devfs.c.

◆ DevFSDelDevice()

int DevFSDelDevice ( HDEV  hDev)

#include <iop/fs/devfs/include/devfs.h>

Define to add DevFSAddDevice to the imports list Deletes an previously opened device.

Parameters
hDevHandle to the device to delete
Returns
0 if device deleted, -1 on error

Definition at line 1162 of file devfs.c.

References devfs_find_deviceid(), DEVFS_MAX_SUBDEVS, and _devfs_device::forw.

◆ DevFSAddSubDevice()

int DevFSAddSubDevice ( HDEV  hDev,
u32  subdev_no,
s32  mode,
devfs_loc_t  extent,
void *  data 
)

#include <iop/fs/devfs/include/devfs.h>

Adds a sub device to a previously opened device

Parameters
hDevHandle to an opened device
subdev_noThe number of the subdevice. Can be 0 to DEVFS_MAX_SUBDEVS
extentA 64bit extent which reflects the size of the underlying device
dataPointer to some private data to associate with this sub device
Returns
0 if sub device added, else -1

Definition at line 1213 of file devfs.c.

◆ DevFSDelSubDevice()

int DevFSDelSubDevice ( HDEV  hDev,
u32  subdev_no 
)

#include <iop/fs/devfs/include/devfs.h>

Deletes a sub device.

Parameters
hDevHandle to an opened device.
subdev_noThe number of the subdevice to delete.
Returns
0 if device deleted. -1 on error.

Definition at line 1251 of file devfs.c.

References devfs_find_deviceid().