Alchemy
Loading...
Searching...
No Matches

flash.c File Reference

Go to the source code of this file.

Typedefs

typedef u8(*) FlashByteRead(u8 *address)
typedef void(*) FlashReadCore(const u8 *source, u8 *destination, u32 size)
typedef u8 *(*) FlashVerifyCore(u8 *source, u8 *flash, u16 size)

Functions

s32 ReadFlashId (void)
 Enters flash ID mode, waits for the chip and reads its device and manufacturer IDs.
s32 IdentifyFlash (void)
 Selects matching chip handlers, falling back to the final table entry when unknown.
void FlashTimerIntr (void)
 Counts down the active flash timeout and marks its expiration.
s32 SetFlashTimerIntr (u8 timerIndex, void(**callback)(void))
 Selects a hardware timer and returns its timeout interrupt callback.
void StartFlashTimer (u8 timingIndex)
 Starts the selected operation timeout, saving the interrupt-enable state.
void StopFlashTimer (void)
 Stops the flash timer and restores the saved interrupt-enable state.
u8 ReadFlashByte (u8 *source)
 Reads one byte; copied into RAM so the cartridge can be polled during a write.
void CopyFlashReadRoutineToRam (void *destination)
 Copies the byte reader to RAM and installs its Thumb entry point.
u16 WaitForFlashWrite (u8 timingIndex, volatile u8 *address, u8 expected)
 Polls for the expected byte until success or timeout, returning an operation error.
void ReadFlashCore (const u8 *source, u8 *destination, u32 size)
 Copies flash bytes into RAM; this routine executes from a RAM copy.
void ReadFlash (u16 sector, u32 offset, u8 *destination, s32 size)
 Copies the RAM reader and reads a range using the standard sector geometry.
u8 * VerifyFlashCore (u8 *left, u8 *right, u16 size)
 Returns the first differing byte in the right buffer, or NULL when all bytes match.
s32 Flash_VerifySector (u16 sector, s32 source)
 Copies the verifier to RAM and compares a standard flash sector with source data.

Variables

const struct FlashSetupInfo *const gFlash_Chips []
FlashWaitProc gFlash_Handler3
u32 gFlash_Handler0
u32 gFlash_Handler1
u32 gEraseFlashSector
u16 * gFlash_Handler4
volatile u16 gFlashTimerCount
u8 gFlashTimeoutFlag
u8 gFlashTimerNum
u16 * gFlashTimerReg
u16 gFlashSavedIme

Typedef Documentation

◆ FlashByteRead

typedef u8(*) FlashByteRead(u8 *address)

Definition at line 6 of file flash.c.

◆ FlashReadCore

typedef void(*) FlashReadCore(const u8 *source, u8 *destination, u32 size)

Definition at line 211 of file flash.c.

◆ FlashVerifyCore

typedef u8 *(*) FlashVerifyCore(u8 *source, u8 *flash, u16 size)

Definition at line 255 of file flash.c.

Function Documentation

◆ ReadFlashId()

s32 ReadFlashId ( void )

Enters flash ID mode, waits for the chip and reads its device and manufacturer IDs.

Definition at line 10 of file flash.c.

Referenced by IdentifyFlash(), and ReadFlashId().

◆ IdentifyFlash()

s32 IdentifyFlash ( void )

Selects matching chip handlers, falling back to the final table entry when unknown.

Definition at line 61 of file flash.c.

Referenced by IdentifyFlash(), and SaveState_InitializeWorkspace().

◆ FlashTimerIntr()

void FlashTimerIntr ( void )

Counts down the active flash timeout and marks its expiration.

Definition at line 93 of file flash.c.

Referenced by FlashTimerIntr(), and SetFlashTimerIntr().

◆ SetFlashTimerIntr()

s32 SetFlashTimerIntr ( u8 timerIndex,
void(* callback *)(void) )

Selects a hardware timer and returns its timeout interrupt callback.

Definition at line 106 of file flash.c.

Referenced by SaveState_InitializeWorkspace(), and SetFlashTimerIntr().

◆ StartFlashTimer()

void StartFlashTimer ( u8 timingIndex)

Starts the selected operation timeout, saving the interrupt-enable state.

Definition at line 119 of file flash.c.

Referenced by RunFlashEraseVerifier(), StartFlashTimer(), and WaitForFlashWrite().

◆ StopFlashTimer()

void StopFlashTimer ( void )

Stops the flash timer and restores the saved interrupt-enable state.

Definition at line 140 of file flash.c.

Referenced by StopFlashTimer(), and WaitForFlashWrite().

◆ ReadFlashByte()

u8 ReadFlashByte ( u8 * source)

Reads one byte; copied into RAM so the cartridge can be polled during a write.

Definition at line 158 of file flash.c.

Referenced by CopyFlashReadRoutineToRam(), and ReadFlashByte().

◆ CopyFlashReadRoutineToRam()

void CopyFlashReadRoutineToRam ( void * destination)

◆ WaitForFlashWrite()

u16 WaitForFlashWrite ( u8 timingIndex,
volatile u8 * address,
u8 expected )

Polls for the expected byte until success or timeout, returning an operation error.

Definition at line 181 of file flash.c.

Referenced by WaitForFlashWrite().

◆ ReadFlashCore()

void ReadFlashCore ( const u8 * source,
u8 * destination,
u32 size )

Copies flash bytes into RAM; this routine executes from a RAM copy.

Definition at line 201 of file flash.c.

Referenced by ReadFlash(), and ReadFlashCore().

◆ ReadFlash()

void ReadFlash ( u16 sector,
u32 offset,
u8 * destination,
s32 size )

Copies the RAM reader and reads a range using the standard sector geometry.

Definition at line 214 of file flash.c.

Referenced by ReadFlash(), SaveState_LoadSummaryRecords(), and SaveState_ReadSlotAndCheckChecksum().

◆ VerifyFlashCore()

u8 * VerifyFlashCore ( u8 * left,
u8 * right,
u16 size )

Returns the first differing byte in the right buffer, or NULL when all bytes match.

Definition at line 238 of file flash.c.

Referenced by Flash_VerifySector(), and VerifyFlashCore().

◆ Flash_VerifySector()

s32 Flash_VerifySector ( u16 sector,
s32 source )

Copies the verifier to RAM and compares a standard flash sector with source data.

Definition at line 259 of file flash.c.

Referenced by Flash_VerifySector(), and SaveState_WriteWorkspaceSlot().

Variable Documentation

◆ gFlash_Chips

const struct FlashSetupInfo* const gFlash_Chips[]
extern

Referenced by IdentifyFlash().

◆ gFlash_Handler3

FlashWaitProc gFlash_Handler3
extern

◆ gFlash_Handler0

u32 gFlash_Handler0
extern

◆ gFlash_Handler1

u32 gFlash_Handler1
extern

Referenced by Bios_SoundBiasOn(), and IdentifyFlash().

◆ gEraseFlashSector

u32 gEraseFlashSector
extern

◆ gFlash_Handler4

u16* gFlash_Handler4
extern

◆ gFlashTimerCount

volatile u16 gFlashTimerCount
extern

Referenced by FlashTimerIntr(), and StartFlashTimer().

◆ gFlashTimeoutFlag

u8 gFlashTimeoutFlag
extern

◆ gFlashTimerNum

u8 gFlashTimerNum
extern

◆ gFlashTimerReg

u16* gFlashTimerReg
extern

◆ gFlashSavedIme

u16 gFlashSavedIme
extern