Exemple #1
0
int load_ptbl(int mmc_cont)
{
	static unsigned char data[512];
	static struct efi_entry entry[4];
	int n,m,r;

	fastboot_flash_reset_ptn();
	r = mmc_read(mmc_cont, 1, data, 512);
	if (r != 1) {
		printf("error reading partition table\n");
		return -1;
	}
	if (memcmp(data, "EFI PART", 8)) {
		//printf("efi partition table not found\n");
		return -1;
	}

	for (n = 0; n < (128/4); n++) {
		r = mmc_read(mmc_cont, 2 + n, (void*) entry, 512);
		if (r != 1) {
			printf("partition read failed\n");
			return 1;
		}
		for (m = 0; m < 4; m ++)
			import_efi_partition(entry + m);
	}
	return 0;
}
Exemple #2
0
int load_ptbl(void)
{
	static unsigned char data[512];
	static struct efi_entry entry[4];
	int n,m,r;
	r = mmc_read(1, 1, data, 512);
	if (r != 1) {
		printf("error reading partition table\n");
		return -1;
	}
	if (memcmp(data, "EFI PART", 8)) {
		printf("efi partition table not found\n");
		printf("===============================\n");
		printf("            format             \n");
		printf("===============================\n");
		do_format();
		return -1;
	}
	for (n = 0; n < (128/4); n++) {
		r = mmc_read(1, 1 + n, (void*) entry, 512);
		if (r != 1) {
			printf("partition read failed\n");
			return 1;
		}
		for (m = 0; m < 4; m ++)
			import_efi_partition(entry + m);
	}
	return 0;
}
Exemple #3
0
static int load_ptbl(void)
{
	static unsigned char data[512];
	static struct efi_entry entry[4];
	int n,m,r;
	printf("ptbl slot: %s:(%d).\n",
			mmc_slot?"EMMC":"SD", mmc_slot);
	r = mmc_read(mmc_slot, 1, data, 512);
	if (r != 1) {
		printf("error reading partition table\n");
		return -1;
	}
	if (memcmp(data, "EFI PART", 8)) {
		printf("efi partition table not found\n");
		return -1;
	}
	for (n = 0; n < (128/4); n++) {
		r = mmc_read(mmc_slot, 1 + n, (void*) entry, 512);
		if (r != 1) {
			printf("partition read failed\n");
			return 1;
		}
		for (m = 0; m < 4; m ++)
			import_efi_partition(entry + m);
	}
	return 0;
}
Exemple #4
0
int load_ptbl(struct storage_specific_functions *storage, u8 silent)
{
	u32 sector_sz = storage->get_sector_size();
	u64 ptbl_sectors = 0;
	int i = 0, r = 0;

	struct ptable *gpt;
	int gpt_size = sizeof(struct ptable);

	gpt =  (struct ptable *) alloc_memory(gpt_size);
	if (!gpt) {
		r = 0;
		goto fail;
	}

	ptbl_sectors = (u64)(gpt_size / sector_sz);

	r = storage->read(0, ptbl_sectors, (void *)gpt);
	if (r != 0) {
		printf("error reading GPT\n");
		return r;
		goto fail;
	}

	if (memcmp(gpt->header.magic, "EFI PART", 8)) {
		if (!silent)
			printf("efi partition table not found\n");
		r = -1;
		goto fail;
	}

	for (i = 0; i < EFI_ENTRIES; i++)
		import_efi_partition(&gpt->entry[i], i, silent);

fail:
	free_memory((void *)gpt);
	return r;
}