xref: /utopia/UTPA2-700.0.x/projects/tools/gr/main.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2006-2007 MStar Semiconductor, Inc.
4 // All rights reserved.
5 //
6 // Unless otherwise stipulated in writing, any and all information contained
7 // herein regardless in any format shall remain the sole proprietary of
8 // MStar Semiconductor Inc. and be kept in strict confidence
9 // (��MStar Confidential Information��) by the recipient.
10 // Any unauthorized act including without limitation unauthorized disclosure,
11 // copying, use, reproduction, sale, distribution, modification, disassembling,
12 // reverse engineering and compiling of the contents of MStar Confidential
13 // Information is unlawful and strictly prohibited. MStar hereby reserves the
14 // rights to any and all damages, losses, costs and expenses resulting therefrom.
15 //
16 ////////////////////////////////////////////////////////////////////////////////
17 
18 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 ///
20 /// file    main.c
21 /// @brief  main entry point of the application program
22 /// @author MStar Semiconductor Inc.
23 ///////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-------------------------------------------------------------------------------------------------
26 //  Include Files
27 //-------------------------------------------------------------------------------------------------
28 
29 #include<stdio.h>
30 #include<stdlib.h>
31 #include<string.h>
32 #include <fcntl.h>
33 #include "mdrv_types.h"
34 
SPILoad(void)35 int SPILoad(void)
36 {
37 	FILE *fp;
38 	int size;
39 	unsigned int start;
40 	unsigned char *pp=0;
41 
42 	char fn[256];
43 	printf("--- Start to load file from SPI or DRAM ---\n");
44 	printf("SPI base: 0xBFC00000, DRAM base: 0x80000000\n");
45 	printf("file name: ");
46 	scanf("%s",&fn);
47 	printf("start address: 0x ");
48 	scanf("%x",&start);
49 	printf("size (bytes): ");
50 	scanf("%d",&size);
51 
52 	//pp = malloc( DEFAULT_SIZE ) ;
53 	pp = malloc( size+4 ) ;
54 	if( 0==pp ){
55 		printf( "alloc fail\n" ) ;
56 		return 0 ;
57 	}
58 
59 	//MAdp_getSPI(pp);
60 	MAdp_SPI_Load(start,size,pp);
61 	printf( "\nfirst: 0x%02X-0x%02X-0x%02X-0x%02X\n", pp[0],pp[1],pp[2],pp[3] );
62 	fp = fopen( fn, "w+" ) ;
63 	fwrite( pp, 1, size, fp ) ;
64 	fclose(fp) ;
65 
66 	free(pp) ;
67 
68 }
69 
70 
71 extern void MAdp_SYS_Init(void);
main(int argc,char * argv[])72 int main(int argc, char* argv[])
73 {
74     //----------------------------------------------------------------------------------------------
75     //  System Initialization
76     //----------------------------------------------------------------------------------------------
77     MAdp_SYS_Init(); //call adaptation function
78 
79     SPILoad();   //gr
80     return 0;
81 }
82 
83 
84 
85