SSBM Decomp
Loading...
Searching...
No Matches
card.h File Reference
#include <Runtime/platform.h>
#include <dolphin/card.h>

Go to the source code of this file.

Data Structures

struct  CardIconInfo
struct  CardState
 One CARD file containing up to nine logical files. More...
struct  CardWriteArgs
 CARD_CMD_WRITE_BLOCK: 0x20-byte block header followed by size bytes of data; the remaining bytes in the block are cleared. More...
struct  CardReadArgs
 CARD_CMD_READ_BLOCK, CARD_CMD_SCAN_BLOCK: phys 0 shares the last header sector. More...
struct  CardVerifyArgs
 CARD_CMD_VERIFY_BLOCK: compare the block header and data against block_id/seq/data. More...
struct  CardSectorArgs
 CARD_CMD_READ_SECTOR, CARD_CMD_WRITE_SECTOR: transfer through sector_buf. More...
struct  CardClearArgs
 CARD_CMD_CLEAR_BUF: memset(data, 0, size). More...
struct  CardCreateArgs
 CARD_CMD_CREATE_FILE. More...
struct  CardHeaderArgs
 CARD_CMD_WRITE_HEADER, CARD_CMD_VERIFY_HEADER: header sector index and the banner/icons buffers (the comment comes from CardState). More...
struct  CardReadHeaderArgs
 CARD_CMD_READ_HEADER: destination buffers, any of which may be NULL. More...
struct  CardGetStatusArgs
 CARD_CMD_GET_STATUS. More...
struct  CardCmd
 One entry of the command ring hsd_804D1148. More...
union  CardCmd::CardCmd_x8
struct  CardFileReqArgs
 CARD_REQ_READ_FILE, CARD_REQ_WRITE_FILE. More...
struct  CardCreateReqArgs
 CARD_REQ_CREATE_FILE. More...
struct  CardStatusReqArgs
 CARD_REQ_SET_STATUS. More...
struct  CardOpenReqArgs
 CARD_REQ_OPEN_FILE. More...
struct  CardHeaderReqArgs
 CARD_REQ_READ_HEADER: destination buffers, any of which may be NULL. More...
struct  CardRequest
 One entry of the request queue hsd_804D2348. More...
union  CardRequest::CardRequest_x8

Macros

#define HSD_CARD_MAX_FILES   9

Typedefs

typedef void(* CardCallback) (int file_idx, int result)
 Completion callback: (file index or 0, result).

Enumerations

enum  HSD_CardResult {
  HSD_CardResult_Ok ,
  HSD_CardResult_UnkN1 ,
  HSD_CardResult_UnkN2 ,
  HSD_CardResult_UnkN3 ,
  HSD_CardResult_UnkN4 ,
  HSD_CardResult_UnkN261 = -261
}
enum  CardBannerFormat {
  CardBanner_None ,
  CardBanner_Small ,
  CardBanner_Large
}
enum  CardCmdType {
  CARD_CMD_NONE ,
  CARD_CMD_WRITE_BLOCK ,
  CARD_CMD_READ_BLOCK ,
  CARD_CMD_UNK_0x03 ,
  CARD_CMD_CLEAR_BUF ,
  CARD_CMD_VERIFY_BLOCK ,
  CARD_CMD_CHECK_VERIFIED ,
  CARD_CMD_CREATE_FILE ,
  CARD_CMD_SET_STATUS ,
  CARD_CMD_WRITE_HEADER ,
  CARD_CMD_VERIFY_HEADER ,
  CARD_CMD_READ_HEADER ,
  CARD_CMD_GET_STATUS ,
  CARD_CMD_SCAN_BLOCK ,
  CARD_CMD_REPAIR ,
  CARD_CMD_READ_SECTOR ,
  CARD_CMD_WRITE_SECTOR ,
  CARD_CMD_SCAN_FILE
}
 Ring commands run by hsd_803AAA48; asynchronous CARD operations are completed by hsd_803A949C. More...
enum  CardRequestType {
  CARD_REQ_NONE ,
  CARD_REQ_READ_FILE ,
  CARD_REQ_WRITE_FILE ,
  CARD_REQ_CREATE_FILE ,
  CARD_REQ_SET_STATUS ,
  CARD_REQ_OPEN_FILE ,
  CARD_REQ_READ_HEADER
}
 Requests queued by hsd_3B27.c and started by fn_803AA790. More...
