diff options
Diffstat (limited to 'drivers')
-rwxr-xr-x | drivers/crypto/fsl_caam.c | 54 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 132 |
2 files changed, 126 insertions, 60 deletions
diff --git a/drivers/crypto/fsl_caam.c b/drivers/crypto/fsl_caam.c index 4ba4718..3ae9bf7 100755 --- a/drivers/crypto/fsl_caam.c +++ b/drivers/crypto/fsl_caam.c @@ -86,6 +86,8 @@ static uint8_t skeymod[] = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 }; +/* arm v7 need 64 align */ +#define ALIGN_MASK 0xffffffc0 /*! * Secure memory run command. @@ -155,14 +157,14 @@ uint32_t caam_decap_blob(uint32_t plain_text, uint32_t blob_addr, uint32_t size) /* Add job to input ring */ g_input_ring[0] = (uint32_t)decap_dsc; - flush_dcache_range((uint32_t)blob_addr & 0xffffffe0, - ((uint32_t)blob_addr & 0xffffffe0) + 2*size); - flush_dcache_range((uint32_t)plain_text & 0xffffffe0, - ((uint32_t)plain_text & 0xffffffe0) + 2*size); - flush_dcache_range((uint32_t)decap_dsc & 0xffffffe0, - ((uint32_t)decap_dsc & 0xffffffe0) + 128); - flush_dcache_range((uint32_t)g_input_ring & 0xffffffe0, - ((uint32_t)g_input_ring & 0xffffffe0) + 128); + flush_dcache_range((uint32_t)blob_addr & ALIGN_MASK, + ((uint32_t)blob_addr & ALIGN_MASK) + 2*size); + flush_dcache_range((uint32_t)plain_text & ALIGN_MASK, + ((uint32_t)plain_text & ALIGN_MASK) + 2*size); + flush_dcache_range((uint32_t)decap_dsc & ALIGN_MASK, + ((uint32_t)decap_dsc & ALIGN_MASK) + 128); + flush_dcache_range((uint32_t)g_input_ring & ALIGN_MASK, + ((uint32_t)g_input_ring & ALIGN_MASK) + 128); /* Increment jobs added */ __raw_writel(1, CAAM_IRJAR0); @@ -170,8 +172,8 @@ uint32_t caam_decap_blob(uint32_t plain_text, uint32_t blob_addr, uint32_t size) while(__raw_readl(CAAM_ORSFR0) != 1); // TODO: check if Secure memory is cacheable. - invalidate_dcache_range((uint32_t)g_output_ring & 0xffffffe0, - ((uint32_t)g_output_ring & 0xffffffe0) + 128); + invalidate_dcache_range((uint32_t)g_output_ring & ALIGN_MASK, + ((uint32_t)g_output_ring & ALIGN_MASK) + 128); /* check that descriptor address is the one expected in the output ring */ if(g_output_ring[0] == (uint32_t)decap_dsc) { @@ -187,8 +189,8 @@ uint32_t caam_decap_blob(uint32_t plain_text, uint32_t blob_addr, uint32_t size) printf("Error: blob decap job output ring descriptor address does" \ " not match\n"); } - flush_dcache_range((uint32_t)plain_text & 0xffffffe0, - ((uint32_t)plain_text & 0xffffffe0) + 2*size); + flush_dcache_range((uint32_t)plain_text & ALIGN_MASK, + ((uint32_t)plain_text & ALIGN_MASK) + 2*size); /* Remove job from Job Ring Output Queue */ @@ -254,12 +256,12 @@ uint32_t caam_gen_blob(uint32_t plain_data_addr, uint32_t blob_addr, uint32_t si /* Add job to input ring */ g_input_ring[0] = (uint32_t)encap_dsc; - flush_dcache_range((uint32_t)plain_data_addr & 0xffffffe0, - ((uint32_t)plain_data_addr & 0xffffffe0) + size); - flush_dcache_range((uint32_t)encap_dsc & 0xffffffe0, - ((uint32_t)encap_dsc & 0xffffffe0) + 128); - flush_dcache_range((uint32_t)blob & 0xffffffe0, - ((uint32_t)g_input_ring & 0xffffffe0) + 2 * size); + flush_dcache_range((uint32_t)plain_data_addr & ALIGN_MASK, + ((uint32_t)plain_data_addr & ALIGN_MASK) + size); + flush_dcache_range((uint32_t)encap_dsc & ALIGN_MASK, + ((uint32_t)encap_dsc & ALIGN_MASK) + 128); + flush_dcache_range((uint32_t)blob & ALIGN_MASK, + ((uint32_t)g_input_ring & ALIGN_MASK) + 2 * size); /* Increment jobs added */ __raw_writel(1, CAAM_IRJAR0); @@ -267,10 +269,10 @@ uint32_t caam_gen_blob(uint32_t plain_data_addr, uint32_t blob_addr, uint32_t si while(__raw_readl(CAAM_ORSFR0) != 1); // flush cache - invalidate_dcache_range((uint32_t)g_output_ring & 0xffffffe0, - ((uint32_t)g_output_ring & 0xffffffe0) + 128); - invalidate_dcache_range((uint32_t)g_output_ring & 0xffffffe0, - ((uint32_t)g_output_ring & 0xffffffe0) + 128); + invalidate_dcache_range((uint32_t)g_output_ring & ALIGN_MASK, + ((uint32_t)g_output_ring & ALIGN_MASK) + 128); + invalidate_dcache_range((uint32_t)g_output_ring & ALIGN_MASK, + ((uint32_t)g_output_ring & ALIGN_MASK) + 128); /* check that descriptor address is the one expected in the output ring */ if(g_output_ring[0] == (uint32_t)encap_dsc) { @@ -362,8 +364,8 @@ void caam_open(void) /* Add job to input ring */ g_input_ring[0] = (uint32_t)rng_inst_dsc; - flush_dcache_range((uint32_t)g_input_ring & 0xffffffe0, - ((uint32_t)g_input_ring & 0xffffffe0) + 128); + flush_dcache_range((uint32_t)g_input_ring & ALIGN_MASK, + ((uint32_t)g_input_ring & ALIGN_MASK) + 128); /* Increment jobs added */ __raw_writel(1, CAAM_IRJAR0); @@ -371,8 +373,8 @@ void caam_open(void) while(__raw_readl(CAAM_ORSFR0) != 1); - invalidate_dcache_range((uint32_t)g_output_ring & 0xffffffe0, - ((uint32_t)g_output_ring & 0xffffffe0) + 128); + invalidate_dcache_range((uint32_t)g_output_ring & ALIGN_MASK, + ((uint32_t)g_output_ring & ALIGN_MASK) + 128); /* check that descriptor address is the one expected in the out ring */ if(g_output_ring[0] == (uint32_t)rng_inst_dsc) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index b22ec76..1fd551c 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -152,6 +152,12 @@ static struct usb_gadget_strings *fastboot_strings[] = { #ifdef CONFIG_FSL_FASTBOOT + +#ifdef CONFIG_EFI_PARTITION +#define ANDROID_GPT_OFFSET 0 +#define ANDROID_GPT_SIZE 0x10000 +#endif + #define ANDROID_MBR_OFFSET 0 #define ANDROID_MBR_SIZE 0x200 #define ANDROID_BOOTLOADER_OFFSET 0x400 @@ -170,6 +176,28 @@ static struct usb_gadget_strings *fastboot_strings[] = { /*pentry index internally*/ +#ifdef CONFIG_BRILLO_SUPPORT + +enum { +#ifdef CONFIG_EFI_PARTITION + PTN_GPT_INDEX = 0, +#endif + PTN_MBR_INDEX = 0, + PTN_BOOTLOADER_INDEX, + PTN_BOOT_A_INDEX, + PTN_BOOT_B_INDEX, + PTN_SYSTEM_A_INDEX, + PTN_SYSTEM_B_INDEX, + PTN_ODM_A_INDEX, + PTN_ODM_B_INDEX, + PTN_MISC_INDEX, + PTN_DATA_INDEX, + PTN_FBMISC_INDEX, + PTN_NUM +}; + +#else + enum { PTN_MBR_INDEX = 0, PTN_BOOTLOADER_INDEX, @@ -178,14 +206,11 @@ enum { PTN_SYSTEM_INDEX, PTN_RECOVERY_INDEX, PTN_DATA_INDEX, -#ifdef CONFIG_BRILLO_SUPPORT - PTN_KERNEL_B_INDEX, - PTN_SYSTEM_B_INDEX, - PTN_MISC_INDEX, -#endif PTN_NUM }; +#endif + static unsigned int download_bytes_unpadded; static struct cmd_fastboot_interface interface = { @@ -1137,20 +1162,32 @@ static int _fastboot_parts_add_ptable_entry(int ptable_index, struct fastboot_ptentry *ptable) { disk_partition_t info; - strcpy(ptable[ptable_index].name, name); - strcpy(ptable[ptable_index].fstype, fstype); if (get_partition_info(dev_desc, mmc_dos_partition_index, &info)) { - printf("Bad partition index:%d for partition:%s\n", - mmc_dos_partition_index, name); + printf("%s, Bad partition index:%d for partition:%s\n", + __func__, mmc_dos_partition_index, name); return -1; + } + + ptable[ptable_index].start = info.start; + ptable[ptable_index].length = info.size; + ptable[ptable_index].partition_id = mmc_partition_index; + ptable[ptable_index].partition_index = mmc_dos_partition_index; + +#ifdef CONFIG_EFI_PARTITION + strcpy(ptable[ptable_index].name, (const char *)info.name); + strcpy(ptable[ptable_index].fstype, (const char *)info.type); +#else + strcpy(ptable[ptable_index].name, name); + if (!strcmp(name, "userdata") || !strcmp(name, "system_a") || + !strcmp(name, "system_b")) { + strcpy(ptable[ptable_index].fstype, "ext4"); } else { - ptable[ptable_index].start = info.start; - ptable[ptable_index].length = info.size; - ptable[ptable_index].partition_id = mmc_partition_index; - ptable[ptable_index].partition_index = mmc_dos_partition_index; + strcpy(ptable[ptable_index].fstype, "emmc"); } +#endif + return 0; } @@ -1216,11 +1253,21 @@ static int _fastboot_parts_load_from_ptable(void) memset((char *)ptable, 0, sizeof(struct fastboot_ptentry) * (PTN_NUM)); + +#ifdef CONFIG_EFI_PARTITION + /* GPT */ + strcpy(ptable[PTN_GPT_INDEX].name, "gpt"); + ptable[PTN_GPT_INDEX].start = ANDROID_GPT_OFFSET / dev_desc->blksz; + ptable[PTN_GPT_INDEX].length = ANDROID_GPT_SIZE / dev_desc->blksz; + ptable[PTN_GPT_INDEX].partition_id = user_partition; +#else /* MBR */ strcpy(ptable[PTN_MBR_INDEX].name, "mbr"); ptable[PTN_MBR_INDEX].start = ANDROID_MBR_OFFSET / dev_desc->blksz; ptable[PTN_MBR_INDEX].length = ANDROID_MBR_SIZE / dev_desc->blksz; ptable[PTN_MBR_INDEX].partition_id = user_partition; +#endif + /* Bootloader */ strcpy(ptable[PTN_BOOTLOADER_INDEX].name, FASTBOOT_PARTITION_BOOTLOADER); ptable[PTN_BOOTLOADER_INDEX].start = @@ -1230,41 +1277,48 @@ static int _fastboot_parts_load_from_ptable(void) ptable[PTN_BOOTLOADER_INDEX].partition_id = boot_partition; #ifdef CONFIG_BRILLO_SUPPORT - _fastboot_parts_add_ptable_entry(PTN_KERNEL_INDEX, + +#ifdef CONFIG_EFI_PARTITION + + int tbl_idx; + int part_idx = 1; + int ret; + for (tbl_idx = 2; tbl_idx < PTN_NUM; tbl_idx++) { + ret = _fastboot_parts_add_ptable_entry(tbl_idx, + part_idx++, + user_partition, + NULL, + NULL, + dev_desc, ptable); + + if (ret) + break; + } + +#else + + _fastboot_parts_add_ptable_entry(PTN_BOOT_A_INDEX, CONFIG_ANDROID_BOOT_PARTITION_MMC, user_partition, FASTBOOT_PARTITION_BOOT_A, FASTBOOT_PARTITION_BOOT_FS, dev_desc, ptable); - _fastboot_parts_add_ptable_entry(PTN_RECOVERY_INDEX, - CONFIG_ANDROID_RECOVERY_PARTITION_MMC, + _fastboot_parts_add_ptable_entry(PTN_BOOT_B_INDEX, + CONFIG_ANDROID_BOOT_B_PARTITION_MMC, user_partition, - FASTBOOT_PARTITION_RECOVERY, - FASTBOOT_PARTITION_RECOVERY_FS, + FASTBOOT_PARTITION_BOOT_B, + FASTBOOT_PARTITION_BOOT_FS, dev_desc, ptable); - _fastboot_parts_add_ptable_entry(PTN_SYSTEM_INDEX, + + _fastboot_parts_add_ptable_entry(PTN_SYSTEM_A_INDEX, CONFIG_ANDROID_SYSTEM_PARTITION_MMC, user_partition, FASTBOOT_PARTITION_SYSTEM_A, FASTBOOT_PARTITION_SYSTEM_FS, dev_desc, ptable); - _fastboot_parts_add_ptable_entry(PTN_DATA_INDEX, - CONFIG_ANDROID_DATA_PARTITION_MMC, - user_partition, - FASTBOOT_PARTITION_DATA, - FASTBOOT_PARTITION_DATA_FS, - dev_desc, ptable); - - _fastboot_parts_add_ptable_entry(PTN_KERNEL_B_INDEX, - CONFIG_ANDROID_BOOT_B_PARTITION_MMC, - user_partition, - FASTBOOT_PARTITION_BOOT_B, - FASTBOOT_PARTITION_BOOT_FS, - dev_desc, ptable); - _fastboot_parts_add_ptable_entry(PTN_SYSTEM_B_INDEX, CONFIG_ANDROID_SYSTEM_B_PARTITION_MMC, user_partition, @@ -1278,7 +1332,17 @@ static int _fastboot_parts_load_from_ptable(void) FASTBOOT_PARTITION_MISC, FASTBOOT_PARTITION_MISC_FS, dev_desc, ptable); -#else + + _fastboot_parts_add_ptable_entry(PTN_DATA_INDEX, + CONFIG_ANDROID_DATA_PARTITION_MMC, + user_partition, + FASTBOOT_PARTITION_DATA, + FASTBOOT_PARTITION_DATA_FS, + dev_desc, ptable); + +#endif /* CONFIG_EFI_PARTITION */ + +#else /* CONFIG_BRILLO_SUPPORT */ _fastboot_parts_add_ptable_entry(PTN_KERNEL_INDEX, CONFIG_ANDROID_BOOT_PARTITION_MMC, user_partition, |