総数:12 今日:1 昨日:0
https://en.wikipedia.org/wiki/GUID_Partition_Table
https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/boot_control.h
https://android.googlesource.com/platform/hardware/qcom/bootctrl/+/nougat-mr1-dev/boot_control.cpp
https://android.googlesource.com/device/google/marlin/+/nougat-dr1-release/recovery/oem-recovery/gpt-utils.h
https://android.googlesource.com/device/google/marlin/+/nougat-mr1-dev/recovery/oem-recovery/gpt-utils.cpp
gpt-utils.h
/****************************************************************************** * GPT HEADER DEFINES ******************************************************************************/ #define GPT_SIGNATURE "EFI PART" #define HEADER_SIZE_OFFSET 12 #define HEADER_CRC_OFFSET 16 #define PRIMARY_HEADER_OFFSET 24 #define BACKUP_HEADER_OFFSET 32 #define FIRST_USABLE_LBA_OFFSET 40 #define LAST_USABLE_LBA_OFFSET 48 #define PENTRIES_OFFSET 72 #define PARTITION_COUNT_OFFSET 80 #define PENTRY_SIZE_OFFSET 84 #define PARTITION_CRC_OFFSET 88 #define TYPE_GUID_OFFSET 0 #define TYPE_GUID_SIZE 16 #define PTN_ENTRY_SIZE 128 #define UNIQUE_GUID_OFFSET 16 #define FIRST_LBA_OFFSET 32 #define LAST_LBA_OFFSET 40 #define ATTRIBUTE_FLAG_OFFSET 48 ★ #define PARTITION_NAME_OFFSET 56 #define MAX_GPT_NAME_SIZE 72 /****************************************************************************** * AB RELATED DEFINES ******************************************************************************/ //Bit 48 onwords in the attribute field are the ones where we are allowed to //store our AB attributes. #define AB_FLAG_OFFSET (ATTRIBUTE_FLAG_OFFSET + 6) ★ #define GPT_DISK_INIT_MAGIC 0xABCD #define AB_PARTITION_ATTR_SLOT_ACTIVE (0x1<<2) ★ #define AB_PARTITION_ATTR_BOOT_SUCCESSFUL (0x1<<6) #define AB_PARTITION_ATTR_UNBOOTABLE (0x1<<7) #define AB_SLOT_ACTIVE_VAL 0x3F ★ #define AB_SLOT_INACTIVE_VAL 0x0 #define AB_SLOT_ACTIVE 1 #define AB_SLOT_INACTIVE 0 #define AB_SLOT_A_SUFFIX "_a" #define AB_SLOT_B_SUFFIX "_b"
boot_control.cpp
#define SLOT_ACTIVE 1
#define SLOT_INACTIVE 2
#define UPDATE_SLOT(pentry, guid, slot_state) ({ \
memcpy(pentry, guid, TYPE_GUID_SIZE); \
if (slot_state == SLOT_ACTIVE)\
*(pentry + AB_FLAG_OFFSET) = AB_SLOT_ACTIVE_VAL; ★54バイト目に0x3Fを代入する
else if (slot_state == SLOT_INACTIVE) \
*(pentry + AB_FLAG_OFFSET) = (*(pentry + AB_FLAG_OFFSET)& \
~AB_PARTITION_ATTR_SLOT_ACTIVE); \ ★54バイト目に0xC0との論理積を代入する
})