enum  CardActiveType {
  CARD_ACTIVE_NONE ,
  CARD_ACTIVE_READ_FILE ,
  CARD_ACTIVE_WRITE_FILE ,
  CARD_ACTIVE_WRITE_FILE_1_2 ,
  CARD_ACTIVE_WRITE_FILE_3 ,
  CARD_ACTIVE_OPEN_OR_READ_HEADER ,
  CARD_ACTIVE_CREATE_FILE ,
  CARD_ACTIVE_SET_STATUS
}
 What the queued commands complete; its callback runs when the ring drains. More...

Functions

 ASSERT_SIZE (CardIconInfo, 0x12)
 ASSERT_SIZE (CardState, 0x464)
 ASSERT_SIZE (CardCmd, 0x24)
 ASSERT_SIZE (CardRequest, 0x18)
void hsd_803AAA48 (void)
 Drives queued requests and commands until idle or waiting for CARD I/O.
int hsd_803AC340 (CardIconInfo *icon_info)
void hsd_803AC3E0 (CardState *statestate, int file_idx, int file_size, int file_flags, u8 *data)
void hsd_803B2374 (void)
void hsd_803B24E4 (CardState *statestate, int chan, int sector_size, void *work_buf)
int hsd_803B2550 (CardState *statestate, const char *filename, CardCallback callback)
int hsd_803B2674 (CardState *statestate)
int hsd_803B27F4 (CardState *statestate, void *comment, void *banner, void *icons, CardCallback callback)
 Queues a header read into the non-NULL destination buffers.
int hsd_803B286C (CardState *statestate, const char *filename, const char *comment, void *banner, void *icons, CardCallback callback)
 Queues file creation.
int hsd_803B2928 (CardState *statestate, const char *comment, void *banner, void *icons, CardCallback callback)
 Queues a header/status update.
int hsd_803B29D8 (CardState *statestate, int file_idx, u8 *buf, CardCallback callback)
 Queues a logical-file read into the borrowed destination buffer.
int hsd_803B2A4C (CardState *statestate, int file_idx, u8 *buf, CardCallback callback)
 Queues a logical-file write from the borrowed source buffer.
int hsd_SetCardIconInfo (CardState *statestate, CardIconInfo *icon_info)

Macro Definition Documentation

◆ HSD_CARD_MAX_FILES

#define HSD_CARD_MAX_FILES   9

Typedef Documentation

◆ CardCallback

typedef void(* CardCallback) (int file_idx, int result)

Completion callback: (file index or 0, result).

Enumeration Type Documentation

◆ HSD_CardResult

Enumerator
HSD_CardResult_Ok 
HSD_CardResult_UnkN1 
HSD_CardResult_UnkN2 
HSD_CardResult_UnkN3 
HSD_CardResult_UnkN4 
HSD_CardResult_UnkN261 

◆ CardBannerFormat

Enumerator
CardBanner_None 
CardBanner_Small 

Indexed color, including its palette.

CardBanner_Large 

RGB5A3 color.

◆ CardCmdType

Ring commands run by hsd_803AAA48; asynchronous CARD operations are completed by hsd_803A949C.

Names describe the observed operations; they are not recovered original identifiers.

Enumerator
CARD_CMD_NONE 
CARD_CMD_WRITE_BLOCK 
CARD_CMD_READ_BLOCK 
CARD_CMD_UNK_0x03 

No producer or handler identified.

CARD_CMD_CLEAR_BUF 
CARD_CMD_VERIFY_BLOCK 
CARD_CMD_CHECK_VERIFIED 

After queued verification, changes result 2 to 0 and otherwise sets result 1.

Subsequent write commands skip their work when result is 1.

CARD_CMD_CREATE_FILE 
CARD_CMD_SET_STATUS 
CARD_CMD_WRITE_HEADER 
CARD_CMD_VERIFY_HEADER 
CARD_CMD_READ_HEADER 
CARD_CMD_GET_STATUS 
CARD_CMD_SCAN_BLOCK 

Reads one block's header into block_ids/block_seqs and merges its file table into file_flags/file_sizes.

CARD_CMD_REPAIR 

fn_803AD16C: mark stale copies negative; for file_flags 0 files also clear surplus copies and rebuild a missing or stale mirror.

CARD_CMD_READ_SECTOR 
CARD_CMD_WRITE_SECTOR 
CARD_CMD_SCAN_FILE 

