/* * /net/spidupd.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_H__ #define __SPIDUPD_H__ /* mme part of eth message is always in little endian byteorder */ # define mmetohl(x) __le32_to_cpu(x) # define mmetohs(x) __le16_to_cpu(x) # define htommel(x) __cpu_to_le32(x) # define htommes(x) __cpu_to_le16(x) #define MAX_MME_SIZE (PKTSIZE - MME_HDR_SIZE) #define MME_MMV 1 /* Management Message Version */ /* * SPIDUPD operations */ /* SPIDUPD Messages */ #define VS_UPDATE_START 0xA064 #define VS_UPDATE_TRANSFER 0xA068 #define VS_UPDATE_END 0xA06C /* 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) #define VS_UPDATE_RANGE(type) ((type >= VS_UPDATE_START) && (type <= VS_UPDATE_END)) /* * SPIDUPD Primitive types */ typedef struct { unsigned char version[16]; /* version string of the fw to send */ unsigned long arch; /* modem arch type; default: 0 (spc300) */ unsigned long upd_type; /* update type; default: 0 for normal image */ } __attribute__ ((__packed__)) VsUpdStartReq_t; typedef struct { unsigned char start_update; /* 0 - success, 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 - success, 0x1 - failure */ unsigned int next_block; /* next block ID that server expects */ } __attribute__ ((__packed__)) VsUpdTransfCnf_t; typedef struct { unsigned char md5_sum[16]; /* 0 - success, 0x1 - failure */ } __attribute__ ((__packed__)) VsUpdEndReq_t; typedef struct { unsigned char result; /* 0 - success, 0x1 - failure */ } __attribute__ ((__packed__)) VsUpdEndCnf_t; typedef struct { unsigned char result; /* 0 - success, 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 /* transfer_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_TOUT 0x03 /**********************************************************************/ /* * Global functions and variables. */ /* spidupd.c */ extern void SpidupdStart (void); /* Begin SPIDUPD get */ /**********************************************************************/ #endif /* __SPIDUPD_H__ */