Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / util / cbfstool / common.c
index dd675cac03128392af2b4d2adeea824005bfe7ca..b071864b5c81923f9ed4772722e76976f7d2bc95 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <libgen.h>
 #include "common.h"
 #include "cbfs.h"
 #include "elf.h"
@@ -127,10 +128,26 @@ struct filetypes_t {
        {CBFS_COMPONENT_STAGE, "stage"},
        {CBFS_COMPONENT_PAYLOAD, "payload"},
        {CBFS_COMPONENT_OPTIONROM, "optionrom"},
+       {CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
+       {CBFS_COMPONENT_RAW, "raw"},
+       {CBFS_COMPONENT_VSA, "vsa"},
+       {CBFS_COMPONENT_MBI, "mbi"},
+       {CBFS_COMPONENT_MICROCODE, "microcode"},
        {CBFS_COMPONENT_DELETED, "deleted"},
        {CBFS_COMPONENT_NULL, "null"}
 };
 
+void print_supported_filetypes(void)
+{
+       int i, number = ARRAY_SIZE(filetypes);
+
+       for (i=0; i<number; i++) {
+               printf(" %s%c", filetypes[i].name, (i==(number-1))?'\n':',');
+               if ((i%8) == 7)
+                       printf("\n");
+       }
+}
+
 const char *strfiletype(uint32_t number)
 {
        int i;
@@ -153,7 +170,7 @@ void print_cbfs_directory(const char *filename)
 {
        printf
            ("%s: %d kB, bootblocksize %d, romsize %d, offset 0x%x\nAlignment: %d bytes\n\n",
-            filename, romsize / 1024, ntohl(master_header->bootblocksize),
+            basename((char *)filename), romsize / 1024, ntohl(master_header->bootblocksize),
             romsize, ntohl(master_header->offset), align);
        printf("%-30s %-10s %-12s Size\n", "Name", "Offset", "Type");
        uint32_t current = phys_start;
@@ -165,9 +182,11 @@ void print_cbfs_directory(const char *filename)
                struct cbfs_file *thisfile =
                    (struct cbfs_file *)phys_to_virt(current);
                uint32_t length = ntohl(thisfile->len);
-               printf("%-30s 0x%-8x %-12s %d\n",
-                      (const char *)(phys_to_virt(current) +
-                                     sizeof(struct cbfs_file)),
+               char *fname = (char *)(phys_to_virt(current) + sizeof(struct cbfs_file));
+               if (strlen(fname) == 0)
+                       fname = "(empty)";
+
+               printf("%-30s 0x%-8x %-12s %d\n", fname,
                       current - phys_start, strfiletype(ntohl(thisfile->type)),
                       length);
                current =