総数: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を代入する 0011 1111
		else if (slot_state == SLOT_INACTIVE) \
		*(pentry + AB_FLAG_OFFSET)  = (*(pentry + AB_FLAG_OFFSET)& \
			~AB_PARTITION_ATTR_SLOT_ACTIVE); \ ★54バイト目のbit2のみゼロを代入する XXXX X0XX
		})
//Get the value of one of the attribute fields for a partition.
static int get_partition_attribute(char *partname,
		enum part_attr_type part_attr)
{
	struct gpt_disk *disk = NULL;
	uint8_t *pentry = NULL;
	int retval = -1;
	uint8_t *attr = NULL;
	if (!partname)
		goto error;
	disk = gpt_disk_alloc();
	if (!disk) {
		ALOGE("%s: Failed to alloc disk struct", __func__);
		goto error;
	}
	if (gpt_disk_get_disk_info(partname, disk)) {
		ALOGE("%s: Failed to get disk info", __func__);
		goto error;
	}
	pentry = gpt_disk_get_pentry(disk, partname, PRIMARY_GPT);
	if (!pentry) {
		ALOGE("%s: pentry does not exist in disk struct",
				__func__);
		goto error;
	}
	attr = pentry + AB_FLAG_OFFSET;
	if (part_attr == ATTR_SLOT_ACTIVE)
		retval = !!(*attr & AB_PARTITION_ATTR_SLOT_ACTIVE);    ★54バイト目のbit2が1であれば XXXX X1XX SLOT_ACTIVE
	else if (part_attr == ATTR_BOOT_SUCCESSFUL)
		retval = !!(*attr & AB_PARTITION_ATTR_BOOT_SUCCESSFUL);★54バイト目のbit6が1であれば X1XX XXXX BOOT_SUCCESSFUL
	else if (part_attr == ATTR_UNBOOTABLE)
		retval = !!(*attr & AB_PARTITION_ATTR_UNBOOTABLE);     ★54バイト目のbit7が1であれば 1XXX XXXX UNBOOTABLE
	else
		retval = -1;
	gpt_disk_free(disk);
	return retval;
error:
	if (disk)
		gpt_disk_free(disk);
	return retval;
}

★54バイト目のbit2が1であれば XXXX X1XX SLOT_ACTIVE

partition name and filename

modemst1 modemst2 bspdata rf_nv securefs deviceinfo fsc fsg modem_a NON-HLOS.bin modem_b xbl_a xbl.elf xbl_b tz_a tz.mbn tz_b rpm_a rpm.mbn rpm_b hyp_a hyp.mbn hyp_b pmic_a pmic.elf pmic_b keymaster_a km4.mbn keymaster_b cmnlib_a cmnlib.mbn cmnlib64_a cmnlib64.mbn cmnlib_b cmnlib64_b mdtpsecapp_a mdtpsecapp.mbn mdtpsecapp_b dsp_a dspso.bin dsp_b abl_a abl.elf ? abl_service.elf abl_b bluetooth_a BTFM.bin bluetooth_b devinfo mdtp_a mdtp.img mdtp_b dip apdp msadp dpo limits toolsfv sec storsec ddr battprof vbmeta_a vbmeta.img vbmeta_b devcfg_a devcfg.mbn devcfg_b boot_a boot.img (xbl.elf ???) boot_b reserved logbk box hwcfg nvcust nvdef_a NV-default.mbn nvdef_b sutinfo systeminfo_a systeminfo.img systeminfo_b hidden_a hidden.img.ext4 hidden_b splash_a splash.img splash_b splash2 elabel reserved_bak persist misc logfs ssd keystore frp logdump sti system_a system.img system_b system_other.img vendor_a vendor.img vendor_b odm_a odm.img odm_b product_a product.img product_b kitting fota durable tombstones shbootlog resetlog chameleon dtbo_a dtbo.img dtbo_b userdata


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS