static void mmc_load_image_fat(struct mmc *mmc) { s32 err; struct image_header *header; header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header)); err = fat_register_device(&mmc->block_dev, CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); if (err) { printf("spl: fat register err - %d\n", err); hang(); } err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, (u8 *)header, sizeof(struct image_header)); if (err <= 0) goto end; parse_image_header(header); err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, (u8 *)image_load_addr, 0); end: if (err <= 0) { printf("spl: error reading image %s, err - %d\n", CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err); hang(); } }
static void mmc_load_image_raw(struct mmc *mmc) { u32 image_size_sectors, err; const struct image_header *header; header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header)); /* read image header to find the image size & load address */ err = mmc->block_dev.block_read(0, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1, (void *)header); if (err <= 0) goto end; parse_image_header(header); /* convert size to sectors - round up */ image_size_sectors = (image_size + MMCSD_SECTOR_SIZE - 1) / MMCSD_SECTOR_SIZE; /* Read the header too to avoid extra memcpy */ err = mmc->block_dev.block_read(0, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, image_size_sectors, (void *)image_load_addr); end: if (err <= 0) { printf("spl: mmc blk read err - %d\n", err); hang(); } }
void show_photos(const struct user_attribute *attrs, int count,PKT_public_key *pk,PKT_secret_key *sk, PKT_user_id *uid) { #ifndef DISABLE_PHOTO_VIEWER int i; struct expando_args args; u32 len; u32 kid[2]={0,0}; memset(&args,0,sizeof(args)); args.pk=pk; args.sk=sk; args.validity_info=get_validity_info(pk,uid); args.validity_string=get_validity_string(pk,uid); if(pk) keyid_from_pk(pk,kid); else if(sk) keyid_from_sk(sk,kid); for(i=0;i<count;i++) if(attrs[i].type==ATTRIB_IMAGE && parse_image_header(&attrs[i],&args.imagetype,&len)) { char *command,*name; struct exec_info *spawn; int offset=attrs[i].len-len; #ifdef FIXED_PHOTO_VIEWER opt.photo_viewer=FIXED_PHOTO_VIEWER; #else if(!opt.photo_viewer) opt.photo_viewer=get_default_photo_command(); #endif /* make command grow */ command=pct_expando(opt.photo_viewer,&args); if(!command) goto fail; name=xmalloc(16+strlen(EXTSEP_S)+ strlen(image_type_to_string(args.imagetype,0))+1); /* Make the filename. Notice we are not using the image encoding type for more than cosmetics. Most external image viewers can handle a multitude of types, and even if one cannot understand a particular type, we have no way to know which. The spec permits this, by the way. -dms */ #ifdef USE_ONLY_8DOT3 sprintf(name,"%08lX" EXTSEP_S "%s",(ulong)kid[1], image_type_to_string(args.imagetype,0)); #else sprintf(name,"%08lX%08lX" EXTSEP_S "%s",(ulong)kid[0],(ulong)kid[1], image_type_to_string(args.imagetype,0)); #endif if(exec_write(&spawn,NULL,command,name,1,1)!=0) { xfree(name); goto fail; } #ifdef __riscos__ riscos_set_filetype_by_mimetype(spawn->tempfile_in, image_type_to_string(args.imagetype,2)); #endif xfree(name); fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild); if(exec_read(spawn)!=0) { exec_finish(spawn); goto fail; } if(exec_finish(spawn)!=0) goto fail; } return; fail: log_error(_("unable to display photo ID!\n")); #endif }