Add support for reading the seeprom.

This commit is contained in:
Maschell 2022-01-29 18:42:45 +01:00
parent fbfbd3ef7c
commit 9faa95af56
3 changed files with 34 additions and 1 deletions

View File

@ -11,7 +11,7 @@ TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/wut/share/wut_rules
export VER_MAJOR := 1
export VER_MINOR := 0
export VER_MINOR := 1
export VER_PATCH := 0
VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)

View File

@ -72,6 +72,8 @@ int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count);
int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size);
int IOSUHAX_read_seeprom(uint8_t * out_buffer, uint32_t offset, uint32_t size);
int IOSUHAX_ODM_GetDiscKey(uint8_t * discKey);
int IOSUHAX_SVC(uint32_t svc_id, uint32_t *args, uint32_t arg_cnt);

View File

@ -199,6 +199,37 @@ int IOSUHAX_read_otp(uint8_t * out_buffer, uint32_t size) {
return res;
}
extern int bspRead(const char*, uint32_t, const char*, uint32_t, uint16_t*);
int IOSUHAX_read_seeprom(uint8_t * out_buffer, uint32_t offset, uint32_t size) {
if(out_buffer == NULL || offset > 0x200 || offset & 0x01) {
return -1;
}
uint32_t sizeInShorts = size >> 1;
uint32_t offsetInShorts = offset >> 1;
int32_t maxReadCount = 0x100 - offsetInShorts;
if(maxReadCount <= 0){
return 0;
}
uint32_t count = sizeInShorts > maxReadCount ? maxReadCount : sizeInShorts;
uint16_t *ptr = (uint16_t *) out_buffer;
int res = 0;
for(int i = 0; i < count; i++) {
if(bspRead("EE", offsetInShorts + i, "access", 2, ptr) != 0) {
return -2;
}
res += 2;
ptr++;
}
return res;
}
int IOSUHAX_kern_read32(uint32_t address, uint32_t *out_buffer, uint32_t count) {
if (iosuhaxHandle < 0)
return iosuhaxHandle;