📄 cmd_zsp.c
字号:
/* * (C) Copyright 2005 * Yebucai, Hisilicon company, yebucai@huawei.com * * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA *//* * ZSP Functions For Hisilicon SOC * */#include <common.h>#include <command.h>#include <linux-adapter.h>#ifdef CMD_HISILICON_ZSP#define RESET_ADDR 0#define ZSP_CONTROL_REG 0x101e001c#define ZSP_IMEM_ADDRESS 0x80000000#define ZSP_DATA_MEMBASEADDR 0x80040000 /*ZSP数据MEM地址*/#define ZSP_INS_MEMBASEADDR 0x80000000 /*ZSP指令MEM地址*/#define ZSP_BINFILE_LEN 0x40000#define NAMELENGTH 16 #define HALF_LENGTH 2 #define WORD_LENGTH 4 typedef unsigned short Elf32_Half; /*16bit*/typedef unsigned long Elf32_Word; /*32bit*/typedef unsigned long Elf32_Addr; /*32bit*/typedef unsigned long Elf32_Off; /*32bit*/typedef struct { Elf32_Half b_snum; Elf32_Half b_binsize; Elf32_Half b_shsize; Elf32_Half b_resv1; Elf32_Off b_shoff; Elf32_Word b_flag; } Bin_Flag;typedef struct { unsigned char sh_name[NAMELENGTH]; Elf32_Word sh_type; Elf32_Addr sh_addr; Elf32_Off sh_offset; Elf32_Word sh_size; Elf32_Word sh_chknum; Elf32_Word sh_resv1; Elf32_Word sh_resv2; Elf32_Word sh_resv3; } Bin_Shdr;Bin_Flag binflag;Bin_Shdr binshdr;static unsigned short jtagData[]={0xf000,0x0088,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xf000,0x00c4,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x00e0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xa1f0,0xa1f1,0xf71f,0x3fff,0xf717,0x0001,0xf722,0x0200,0xf80d,0x0010,0x38e2,0xf722,0x0400,0xf80d,0x0012,0x38e2,0xf804,0x5400,0xf805,0x101e,0xf806,0x00ff,0xad70,0xf008,0x0201,0xf718,0xaaaa,0xf710,0x5555,0xf71a,0x5555,0xf712,0xaaaa,0xfd42,0x0000,0x0000,0x0000,0xfd50,0x0000,0xf804,0x5200,0xf805,0x101e,0xf806,0x0080,0xad70,0xf008,0x01ea,0xad41,0xf806,0x07ff,0xf807,0x0fff,0xca74,0x07ff,0xca64,0x07fb,0xf804,0x5200,0xf805,0x101e,0xad60,0xad70,0xf008,0x01d9,0xad41,0xf806,0x07ff,0xf807,0x0fff,0xca74,0x07ff,0xca64,0x07fb,0xf000,0xffcf,0x7a70,0x6008,0x63e0,0xa081,0xa580,0x06ff,0xa001,0xa580,0x07ff,0x7c01,0x7a70,0x600d,0x63e0,0xa081,0xa580,0x06ff,0xa001,0xa580,0x07ff,0x7a72,0x6000,0x63e0,0xf008,0x01ae,0x7a74,0x600f,0x63e0,0xf008,0x01a9,0x7a76,0x600e,0x63e0,0xf008,0x01a4,0x7a78,0x6002,0x63e0,0xf008,0x019f,0x7a7a,0x6009,0x63e0,0xf008,0x019a,0x7a7c,0x6003,0x63e0,0xf008,0x0195,0x7a7e,0x6004,0x63e0,0xf008,0x0190,0x7c80,0x7a70,0x7e80,0x63e0,0xf008,0x018a,0x7c81,0x7a70,0x7e81,0x63e0,0xf008,0x0184,0x7c82,0x7a70,0x7e82,0x63e0,0xf008,0x017e,0x7c83,0x7a70,0x7e83,0x63e0,0xf008,0x0178,0x7c84,0x7a70,0x7e84,0x63e0,0xf008,0x0172,0x7c85,0x7a70,0x7e85,0x63e0,0xf008,0x016c,0x7c86,0x7a70,0x7e86,0x63e0,0xf008,0x0166,0x7c87,0x7a70,0x7e87,0x63e0,0xf008,0x0160,0x7b80,0x7c80,0x7a70,0x6005,0x63e0,0xf008,0x0159,0x7b82,0x7c80,0x7a70,0x6006,0x63e0,0xf008,0x0152,0x7b84,0x7c80,0x7a70,0x6019,0x63e0,0xf008,0x014b,0x7b86,0x7c80,0x7a70,0x601a,0x63e0,0xf008,0x0144,0x7b81,0x7c80,0x7a70,0xfa88,0x0000,0x63e0,0xf008,0x013c,0x7b83,0x7c80,0x7a70,0xfa88,0x0001,0x63e0,0xf008,0x0134,0x7b85,0x7c80,0x7a70,0xfa88,0x0002,0x63e0,0xf008,0x012c,0x7b87,0x7c80,0x7a70,0xfa88,0x0003,0x63e0,0xf008,0x0124,0x7c02,0x7a70,0x6007,0x63e0,0xf008,0x011e,0x7c03,0x7a70,0x6001,0x63e0,0xf008,0x0118,0x6017,0x6038,0x7a70,0xf800,0xd01e,0x63e0,0xf008,0x0110,0x60be,0xb115,0xa95c,0x7414,0x0645,0xf865,0x0004,0x060d,0xf865,0x0008,0x061e,0xf865,0x000a,0x0631,0xf000,0x003d,0xf008,0x00fe,0xf000,0xffee,0x7c17,0x4472,0xb151,0xf803,0x0fff,0xc653,0x060a,0xae5f,0x6255,0x120f,0x7a72,0xf008,0x00ef,0x02fc,0xf000,0xffde,0x2817,0x63f2,0xf000,0xffea,0x7c17,0x4472,0xb151,0xf803,0x0fff,0xc653,0x060a,0xae5f,0x6255,0xf008,0x00dd,0x7c17,0x1a0f,0x02fc,0xf000,0xffda,0xf008,0x00d6,0x605f,0x3817,0xf000,0xffd4,0xb151,0xf802,0x001f,0xc652,0xf865,0x000f,0x07cc,0x605f,0x62f2,0xf000,0xffc9,0xf000,0xffc7,0x7c17,0xf008,0x00c2,0x7c27,0xf008,0x00bf,0x7c37,0xf008,0x00bc,0x7c47,0xf008,0x00b9,0x7c57,0xf008,0x00b6,0x7c67,0xf008,0x00b3,0x7c77,0xf008,0x00b0,0x7c07,0x4400,0x7d18,0xf008,0x00ab,0x7c07,0x4400,0x7d20,0xf008,0x00a6,0x7c07,0x4400,0x7d50,0xf008,0x00a1,0x7c07,0x4400,0x7d38,0xf008,0x009c,0x7c07,0x4400,0x7d28,0xf008,0x0097,0x7c07,0x4400,0x7d30,0xf008,0x0092,0x7c07,0x4400,0x7d58,0xf008,0x008d,0x7c07,0x4400,0x7d40,0xf008,0x0088,0x7c07,0x4400,0xf008,0x0084,0x7c07,0x4410,0xf008,0x0080,0x7c07,0x4420,0xf008,0x007c,0x7c07,0x4430,0xf008,0x0078,0x7c07,0x4440,0xf008,0x0074,0x7c07,0x4450,0xf008,0x0070,0x7c07,0x4460,0xf008,0x006c,0x7c07,0x4470,0xf008,0x0068,0x7c07,0x4480,0x4491,0xf008,0x0063,0x7c07,0x44a0,0x44b1,0xf008,0x005e,0x7c07,0x44c0,0x44d1,0xf008,0x0059,0x7c07,0x44e0,0x44f1,0xf008,0x0054,0x7c07,0x6200,0x6211,0xf008,0x004f,0x7c07,0x6290,0x6221,0xf008,0x004a,0x7c07,0x6230,0x6241,0xf008,0x0045,0x7c07,0x6250,0x6261,0xf008,0x0040,0x7c07,0x6390,0x63a1,0xf008,0x003b,0x7c07,0xfa80,0x0000,0xfa80,0x0011,0xf008,0x0034,0x7c07,0xfa80,0x0020,0xfa80,0x0031,0xf008,0x002d,0xf008,0x002b,0x7c07,0x62f0,0x6271,0xf008,0x0026,0x7c07,0x62e0,0xf008,0x0022,0x7c07,0x7a01,0xf008,0x001e,0x7c07,0x7a20,0xf008,0x001a,0x7c07,0x7a10,0xa081,0xa580,0x06ff,0xa001,0xa580,0x07ff,0x7c07,0x7910,0xa081,0xa580,0x06ff,0xa001,0xa580,0x07ff,0xa2f9,0x63e1,0x7c07,0xf811,0xfffc,0x7901,0x603e,0x00e0,0xa081,0xa580,0x06ff,0xa001,0xa580,0x07ff,0x00c0,0x0000,0x1e85,0x1e87,0xb1a5,0xf80c,0x0009,0xc1ac,0xadb0,0xfd95,0x0088,0x61af,0xa1f0,0xadc1,0xd8ac,0xadaf,0xf80b,0x00ff,0x9a15,0x4404,0xa270,0x38b0,0xa1f0,0x62fd,0x1687,0x1685,0x00c0,0x0000,0x1e85,0x1e87,0xb1a5,0xf80c,0x0009,0xc1ac,0xadb0,0xfd95,0x0088,0x61af,0xa1f0,0xadc1,0xd8ac,0xadaf,0xf80b,0x00ff,0x9a15,0x4404,0xa270,0x28a0,0xa1f0,0x62fd,0x1687,0x1685,0x00c0,0x0000,0x1e85,0x1e87,0xb1a5,0xf80c,0x0009,0xc1ac,0xadb0,0xfd95,0x0088,0x61af,0xa1f0,0xadc1,0xd8ac,0xadaf,0xf80b,0x00ff,0x9a15,0x4404,0xa270,0x3830,0xa1f0,0x62fd,0x1687,0x1685,0x00c0,0x0000,0x1e85,0x1e87,0xb1a5,0xf80c,0x0009,0xc1ac,0xadb0,0xfd95,0x0088,0x61af,0xa1f0,0xadc1,0xd8ac,0xadaf,0xf80b,0x00ff,0x9a15,0x4404,0xa270,0x2820,0xa1f0,0x62fd,0x1687,0x1685,0x00c0,};int zspJtag(void);unsigned int get_short( unsigned long base ){ unsigned int result; unsigned char *ptr; ptr = ( unsigned char *)base; result = ( unsigned long )( ptr[0]+ 256 * ptr[ 1 ]); return( result );}unsigned long get_long( unsigned long base ){ unsigned long result; unsigned char *ptr; ptr = ( unsigned char *)base; result = ( unsigned long )( ptr[0]+ 256 * ptr[ 1 ] + 256 * 256 * ptr[ 2 ] + 256 * 256 * 256 * ptr[ 3 ] ); return( result );}void get_string( char *buf, unsigned long base, unsigned char length ){ unsigned char count, len; unsigned char *ptr; ptr = ( unsigned char * )base; len = length; for ( count = 0; count < len; count ++ ) buf[ count ] = *ptr++; buf[ len ] = '\0'; return;}int get_elf_header(unsigned long base, Bin_Flag *pstru){ pstru->b_snum = get_short( base ); base = base + HALF_LENGTH; pstru->b_binsize = get_short( base ); base = base + HALF_LENGTH; pstru->b_shsize = get_short( base ); base = base + HALF_LENGTH + HALF_LENGTH; pstru->b_shoff = get_long( base ); base = base + HALF_LENGTH + HALF_LENGTH; pstru->b_flag = get_long( base ); return 0;}int get_section_header(unsigned long base, Bin_Shdr *pstru){ get_string( pstru->sh_name, base, NAMELENGTH ); base = base + NAMELENGTH; pstru->sh_type = get_long( base ); base = base + WORD_LENGTH; pstru->sh_addr = get_long( base ); base = base + WORD_LENGTH; pstru->sh_offset = get_long( base ); base = base + WORD_LENGTH; pstru->sh_size = get_long( base ); base = base + WORD_LENGTH; pstru->sh_chknum = get_long( base ); return 0;}int loadbin(void* pvAddress){ unsigned long BIN_SDRAM_ADDR; /*BIN文件在SDRAM中的首地址*/ Bin_Flag *pbinflag = &binflag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -