PowerBlocks SDK
 
Loading...
Searching...
No Matches
ios.h File Reference

Input Output System. More...

#include <stdint.h>
#include "powerblocks/core/system/ipc.h"

Go to the source code of this file.

Classes

struct  ios_ioctlv_t
 Used with ios_ioctlv for sending multiple IO ctrl structures. More...
 

Macros

#define IOS_MODE_READ   1
 
#define IOS_MODE_WRITE   2
 
#define IOS_MAX_PATH   64
 

Functions

void ios_initialize ()
 TODO: Explore and properly document what needs alignment and what does not.
 
int ios_open (const char *path, int mode)
 Opens a file on IOS.
 
int ios_close (int file_handle)
 Closes a file on IOS.
 
int ios_read (int file_handle, void *buffer, int size)
 Read from a file.
 
int ios_write (int file_handle, void *buffer, int size)
 Write to a file.
 
int ios_seek (int file_handle, int where, int whence)
 Seek to a position in a file.
 
int ios_ioctl (int file_handle, int ioctl, void *buffer_in, int in_size, void *buffer_io, int io_size)
 Send control commands to a device.
 
int ios_ioctlv (int file_handle, int ioctl, int in_size, int io_size, ios_ioctlv_t *argv)
 Send multiple IO ctrl buffers.
 
int ios_open_async (const char *path, int mode, ipc_message *message, ipc_async_handler_t handler, void *params)
 Opens a file on IOS with callback with async.
 
int ios_close_async (int file_handle, ipc_message *message, ipc_async_handler_t handler, void *params)
 Closes a file on IOS with async.
 
int ios_read_async (int file_handle, void *buffer, int size, ipc_message *message, ipc_async_handler_t handler, void *params)
 Read from a file with async.
 
int ios_write_async (int file_handle, void *buffer, int size, ipc_message *message, ipc_async_handler_t handler, void *params)
 Write to a file with async.
 
int ios_seek_async (int file_handle, int where, int whence, ipc_message *message, ipc_async_handler_t handler, void *params)
 Seek to a position in a file with async.
 
int ios_ioctl_async (int file_handle, int ioctl, void *buffer_in, int in_size, void *buffer_io, int io_size, ipc_message *message, ipc_async_handler_t handler, void *params)
 Send control commands to a device with async.
 
int ios_ioctlv_async (int file_handle, int ioctl, int in_size, int io_size, ios_ioctlv_t *args, ipc_message *message, ios_ioctlv_t *args_buffer, ipc_async_handler_t handler, void *params)
 Send multiple IO ctrl buffers with async.
 

Detailed Description

Input Output System.

IOS uses the IPC between broadway and starlet to command starlet to interact with some IO.

This includes things like the SD card and wiimotes. All through starlet's unix like file system for device modules.

Author
Samuel Fitzsimons (rainbain)
Date
2025 @license MIT (see LICENSE file)

Function Documentation

◆ ios_close()

int ios_close ( int file_handle)
extern

Closes a file on IOS.

Closes a file descriptor made with ios_open.

Parameters
file_handleFile handle to close
Returns
Negative if error.

◆ ios_close_async()

