Remove static keyword to read_fru_area, write_fru_area, get_fru_area_str to be used in other files

This commit is contained in:
Jean-Michel Audet 2006-04-21 19:15:12 +00:00
parent a089b441f9
commit ee044f0169

View File

@ -28,6 +28,10 @@
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
*/ */
#include <ipmitool/ipmi.h> #include <ipmitool/ipmi.h>
@ -57,26 +61,26 @@
extern int verbose; extern int verbose;
extern int ipmi_spd_print(struct ipmi_intf * intf, uint8_t id); extern int ipmi_spd_print(struct ipmi_intf * intf, uint8_t id);
static void ipmi_fru_read_to_bin(struct ipmi_intf * intf, char * pFileName, unsigned char fruId); static void ipmi_fru_read_to_bin(struct ipmi_intf * intf,unsigned char * pFileName, unsigned char fruId);
static void ipmi_fru_write_from_bin(struct ipmi_intf * intf, char * pFileName, unsigned char fruId); static void ipmi_fru_write_from_bin(struct ipmi_intf * intf, unsigned char * pFileName, unsigned char fruId);
static int ipmi_fru_upg_ekeying(struct ipmi_intf * intf, char * pFileName, unsigned char fruId); static int ipmi_fru_upg_ekeying(struct ipmi_intf * intf,unsigned char * pFileName, unsigned char fruId);
static int ipmi_fru_get_multirec_location_from_fru(struct ipmi_intf * intf, static int ipmi_fru_get_multirec_location_from_fru(struct ipmi_intf * intf,
unsigned char fruId, unsigned char fruId,
struct fru_info *pFruInfo, struct fru_info *pFruInfo,
unsigned long * pRetLocation, unsigned long * pRetLocation,
unsigned long * pRetSize); unsigned long * pRetSize);
static int ipmi_fru_get_multirec_from_file(char * pFileName, static int ipmi_fru_get_multirec_from_file(unsigned char * pFileName,
unsigned char * pBufArea, unsigned char * pBufArea,
unsigned long size, unsigned long size,
unsigned long offset); unsigned long offset);
static int ipmi_fru_get_multirec_size_from_file(char * pFileName, static int ipmi_fru_get_multirec_size_from_file(unsigned char * pFileName,
unsigned long * pSize, unsigned long * pSize,
unsigned long * pOffset); unsigned long * pOffset);
static void ipmi_fru_get_adjust_size_from_buffer(unsigned char * pBufArea, static void ipmi_fru_get_adjust_size_from_buffer(unsigned char * pBufArea,
unsigned long *pSize); unsigned long *pSize);
static char fileName[512]; static unsigned char fileName[512];
static void ipmi_fru_picmg_ext_print(unsigned char * fru_data, int off, int length); static void ipmi_fru_picmg_ext_print(unsigned char * fru_data, int off, int length);
@ -88,7 +92,7 @@ static void ipmi_fru_picmg_ext_print(unsigned char * fru_data, int off, int leng
* *
* returns pointer to FRU area string * returns pointer to FRU area string
*/ */
static char * char *
get_fru_area_str(uint8_t * data, uint32_t * offset) get_fru_area_str(uint8_t * data, uint32_t * offset)
{ {
static const char bcd_plus[] = "0123456789 -.:,_"; static const char bcd_plus[] = "0123456789 -.:,_";
@ -198,7 +202,7 @@ get_fru_area_str(uint8_t * data, uint32_t * offset)
* returns 0 on success * returns 0 on success
* returns -1 on error * returns -1 on error
*/ */
static int int
write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, unsigned char id, write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, unsigned char id,
unsigned int soffset, unsigned int doffset, unsigned int soffset, unsigned int doffset,
unsigned int length, unsigned char *pFrubuf) unsigned int length, unsigned char *pFrubuf)
@ -282,7 +286,7 @@ write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, unsigned char id,
* returns -1 on error * returns -1 on error
* returns 0 if successful * returns 0 if successful
*/ */
static int int
read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
uint32_t offset, uint32_t length, uint8_t *frubuf) uint32_t offset, uint32_t length, uint8_t *frubuf)
{ {
@ -377,8 +381,7 @@ static void
fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru, fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset) uint8_t id, uint32_t offset)
{ {
char * fru_area; uint8_t * fru_area, * fru_data;
uint8_t * fru_data;
uint32_t fru_len, area_len, i; uint32_t fru_len, area_len, i;
i = offset; i = offset;
@ -450,8 +453,7 @@ static void
fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru, fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset) uint8_t id, uint32_t offset)
{ {
char * fru_area; uint8_t * fru_area, * fru_data;
uint8_t * fru_data;
uint32_t fru_len, area_len, i; uint32_t fru_len, area_len, i;
i = offset; i = offset;
@ -542,8 +544,7 @@ static void
fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru, fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
uint8_t id, uint32_t offset) uint8_t id, uint32_t offset)
{ {
char * fru_area; uint8_t * fru_area, * fru_data;
uint8_t * fru_data;
uint32_t fru_len, area_len, i; uint32_t fru_len, area_len, i;
i = offset; i = offset;
@ -834,7 +835,7 @@ static void ipmi_fru_picmg_ext_print(unsigned char * fru_data, int off, int leng
case FRU_PICMG_BACKPLANE_P2P: case FRU_PICMG_BACKPLANE_P2P:
{ {
unsigned char index; unsigned char index, index2;
struct fru_picmgext_slot_desc * slot_d struct fru_picmgext_slot_desc * slot_d
= (struct fru_picmgext_slot_desc*) &fru_data[offset]; = (struct fru_picmgext_slot_desc*) &fru_data[offset];
@ -1026,7 +1027,7 @@ static void ipmi_fru_picmg_ext_print(unsigned char * fru_data, int off, int leng
{ {
unsigned int index; unsigned int index;
for(; offset < off + length; ) for(offset; offset < off + length; )
{ {
struct fru_picmgext_carrier_p2p_record * h = struct fru_picmgext_carrier_p2p_record * h =
(struct fru_picmgext_carrier_p2p_record *) &fru_data[offset]; (struct fru_picmgext_carrier_p2p_record *) &fru_data[offset];
@ -1423,13 +1424,17 @@ ipmi_fru_main(struct ipmi_intf * intf, int argc, char ** argv)
return rc; return rc;
} }
static void ipmi_fru_read_to_bin(struct ipmi_intf * intf, char * pFileName, unsigned char fruId) static void ipmi_fru_read_to_bin(struct ipmi_intf * intf,unsigned char * pFileName, unsigned char fruId)
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
unsigned char * fru_data;
struct fru_info fru; struct fru_info fru;
unsigned char msg_data[4]; unsigned char msg_data[4];
unsigned char * pFruBuf; unsigned char * pFruBuf;
unsigned int counter;
unsigned int len;
msg_data[0] = fruId; msg_data[0] = fruId;
@ -1488,10 +1493,11 @@ static void ipmi_fru_read_to_bin(struct ipmi_intf * intf, char * pFileName, unsi
} }
static void ipmi_fru_write_from_bin(struct ipmi_intf * intf, static void ipmi_fru_write_from_bin(struct ipmi_intf * intf,
char * pFileName, unsigned char fruId) unsigned char * pFileName, unsigned char fruId)
{ {
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
struct ipmi_rq req; struct ipmi_rq req;
unsigned char *fru_data;
struct fru_info fru; struct fru_info fru;
unsigned char msg_data[4]; unsigned char msg_data[4];
@ -1549,13 +1555,13 @@ static void ipmi_fru_write_from_bin(struct ipmi_intf * intf,
} }
static int static int
ipmi_fru_upg_ekeying(struct ipmi_intf * intf, char * pFileName, ipmi_fru_upg_ekeying(struct ipmi_intf * intf,unsigned char * pFileName,
unsigned char fruId) unsigned char fruId)
{ {
unsigned int retStatus = 0; unsigned int retStatus = 0;
unsigned long offFruMultiRec; unsigned long offFruMultiRec;
unsigned long fruMultiRecSize = 0; unsigned long fruMultiRecSize = 0;
unsigned long offFileMultiRec = 0; unsigned long offFileMultiRec;
unsigned long fileMultiRecSize = 0; unsigned long fileMultiRecSize = 0;
struct fru_info fruInfo; struct fru_info fruInfo;
unsigned char *buf = NULL; unsigned char *buf = NULL;
@ -1565,8 +1571,8 @@ ipmi_fru_upg_ekeying(struct ipmi_intf * intf, char * pFileName,
&fruMultiRecSize); &fruMultiRecSize);
if (verbose) { if (verbose) {
printf("FRU Size : %lu\n\r", fruMultiRecSize); printf("FRU Size : %u\n\r", fruMultiRecSize);
printf("Multi Rec offset: %lu\n\r", offFruMultiRec); printf("Multi Rec offset: %u\n\r", offFruMultiRec);
} }
if (retStatus == 0) { if (retStatus == 0) {
@ -1611,18 +1617,16 @@ ipmi_fru_upg_ekeying(struct ipmi_intf * intf, char * pFileName,
{ {
lprintf(LOG_ERR, "Failed"); lprintf(LOG_ERR, "Failed");
} }
return 0;
} }
static int ipmi_fru_get_multirec_size_from_file(char * pFileName, static int ipmi_fru_get_multirec_size_from_file(unsigned char * pFileName,
unsigned long * pSize, unsigned long * pSize,
unsigned long * pOffset) unsigned long * pOffset)
{ {
struct fru_header header; struct fru_header header;
FILE * pFile; FILE * pFile;
unsigned char len = 0; unsigned char len = 0;
unsigned long end = 0; unsigned long end;
*pSize = 0; *pSize = 0;
@ -1639,7 +1643,7 @@ static int ipmi_fru_get_multirec_size_from_file(char * pFileName,
if(verbose) if(verbose)
{ {
printf("File Size = %lu\n", end); printf("File Size = %lu\n", end);
printf("Len = %d\n", len); printf("Len = %lu\n", len);
} }
@ -1695,6 +1699,7 @@ static void ipmi_fru_get_adjust_size_from_buffer(unsigned char * fru_data,
unsigned long *pSize) unsigned long *pSize)
{ {
struct fru_multirec_header * head; struct fru_multirec_header * head;
unsigned int last_off;
#define CHUNK_SIZE (255 + sizeof(struct fru_multirec_header)) #define CHUNK_SIZE (255 + sizeof(struct fru_multirec_header))
unsigned int count = 0; unsigned int count = 0;
unsigned int status = 0; unsigned int status = 0;
@ -1762,19 +1767,21 @@ static void ipmi_fru_get_adjust_size_from_buffer(unsigned char * fru_data,
if (verbose > 1) if (verbose > 1)
{ {
printf("Size of multirec: %lu\n\r", *pSize); printf("Size of multirec: %u\n\r", *pSize);
} }
} }
static int ipmi_fru_get_multirec_from_file(char * pFileName, static int ipmi_fru_get_multirec_from_file(unsigned char * pFileName,
unsigned char * pBufArea, unsigned char * pBufArea,
unsigned long size, unsigned long size,
unsigned long offset) unsigned long offset)
{ {
struct fru_header header;
FILE * pFile; FILE * pFile;
unsigned long len = 0; unsigned long len = 0;
pFile = fopen(pFileName,"rb"); pFile = fopen(pFileName,"rb");
if(pFile!=NULL) if(pFile!=NULL)
{ {
@ -1806,8 +1813,12 @@ static int ipmi_fru_get_multirec_location_from_fru(struct ipmi_intf * intf,
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
struct ipmi_rq req; struct ipmi_rq req;
unsigned char * fru_data;
unsigned char msg_data[4]; unsigned char msg_data[4];
int i, len;
unsigned long end; unsigned long end;
struct fru_header header; struct fru_header header;
*pRetLocation = 0; *pRetLocation = 0;