|
PS2SDK
PS2 Homebrew Libraries
|
#include "types.h"#include "defs.h"#include "irx.h"#include "loadcore.h"#include "thbase.h"#include "thevent.h"#include "thsemap.h"#include "intrman.h"#include "stdio.h"#include "sysclib.h"#include <errno.h>#include "devfs.h"#include "sysmem.h"#include "iomanX.h"
Include dependency graph for devfs.c:Go to the source code of this file.
Data Structures | |
| struct | subdev_t |
| struct | _devfs_device |
| struct | _ioman_data |
| struct | _directory_file |
Macros | |
| #define | MODNAME "devfs" |
| #define | M_PRINTF(format, args...) |
| #define | BANNER "DEVFS %s\n" |
| #define | VERSION "v0.1" |
| #define | MAX_OPENFILES 32 |
| #define | MAX_OPEN_DIRFILES 16 |
Typedefs | |
| typedef struct _devfs_device | devfs_device_t |
| typedef struct _ioman_data | ioman_data_t |
| typedef struct _directory_file | directory_file_t |
Functions | |
| IRX_ID (MODNAME, 1, 1) | |
| const char * | devfs_subdev_to_str (int subdev) |
| int | devfs_fill_dirent (iox_dirent_t *dirent, int devno) |
| devfs_device_t * | devfs_create_device (const devfs_node_t *node) |
| int | devfs_delete_device (devfs_device_t *dev) |
| devfs_device_t * | devfs_find_devicename (const char *name) |
| devfs_device_t * | devfs_find_deviceid (HDEV hDev) |
| int | devfs_open (iop_file_t *file, const char *name, int mode, int unused) |
| int | devfs_close (iop_file_t *file) |
| int | devfs_ioctl (iop_file_t *file, int cmd, void *args) |
| int | devfs_ioctl2 (iop_file_t *file, int cmd, void *args, unsigned int arglen, void *buf, unsigned int buflen) |
| int | devfs_read (iop_file_t *file, void *buf, int len) |
| int | devfs_write (iop_file_t *file, void *buf, int len) |
| int | devfs_lseek (iop_file_t *file, long loc, int whence) |
| int | devfs_lseek64 (iop_file_t *file, long long loc, int whence) |
| int | devfs_dopen (iop_file_t *file, const char *name) |
| int | devfs_dclose (iop_file_t *file) |
| int | devfs_dread (iop_file_t *file, iox_dirent_t *buf) |
| int | devfs_getstat (iop_file_t *file, const char *name, iox_stat_t *stat) |
| IOMANX_RETURN_VALUE_IMPL (0) | |
| IOMANX_RETURN_VALUE_IMPL (EPERM) | |
| int | init_devfs (void) |
| int | _start (int argc, char *argv[]) |
| int | devfs_check_devname (const char *name) |
| 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) |
Variables | |
| struct irx_export_table | _exp_devfs |
| devfs_device_t * | root_device |
| HDEV | dev_count |
| directory_file_t | open_dirfiles [MAX_OPEN_DIRFILES] |
| static iop_device_ops_t | devfs_ops |
| static iop_device_t | devfs_device |
DevFS source file
Definition in file devfs.c.
| struct subdev_t |
Collaboration diagram for subdev_t:| Data Fields | ||
|---|---|---|
| void * | data | |
| s32 | valid | |
| u32 | mode | |
| u32 | open_refcount | |
| devfs_loc_t | extent | |
| struct _ioman_data * | open_files[MAX_OPENFILES] | |
| struct _devfs_device |
Collaboration diagram for _devfs_device:| Data Fields | ||
|---|---|---|
| struct _devfs_device * | forw |
Pointers to the next device in the chain |
| struct _devfs_device * | back | |
| HDEV | hDev | |
| devfs_node_t | node | |
| subdev_t | subdevs[DEVFS_MAX_SUBDEVS] | |
| u32 | subdev_count | |
| u32 | open_refcount | |
| struct _ioman_data |
Collaboration diagram for _ioman_data:| Data Fields | ||
|---|---|---|
| HDEV | hDev | |
| devfs_device_t * | dev |
Pointer to the main device, set to NULL if device closed |
| int | subdev | |
| u32 | mode | |
| devfs_loc_t | loc | |
| struct _directory_file |
| #define M_PRINTF | ( | format, | |
| args... ) |
| const char * devfs_subdev_to_str | ( | int | subdev | ) |
Simple function to convert a number to a string
| subdev | The number to convert. |
Definition at line 103 of file devfs.c.
Referenced by devfs_fill_dirent().
| int devfs_fill_dirent | ( | iox_dirent_t * | dirent, |
| int | devno ) |
Scans the device list and fills in the corresponding directory entry
| dirent | Pointer to a iox_dirent_t structure. |
| devno | The sequential device number to read |
Definition at line 137 of file devfs.c.
References DEVFS_MAX_SUBDEVS, DEVFS_MODE_R, DEVFS_MODE_W, devfs_subdev_to_str(), FIO_S_IFREG, FIO_S_IRUSR, FIO_S_IWUSR, _devfs_device::forw, devfs_loc_t::loc32, devfs_node_t::name, and root_device.
| devfs_device_t * devfs_create_device | ( | const devfs_node_t * | node | ) |
Creates a new device based on the node data supplied
| node | Pointer to a devfs_node_t structure |
Definition at line 198 of file devfs.c.
References devfs_node_t::desc, and devfs_node_t::name.
Referenced by DevFSAddDevice().
| int devfs_delete_device | ( | devfs_device_t * | dev | ) |
Deletes a device
| dev | Pointer to a previously allocated device structure |
Definition at line 248 of file devfs.c.
References devfs_node_t::desc, and devfs_node_t::name.
Referenced by DevFSDelDevice().
| devfs_device_t * devfs_find_devicename | ( | const char * | name | ) |
Trys to find a device with a matching name.
The name can be a full device name with subdev on the end, the function should still find the device.
| name | The name of the device to find |
Definition at line 276 of file devfs.c.
References _devfs_device::forw, devfs_node_t::name, and root_device.
Referenced by devfs_getstat(), devfs_open(), and DevFSAddDevice().
| devfs_device_t * devfs_find_deviceid | ( | HDEV | hDev | ) |
Finds a device from its device handle.
| hDev | Handle to the device. |
Definition at line 309 of file devfs.c.
References _devfs_device::forw, and root_device.
Referenced by DevFSAddSubDevice(), DevFSDelDevice(), and DevFSDelSubDevice().
| int devfs_open | ( | iop_file_t * | file, |
| const char * | name, | ||
| int | mode, | ||
| int | unused ) |
ioman open handler @oaram file: Pointer to the ioman file structure
| name | Name of file to open |
| mode | Open file mode settings |
Definition at line 337 of file devfs.c.
References devfs_find_devicename(), DEVFS_MAX_SUBDEVS, DEVFS_MODE_EX, DEVFS_MODE_R, DEVFS_MODE_W, EPERM, devfs_node_t::name, and _iop_file::privdata.
| int devfs_close | ( | iop_file_t * | file | ) |
ioman close handler
| file | Pointer to an ioman file structure |
Definition at line 469 of file devfs.c.
References EPERM, INVALID_HDEV, devfs_node_t::name, and _iop_file::privdata.
| int devfs_ioctl | ( | iop_file_t * | file, |
| int | cmd, | ||
| void * | args ) |
ioman ioctl handler
| file | Pointer to an ioman file structure |
| cmd | ioctl command number |
| args | Pointer to a buffer containing any arguments |
Definition at line 532 of file devfs.c.
References devfs_info_t::data, DEVFS_IOCTL_GETDESC, DEVFS_IOCTL_TYPE_1, EPERM, INVALID_HDEV, devfs_node_t::ioctl, devfs_info_t::loc, devfs_info_t::mode, _iop_file::privdata, and devfs_info_t::subdev.
| int devfs_ioctl2 | ( | iop_file_t * | file, |
| int | cmd, | ||
| void * | args, | ||
| unsigned int | arglen, | ||
| void * | buf, | ||
| unsigned int | buflen ) |
ioman ioctl2 handler
| file | Pointer to an ioman file structure |
| cmd | ioctl command number |
| args | Pointer a buffer containing command arguments |
| arglen | Length of args buffer |
| buf | Pointer to a return buffer |
| buflen | Length of buf |
Definition at line 580 of file devfs.c.
References devfs_info_t::data, devfs_node_t::desc, DEVFS_IOCTL_GETDESC, DEVFS_IOCTL_TYPE_2, DEVFS_MAX_DESC_LENGTH, EPERM, INVALID_HDEV, devfs_node_t::ioctl, devfs_info_t::loc, devfs_info_t::mode, _iop_file::privdata, and devfs_info_t::subdev.
| int devfs_read | ( | iop_file_t * | file, |
| void * | buf, | ||
| int | len ) |
ioman read handler
| file | Pointer to an ioman file structure |
| buf | Buffer to read data to |
| len | Length of data to read |
Definition at line 632 of file devfs.c.
References devfs_info_t::data, DEVFS_MODE_R, EPERM, INVALID_HDEV, devfs_info_t::loc, devfs_info_t::mode, _iop_file::privdata, devfs_node_t::read, and devfs_info_t::subdev.
| int devfs_write | ( | iop_file_t * | file, |
| void * | buf, | ||
| int | len ) |
ioman write handler
| file | Pointer to an ioman file structure |
| buf | Pointer to the buffer to write |
| len | Length of data to write |
Definition at line 680 of file devfs.c.
References devfs_info_t::data, DEVFS_MODE_W, EPERM, INVALID_HDEV, devfs_info_t::loc, devfs_info_t::mode, _iop_file::privdata, devfs_info_t::subdev, and devfs_node_t::write.
| int devfs_lseek | ( | iop_file_t * | file, |
| long | loc, | ||
| int | whence ) |
ioman lseek handler
| file | Pointer to a ioman file structure |
| loc | Location to seek to |
| whence | Seek base. |
Definition at line 727 of file devfs.c.
References EPERM, INVALID_HDEV, devfs_loc_t::loc64, and _iop_file::privdata.
| int devfs_lseek64 | ( | iop_file_t * | file, |
| long long | loc, | ||
| int | whence ) |
ioman lseek64 handler
| file | Pointer to an ioman file structure |
| loc | 64bit seek location |
| whence | Seek base |
Definition at line 775 of file devfs.c.
References EPERM, INVALID_HDEV, devfs_loc_t::loc64, and _iop_file::privdata.
| int devfs_dopen | ( | iop_file_t * | file, |
| const char * | name ) |
ioman dopen handler
| file | Pointer to an ioman file structure |
| name | Name of directory to open |
Definition at line 823 of file devfs.c.
References _directory_file::devno, EPERM, _directory_file::hDev, INVALID_HDEV, and _iop_file::privdata.
| int devfs_dclose | ( | iop_file_t * | file | ) |
ioman dclose handler
| file | Pointer to an ioman file structure |
Definition at line 852 of file devfs.c.
References _directory_file::hDev, INVALID_HDEV, _directory_file::opened, and _iop_file::privdata.
| int devfs_dread | ( | iop_file_t * | file, |
| iox_dirent_t * | buf ) |
| int devfs_getstat | ( | iop_file_t * | file, |
| const char * | name, | ||
| iox_stat_t * | stat ) |
ioman getstat handler
| file | Pointer to an ioman file structure |
| name | Name of the file to stat |
| stat | Buffer to receive the stat |
Definition at line 900 of file devfs.c.
References devfs_find_devicename(), DEVFS_MAX_SUBDEVS, DEVFS_MODE_R, DEVFS_MODE_W, EPERM, FIO_S_IFREG, FIO_S_IRUSR, FIO_S_IWUSR, devfs_loc_t::loc32, and devfs_node_t::name.
| int init_devfs | ( | void | ) |
DevFS initialise function
Definition at line 1026 of file devfs.c.
References root_device.
Referenced by _start().
| int _start | ( | int | argc, |
| char * | argv[] ) |
Main start function of the module
| argc | Unused |
| argv | Unused |
Definition at line 1044 of file devfs.c.
References init_devfs().
| int devfs_check_devname | ( | const char * | name | ) |
Function to check a device name only contains alphabetic characters
| name | The name to check. |
Definition at line 1073 of file devfs.c.
References DEVFS_MAX_DEVNAME_LENGTH.
Referenced by DevFSAddDevice().
| devfs_device_t* root_device |
Pointer to the root device
Definition at line 82 of file devfs.c.
Referenced by devfs_fill_dirent(), devfs_find_deviceid(), devfs_find_devicename(), DevFSAddDevice(), DevFSDelDevice(), and init_devfs().
| directory_file_t open_dirfiles[MAX_OPEN_DIRFILES] |
|
static |
|
static |