This commit is contained in:
Christoph Baumann
2025-05-06 12:37:46 +02:00
parent ba6073610c
commit 241b0f2274
19 changed files with 1518 additions and 386 deletions

39
bdk/storage/mbr_gpt.c Normal file
View File

@@ -0,0 +1,39 @@
#include "mbr_gpt.h"
#include <utils/types.h>
#include <string.h>
bool mbr_has_gpt(const mbr_t *mbr){
for(u32 i = 0; i < 4; i++){
if(mbr->partitions[i].type == 0xee){
return true;
}
}
return false;
}
void wctombs(const u16 *src, char *dest, u32 len_max){
const u16 *cur = src;
do{
*dest++ = *cur & 0xff;
len_max--;
}while(*cur++ && len_max);
}
void ctowcs(const char *src, u16 *dest, u32 len_max){
const char *cur = src;
do{
*dest++ = *cur;
len_max--;
}while(*cur++ && len_max);
}
s32 gpt_get_part_by_name(gpt_t *gpt, const char* name, s32 prev){
u16 wc_name[36];
ctowcs(name, wc_name, 36);
for(s32 i = prev + 1; i < (s32)gpt->header.num_part_ents && i < 128; i++){
if(!memcmp(wc_name, gpt->entries[i].name, strlen(name) * 2)){
return i;
}
}
return -1;
}

View File

@@ -81,4 +81,10 @@ typedef struct _gpt_t
gpt_entry_t entries[128];
} gpt_t;
bool mbr_has_gpt(const mbr_t *mbr);
void wctombs(const u16 *src, char *dest, u32 len_max);
void ctowcs(const char *src, u16 *dest, u32 len_max);
s32 gpt_get_part_by_name(gpt_t *gpt, const char* name, s32 prev);
#endif

View File

@@ -129,7 +129,11 @@ typedef enum _nyx_ums_type
NYX_UMS_EMMC_GPP,
NYX_UMS_EMUMMC_BOOT0,
NYX_UMS_EMUMMC_BOOT1,
NYX_UMS_EMUMMC_GPP
NYX_UMS_EMUMMC_GPP,
NYX_UMS_BOOT_STRG_SD,
NYX_UMS_BOOT_STRG_BOOT1,
NYX_UMS_BOOT_STRG_BOOT1_1MB,
NYX_UMS_BOOT_STRG_GPP,
} nyx_ums_type;
typedef struct __attribute__((__packed__)) _boot_cfg_t