diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2023-09-15 05:41:51 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-15 09:41:51 -0300 |
| commit | 626f09266d264dc994e51d8ce9e57b8da80704d4 (patch) | |
| tree | ea5e8174c1a307aece7056944875d520f253c7ea /include | |
| parent | 57501ed415982ee8cf9788a8b22575c17d718c64 (diff) | |
Flash Headers (#1367)
* Move flash stuff
* format
* Cleanup
* format
* bss names
* Small cleanup
* osFlashGetAddr
* uintptr_t
Diffstat (limited to 'include')
| -rw-r--r-- | include/PR/os_flash.h | 29 | ||||
| -rw-r--r-- | include/PR/os_internal_flash.h | 27 | ||||
| -rw-r--r-- | include/PR/os_pi.h | 6 | ||||
| -rw-r--r-- | include/sys_flashrom.h | 20 | ||||
| -rw-r--r-- | include/z64.h | 61 |
5 files changed, 82 insertions, 61 deletions
diff --git a/include/PR/os_flash.h b/include/PR/os_flash.h index 36e728c5a..9388a0a98 100644 --- a/include/PR/os_flash.h +++ b/include/PR/os_flash.h @@ -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); diff --git a/include/PR/os_internal_flash.h b/include/PR/os_internal_flash.h new file mode 100644 index 000000000..ef227df99 --- /dev/null +++ b/include/PR/os_internal_flash.h @@ -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 diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h index 2e67ca840..134b43a93 100644 --- a/include/PR/os_pi.h +++ b/include/PR/os_pi.h @@ -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); diff --git a/include/sys_flashrom.h b/include/sys_flashrom.h new file mode 100644 index 000000000..5fc2821d6 --- /dev/null +++ b/include/sys_flashrom.h @@ -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 diff --git a/include/z64.h b/include/z64.h index 69e7e01f2..ca9748509 100644 --- a/include/z64.h +++ b/include/z64.h @@ -64,15 +64,6 @@ #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; /* 0x16C */ u8* iconItem24Segment; @@ -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 |
