2c8b50e884951416e8b7594435e4aceb73f4e547
[openwrt/svn-archive/archive.git] / tools / firmware-utils / src / myloader.h
1 /*
2 * Copyright (C) 2006,2007 Gabor Juhos
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 */
10
11 #ifndef _MYLOADER_H_
12 #define _MYLOADER_H_
13
14 /*
15 * Firmware file format:
16 *
17 * <header>
18 * [<block descriptor 0>]
19 * ...
20 * [<block descriptor n>]
21 * <null block descriptor>
22 * [<block data 0>]
23 * ...
24 * [<block data n>]
25 *
26 *
27 */
28
29 #define MYLO_MAGIC_FIRMWARE 0x4C594D00
30 #define MYLO_MAGIC_20021103 0x20021103
31 #define MYLO_MAGIC_20021107 0x20021107
32
33 #define MYLO_MAGIC_SYSSETUP MYLO_MAGIC_20021107
34 #define MYLO_MAGIC_PARTITIONS MYLO_MAGIC_20021103
35
36 /* Vendor ID's (seems to be same as the PCI vendor ID's) */
37 #define VENID_COMPEX 0x11F6
38
39 /* Devices based on the ADM5120 */
40 #define DEVID_COMPEX_NP27G 0x0078
41 #define DEVID_COMPEX_NP28G 0x044C
42 #define DEVID_COMPEX_NP28GHS 0x044E
43 #define DEVID_COMPEX_WP54Gv1C 0x0514
44 #define DEVID_COMPEX_WP54G 0x0515
45 #define DEVID_COMPEX_WP54AG 0x0546
46 #define DEVID_COMPEX_WPP54AG 0x0550
47 #define DEVID_COMPEX_WPP54G 0x0555
48
49 /* Devices based on the IXP422 */
50 #define DEVID_COMPEX_WP18 0x047E
51 #define DEVID_COMPEX_NP18A 0x0489
52
53 /* Other devices */
54 #define DEVID_COMPEX_NP26G8M 0x03E8
55 #define DEVID_COMPEX_NP26G16M 0x03E9
56
57 struct mylo_fw_header {
58 uint32_t magic; /* must be MYLO_MAGIC_MYLO */
59 uint32_t crc; /* CRC of the whole firmware */
60 uint32_t res0; /* unknown/unused */
61 uint32_t res1; /* unknown/unused */
62 uint16_t vid; /* vendor ID */
63 uint16_t did; /* device ID */
64 uint16_t svid; /* sub vendor ID */
65 uint16_t sdid; /* sub device ID */
66 uint32_t rev; /* device revision */
67 uint32_t fwhi; /* FIXME: firmware version high? */
68 uint32_t fwlo; /* FIXME: firmware version low? */
69 uint32_t flags; /* firmware flags */
70 };
71
72 #define FW_FLAG_BOARD_PARAMS_WP 0x01 /* board parameters are write protected */
73 #define FW_FLAG_BOOT_SECTOR_WE 0x02 /* enable of write boot sectors (below 64K) */
74
75 struct mylo_fw_blockdesc {
76 uint32_t type; /* block type */
77 uint32_t addr; /* relative address to flash start */
78 uint32_t dlen; /* size of block data in bytes */
79 uint32_t blen; /* total size of block in bytes */
80 };
81
82 #define FW_DESC_TYPE_UNUSED 0
83 #define FW_DESC_TYPE_USED 1
84
85 struct mylo_partition {
86 uint16_t flags; /* partition flags */
87 uint16_t type; /* type of the partition */
88 uint32_t addr; /* relative address of the partition from the
89 flash start */
90 uint32_t size; /* size of the partition in bytes */
91 uint32_t param; /* if this is the active partition, the
92 MyLoader load code to this address */
93 };
94
95 #define PARTITION_FLAG_ACTIVE 0x8000 /* this is the active partition,
96 * MyLoader loads firmware from here */
97 #define PARTITION_FLAG_ISRAM 0x2000 /* FIXME: this is a RAM partition? */
98 #define PARTIIION_FLAG_RAMLOAD 0x1000 /* FIXME: load this partition into the RAM? */
99 #define PARTITION_FLAG_PRELOAD 0x0800 /* the partition data preloaded to RAM
100 * before decompression */
101 #define PARTITION_FLAG_HAVEHDR 0x0002 /* the partition data have a header */
102
103 #define PARTITION_TYPE_FREE 0
104 #define PARTITION_TYPE_USED 1
105
106 #define MYLO_MAX_PARTITIONS 8 /* maximum number of partitions in the
107 partition table */
108
109 struct mylo_partition_table {
110 uint32_t magic; /* must be 0x20021103 */
111 uint32_t res0; /* unknown/unused */
112 uint32_t res1; /* unknown/unused */
113 uint32_t res2; /* unknown/unused */
114 struct mylo_partition partitions[MYLO_MAX_PARTITIONS];
115 };
116
117 struct mylo_partition_header {
118 uint32_t len; /* length of the partition data */
119 uint32_t crc; /* CRC value of the partition data */
120 };
121
122 struct mylo_system_params {
123 uint32_t magic;
124 uint32_t res0;
125 uint32_t res1;
126 uint32_t mylo_ver;
127 uint16_t vid; /* Vendor ID */
128 uint16_t did; /* Device ID */
129 uint16_t svid; /* Sub Vendor ID */
130 uint16_t sdid; /* Sub Device ID */
131 uint32_t rev; /* device revision */
132 uint32_t fwhi;
133 uint32_t fwlo;
134 uint32_t tftp_addr;
135 uint32_t prog_start;
136 uint32_t flash_size;
137 uint32_t dram_size;
138 };
139
140
141 struct mylo_eth_addr {
142 uint8_t mac[6];
143 uint8_t csum[2];
144 };
145
146 #define MYLO_ETHADDR_COUNT 8 /* maximum number of ethernet address
147 in the board parameters */
148
149 struct mylo_board_params {
150 uint32_t magic;
151 uint32_t res0;
152 uint32_t res1;
153 uint32_t res2;
154 struct mylo_eth_addr addr[MYLO_ETHADDR_COUNT];
155 };
156
157 #endif /* _MYLOADER_H_*/