Flash Headers (#1367)

* Move flash stuff

* format

* Cleanup

* format

* bss names

* Small cleanup

* osFlashGetAddr

* uintptr_t
This commit is contained in:
Derek Hensley
2023-09-15 09:41:51 -03:00
committed by GitHub
parent 57501ed415
commit 626f09266d
7 changed files with 160 additions and 151 deletions
+29
View File
@@ -4,6 +4,35 @@
#include "ultratypes.h"
#include "os_pi.h"
#define FLASH_START_ADDR 0x08000000 // FRAM Base Address in Cart Memory
#define FLASH_SIZE 0x20000
#define FLASH_LATENCY 0x5
#define FLASH_PULSE 0x0C
#define FLASH_PAGE_SIZE 0xF
#define FLASH_REL_DURATION 0x2
#define DEVICE_TYPE_FLASH 8
/* OLD_FLASH is MX_PROTO_A, MX_A and MX_C */
#define OLD_FLASH 0
/* NEW_FLASH is MX_B_AND_D and MATSUSHITA flash */
#define NEW_FLASH 1
#define FLASH_STATUS_ERASE_BUSY 2
#define FLASH_STATUS_ERASE_OK 0
#define FLASH_STATUS_ERASE_ERROR -1
#define FLASH_STATUS_WRITE_BUSY 1
#define FLASH_STATUS_WRITE_OK 0
#define FLASH_STATUS_WRITE_ERROR -1
#define FLASH_VERSION_MX_PROTO_A 0x00C20000
#define FLASH_VERSION_MX_A 0x00C20001
#define FLASH_VERSION_MX_C 0x00C2001E
#define FLASH_VERSION_MX_B_AND_D 0x00C2001D
#define FLASH_VERSION_MEI 0x003200F1
OSPiHandle* osFlashReInit(u8 latency, u8 pulse, u8 pageSize, u8 relDuration, u32 start);
OSPiHandle* osFlashInit(void);
+27
View File
@@ -0,0 +1,27 @@
#ifndef PR_OS_INTERNAL_FLASH_H
#define PR_OS_INTERNAL_FLASH_H
#include "os_flash.h"
#define FLASH_BLOCK_SIZE 128
#define FLASH_CMD_REG 0x10000 // Located at 0x08010000 on the Cart
/* set whole chip erase mode */
#define FLASH_CMD_CHIP_ERASE 0x3C000000
/* set sector erase mode */
#define FLASH_CMD_SECTOR_ERASE 0x4B000000
/* do erasure */
#define FLASH_CMD_EXECUTE_ERASE 0x78000000
/* program selected page */
#define FLASH_CMD_PROGRAM_PAGE 0xA5000000
/* set page program mode */
#define FLASH_CMD_PAGE_PROGRAM 0xB4000000
/* set status mode */
#define FLASH_CMD_STATUS 0xD2000000
/* set silicon id mode */
#define FLASH_CMD_ID 0xE1000000
/* set read mode */
#define FLASH_CMD_READ_ARRAY 0xF0000000
#endif
+6
View File
@@ -93,6 +93,12 @@ typedef struct {
#define OS_MESG_PRI_NORMAL 0
#define OS_MESG_PRI_HIGH 1
/*
* PI/EPI
*/
#define PI_DOMAIN1 0
#define PI_DOMAIN2 1
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt);
+20
View File
@@ -0,0 +1,20 @@
#ifndef SYS_FLASHROM_H
#define SYS_FLASHROM_H
#include "ultra64.h"
typedef struct {
/* 0x00 */ s32 requestType;
/* 0x04 */ OSMesg response;
/* 0x08 */ void* addr;
/* 0x0C */ s32 pageNum;
/* 0x10 */ s32 pageCount;
/* 0x14 */ OSMesgQueue messageQueue;
} FlashromRequest; // size = 0x2C
#define FLASHROM_REQUEST_WRITE 1
#define FLASHROM_REQUEST_READ 2
#define FLASH_TYPE_MAGIC 0x11118001
#endif
-61
View File
@@ -63,15 +63,6 @@
#include "z64view.h"
#include "regs.h"
typedef struct {
/* 0x00 */ s32 requestType;
/* 0x04 */ OSMesg response;
/* 0x08 */ void* addr;
/* 0x0C */ s32 pageNum;
/* 0x10 */ s32 pageCount;
/* 0x14 */ OSMesgQueue messageQueue;
} FlashromRequest; // size = 0x2C
typedef struct {
/* 0x000 */ View view;
/* 0x168 */ u8* iconItemSegment;
@@ -393,56 +384,4 @@ typedef struct {
/* 0x10 */ Color_RGBA8_u32 envColor;
} Struct_80140E80; // size = 0x14
// TODO: Dedicated Header?
#define FRAM_BASE_ADDRESS 0x08000000 // FRAM Base Address in Cart Memory
#define FRAM_STATUS_REGISTER FRAM_BASE_ADDRESS // FRAM Base Address in Cart Memory
#define FRAM_COMMAND_REGISTER 0x10000 // Located at 0x08010000 on the Cart
#define FLASH_VERSION_MX_PROTO_A 0x00C20000
#define FLASH_VERSION_MX_A 0x00C20001
#define FLASH_VERSION_MX_C 0x00C2001E
#define FLASH_VERSION_MX_B_AND_D 0x00C2001D
#define FLASH_VERSION_MEI 0x003200F1
#define FLASH_TYPE_MAGIC 0x11118001
#define FLASH_PAGE_SIZE 128
#define FLASHROM_REQUEST_WRITE 1
#define FLASHROM_REQUEST_READ 2
typedef enum FramCommand {
/* Does nothing for FRAM_COMMAND_SET_MODE_READ_AND_STATUS, FRAM_MODE_NOP, FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS
Initializes fram to 0xFF in FRAM_MODE_ERASE
Writes Contents in FLASHRAM_MODE_WRITE
After execution, sets FRAM_MODE to FRAM_MODE_NOP */
FRAM_COMMAND_EXECUTE = 0xD2000000,
/* flashram->erase_offset = (command & 0xFFFF) * 128; */
FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET = 0x4B000000,
/* flashram->mode = FLASHRAM_MODE_ERASE;
flashram->status = 0x1111800800C20000LL; */
FRAM_COMMAND_SET_MODE_ERASE_AND_STATUS = 0x78000000,
/* flashram->erase_offset = (command & 0xFFFF) * 128;
flashram->status = 0x1111800400C20000LL; */
FRAM_COMMAND_SET_ERASE_SECTOR_OFFSET_AND_STATUS = 0xA5000000,
/* flashram->mode = FLASHRAM_MODE_WRITE; */
FRAM_COMMAND_SET_MODE_WRITE = 0xB4000000,
/* flashram->mode = FLASHRAM_MODE_STATUS;
flashram->status = 0x1111800100C20000LL; */
FRAM_COMMAND_SET_MODE_STATUS_AND_STATUS = 0xE1000000,
/* flashram->mode = FLASHRAM_MODE_READ;
flashram->status = 0x11118004F0000000LL; */
FRAM_COMMAND_SET_MODE_READ_AND_STATUS = 0xF0000000,
/* unk */
FRAM_COMMAND_UNK_ERASE_OPERATION = 0x3C000000
} FramCommand;
typedef enum FramMode {
/* 0 */ FRAM_MODE_NOP,
/* 1 */ FRAM_MODE_ERASE,
/* 2 */ FRAM_MODE_WRITE,
/* 3 */ FRAM_MODE_READ,
/* 4 */ FRAM_MODE_STATUS
} FramMode;
#endif