2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0+
14 int do_cbfs_init(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
16 uintptr_t end_of_rom
= 0xffffffff;
20 printf("usage: cbfsls [end of rom]>\n");
24 end_of_rom
= (int)simple_strtoul(argv
[1], &ep
, 16);
26 puts("\n** Invalid end of ROM **\n");
30 file_cbfs_init(end_of_rom
);
31 if (file_cbfs_result
!= CBFS_SUCCESS
) {
32 printf("%s.\n", file_cbfs_error());
39 cbfsinit
, 2, 0, do_cbfs_init
,
40 "initialize the cbfs driver",
42 " - Initialize the cbfs driver. The optional 'end of rom'\n"
43 " parameter specifies where the end of the ROM is that the\n"
44 " CBFS is in. It defaults to 0xFFFFFFFF\n"
47 int do_cbfs_fsload(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
49 const struct cbfs_cachenode
*file
;
55 printf("usage: cbfsload <addr> <filename> [bytes]\n");
59 /* parse offset and count */
60 offset
= simple_strtoul(argv
[1], NULL
, 16);
62 count
= simple_strtoul(argv
[3], NULL
, 16);
66 file
= file_cbfs_find(argv
[2]);
68 if (file_cbfs_result
== CBFS_FILE_NOT_FOUND
)
69 printf("%s: %s\n", file_cbfs_error(), argv
[2]);
71 printf("%s.\n", file_cbfs_error());
75 printf("reading %s\n", file_cbfs_name(file
));
77 size
= file_cbfs_read(file
, (void *)offset
, count
);
79 printf("\n%ld bytes read\n", size
);
81 setenv_hex("filesize", size
);
87 cbfsload
, 4, 0, do_cbfs_fsload
,
88 "load binary file from a cbfs filesystem",
89 "<addr> <filename> [bytes]\n"
90 " - load binary file 'filename' from the cbfs to address 'addr'\n"
93 int do_cbfs_ls(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
95 const struct cbfs_cachenode
*file
= file_cbfs_get_first();
99 printf("%s.\n", file_cbfs_error());
103 printf(" size type name\n");
104 printf("------------------------------------------\n");
106 u32 type
= file_cbfs_type(file
);
107 char *type_name
= NULL
;
108 const char *filename
= file_cbfs_name(file
);
110 printf(" %8d", file_cbfs_size(file
));
113 case CBFS_TYPE_STAGE
:
116 case CBFS_TYPE_PAYLOAD
:
117 type_name
= "payload";
119 case CBFS_TYPE_OPTIONROM
:
120 type_name
= "option rom";
122 case CBFS_TYPE_BOOTSPLASH
:
123 type_name
= "boot splash";
134 case CBFS_TYPE_MICROCODE
:
135 type_name
= "microcode";
137 case CBFS_COMPONENT_CMOS_DEFAULT
:
138 type_name
= "cmos default";
140 case CBFS_COMPONENT_CMOS_LAYOUT
:
141 type_name
= "cmos layout";
148 printf(" %16s", type_name
);
150 printf(" %16d", type
);
153 printf(" %s\n", filename
);
155 printf(" %s\n", "(empty)");
156 file_cbfs_get_next(&file
);
160 printf("\n%d file(s)\n\n", files
);
165 cbfsls
, 1, 1, do_cbfs_ls
,
167 " - list the files in the cbfs\n"
170 int do_cbfs_fsinfo(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
172 const struct cbfs_header
*header
= file_cbfs_get_header();
175 printf("%s.\n", file_cbfs_error());
180 printf("CBFS version: %#x\n", header
->version
);
181 printf("ROM size: %#x\n", header
->rom_size
);
182 printf("Boot block size: %#x\n", header
->boot_block_size
);
183 printf("CBFS size: %#x\n",
184 header
->rom_size
- header
->boot_block_size
- header
->offset
);
185 printf("Alignment: %d\n", header
->align
);
186 printf("Offset: %#x\n", header
->offset
);
193 cbfsinfo
, 1, 1, do_cbfs_fsinfo
,
194 "print information about filesystem",
195 " - print information about the cbfs filesystem\n"