Skip to content

Commit

Permalink
Merge pull request #376 from uyjulian/fileio_module
Browse files Browse the repository at this point in the history
Add FILEIO module
  • Loading branch information
fjtrujy authored Dec 27, 2022
2 parents 6c043a4 + 3f384ac commit c45ad1d
Show file tree
Hide file tree
Showing 11 changed files with 948 additions and 125 deletions.
134 changes: 134 additions & 0 deletions common/include/fileio-common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2009, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
* @file
* Common definitions for fileio between the client and server sides of the FILEIO protocol.
*/

#ifndef __FILEIO_COMMON_H__
#define __FILEIO_COMMON_H__

#include <tamtypes.h>
#include <io_common.h>

// fileio common definitions

enum _fio_functions {
FIO_F_OPEN = 0,
FIO_F_CLOSE,
FIO_F_READ,
FIO_F_WRITE,
FIO_F_LSEEK,
FIO_F_IOCTL,
FIO_F_REMOVE,
FIO_F_MKDIR,
FIO_F_RMDIR,
FIO_F_DOPEN,
FIO_F_DCLOSE,
FIO_F_DREAD,
FIO_F_GETSTAT,
FIO_F_CHSTAT,
FIO_F_FORMAT,
FIO_F_ADDDRV,
FIO_F_DELDRV,
};

/** Shared between _fio_read_intr and fio_read. The updated modules shipped
with licensed games changed the size of the buffers from 16 to 64. */
struct _fio_read_data
{
u32 size1;
u32 size2;
void *dest1;
void *dest2;
u8 buf1[16];
u8 buf2[16];
};

#define FIO_PATH_MAX 256

struct _fio_open_arg
{
int mode;
char name[FIO_PATH_MAX];
} __attribute__((aligned(16)));

struct _fio_read_arg
{
int fd;
void *ptr;
int size;
struct _fio_read_data *read_data;
} __attribute__((aligned(16)));

struct _fio_write_arg
{
int fd;
const void *ptr;
u32 size;
u32 mis;
u8 aligned[16];
} __attribute__((aligned(16)));

struct _fio_lseek_arg
{
union
{
int fd;
int result;
} p;
int offset;
int whence;
} __attribute__((aligned(16)));

struct _fio_ioctl_arg
{
union
{
int fd;
int result;
} p;
int request;
u8 data[1024]; // Will this be ok ?
} __attribute__((aligned(16)));

struct _fio_dread_arg
{
union
{
int fd;
int result;
} p;
io_dirent_t *buf;
} __attribute__((aligned(16)));

struct _fio_getstat_arg
{
union
{
io_stat_t *buf;
int result;
} p;
char name[FIO_PATH_MAX];
} __attribute__((aligned(16)));

struct _fio_chstat_arg
{
union
{
int cbit;
int result;
} p;
io_stat_t stat;
char name[FIO_PATH_MAX];
};

#endif /* __FILEIO_COMMON_H__ */
35 changes: 35 additions & 0 deletions common/include/iopheap-common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
# _____ ___ ____ ___ ____
# ____| | ____| | | |____|
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright 2001-2009, ps2dev - http://www.ps2dev.org
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
* @file
* Common definitions for iopheap between the client and server sides of the FILEIO protocol.
*/

#ifndef __IOPHEAP_COMMON_H__
#define __IOPHEAP_COMMON_H__

#include <tamtypes.h>

// iopheap common definitions

#define LIH_PATH_MAX 252

struct _iop_load_heap_arg
{
union
{
void *addr;
int result;
} p;
char path[LIH_PATH_MAX];
};

#endif /* __IOPHEAP_COMMON_H__ */
2 changes: 0 additions & 2 deletions ee/kernel/include/fileio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#error "Use posix function calls instead."
#endif

#define FIO_PATH_MAX 256

#define FIO_WAIT 0
#define FIO_NOWAIT 1

Expand Down
110 changes: 1 addition & 109 deletions ee/kernel/src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,10 @@
#define NEWLIB_PORT_AWARE
#include <fileio.h>
#include <string.h>
#include <fileio-common.h>

#define D(fmt, args...) printf("(%s:%s:%i):" #fmt, __FILE__, __FUNCTION__, __LINE__, ##args)

enum _fio_functions {
FIO_F_OPEN = 0,
FIO_F_CLOSE,
FIO_F_READ,
FIO_F_WRITE,
FIO_F_LSEEK,
FIO_F_IOCTL,
FIO_F_REMOVE,
FIO_F_MKDIR,
FIO_F_RMDIR,
FIO_F_DOPEN,
FIO_F_DCLOSE,
FIO_F_DREAD,
FIO_F_GETSTAT,
FIO_F_CHSTAT,
FIO_F_FORMAT,
FIO_F_ADDDRV,
FIO_F_DELDRV
};

