Flash memory: erasing, programming and reading sectors. More...
Go to the source code of this file.
Functions | |
| u16 | EraseFlashSector (u16 sector) |
| Erases one of sixteen sectors, restoring the cartridge wait setting afterward. | |
| u16 | ProgramFlashByte (u8 *source, u8 *destination) |
| Issues a byte-program command and waits for its destination to match. | |
| u16 | ProgramFlashSectorWithEraseRetry (u16 sector, u8 *source) |
| Erases and verifies a sector with retries, then programs its bytes. | |
| u16 | ProgramFlashSector (u16 sector, u8 *source) |
| Erases a standard sector and programs bytes until completion or an error. | |
| 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. | |
| 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. | |
| u16 | EraseFlashChip (void) |
| Issues the chip-erase command and waits for an erased byte. | |
| u16 | WaitForFlashWrite (u8 timingIndex, volatile u8 *address, u8 expected) |
| Polls for the expected byte until success or timeout, returning an operation error. | |
| u16 | EraseAtmelFlashChip (void) |
| Erases the Atmel chip and waits for completion with its configured timing. | |
| u16 | EraseAtmelFlashSector (u16 sector) |
| Erases one small Atmel sector by programming every byte to 0xff. | |
| u16 | EraseAtmelFlashBlock (u16 block) |
| Erases thirty-two small sectors, trying each sector at most twice. | |
| u16 | ProgramAtmelFlashSector (u32 sector, const u8 *source) |
| Programs a small Atmel sector with interrupts disabled, then polls its last byte. | |
| u16 | ProgramAtmelFlashBlock (u16 block, u8 *source) |
| Programs an Atmel block in small sectors, trying each sector at most twice. | |
| void | FlashTimerIntr (void) |
| Counts down the active flash timeout and marks its expiration. | |
| s32 | SetFlashTimerIntr (u8 timer_index, void(**callback)(void)) |
| Selects a hardware timer and returns its timeout interrupt callback. | |
| 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 | |
| u8(*) | gFlashReadRoutine (u8 *source) |
Flash memory: erasing, programming and reading sectors.
Definition in file flash.h.
Erases one of sixteen sectors, restoring the cartridge wait setting afterward.
Definition at line 39 of file sst.c.
Referenced by EraseFlashSector(), ProgramFlashSector(), and ProgramFlashSectorWithEraseRetry().
Issues a byte-program command and waits for its destination to match.
Definition at line 81 of file sst.c.
Referenced by ProgramFlashByte(), ProgramFlashSector(), and ProgramFlashSectorWithEraseRetry().
Erases and verifies a sector with retries, then programs its bytes.
Definition at line 95 of file sst.c.
Referenced by ProgramFlashSectorWithEraseRetry().
Erases a standard sector and programs bytes until completion or an error.
Definition at line 8 of file program_flash_sector.c.
Referenced by ProgramFlashSector().
| 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().
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().
| void CopyFlashReadRoutineToRam | ( | void * | destination | ) |
Copies the byte reader to RAM and installs its Thumb entry point.
Definition at line 161 of file flash.c.
Referenced by CopyFlashReadRoutineToRam(), EraseAtmelFlashBlock(), EraseAtmelFlashChip(), EraseFlashChip(), EraseFlashSector(), ProgramAtmelFlashBlock(), ProgramFlashSector(), ProgramFlashSectorWithEraseRetry(), and 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().
| 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().
| u16 EraseFlashChip | ( | void | ) |
Issues the chip-erase command and waits for an erased byte.
Definition at line 13 of file sst.c.
Referenced by EraseFlashChip().
Polls for the expected byte until success or timeout, returning an operation error.
Definition at line 181 of file flash.c.
Referenced by WaitForFlashWrite().
| u16 EraseAtmelFlashChip | ( | void | ) |
Erases the Atmel chip and waits for completion with its configured timing.
Definition at line 8 of file atmel.c.
Referenced by EraseAtmelFlashChip().
Erases one small Atmel sector by programming every byte to 0xff.
Definition at line 35 of file atmel.c.
Referenced by EraseAtmelFlashBlock(), and EraseAtmelFlashSector().
Erases thirty-two small sectors, trying each sector at most twice.
Definition at line 64 of file atmel.c.
Referenced by EraseAtmelFlashBlock().
Programs a small Atmel sector with interrupts disabled, then polls its last byte.
Definition at line 105 of file atmel.c.
Referenced by ProgramAtmelFlashBlock(), and ProgramAtmelFlashSector().
Programs an Atmel block in small sectors, trying each sector at most twice.
Definition at line 139 of file atmel.c.
Referenced by ProgramAtmelFlashBlock().
| 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().
Selects a hardware timer and returns its timeout interrupt callback.
Definition at line 106 of file flash.c.
Referenced by SaveState_InitializeWorkspace(), and SetFlashTimerIntr().
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().
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().
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().
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().
Referenced by CopyFlashReadRoutineToRam(), and WaitForFlashWrite().