Various fixes to cbfstool.
- add ntohll and htonll (as coreboot parses 64bit fields now) - use the same byte swapping code across platforms - detect endianess early - fix lots of warnings - Don't override CFLAGS in Makefile Change-Id: Iaea02ff7a31ab6a95fd47858d0efd9af764a3e5f Signed-off-by: Stefan Reinauer <reinauer@google.com> Reviewed-on: http://review.coreboot.org/313 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
committed by
Stefan Reinauer
parent
3c976791b0
commit
a1e4824f73
@@ -19,7 +19,9 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "common.h"
|
||||
#include "cbfs.h"
|
||||
|
||||
@@ -196,7 +198,6 @@ static int cbfs_add_stage(int argc, char **argv)
|
||||
static int cbfs_create(int argc, char **argv)
|
||||
{
|
||||
char *romname = argv[1];
|
||||
char *cmd = argv[2];
|
||||
if (argc < 5) {
|
||||
printf("not enough arguments to 'create'.\n");
|
||||
return 1;
|
||||
@@ -239,7 +240,6 @@ static int cbfs_locate(int argc, char **argv)
|
||||
static int cbfs_print(int argc, char **argv)
|
||||
{
|
||||
char *romname = argv[1];
|
||||
char *cmd = argv[2];
|
||||
void *rom = loadrom(romname);
|
||||
|
||||
if (rom == NULL) {
|
||||
@@ -254,7 +254,6 @@ static int cbfs_print(int argc, char **argv)
|
||||
static int cbfs_extract(int argc, char **argv)
|
||||
{
|
||||
char *romname = argv[1];
|
||||
char *cmd = argv[2];
|
||||
void *rom = loadrom(romname);
|
||||
|
||||
if (rom == NULL) {
|
||||
@@ -271,7 +270,7 @@ static int cbfs_extract(int argc, char **argv)
|
||||
return extract_file_from_cbfs(romname, argv[3], argv[4]);
|
||||
}
|
||||
|
||||
struct command commands[] = {
|
||||
static const struct command commands[] = {
|
||||
{CMD_ADD, "add", cbfs_add},
|
||||
{CMD_ADD_PAYLOAD, "add-payload", cbfs_add_payload},
|
||||
{CMD_ADD_STAGE, "add-stage", cbfs_add_stage},
|
||||
@@ -281,7 +280,7 @@ struct command commands[] = {
|
||||
{CMD_EXTRACT, "extract", cbfs_extract},
|
||||
};
|
||||
|
||||
void usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
printf
|
||||
("cbfstool: Management utility for CBFS formatted ROM images\n\n"
|
||||
@@ -302,6 +301,20 @@ void usage(void)
|
||||
print_supported_filetypes();
|
||||
}
|
||||
|
||||
/* Small, OS/libc independent runtime check
|
||||
* for endianess
|
||||
*/
|
||||
int host_bigendian = 0;
|
||||
|
||||
static void which_endian(void)
|
||||
{
|
||||
char test[4] = "1234";
|
||||
uint32_t inttest = *(uint32_t *) test;
|
||||
if (inttest == 0x31323334) {
|
||||
host_bigendian = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
@@ -311,6 +324,8 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
which_endian();
|
||||
|
||||
char *cmd = argv[2];
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(commands); i++) {
|
||||
|
Reference in New Issue
Block a user