msvdx_bin.c revision 06c7c30796be2e6b18a6263956a0ca308616ecde
1/* 2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved. 3 * Copyright (c) Imagination Technologies Limited, UK 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sub license, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the 14 * next paragraph) shall be included in all copies or substantial portions 15 * of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR 21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 * 25 * Authors: 26 * Waldo Bastian <waldo.bastian@intel.com> 27 * 28 */ 29 30#include <stdio.h> 31#include <stdlib.h> 32#include <string.h> 33#include "thread1_bin.h" 34 35#define MTX_SIZE (40*1024) 36#define STACKGUARDWORD ( 0x10101010 ) 37#define UNINITILISE_MEM ( 0xcd ) 38#define LINKED_LIST_SIZE ( 32*5 ) 39 40struct msvdx_fw { 41 unsigned int ver; 42 unsigned int text_size; 43 unsigned int data_size; 44 unsigned int data_location; 45}; 46 47int main() 48{ 49 unsigned long i = 0; 50 unsigned long lseek; 51 FILE *ptr = NULL; 52 FILE *fp_ll_dma = NULL; 53 struct msvdx_fw fw; 54 FIRMWARE fw_DE3; 55 56 fw_DE3 = sFirmware1366_FS; /* VXD3xx_DEVA_DDK_3_0_5 */ 57 fw_DE3 = sFirmware1366_SS; /* VXD3xx_DEVA_DDK_3_0_5 */ 58 fw_DE3 = sFirmware1419_FS; /* VXD3xx_DEVA_DDK_3_1_2 */ 59 fw_DE3 = sFirmware_FS; /* VXD3xx_DEVA_DDK_3_2_4 */ 60 fw_DE3 = sFirmware_SS; /* VXD3xx_DEVA_DDK_3_2_4 */ 61 //fw_DE3 = sFirmware0000_SS; /* 1366based, for VP only, be able to disable WDT in Csim */ 62 63 fw.ver = 0x0496; 64 fw.text_size = fw_DE3.uiTextSize / 4; 65 fw.data_size = fw_DE3.uiDataSize / 4;; 66 fw.data_location = fw_DE3.DataOffset + 0x82880000; 67 68 ptr = fopen("msvdx_fw_mfld_DE2.0.bin", "w"); 69 if (ptr == NULL) { 70 fprintf(stderr, "Create msvdx_fw_mfld_DE2.0.bin failed\n"); 71 exit(-1); 72 } 73 fwrite(&fw, sizeof(fw), 1, ptr); 74 75 for (i = 0; i < fw.text_size; i++) { 76 fwrite(&fw_DE3.pui8Text[i*4], 4, 1, ptr); 77 } 78 for (i = 0; i < fw.data_size; i++) { 79 fwrite(&fw_DE3.pui8Data[i*4], 4, 1, ptr); 80 } 81 fclose(ptr); 82 83 /* Create stitch image of msvdx fw */ 84 ptr = fopen("unsigned_msvdx_fw.bin", "w"); 85 if (ptr == NULL) { 86 fprintf(stderr, "Create unsigned_msvdx_fw failed\n"); 87 exit(-1); 88 } 89 fp_ll_dma = fopen("linked_list_struct", "r"); 90 if (fp_ll_dma == NULL) { 91 fprintf(stderr, "Cannot open linked_list_sturct failed\n"); 92 exit(-1); 93 } 94 95 96 unsigned int buf[(MTX_SIZE + sizeof(fw))/4]; 97 fread(buf, 1, LINKED_LIST_SIZE, fp_ll_dma); 98 fwrite(buf, 1, LINKED_LIST_SIZE, ptr); 99 100 memset(buf, UNINITILISE_MEM, MTX_SIZE + sizeof(fw)); 101 buf[((MTX_SIZE + sizeof(fw))/4) - 1] = STACKGUARDWORD; 102 103 fwrite(buf, 1, MTX_SIZE + sizeof(fw), ptr); 104 105 fseek(ptr, LINKED_LIST_SIZE, SEEK_SET); 106 fwrite(&fw, sizeof(fw), 1, ptr); 107 108 for (i = 0; i < fw.text_size; i++) { 109 fwrite(&fw_DE3.pui8Text[i*4], 4, 1, ptr); 110 } 111 112 fseek(ptr, LINKED_LIST_SIZE + fw_DE3.DataOffset + sizeof(fw), SEEK_SET); 113 114 for (i = 0; i < fw.data_size; i++) { 115 fwrite(&fw_DE3.pui8Data[i*4], 4, 1, ptr); 116 } 117 fclose(ptr); 118 119 return 0; 120} 121 122