Queues header validation and CARD_CMD_SCAN_BLOCK for each block, followed by CARD_CMD_REPAIR.

◆ CardRequestType

Requests queued by hsd_3B27.c and started by fn_803AA790.

Enumerator
CARD_REQ_NONE 
CARD_REQ_READ_FILE 
CARD_REQ_WRITE_FILE 
CARD_REQ_CREATE_FILE 
CARD_REQ_SET_STATUS 

Rewrites the comment/banner/icons header if it changed, then CARDSetStatus.

CARD_REQ_OPEN_FILE 
CARD_REQ_READ_HEADER 

Reads the header sectors back into the caller's buffers.

◆ CardActiveType

What the queued commands complete; its callback runs when the ring drains.

Write suffixes refer to file_flags modes, not these tag values.

Enumerator
CARD_ACTIVE_NONE 
CARD_ACTIVE_READ_FILE 
CARD_ACTIVE_WRITE_FILE 

file_flags 0

CARD_ACTIVE_WRITE_FILE_1_2 

Writes files with file_flags 1 or 2.

On completion the older of two copies of each block is marked stale.

CARD_ACTIVE_WRITE_FILE_3 

file_flags 3

CARD_ACTIVE_OPEN_OR_READ_HEADER 

Set by fn_803ADE4C (open file) and fn_803B26CC (read header).

CARD_ACTIVE_CREATE_FILE 
CARD_ACTIVE_SET_STATUS 

Function Documentation

◆ ASSERT_SIZE() [1/4]

ASSERT_SIZE ( CardIconInfo ,
0x12  )

◆ ASSERT_SIZE() [2/4]

ASSERT_SIZE ( CardState ,
0x464  )

◆ ASSERT_SIZE() [3/4]

ASSERT_SIZE ( CardCmd ,
0x24  )

◆ ASSERT_SIZE() [4/4]

ASSERT_SIZE ( CardRequest ,
0x18  )

◆ hsd_803AAA48()

void hsd_803AAA48 ( void )

Drives queued requests and commands until idle or waiting for CARD I/O.

Async CARD calls start with interrupts disabled; the busy flag is set after the call returns, before interrupts are restored. CARD completion callbacks must therefore not run inline from those calls.

◆ hsd_803AC340()

int hsd_803AC340 ( CardIconInfo * icon_info)

◆ hsd_803AC3E0()

void hsd_803AC3E0 ( CardState * state,
int file_idx,
int file_size,
int file_flags,
u8 * data )

◆ hsd_803B2374()

void hsd_803B2374 ( void )

◆ hsd_803B24E4()

void hsd_803B24E4 ( CardState * state,
int chan,
int sector_size,
void * work_buf )

◆ hsd_803B2550()

int hsd_803B2550 ( CardState * state,
const char * filename,
CardCallback callback )

◆ hsd_803B2674()

int hsd_803B2674 ( CardState * state)

◆ hsd_803B27F4()

int hsd_803B27F4 ( CardState * state,
void * comment,
void * banner,
void * icons,
CardCallback callback )

Queues a header read into the non-NULL destination buffers.

Returns 0 when queued, not when complete; a negative return does not queue a request or invoke the callback. The same return contract applies to the create, status, read and write request functions below.

◆ hsd_803B286C()

int hsd_803B286C ( CardState * state,
const char * filename,
const char * comment,
void * banner,
void * icons,
CardCallback callback )

Queues file creation.

Copies 0x40 bytes from comment into state even if the queue is full; filename, banner and icons are borrowed.

◆ hsd_803B2928()

int hsd_803B2928 ( CardState * state,
const char * comment,
void * banner,
void * icons,
CardCallback callback )

Queues a header/status update.

Copies 0x40 bytes from comment into state even if the queue is full; banner and icons are borrowed.

◆ hsd_803B29D8()

int hsd_803B29D8 ( CardState * state,
int file_idx,
u8 * buf,
CardCallback callback )

Queues a logical-file read into the borrowed destination buffer.

◆ hsd_803B2A4C()

int hsd_803B2A4C ( CardState * state,
int file_idx,
u8 * buf,
CardCallback callback )

Queues a logical-file write from the borrowed source buffer.

◆ hsd_SetCardIconInfo()

int hsd_SetCardIconInfo ( CardState * state,
CardIconInfo * icon_info )