/** Shared between _fio_read_intr and fio_read. The updated modules shipped
with licensed games changed the size of the buffers from 16 to 64. */
struct _fio_read_data
{
u32 size1;
u32 size2;
void *dest1;
void *dest2;
u8 buf1[16];
u8 buf2[16];
};

extern int _iop_reboot_count;
extern SifRpcClientData_t _fio_cd;
extern int _fio_init;
Expand Down Expand Up @@ -177,7 +146,6 @@ void fioSetBlockMode(int blocking)
{
_fio_block_mode = blocking;
}

#endif

#ifdef F_fio_exit
Expand All @@ -197,12 +165,6 @@ void fioExit(void)
#endif

#ifdef F_fio_open
struct _fio_open_arg
{
int mode;
char name[FIO_PATH_MAX];
} ALIGNED(16);

int fioOpen(const char *name, int mode)
{
struct _fio_open_arg arg;
Expand Down Expand Up @@ -282,14 +244,6 @@ void _fio_read_intr(struct _fio_read_data *data)
#endif

#ifdef F_fio_read
struct _fio_read_arg
{
int fd;
void *ptr;
int size;
struct _fio_read_data *read_data;
} ALIGNED(16);

int fioRead(int fd, void *ptr, int size)
{
struct _fio_read_arg arg;
Expand Down Expand Up @@ -324,15 +278,6 @@ int fioRead(int fd, void *ptr, int size)
#endif

#ifdef F_fio_write
struct _fio_write_arg
{
int fd;
const void *ptr;
u32 size;
u32 mis;
u8 aligned[16];
} ALIGNED(16);

int fioWrite(int fd, const void *ptr, int size)
{
struct _fio_write_arg arg;
Expand Down Expand Up @@ -378,17 +323,6 @@ int fioWrite(int fd, const void *ptr, int size)
#endif

#ifdef F_fio_lseek
struct _fio_lseek_arg
{
union
{
int fd;
int result;
} p;
int offset;
int whence;
} ALIGNED(16);

int fioLseek(int fd, int offset, int whence)
{
struct _fio_lseek_arg arg;
Expand Down Expand Up @@ -419,17 +353,6 @@ int fioLseek(int fd, int offset, int whence)
#endif

#ifdef F_fio_ioctl
struct _fio_ioctl_arg
{
union
{
int fd;
int result;
} p;
int request;
u8 data[1024]; // Will this be ok ?
} ALIGNED(16);

int fioIoctl(int fd, int request, void *data)
{
struct _fio_ioctl_arg arg;
Expand Down Expand Up @@ -670,16 +593,6 @@ int fioDclose(int fd)
#endif

#ifdef F_fio_dread
struct _fio_dread_arg
{
union
{
int fd;
int result;
} p;
io_dirent_t *buf;
} ALIGNED(16);

int fioDread(int fd, io_dirent_t *buf)
{
struct _fio_dread_arg arg;
Expand Down Expand Up @@ -712,16 +625,6 @@ int fioDread(int fd, io_dirent_t *buf)
#endif

#ifdef F_fio_getstat
struct _fio_getstat_arg
{
union
{
io_stat_t *buf;
int result;
} p;
char name[FIO_PATH_MAX];
} ALIGNED(16);

int fioGetstat(const char *name, io_stat_t *buf)
{
struct _fio_getstat_arg arg;
Expand Down Expand Up @@ -755,17 +658,6 @@ int fioGetstat(const char *name, io_stat_t *buf)
#endif

#ifdef F_fio_chstat
struct _fio_chstat_arg
{
union
{
int cbit;
int result;
} p;
io_stat_t stat;
char name[FIO_PATH_MAX];
};

int fioChstat(const char *name, io_stat_t *buf, u32 cbit)
{
struct _fio_chstat_arg arg;
Expand Down
14 changes: 1 addition & 13 deletions ee/kernel/src/iopheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "sifrpc.h"
#include "sifcmd.h"
#include "string.h"
#include "iopheap-common.h"

#include "iopheap.h"

Expand Down Expand Up @@ -108,19 +109,6 @@ int SifFreeIopHeap(void *addr)
#endif

#ifdef F_SifLoadIopHeap

#define LIH_PATH_MAX 252

struct _iop_load_heap_arg
{
union
{
void *addr;
int result;
} p;
char path[LIH_PATH_MAX];
};

int SifLoadIopHeap(const char *path, void *addr)
{
struct _iop_load_heap_arg arg;
Expand Down
Loading

0 comments on commit c45ad1d

Please sign in to comment.