libdragon
Functions
mempak.c File Reference

Mempak Filesystem Routine. More...

#include <string.h>
#include "libdragon.h"
#include "regsinternal.h"

Defines

Inode values
#define BLOCK_EMPTY   0x03
 This block is empty.
#define BLOCK_LAST   0x01
 This is the last block in the note.
#define BLOCK_VALID_FIRST   0x05
 First valid block that can contain user data.
#define BLOCK_VALID_LAST   0x7F
 Last valid block that can contain user data.

Functions

int read_mempak_sector (int controller, int sector, uint8_t *sector_data)
 Read a sector from a mempak.
int write_mempak_sector (int controller, int sector, uint8_t *sector_data)
 Write a sector to a mempak.
static int __validate_header (uint8_t *sector)
 Check a mempak header for validity.
static uint8_t __get_toc_checksum (uint8_t *sector)
 Calculate the checksum over a TOC sector.
static int __validate_toc (uint8_t *sector)
 Check a mempak TOC sector for validity.
static char __n64_to_ascii (char c)
 Convert a N64 mempak character to ASCII.
static char __ascii_to_n64 (char c)
 Convert an ASCII character to a N64 mempak character.
static int __validate_region (uint8_t region)
 Check a region read from a mempak entry for validity.
static int __read_note (uint8_t *tnote, entry_structure_t *note)
 Parse a note structure from a TOC.
static int __write_note (entry_structure_t *note, uint8_t *out_note)
 Create a note structure for a mempak TOC.
static int __get_num_pages (uint8_t *sector, int inode)
 Return number of pages a note occupies.
static int __get_free_space (uint8_t *sector)
 Get number of free blocks on a mempak.
static int __get_note_block (uint8_t *sector, int inode, int block)
 Get the inode of the n'th block in a note.
static int __get_valid_toc (int controller)
 Retrieve the sector number of the first valid TOC found.
int validate_mempak (int controller)
 Return whether a mempak is valid.
int get_mempak_entry (int controller, int entry, entry_structure_t *entry_data)
 Read an entry on a mempak.
int get_mempak_free_space (int controller)
 Return the number of free blocks on a mempak.
int format_mempak (int controller)
 Format a mempak.
int read_mempak_entry_data (int controller, entry_structure_t *entry, uint8_t *data)
 Read the data associated with an entry on a mempak.
int write_mempak_entry_data (int controller, entry_structure_t *entry, uint8_t *data)
 Write associated data to a mempak entry.
int delete_mempak_entry (int controller, entry_structure_t *entry)
 Delete a mempak entry and associated data.

Detailed Description

Mempak Filesystem Routine.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines