libctr9
Nintendo 3DS ARM9 library
ctr_io_interface.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (C) 2016 Gabriel Marcano
3  *
4  * Refer to the COPYING.txt file at the top of the project directory. If that is
5  * missing, this file is licensed under the GPL version 2.0 or later.
6  *
7  ******************************************************************************/
8 
11 #ifndef CTR_IO_INTERFACE_H_
12 #define CTR_IO_INTERFACE_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
31 typedef int (*ctr_io_interface_read)(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count);
32 
43 typedef int (*ctr_io_interface_write)(void *io, const void *buffer, size_t buffer_size, uint64_t position);
44 
58 typedef int (*ctr_io_interface_read_sector)(void *io, void *buffer, size_t buffer_size, size_t sector, size_t count);
59 
72 typedef int (*ctr_io_interface_write_sector)(void *io, const void *buffer, size_t buffer_size, size_t sector);
73 
78 typedef uint64_t (*ctr_io_interface_disk_size)(void *io);
79 
85 typedef size_t (*ctr_io_interface_sector_size)(void *io);
86 
89 typedef struct
90 {
93  ctr_io_interface_read_sector read_sector;
94  ctr_io_interface_write_sector write_sector;
96  ctr_io_interface_sector_size sector_size;
98 
112 int ctr_io_read(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count);
113 
127 int ctr_io_write(void *io, const void *buffer, size_t buffer_size, uint64_t position);
128 
145 int ctr_io_read_sector(void *io, void *buffer, size_t buffer_size, size_t sector, size_t count);
146 
162 int ctr_io_write_sector(void *io, const void *buffer, size_t buffer_size, size_t sector);
163 
171 uint64_t ctr_io_disk_size(void *io);
172 
180 size_t ctr_io_sector_size(void *io);
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif//CTR_IO_INTERFACE_H_
187 
size_t ctr_io_sector_size(void *io)
Returns the size of the sectors used by the io interface.
int(* ctr_io_interface_write_sector)(void *io, const void *buffer, size_t buffer_size, size_t sector)
Pointer to an io interface function used to write sectors.
Definition: ctr_io_interface.h:72
int ctr_io_read_sector(void *io, void *buffer, size_t buffer_size, size_t sector, size_t count)
Reads sectors from the given io interface.
int(* ctr_io_interface_read_sector)(void *io, void *buffer, size_t buffer_size, size_t sector, size_t count)
Pointer to an io interface function used to read sectors.
Definition: ctr_io_interface.h:58
int(* ctr_io_interface_read)(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count)
Pointer to an io interface function used to read.
Definition: ctr_io_interface.h:31
int(* ctr_io_interface_write)(void *io, const void *buffer, size_t buffer_size, uint64_t position)
Pointer to an io interface function used to write.
Definition: ctr_io_interface.h:43
int ctr_io_write(void *io, const void *buffer, size_t buffer_size, uint64_t position)
Writes bytes to the given io interface.
uint64_t ctr_io_disk_size(void *io)
Returns the size of the underlying disk for the given io interface.
Virtual table for io interface dispatching.
Definition: ctr_io_interface.h:89
uint64_t(* ctr_io_interface_disk_size)(void *io)
Pointer to an io interface function used to get the size of the disk.
Definition: ctr_io_interface.h:78
size_t(* ctr_io_interface_sector_size)(void *io)
Pointer to an io interface function used to get the sector size in bytes.
Definition: ctr_io_interface.h:85
int ctr_io_write_sector(void *io, const void *buffer, size_t buffer_size, size_t sector)
Writes sectors from the given io interface.
int ctr_io_read(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count)
Reads bytes from the given io interface.