| 3048 | } |
| 3049 | |
| 3050 | UINT8 FfsEngine::reconstructIntelImage(const QModelIndex& index, QByteArray& reconstructed) |
| 3051 | { |
| 3052 | if (!index.isValid()) |
| 3053 | return ERR_SUCCESS; |
| 3054 | |
| 3055 | UINT8 result; |
| 3056 | |
| 3057 | // No action |
| 3058 | if (model->action(index) == Actions::NoAction || model->action(index) == Actions::DoNotRebuild) { |
| 3059 | reconstructed = model->header(index).append(model->body(index)); |
| 3060 | return ERR_SUCCESS; |
| 3061 | } |
| 3062 | |
| 3063 | // Other supported actions |
| 3064 | else if (model->action(index) == Actions::Rebuild) { |
| 3065 | reconstructed.clear(); |
| 3066 | // First child will always be descriptor for this type of image |
| 3067 | QByteArray descriptor; |
| 3068 | result = reconstructRegion(index.child(0, 0), descriptor); |
| 3069 | if (result) |
| 3070 | return result; |
| 3071 | reconstructed.append(descriptor); |
| 3072 | |
| 3073 | // Check descriptor size |
| 3074 | if ((UINT32)descriptor.size() < FLASH_DESCRIPTOR_SIZE) { |
| 3075 | msg(tr("reconstructIntelImage: descriptor is smaller than minimum size of 1000h (4096) bytes")); |
| 3076 | return ERR_INVALID_FLASH_DESCRIPTOR; |
| 3077 | } |
| 3078 | |
| 3079 | const FLASH_DESCRIPTOR_MAP* descriptorMap = (const FLASH_DESCRIPTOR_MAP*)(descriptor.constData() + sizeof(FLASH_DESCRIPTOR_HEADER)); |
| 3080 | // Check sanity of base values |
| 3081 | if (descriptorMap->MasterBase > FLASH_DESCRIPTOR_MAX_BASE |
| 3082 | || descriptorMap->MasterBase == descriptorMap->RegionBase |
| 3083 | || descriptorMap->MasterBase == descriptorMap->ComponentBase) { |
| 3084 | msg(tr("reconstructIntelImage: invalid descriptor master base %1h").hexarg2(descriptorMap->MasterBase, 2)); |
| 3085 | return ERR_INVALID_FLASH_DESCRIPTOR; |
| 3086 | } |
| 3087 | if (descriptorMap->RegionBase > FLASH_DESCRIPTOR_MAX_BASE |
| 3088 | || descriptorMap->RegionBase == descriptorMap->ComponentBase) { |
| 3089 | msg(tr("reconstructIntelImage: invalid descriptor region base %1h").hexarg2(descriptorMap->RegionBase, 2)); |
| 3090 | return ERR_INVALID_FLASH_DESCRIPTOR; |
| 3091 | } |
| 3092 | if (descriptorMap->ComponentBase > FLASH_DESCRIPTOR_MAX_BASE) { |
| 3093 | msg(tr("reconstructIntelImage: invalid descriptor component base %1h").hexarg2(descriptorMap->ComponentBase, 2)); |
| 3094 | return ERR_INVALID_FLASH_DESCRIPTOR; |
| 3095 | } |
| 3096 | |
| 3097 | |
| 3098 | const FLASH_DESCRIPTOR_REGION_SECTION* regionSection = (const FLASH_DESCRIPTOR_REGION_SECTION*)calculateAddress8((const UINT8*)descriptor.constData(), descriptorMap->RegionBase); |
| 3099 | QByteArray gbe; |
| 3100 | UINT32 gbeBegin = calculateRegionOffset(regionSection->GbeBase); |
| 3101 | UINT32 gbeEnd = gbeBegin + calculateRegionSize(regionSection->GbeBase, regionSection->GbeLimit); |
| 3102 | |
| 3103 | QByteArray me; |
| 3104 | UINT32 meBegin = calculateRegionOffset(regionSection->MeBase); |
| 3105 | UINT32 meEnd = meBegin + calculateRegionSize(regionSection->MeBase, regionSection->MeLimit); |
| 3106 | |
| 3107 | QByteArray bios; |
nothing calls this directly
no test coverage detected