Commit fe2ce5500ebf43d79d227190bd2370232d5b113d

Authored by Harald Welte
Committed by Wolfgang Denk
1 parent 07efc9e321

add 'unzip' command to u-boot commandline

[PATCH] add new 'unzip' command to u-boot commandline

common/cmd_mem.c: new command "unzip srcaddr dstaddr [dstsize]" to unzip from
memory to memory, and option CONFIG_CMD_UNZIP to enable it

Signed-off-by: Werner Almesberger <werner@openmoko.org>
Signed-off-by: Harald Welte <laforge@openmoko.org>

Showing 2 changed files with 37 additions and 0 deletions Side-by-side Diff

... ... @@ -1198,6 +1198,34 @@
1198 1198 }
1199 1199 #endif /* CONFIG_CRC32_VERIFY */
1200 1200  
  1201 +
  1202 +#ifdef CONFIG_CMD_UNZIP
  1203 +int gunzip (void *, int, unsigned char *, unsigned long *);
  1204 +
  1205 +int do_unzip ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  1206 +{
  1207 + unsigned long src, dst;
  1208 + unsigned long src_len = ~0UL, dst_len = ~0UL;
  1209 + int err;
  1210 +
  1211 + switch (argc) {
  1212 + case 4:
  1213 + dst_len = simple_strtoul(argv[3], NULL, 16);
  1214 + /* fall through */
  1215 + case 3:
  1216 + src = simple_strtoul(argv[1], NULL, 16);
  1217 + dst = simple_strtoul(argv[2], NULL, 16);
  1218 + break;
  1219 + default:
  1220 + printf ("Usage:\n%s\n", cmdtp->usage);
  1221 + return 1;
  1222 + }
  1223 +
  1224 + return !!gunzip((void *) dst, dst_len, (void *) src, &src_len);
  1225 +}
  1226 +#endif /* CONFIG_CMD_UNZIP */
  1227 +
  1228 +
1201 1229 /**************************************************/
1202 1230 #if defined(CONFIG_CMD_MEMORY)
1203 1231 U_BOOT_CMD(
... ... @@ -1300,6 +1328,14 @@
1300 1328 "[.b, .w, .l] address value delay(ms)\n - memory write cyclic\n"
1301 1329 );
1302 1330 #endif /* CONFIG_MX_CYCLIC */
  1331 +
  1332 +#ifdef CONFIG_CMD_UNZIP
  1333 +U_BOOT_CMD(
  1334 + unzip, 4, 1, do_unzip,
  1335 + "unzip - unzip a memory region\n",
  1336 + "srcaddr dstaddr [dstsize]\n"
  1337 +);
  1338 +#endif /* CONFIG_CMD_UNZIP */
1303 1339  
1304 1340 #endif
1305 1341 #endif
include/config_cmd_all.h
... ... @@ -77,6 +77,7 @@
77 77 #define CONFIG_CMD_SPI /* SPI utility */
78 78 #define CONFIG_CMD_TERMINAL /* built-in Serial Terminal */
79 79 #define CONFIG_CMD_UNIVERSE /* Tundra Universe Support */
  80 +#define CONFIG_CMD_UNZIP /* unzip from memory to memory */
80 81 #define CONFIG_CMD_USB /* USB Support */
81 82 #define CONFIG_CMD_VFD /* VFD support (TRAB) */
82 83 #define CONFIG_CMD_XIMG /* Load part of Multi Image */