GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBC / dev > pbc_build_prom_image / sun-gcc
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>
#include <ZLIB/zlib.h>
Defines | |
#define | RETURN_SUCCESS (0) |
Successful return from MapFileIntoMemory(). | |
#define | RETURN_FAILED (-1) |
Unsuccessful return from MapFileIntoMemory(). | |
#define | TRUE (1) |
Logical true definition. | |
#define | FALSE (0) |
Logical false definition. | |
#define | SUROM_SIZE (PBC_ROM_SIZE) |
Size (in bytes) of SUROM. | |
Functions | |
int | BuildPromImage (int verbose, const char *inputBuffer, const unsigned long inputSize, const unsigned long fill, char *promImage, unsigned int *start, unsigned int *end) |
Assemble prom image from BAE object file. | |
int | MapFileIntoMemory (const char *name, void **buffer, unsigned long *len) |
Memory map file into process memory. | |
void | CreateBinaryFile (const char *filename, const void *data, const unsigned long length) |
Create binary output file. | |
void | CreateBaeObjectFile (const char *filename, const void *data, const unsigned long length, const unsigned long address) |
Create BAE object file. | |
void | Usage () |
Print usage message. | |
int | main (int argc, char **argv) |
pbc_build_configuration entry point. |
CVS $Id: build_prom_image.c,v 1.5 2011/03/29 23:14:59 apw Exp $
The primary purpose of this program is to build a RAD750 SUROM image. It can also be used to create a binary file from a file in EMC object file format.
To build a SUROM image, the input to the program includes:
-i <filename> - an object file (in EMC object file format) that contains all of the code/data to put into the SUROM image. -f <pattern> - a fill pattern to put between segments in the object file. -o <filename> - the name and format of the output file.
The program will produce a file containing the entire image to be loaded into a RAD750 SUROM. It is in EMC object file format, which can be used directly by the emcLd program to 'burn' the image into the SUROM.
The -b option can be used instead of the -o option to specify that the SUROM image output file should be in binary format instead of EMC object file format.
The -t option can be used to specify that any leading and trailing fill data should be trimmed from (i.e. not included in) the output file. This is useful for creating a single binary file that contains all the code and data included in the input file. The PBC makefile uses this option to create binary files from EMC object files by removing the EMC object file header.
int BuildPromImage | ( | int | verbose, | |
const char * | inputBuffer, | |||
const unsigned long | inputSize, | |||
const unsigned long | fill, | |||
char * | promImage, | |||
unsigned int * | start, | |||
unsigned int * | end | |||
) |
Assemble prom image from BAE object file.
Take a BAE object file and insert the contents into a SUROM image. Any "wholes" before, after and in between the segments in the object file are filled with a specfied 32-bit fill pattern. A small amount of error checking is done to ensure a reasonable object file.
verbose | Input parameter; control verbosity of processing | |
inputBuffer | Input parameter; memory mapped contents of object file | |
inputSize | Input parameter; number of bytes in object file | |
fill | Input parameter; fill pattern | |
promImage | Output parameter; pointer to prom image to assemble | |
start | Output parameter; pointer to first used location | |
end | Output parameter; pointer to last used location |
RETURN_SUCCESS | Success | |
RETURN_FAILED | Failure - Problems in object file. |
References RETURN_FAILED, RETURN_SUCCESS, and SUROM_SIZE.
Referenced by main().
void CreateBaeObjectFile | ( | const char * | filename, | |
const void * | data, | |||
const unsigned long | length, | |||
const unsigned long | address | |||
) |
Create BAE object file.
The BAE object file is a simple format. It contains one or more data blocks. Each data block consists of a 32-bit address (really an offset), a 32-bit length and and then the number of 32-bit data words specified by the length. Blocks are simply concatenated together.
Upon failure, a message is printed, but no error status is returned.
filename | Input parameter; file name. | |
data | Input parameter; file data. | |
address | Input parameter; block address. | |
length | Input parameter; file size, in bytes. |
Referenced by main().
void CreateBinaryFile | ( | const char * | filename, | |
const void * | data, | |||
const unsigned long | length | |||
) |
Create binary output file.
The binary file is a byte-for-byte binary dump of the specfied contents of surom address of mapping. Upon failure, a message is printed, but no error status is returned.
filename | Input parameter; file name. | |
data | Input parameter; file data. | |
length | Input parameter; file size, in bytes. |
Referenced by main().
int MapFileIntoMemory | ( | const char * | name, | |
void ** | buffer, | |||
unsigned long * | len | |||
) |
Memory map file into process memory.
Map name into process memory. Pass back file length and memory address of mapping.
name | Input parameter; file name to map. | |
buffer | Output parameter; pointer to map address. | |
len | Output parameter; pointer to file size. |
RETURN_SUCCESS | Success | |
RETURN_FAILED | Failure |
References RETURN_FAILED, and RETURN_SUCCESS.
Referenced by main().