NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
nand.h
1#ifndef RVL_SDK_NAND_H
2#define RVL_SDK_NAND_H
3#include <types.h>
4
5#include <revolution/FS.h>
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10#define NAND_BANNER_TITLE_MAX 32
11#define NAND_BANNER_ICON_MAX_FRAME 8
12
13// Forward declarations
15
16typedef enum {
17 NAND_RESULT_FATAL_ERROR = -128,
18 NAND_RESULT_UNKNOWN = -64,
19
20 NAND_RESULT_MAXDEPTH = -16,
21 NAND_RESULT_AUTHENTICATION,
22 NAND_RESULT_OPENFD,
23 NAND_RESULT_NOTEMPTY,
24 NAND_RESULT_NOEXISTS,
25 NAND_RESULT_MAXFILES,
26 NAND_RESULT_MAXFD,
27 NAND_RESULT_MAXBLOCKS,
28 NAND_RESULT_INVALID,
29
30 NAND_RESULT_EXISTS = -6,
31 NAND_RESULT_ECC_CRIT,
32 NAND_RESULT_CORRUPT,
33 NAND_RESULT_BUSY,
34 NAND_RESULT_ALLOC_FAILED,
35 NAND_RESULT_ACCESS,
36
37 NAND_RESULT_OK,
38} NANDResult;
39
40typedef enum {
41 NAND_SEEK_BEG,
42 NAND_SEEK_CUR,
43 NAND_SEEK_END,
44} NANDSeekMode;
45
46typedef enum {
47 NAND_ACCESS_NONE,
48 NAND_ACCESS_READ,
49 NAND_ACCESS_WRITE,
50 NAND_ACCESS_RW
51} NANDAccessType;
52
53typedef enum {
54 NAND_FILE_TYPE_NONE,
55 NAND_FILE_TYPE_FILE,
56 NAND_FILE_TYPE_DIR,
57} NANDFileType;
58
59typedef enum {
60 // Read/write by owner
61 NAND_PERM_RUSR = (NAND_ACCESS_READ << 4),
62 NAND_PERM_WUSR = (NAND_ACCESS_WRITE << 4),
63 // Read/write by group
64 NAND_PERM_RGRP = (NAND_ACCESS_READ << 2),
65 NAND_PERM_WGRP = (NAND_ACCESS_WRITE << 2),
66 // Read/write by other
67 NAND_PERM_ROTH = (NAND_ACCESS_READ << 0),
68 NAND_PERM_WOTH = (NAND_ACCESS_WRITE << 0),
69 // Read/write by all
70 NAND_PERM_RALL = NAND_PERM_RUSR | NAND_PERM_RGRP | NAND_PERM_ROTH,
71 NAND_PERM_WALL = NAND_PERM_WUSR | NAND_PERM_WGRP | NAND_PERM_WOTH,
72 NAND_PERM_RWALL = NAND_PERM_RALL | NAND_PERM_WALL
73} NANDPermission;
74
75typedef void (*NANDAsyncCallback)(s32 result, NANDCommandBlock* block);
76
77typedef struct NANDStatus {
78 u32 ownerId; // at 0x0
79 u16 groupId; // at 0x4
80 u8 attr; // at 0x6
81 u8 perm; // at 0x7
83
84typedef struct NANDFileInfo {
85 s32 fd; // at 0x0
86 s32 tempFd; // at 0x4
87 char openPath[FS_MAX_PATH]; // at 0x8
88 char tempPath[FS_MAX_PATH]; // at 0x48
89 u8 access; // at 0x88
90 u8 stage; // at 0x89
91 u8 mark; // at 0x8A
93
94typedef struct NANDCommandBlock {
95 void* userData; // at 0x0
96 NANDAsyncCallback callback; // at 0x4
97 NANDFileInfo* info; // at 0x8
98 void* bytes; // at 0xC
99 void* inodes; // at 0x10
100 NANDStatus* status; // at 0x14
101 u32 ownerId; // at 0x18
102 u16 groupId; // at 0x1C
103 u8 nextStage; // at 0x1E
104 u32 attr; // at 0x20
105 u32 ownerPerm; // at 0x24
106 u32 groupPerm; // at 0x28
107 u32 otherPerm; // at 0x2C
108 u32 dirFileCount; // at 0x30
109 char path[FS_MAX_PATH]; // at 0x34
110 u32* length; // at 0x74
111 u32* position; // at 0x78
112 s32 state; // at 0x7C
113 void* buffer; // at 0x80
114 u32 bufferSize; // at 0x84
115 u8* type; // at 0x88
116 u32 uniqueNo; // at 0x8C
117 u32 reqBlocks; // at 0x90
118 u32 reqInodes; // at 0x94
119 u32* answer; // at 0x98
120 u32 homeBlocks; // at 0x9C
121 u32 homeInodes; // at 0xA0
122 u32 userBlocks; // at 0xA4
123 u32 userInodes; // at 0xA8
124 u32 workBlocks; // at 0xAC
125 u32 workInodes; // at 0xB0
126 const char** dir; // at 0xB4
128
129typedef struct NANDBanner {
130 u32 magic; // at 0x0
131 u32 flags; // at 0x4
132 u16 iconSpeed; // at 0x8
133 u8 reserved[0x20 - 0xA]; // at 0xA
134 wchar_t title[NAND_BANNER_TITLE_MAX]; // at 0x20
135 wchar_t subtitle[NAND_BANNER_TITLE_MAX]; // at 0x60
136 u8 bannerTexture[0x6000]; // at 0xA0
137 u8 iconTexture[0x1200][NAND_BANNER_ICON_MAX_FRAME]; // at 0x60A0
138} NANDBanner;
139
140s32 NANDCreate(const char* path, u8 perm, u8 attr);
141s32 NANDPrivateCreate(const char* path, u8 perm, u8 attr);
142s32 NANDPrivateCreateAsync(const char* path, u8 perm, u8 attr,
143 NANDAsyncCallback callback, NANDCommandBlock* block);
144
145s32 NANDDelete(const char* path);
146s32 NANDPrivateDelete(const char* path);
147s32 NANDPrivateDeleteAsync(const char* path, NANDAsyncCallback callback,
148 NANDCommandBlock* block);
149
150s32 NANDRead(NANDFileInfo* info, void* buf, u32 len);
151s32 NANDReadAsync(NANDFileInfo* info, void* buf, u32 len,
152 NANDAsyncCallback callback, NANDCommandBlock* block);
153
154s32 NANDWrite(NANDFileInfo* info, const void* buf, u32 len);
155s32 NANDWriteAsync(NANDFileInfo* info, const void* buf, u32 len,
156 NANDAsyncCallback callback, NANDCommandBlock* block);
157
158s32 NANDSeek(NANDFileInfo* info, s32 offset, NANDSeekMode whence);
159s32 NANDSeekAsync(NANDFileInfo* info, s32 offset, NANDSeekMode whence,
160 NANDAsyncCallback callback, NANDCommandBlock* block);
161
162s32 NANDPrivateCreateDir(const char* path, u8 perm, u8 attr);
163s32 NANDPrivateCreateDirAsync(const char* path, u8 perm, u8 attr,
164 NANDAsyncCallback callback,
165 NANDCommandBlock* block);
166
167s32 NANDMove(const char* from, const char* to);
168
169s32 NANDGetLength(NANDFileInfo* info, u32* length);
170s32 NANDGetLengthAsync(NANDFileInfo* info, u32* lengthOut,
171 NANDAsyncCallback callback, NANDCommandBlock* block);
172
173s32 NANDGetStatus(const char* path, NANDStatus* status);
174s32 NANDPrivateGetStatusAsync(const char* path, NANDStatus* status,
175 NANDAsyncCallback callback,
176 NANDCommandBlock* block);
177
178void NANDSetUserData(NANDCommandBlock* block, void* data);
179void* NANDGetUserData(NANDCommandBlock* block);
180
181#ifdef __cplusplus
182}
183#endif
184#endif