Difference between revisions of "IOS/Resource request"

From WiiBrew
< IOS
Jump to: navigation, search
(Complete the structs)
Line 1: Line 1:
struct ios_resource_request {
+
<source lang="c">
    enum IOS_resource_cmd cmd;
+
// For IPCCommandType, IOSOpenMode and SeekMode:
    /* ... to be continued */
+
// Copyright 2008 Dolphin Emulator Project
};
+
// Licensed under GPLv2+
  
 +
#include <stddef.h>
  
enum IOS_resource_cmd {
+
typedef int32_t s32;
    IOS_CMD_OPEN   = 1,
+
typedef uint32_t u32;
    IOS_CMD_CLOSE  = 2,
+
typedef uint8_t u8;
    IOS_CMD_READ   = 3,
+
 
    IOS_CMD_WRITE  = 4,
+
enum IPCCommandType : u32
    IOS_CMD_SEEK   = 5,
+
{
    IOS_CMD_IOCTL  = 6,
+
   IPC_CMD_OPEN = 1,
    IOS_CMD_IOCTLV = 7
+
  IPC_CMD_CLOSE = 2,
}
+
   IPC_CMD_READ = 3,
 +
  IPC_CMD_WRITE = 4,
 +
   IPC_CMD_SEEK = 5,
 +
  IPC_CMD_IOCTL = 6,
 +
  IPC_CMD_IOCTLV = 7,
 +
  IPC_REPLY = 8,
 +
};
 +
 
 +
enum IOSOpenMode : s32
 +
{
 +
  IOS_OPEN_READ = 1,
 +
  IOS_OPEN_WRITE = 2,
 +
  IOS_OPEN_RW = (IOS_OPEN_READ | IOS_OPEN_WRITE)
 +
};
 +
 
 +
struct IOSResourceOpenRequest
 +
{
 +
  const u8* path;
 +
  IOSOpenMode flags;
 +
};
 +
 
 +
struct IOSResourceReadWriteRequest
 +
{
 +
  u8* data;
 +
  u32 length;
 +
};
 +
 
 +
enum SeekMode : u32
 +
{
 +
  IOS_SEEK_SET = 0,
 +
  IOS_SEEK_CUR = 1,
 +
  IOS_SEEK_END = 2,
 +
};
 +
 
 +
struct IOSResourceSeekRequest
 +
{
 +
  u32 offset;
 +
  SeekMode mode;
 +
};
 +
 
 +
struct IOSResourceIOCtlRequest
 +
{
 +
  u32 request;
 +
  u8* in;
 +
  u32 in_size;
 +
  u8* out;
 +
  u32 out_size;
 +
};
 +
 
 +
struct IOVector
 +
{
 +
  u8* base;
 +
  u32 length;
 +
};
 +
 
 +
struct IOSResourceIOCtlVRequest
 +
{
 +
  u32 request;
 +
  u32 in_count;
 +
  u32 io_count;
 +
  IOVector* vectors;
 +
};
 +
 
 +
union IOSResourceArgs
 +
{
 +
  IOSResourceOpenRequest open;
 +
  IOSResourceReadWriteRequest read;
 +
  IOSResourceReadWriteRequest write;
 +
  IOSResourceSeekRequest seek;
 +
  IOSResourceIOCtlRequest ioctl;
 +
  IOSResourceIOCtlVRequest ioctlv;
 +
};
 +
 
 +
struct IOSRequest
 +
{
 +
  IPCCommandType cmd;
 +
  s32 ret;
 +
  u32 fd;
 +
  IOSResourceArgs args;
 +
};
 +
 
 +
</source>

Revision as of 00:56, 19 December 2016

// For IPCCommandType, IOSOpenMode and SeekMode:
// Copyright 2008 Dolphin Emulator Project
// Licensed under GPLv2+

#include <stddef.h>

typedef int32_t s32;
typedef uint32_t u32;
typedef uint8_t u8;

enum IPCCommandType : u32
{
  IPC_CMD_OPEN = 1,
  IPC_CMD_CLOSE = 2,
  IPC_CMD_READ = 3,
  IPC_CMD_WRITE = 4,
  IPC_CMD_SEEK = 5,
  IPC_CMD_IOCTL = 6,
  IPC_CMD_IOCTLV = 7,
  IPC_REPLY = 8,
};

enum IOSOpenMode : s32
{
  IOS_OPEN_READ = 1,
  IOS_OPEN_WRITE = 2,
  IOS_OPEN_RW = (IOS_OPEN_READ | IOS_OPEN_WRITE)
};

struct IOSResourceOpenRequest
{
  const u8* path;
  IOSOpenMode flags;
};

struct IOSResourceReadWriteRequest
{
  u8* data;
  u32 length;
};

enum SeekMode : u32
{
  IOS_SEEK_SET = 0,
  IOS_SEEK_CUR = 1,
  IOS_SEEK_END = 2,
};

struct IOSResourceSeekRequest
{
  u32 offset;
  SeekMode mode;
};

struct IOSResourceIOCtlRequest
{
  u32 request;
  u8* in;
  u32 in_size;
  u8* out;
  u32 out_size;
};

struct IOVector
{
  u8* base;
  u32 length;
};

struct IOSResourceIOCtlVRequest
{
  u32 request;
  u32 in_count;
  u32 io_count;
  IOVector* vectors;
};

union IOSResourceArgs
{
  IOSResourceOpenRequest open;
  IOSResourceReadWriteRequest read;
  IOSResourceReadWriteRequest write;
  IOSResourceSeekRequest seek;
  IOSResourceIOCtlRequest ioctl;
  IOSResourceIOCtlVRequest ioctlv;
};

struct IOSRequest
{
  IPCCommandType cmd;
  s32 ret;
  u32 fd;
  IOSResourceArgs args;
};