int ios_close_async ( int file_handle,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Closes a file on IOS with async.

Closes a file descriptor made with ios_open. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
file_handleFile handle to close
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.

◆ ios_initialize()

void ios_initialize ( )
extern

TODO: Explore and properly document what needs alignment and what does not.

Initializes IOS.

Initializes IOS including the IPC.

◆ ios_ioctl()

int ios_ioctl ( int file_handle,
int ioctl,
void * buffer_in,
int in_size,
void * buffer_io,
int io_size )
extern

Send control commands to a device.

Send control commands to a device.

Parameters
ioctlI/O Command Enum
buffer_inInput data to command
in_sizeSize of data coming in
buffer_ioOutput data of command
io_sizeSize of output data
Returns
Negative if error.

◆ ios_ioctl_async()

int ios_ioctl_async ( int file_handle,
int ioctl,
void * buffer_in,
int in_size,
void * buffer_io,
int io_size,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Send control commands to a device with async.

Send control commands to a device. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
ioctlI/O Command Enum
buffer_inInput data to command
in_sizeSize of data coming in
buffer_ioOutput data of command
io_sizeSize of output data
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.

◆ ios_ioctlv()

int ios_ioctlv ( int file_handle,
int ioctl,
int in_size,
int io_size,
ios_ioctlv_t * argv )
extern

Send multiple IO ctrl buffers.

Send multiple IO ctrl buffers.

The vector array itself does not need alignment since this function makes its own copy of the vector table when converting the addresses to physical.

Parameters
ioctlI/O Command Enum
buffer_inInput data to command
in_sizeSize of data coming in
buffer_ioOutput data of command
io_sizeSize of output data
Returns
Negative if error.

◆ ios_ioctlv_async()

int ios_ioctlv_async ( int file_handle,
int ioctl,
int in_size,
int io_size,
ios_ioctlv_t * args,
ipc_message * message,
ios_ioctlv_t * args_buffer,
ipc_async_handler_t handler,
void * params )
extern

Send multiple IO ctrl buffers with async.

Send multiple IO ctrl buffers.

The vector array itself does not need alignment since this function makes its own copy of the vector table when converting the addresses to physical.

The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
ioctlI/O Command Enum
buffer_inInput data to command
in_sizeSize of data coming in
buffer_ioOutput data of command
io_sizeSize of output data
argvVector of arguments.
messageBuffer to store the ipc message in.
argv_bufferBuffer to store the hardware argv list in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.

◆ ios_open()

int ios_open ( const char * path,
int mode )
extern

Opens a file on IOS.

Opens a file from IOS's unix-like file system.

Parameters
pathFile path to the file to open
modeFile mode to open with. IOS_MODE_READ or IOS_MODE_WRITE.
Returns
Returns the file handle. Negative if error.

◆ ios_open_async()

int ios_open_async ( const char * path,
int mode,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Opens a file on IOS with callback with async.

Opens a file from IOS's unix-like file system. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
pathFile path to the file to open
modeFile mode to open with. IOS_MODE_READ or IOS_MODE_WRITE.
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Returns the file handle. Negative if error.

◆ ios_read()

int ios_read ( int file_handle,
void * buffer,
int size )
extern

Read from a file.

Read from a file made with ios_open.

Parameters
file_handleFile Handle
bufferBuffer to read into
sizeNumber of bytes to read
Returns
Negative if error.

◆ ios_read_async()

int ios_read_async ( int file_handle,
void * buffer,
int size,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Read from a file with async.

Read from a file made with ios_open. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
file_handleFile Handle
bufferBuffer to read into
sizeNumber of bytes to read
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.

◆ ios_seek()

int ios_seek ( int file_handle,
int where,
int whence )
extern

Seek to a position in a file.

Seek to a position in a file.

Parameters
file_handleFile Handle
whereHow much to offset from a position
whenceReference point enum for where in the file.
Returns
Negative if error.

◆ ios_seek_async()

int ios_seek_async ( int file_handle,
int where,
int whence,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Seek to a position in a file with async.

Seek to a position in a file. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
file_handleFile Handle
whereHow much to offset from a position
whenceReference point enum for where in the file.
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.

◆ ios_write()

int ios_write ( int file_handle,
void * buffer,
int size )
extern

Write to a file.

Write to a file made with ios_open.

Parameters
file_handleFile Handle
bufferBuffer with data to write
sizeNumber of bytes to write
Returns
Negative if error.

◆ ios_write_async()

int ios_write_async ( int file_handle,
void * buffer,
int size,
ipc_message * message,
ipc_async_handler_t handler,
void * params )
extern

Write to a file with async.

Write to a file made with ios_open. The callback is called upon compilation from the ISR. Do not take too long from the ISR!

Parameters
file_handleFile Handle
bufferBuffer with data to write
sizeNumber of bytes to write
messageBuffer to store the ipc message in.
handlerHandler called from interrupt service upon compilation.
paramsPointer passed to the handler.
Returns
Negative if error.