summaryrefslogtreecommitdiff
path: root/cleopatre/u-boot-1.1.6/test/spidupd_test/spidupd_test.h
blob: 66f9445f1cc6f09932a4b636061290c8f5a97201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * /test/spidupd_test/spidupd_test.h
 *
 * (C) Copyright 2008 SPiDCOM Technologies
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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
 *
 * Author(s): 
 * Drasko DRASKOVIC, drasko.draskovic@spidcom.com
 */

#ifndef __SPIDUPD_TEST_H__
#define __SPIDUPD_TEST_H__

typedef struct 
{
	unsigned char		mme_dest[6];	    /* Destination node		            */
	unsigned char		mme_src[6];	        /* Source node			            */
    //unsigned int        vlan_tag;           /* ieee 802.1q VLAN tag (optional)	*/
    unsigned short      mtype;              /* 0x88e1 (iee assigned Ethertype)  */
    unsigned char       mmv;                /* Management Message Version       */
    unsigned short      mmtype;             /* Management Message Type          */
    //unsigned short      fmi;                /* Fragmentation Management Info    */
} __attribute__ ((__packed__)) MME_t;

#define MME_HDR_SIZE	17		/* MME header size (Homeplug AV)	*/

#define PKTSIZE         1518

#define SPIDUPD_BLOCK_SIZE		1024		    /* default Spidupd block size	*/

#include <linux/byteorder/swab.h>

/* endianess */
# if __BYTE_ORDER == __LITTLE_ENDIAN
/* The host byte order is the same as MME byte order,
   so these functions are all just identity.  */
# define mmetohl(x)    (x)
# define mmetohs(x)    (x)
# define htommel(x)    (x)
# define htommes(x)    (x)
# else
#  if __BYTE_ORDER == __BIG_ENDIAN
#   define mmetohl(x)    ___bswap32((x))
#   define mmetohs(x)    ___bswap16((x))
#   define htommel(x)    ___bswap32((x))
#   define htommes(x)    ___bswap16((x))
#  endif
# endif


/* spidupd.h */

#define MAX_MME_SIZE       (PKTSIZE - MME_HDR_SIZE)

#define MME_MMV             100         /* Management Message Version       */

/*
 *	SPIDUPD operations
 */

/* SPIDUPD Messages */
#define VS_UPDATE_START     0xA300
#define VS_UPDATE_TRANSFER  0xA304
#define VS_UPDATE_END       0xA308

/* information about REQ, CNF IND or RSP is held in two LSBs */
#define VS_UPDATE_START_REQ     (VS_UPDATE_START | 0x0)    
#define VS_UPDATE_START_CNF     (VS_UPDATE_START | 0x1)
#define VS_UPDATE_TRANSFER_REQ  (VS_UPDATE_TRANSFER | 0x0)
#define VS_UPDATE_TRANSFER_CNF  (VS_UPDATE_TRANSFER | 0x1)
#define VS_UPDATE_END_REQ       (VS_UPDATE_END | 0x0)
#define VS_UPDATE_END_CNF       (VS_UPDATE_END | 0x1)
#define VS_UPDATE_END_IND       (VS_UPDATE_END | 0x2)

/* 
 * SPIDUPD Primitive types 
 */
typedef struct 
{
	unsigned char		version_id;	    /* version ID of the fw to send	    	    */
	unsigned char		arch;	        /* modem arch type; default: 0 (spc300)		*/
    unsigned char       upd_type;       /* update type; default: 0 for normal image	*/
} __attribute__ ((__packed__)) VsUpdStartReq_t;

typedef struct 
{
	unsigned char		start_update;	/* 0 - sucess, 0x1..0x5 - error messages	*/
} __attribute__ ((__packed__)) VsUpdStartCnf_t;

typedef struct 
{
	unsigned int		block_id;	            /* block ID of data to be sent              */
	unsigned int		length;	                /* length of data to be sent		        */
    unsigned char       data[MAX_MME_SIZE - 8]; /* padded data (for min size of eth packet) */
} __attribute__ ((__packed__)) VsUpdTransfReq_t;

typedef struct 
{
	unsigned char		ack;	        /* 0 - sucess, 0x1 - failure	        */
    unsigned int		next_block;	    /* next block ID that server expects    */
} __attribute__ ((__packed__)) VsUpdTransfCnf_t;

typedef struct 
{
	unsigned char		md5_sum[16];	/* 0 - sucess, 0x1 - failure	*/
} __attribute__ ((__packed__)) VsUpdEndReq_t;

typedef struct 
{
	unsigned char		result;	        /* 0 - sucess, 0x1 - failure	*/
} __attribute__ ((__packed__)) VsUpdEndCnf_t;

typedef struct 
{
	unsigned char		result;	        /* 0 - sucess, 0x1..0x2 - error messages	*/
} __attribute__ ((__packed__)) VsUpdEndInd_t;


/* Failure codes in server response */
/* start_cnf */
#define SPIDUPD_OK              0x00
#define SPIDUPD_BAD_VERSION     0x01
#define SPIDUPD_BAD_ARCH        0x02
#define SPIDUPD_BAD_UPD_TYPE    0x03
#define SPIDUPD_MODEM_BUSY      0x04

/* tansfer_cnf and end_cnf */
#define SPIDUPD_SUCCESS         0x00
#define SPIDUPD_FAILURE         0x01

/* end_cnf */
#define SPIDUPD_MD5_ERROR           0x01
#define SPIDUPD_FLASH_WRITE_ERROR   0x02

/* end_ind */
#define SPIDUPD_FLASH_WRITE_TOUT    0x02



/**********************************************************************/
/*
 *	Global functions and variables.
 */

/* 
 *define an address in RAM where we will put update image that is coming
 * from PC client. After download, image will be written to flash
 */
#define UPD_IMG_RAM_ADDR    ( (unsigned char *)0x40100000  )
 
/* spidupd.c */
extern void	SpidupdStart (void);	/* Begin SPIDUPD get */

/**********************************************************************/



#endif /* __SPIDUPD_H__ */