2002-11-18 00:14:45 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
2011-08-04 16:45:45 +00:00
|
|
|
* Stäubli Faverges - <www.staubli.com>
|
2002-11-18 00:14:45 +00:00
|
|
|
* Pierre AUBERT p.aubert@staubli.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2002-11-18 00:14:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dos floppy support
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <fdc.h>
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
2003-06-27 21:31:46 +00:00
|
|
|
* do_fdosboot --
|
2002-11-18 00:14:45 +00:00
|
|
|
*-----------------------------------------------------------------------------
|
|
|
|
*/
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2002-11-18 00:14:45 +00:00
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char *ep;
|
|
|
|
int size;
|
2008-10-16 13:01:15 +00:00
|
|
|
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* pre-set load_addr */
|
|
|
|
if ((ep = getenv("loadaddr")) != NULL) {
|
2003-06-27 21:31:46 +00:00
|
|
|
load_addr = simple_strtoul(ep, NULL, 16);
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* pre-set Boot file name */
|
|
|
|
if ((name = getenv("bootfile")) == NULL) {
|
2003-06-27 21:31:46 +00:00
|
|
|
name = "uImage";
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (argc) {
|
|
|
|
case 1:
|
2003-06-27 21:31:46 +00:00
|
|
|
break;
|
2002-11-18 00:14:45 +00:00
|
|
|
case 2:
|
|
|
|
/* only one arg - accept two forms:
|
2003-06-27 21:31:46 +00:00
|
|
|
* 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;
|
2002-11-18 00:14:45 +00:00
|
|
|
case 3:
|
2003-06-27 21:31:46 +00:00
|
|
|
load_addr = simple_strtoul(argv[1], NULL, 16);
|
|
|
|
name = argv [2];
|
|
|
|
break;
|
2002-11-18 00:14:45 +00:00
|
|
|
default:
|
2011-12-10 08:44:01 +00:00
|
|
|
return CMD_RET_USAGE;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init physical layer */
|
|
|
|
if (!fdc_fdos_init (drive)) {
|
2003-06-27 21:31:46 +00:00
|
|
|
return (-1);
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
/* Open file */
|
|
|
|
if (dos_open (name) < 0) {
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("Unable to open %s\n", name);
|
|
|
|
return 1;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
if ((size = dos_read (load_addr)) < 0) {
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("boot error\n");
|
|
|
|
return 1;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
flush_cache (load_addr, size);
|
|
|
|
|
2013-02-24 17:33:22 +00:00
|
|
|
setenv_hex("filesize", size);
|
2002-11-18 00:14:45 +00:00
|
|
|
|
|
|
|
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n",
|
2003-06-27 21:31:46 +00:00
|
|
|
size, load_addr);
|
|
|
|
|
2011-06-05 13:43:02 +00:00
|
|
|
return bootm_maybe_autostart(cmdtp, argv[0]);
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------------------
|
2003-06-27 21:31:46 +00:00
|
|
|
* do_fdosls --
|
2002-11-18 00:14:45 +00:00
|
|
|
*-----------------------------------------------------------------------------
|
|
|
|
*/
|
2010-06-28 20:00:46 +00:00
|
|
|
int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
2002-11-18 00:14:45 +00:00
|
|
|
{
|
|
|
|
char *path = "";
|
2008-10-16 13:01:15 +00:00
|
|
|
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2002-11-18 00:14:45 +00:00
|
|
|
switch (argc) {
|
|
|
|
case 1:
|
2003-06-27 21:31:46 +00:00
|
|
|
break;
|
2002-11-18 00:14:45 +00:00
|
|
|
case 2:
|
2003-06-27 21:31:46 +00:00
|
|
|
path = argv [1];
|
|
|
|
break;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init physical layer */
|
|
|
|
if (!fdc_fdos_init (drive)) {
|
2003-06-27 21:31:46 +00:00
|
|
|
return (-1);
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
/* Open directory */
|
|
|
|
if (dos_open (path) < 0) {
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("Unable to open %s\n", path);
|
|
|
|
return 1;
|
2002-11-18 00:14:45 +00:00
|
|
|
}
|
|
|
|
return (dos_dir ());
|
|
|
|
}
|
|
|
|
|
2003-07-01 21:06:45 +00:00
|
|
|
U_BOOT_CMD(
|
|
|
|
fdosboot, 3, 0, do_fdosboot,
|
2009-01-28 00:03:12 +00:00
|
|
|
"boot from a dos floppy file",
|
2009-05-24 15:06:54 +00:00
|
|
|
"[loadAddr] [filename]"
|
2003-06-27 21:31:46 +00:00
|
|
|
);
|
|
|
|
|
2003-07-01 21:06:45 +00:00
|
|
|
U_BOOT_CMD(
|
|
|
|
fdosls, 2, 0, do_fdosls,
|
2009-01-28 00:03:12 +00:00
|
|
|
"list files in a directory",
|
2009-05-24 15:06:54 +00:00
|
|
|
"[directory]"
|
2003-06-27 21:31:46 +00:00
|
|
|
);
|