libctr9
Nintendo 3DS ARM9 library
ctr_cart_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_CART_H_
12 #define CTR_CART_H_
13 
14 #include <ctr9/ctr_headers.h>
16 
17 #include <stdint.h>
18 #include <stddef.h>
19 #include <stdbool.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
27 typedef struct
28 {
29  ctr_io_interface base;
30 
31  uint32_t cart_id;
32  //From looking at the cart code, the header may only be 0x200 in size...
33  ctr_ncch_header ncch_header;
34  uint8_t ncch_raw[0x200];
35  ctr_ncsd_cart_header ncsd_header;
36  uint32_t sec_keys[4];
37  uint32_t media_unit_size;
39 
48 
53 bool ctr_cart_inserted(void);
54 
71 int ctr_cart_interface_read_sector(void *io, void* buffer, size_t buffer_size, size_t sector, size_t count);
72 
86 int ctr_cart_interface_read(void *io, void* buffer, size_t buffer_size, uint64_t position, size_t count);
87 
101 int ctr_cart_interface_noop_write(void *io, const void* buffer, size_t buffer_size, uint64_t position);
102 
118 int ctr_cart_interface_noop_write_sector(void *io, const void* buffer, size_t buffer_size, size_t sector);
119 
124 uint64_t ctr_cart_interface_disk_size(void *io);
125 
132 size_t ctr_cart_interface_sector_size(void *io);
133 
148 int ctr_cart_raw_interface_read(void *io, void* buffer, size_t buffer_size, uint64_t position, size_t count);
149 
167 int ctr_cart_raw_interface_read_sector(void *io, void* buffer, size_t buffer_size, size_t sector, size_t count);
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 
173 #endif//CTR_CART_H_
174 
io interface object for accessing 3DSS game carts.
Definition: ctr_cart_interface.h:27
uint64_t ctr_cart_interface_disk_size(void *io)
Returns the size of the underlying disk for the given io interface.
int ctr_cart_interface_noop_write(void *io, const void *buffer, size_t buffer_size, uint64_t position)
Writes bytes to the given io interface. Not possible for carts.
bool ctr_cart_interface_initialize(ctr_cart_interface *cart)
Initialize the given 3DS cart io interface object.
Struct representing the NCSD header for carts.
Definition: ctr_headers.h:19
bool ctr_cart_inserted(void)
Returns whether a cart is inserted or not.
Struct representing the NCCH header.
Definition: ctr_headers.h:47
int ctr_cart_raw_interface_read(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count)
Reads bytes from the given io interface.
size_t ctr_cart_interface_sector_size(void *io)
Returns the size of the sectors used by the io interface. This is cart dependent, althoug to date mos...
Virtual table for io interface dispatching.
Definition: ctr_io_interface.h:89
int ctr_cart_interface_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_cart_interface_noop_write_sector(void *io, const void *buffer, size_t buffer_size, size_t sector)
Writes sectors from the given io interface. Not possible for carts.
int ctr_cart_raw_interface_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_cart_interface_read(void *io, void *buffer, size_t buffer_size, uint64_t position, size_t count)
Reads bytes from the given io interface.