summaryrefslogtreecommitdiff
path: root/common/cmd_fdos.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2003-06-27 21:31:46 +0000
committerwdenk <wdenk>2003-06-27 21:31:46 +0000
commit8bde7f776c77b343aca29b8c7b58464d915ac245 (patch)
tree20f1fd99975215e7c658454a15cdb4ed4694e2d4 /common/cmd_fdos.c
parent993cad9364c6b87ae429d1ed1130d8153f6f027e (diff)
downloadu-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.zip
u-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.tar.gz
u-boot-imx-8bde7f776c77b343aca29b8c7b58464d915ac245.tar.bz2
* Code cleanup:
- remove trailing white space, trailing empty lines, C++ comments, etc. - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c) * Patches by Kenneth Johansson, 25 Jun 2003: - major rework of command structure (work done mostly by Michal Cendrowski and Joakim Kristiansen)
Diffstat (limited to 'common/cmd_fdos.c')
-rw-r--r--common/cmd_fdos.c96
1 files changed, 54 insertions, 42 deletions
diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c
index 4b411b3..8257e70 100644
--- a/common/cmd_fdos.c
+++ b/common/cmd_fdos.c
@@ -34,7 +34,7 @@
#if (CONFIG_COMMANDS & CFG_CMD_FDOS)
/*-----------------------------------------------------------------------------
- * do_fdosboot --
+ * do_fdosboot --
*-----------------------------------------------------------------------------
*/
int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
@@ -45,53 +45,53 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
int rcode = 0;
char buf [10];
int drive = CFG_FDC_DRIVE_NUMBER;
-
+
/* pre-set load_addr */
if ((ep = getenv("loadaddr")) != NULL) {
- load_addr = simple_strtoul(ep, NULL, 16);
+ load_addr = simple_strtoul(ep, NULL, 16);
}
/* pre-set Boot file name */
if ((name = getenv("bootfile")) == NULL) {
- name = "uImage";
+ name = "uImage";
}
switch (argc) {
case 1:
- break;
+ break;
case 2:
/* only one arg - accept two forms:
- * just load address, or just boot file name.
- * The latter form must be written "filename" here.
- */
- if (argv[1][0] == '"') { /* just boot filename */
- name = argv [1];
- } else { /* load address */
- load_addr = simple_strtoul(argv[1], NULL, 16);
- }
- break;
+ * just load address, or just boot file name.
+ * The latter form must be written "filename" here.
+ */
+ if (argv[1][0] == '"') { /* just boot filename */
+ name = argv [1];
+ } else { /* load address */
+ load_addr = simple_strtoul(argv[1], NULL, 16);
+ }
+ break;
case 3:
- load_addr = simple_strtoul(argv[1], NULL, 16);
- name = argv [2];
- break;
+ load_addr = simple_strtoul(argv[1], NULL, 16);
+ name = argv [2];
+ break;
default:
- printf ("Usage:\n%s\n", cmdtp->usage);
- break;
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ break;
}
/* Init physical layer */
if (!fdc_fdos_init (drive)) {
- return (-1);
+ return (-1);
}
-
+
/* Open file */
if (dos_open (name) < 0) {
- printf ("Unable to open %s\n", name);
- return 1;
+ printf ("Unable to open %s\n", name);
+ return 1;
}
if ((size = dos_read (load_addr)) < 0) {
- printf ("boot error\n");
- return 1;
+ printf ("boot error\n");
+ return 1;
}
flush_cache (load_addr, size);
@@ -99,47 +99,59 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
setenv("filesize", buf);
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
- size, load_addr);
-
+ size, load_addr);
+
/* Check if we should attempt an auto-start */
if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
- char *local_args[2];
- extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
- local_args[0] = argv[0];
- local_args[1] = NULL;
- printf ("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
- rcode = do_bootm (cmdtp, 0, 1, local_args);
+ char *local_args[2];
+ extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
+ local_args[0] = argv[0];
+ local_args[1] = NULL;
+ printf ("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
+ rcode = do_bootm (cmdtp, 0, 1, local_args);
}
return rcode;
}
/*-----------------------------------------------------------------------------
- * do_fdosls --
+ * do_fdosls --
*-----------------------------------------------------------------------------
*/
int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *path = "";
int drive = CFG_FDC_DRIVE_NUMBER;
-
+
switch (argc) {
case 1:
- break;
+ break;
case 2:
- path = argv [1];
- break;
+ path = argv [1];
+ break;
}
/* Init physical layer */
if (!fdc_fdos_init (drive)) {
- return (-1);
+ return (-1);
}
/* Open directory */
if (dos_open (path) < 0) {
- printf ("Unable to open %s\n", path);
- return 1;
+ printf ("Unable to open %s\n", path);
+ return 1;
}
return (dos_dir ());
}
-#endif
+cmd_tbl_t U_BOOT_CMD(FDOS_BOOT) = MK_CMD_ENTRY(
+ "fdosboot", 3, 0, do_fdosboot,
+ "fdosboot- boot from a dos floppy file\n",
+ "[loadAddr] [filename]\n"
+);
+
+cmd_tbl_t U_BOOT_CMD(FDOS_LS) = MK_CMD_ENTRY(
+ "fdosls", 2, 0, do_fdosls,
+ "fdosls - list files in a directory\n",
+ "[directory]\n"
+);
+
+#endif /* CONFIG_COMMANDS & CFG_CMD_FDOS */