Print name of compression algorithm in addition to the corresponding
number during boot. Convert process_file() to use enum compalgo instead of hardcoded "1","2","3" and change the control structure from a series of if() statements to a switch() statement. Uppercasing enum compalgo also found a name clash between NONE as compression algo and NONE as operation mode of util/lar. Compile and boot tested on Qemu. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://coreboot.org/repository/coreboot-v3@606 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
9f07a52934
commit
24d743968a
5 changed files with 53 additions and 21 deletions
|
|
@ -40,7 +40,7 @@ static int isverbose = 0;
|
|||
static int iselfparse = 0;
|
||||
static long larsize = 0;
|
||||
static char *bootblock = NULL;
|
||||
enum compalgo algo = none;
|
||||
enum compalgo algo = ALGO_NONE;
|
||||
|
||||
static void usage(char *name)
|
||||
{
|
||||
|
|
@ -272,10 +272,10 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'C':
|
||||
if (strcasecmp("lzma", optarg) == 0) {
|
||||
algo = lzma;
|
||||
algo = ALGO_LZMA;
|
||||
}
|
||||
if (strcasecmp("nrv2b", optarg) == 0) {
|
||||
algo = nrv2b;
|
||||
algo = ALGO_NRV2B;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
|
|
|
|||
|
|
@ -92,7 +92,14 @@ struct lar {
|
|||
u32 size; /**< Size of the mmaped file */
|
||||
};
|
||||
|
||||
enum compalgo { none = 0, lzma = 1, nrv2b = 2, zeroes = 3 };
|
||||
enum compalgo {
|
||||
ALGO_NONE = 0,
|
||||
ALGO_LZMA = 1,
|
||||
ALGO_NRV2B = 2,
|
||||
ALGO_ZEROES = 3,
|
||||
/* invalid should always be the last entry. */
|
||||
ALGO_INVALID
|
||||
};
|
||||
|
||||
typedef void (*compress_func) (char *, int, char *, int *);
|
||||
typedef void (*uncompress_func) (char *, int, char *, int);
|
||||
|
|
@ -124,8 +131,10 @@ static uncompress_func uncompress_functions[] = {
|
|||
};
|
||||
|
||||
static const char *algo_name[] = {
|
||||
"",
|
||||
"none",
|
||||
"lzma",
|
||||
"nrv2b",
|
||||
"zeroes",
|
||||
/* invalid should always be the last entry. */
|
||||
"invalid"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ int output_elf_segments(struct lar *lar, char *name, char *filebuf,
|
|||
fprintf(stderr, "Dropping empty section\n");
|
||||
continue;
|
||||
}
|
||||
thisalgo = zeroes;
|
||||
thisalgo = ALGO_ZEROES;
|
||||
if (verbose())
|
||||
fprintf(stderr, "New section addr %#x size %#x\n",
|
||||
(u32)shdr[i].sh_addr, (u32)shdr[i].sh_size);
|
||||
|
|
@ -565,7 +565,7 @@ void lar_list_files(struct lar *lar, struct file *files)
|
|||
if (file_in_list(files, filename)) {
|
||||
printf(" %s ", filename);
|
||||
|
||||
if (ntohl(header->compression) == none) {
|
||||
if (ntohl(header->compression) == ALGO_NONE) {
|
||||
printf("(%d bytes @0x%lx);",
|
||||
ntohl(header->len),
|
||||
(unsigned long)(ptr - lar->map) +
|
||||
|
|
@ -669,7 +669,7 @@ int lar_extract_files(struct lar *lar, struct file *files)
|
|||
|
||||
if (file_in_list(files, filename)) {
|
||||
|
||||
if (ntohl(header->compression) == none) {
|
||||
if (ntohl(header->compression) == ALGO_NONE) {
|
||||
ret = _write_file(filename,
|
||||
(u8 *) (ptr + ntohl(header->offset)),
|
||||
(u32) ntohl(header->len));
|
||||
|
|
@ -730,7 +730,7 @@ int lar_process_name(char *name, char **pfilename, char **ppathname,
|
|||
|
||||
if (!strncmp(name, "nocompress:",11)) {
|
||||
filename += 11;
|
||||
*thisalgo = none;
|
||||
*thisalgo = ALGO_NONE;
|
||||
}
|
||||
|
||||
/* this is dangerous */
|
||||
|
|
@ -846,8 +846,8 @@ int lar_compress(char *ptr, int size, char *temp, enum compalgo *thisalgo)
|
|||
int complen;
|
||||
compress_functions[*thisalgo](ptr, size, temp, &complen);
|
||||
|
||||
if (complen >= size && (*thisalgo != none)) {
|
||||
*thisalgo = none;
|
||||
if (complen >= size && (*thisalgo != ALGO_NONE)) {
|
||||
*thisalgo = ALGO_NONE;
|
||||
compress_functions[*thisalgo](ptr, size, temp, &complen);
|
||||
}
|
||||
return complen;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue