2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
32 uintptr_t end_of_rom = 0xffffffff;
36 printf("usage: cbfsls [end of rom]>\n");
40 end_of_rom = (int)simple_strtoul(argv[1], &ep, 16);
42 puts("\n** Invalid end of ROM **\n");
46 file_cbfs_init(end_of_rom);
47 if (file_cbfs_result != CBFS_SUCCESS) {
48 printf("%s.\n", file_cbfs_error());
55 cbfsinit, 2, 0, do_cbfs_init,
56 "initialize the cbfs driver",
58 " - Initialize the cbfs driver. The optional 'end of rom'\n"
59 " parameter specifies where the end of the ROM is that the\n"
60 " CBFS is in. It defaults to 0xFFFFFFFF\n"
63 int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
65 const struct cbfs_cachenode *file;
71 printf("usage: cbfsload <addr> <filename> [bytes]\n");
75 /* parse offset and count */
76 offset = simple_strtoul(argv[1], NULL, 16);
78 count = simple_strtoul(argv[3], NULL, 16);
82 file = file_cbfs_find(argv[2]);
84 if (file_cbfs_result == CBFS_FILE_NOT_FOUND)
85 printf("%s: %s\n", file_cbfs_error(), argv[2]);
87 printf("%s.\n", file_cbfs_error());
91 printf("reading %s\n", file_cbfs_name(file));
93 size = file_cbfs_read(file, (void *)offset, count);
95 printf("\n%ld bytes read\n", size);
97 setenv_hex("filesize", size);
103 cbfsload, 4, 0, do_cbfs_fsload,
104 "load binary file from a cbfs filesystem",
105 "<addr> <filename> [bytes]\n"
106 " - load binary file 'filename' from the cbfs to address 'addr'\n"
109 int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
111 const struct cbfs_cachenode *file = file_cbfs_get_first();
115 printf("%s.\n", file_cbfs_error());
119 printf(" size type name\n");
120 printf("------------------------------------------\n");
122 u32 type = file_cbfs_type(file);
123 char *type_name = NULL;
124 const char *filename = file_cbfs_name(file);
126 printf(" %8d", file_cbfs_size(file));
129 case CBFS_TYPE_STAGE:
132 case CBFS_TYPE_PAYLOAD:
133 type_name = "payload";
135 case CBFS_TYPE_OPTIONROM:
136 type_name = "option rom";
138 case CBFS_TYPE_BOOTSPLASH:
139 type_name = "boot splash";
150 case CBFS_TYPE_MICROCODE:
151 type_name = "microcode";
153 case CBFS_COMPONENT_CMOS_DEFAULT:
154 type_name = "cmos default";
156 case CBFS_COMPONENT_CMOS_LAYOUT:
157 type_name = "cmos layout";
164 printf(" %16s", type_name);
166 printf(" %16d", type);
169 printf(" %s\n", filename);
171 printf(" %s\n", "(empty)");
172 file_cbfs_get_next(&file);
176 printf("\n%d file(s)\n\n", files);
181 cbfsls, 1, 1, do_cbfs_ls,
183 " - list the files in the cbfs\n"
186 int do_cbfs_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
188 const struct cbfs_header *header = file_cbfs_get_header();
191 printf("%s.\n", file_cbfs_error());
196 printf("CBFS version: %#x\n", header->version);
197 printf("ROM size: %#x\n", header->rom_size);
198 printf("Boot block size: %#x\n", header->boot_block_size);
199 printf("CBFS size: %#x\n",
200 header->rom_size - header->boot_block_size - header->offset);
201 printf("Alignment: %d\n", header->align);
202 printf("Offset: %#x\n", header->offset);
209 cbfsinfo, 1, 1, do_cbfs_fsinfo,
210 "print information about filesystem",
211 " - print information about the cbfs filesystem\n"