Blame view
common/cmd_fdos.c
2.79 KB
2262cfeef * Patch by Daniel... |
1 2 |
/* * (C) Copyright 2002 |
fa82f871c Convert ISO-8859 ... |
3 |
* Stäubli Faverges - <www.staubli.com> |
2262cfeef * Patch by Daniel... |
4 5 |
* Pierre AUBERT p.aubert@staubli.com * |
1a4596601 Add GPL-2.0+ SPDX... |
6 |
* SPDX-License-Identifier: GPL-2.0+ |
2262cfeef * Patch by Daniel... |
7 8 9 10 11 12 13 14 15 16 |
*/ /* * Dos floppy support */ #include <common.h> #include <config.h> #include <command.h> #include <fdc.h> |
2262cfeef * Patch by Daniel... |
17 |
/*----------------------------------------------------------------------------- |
8bde7f776 * Code cleanup: |
18 |
* do_fdosboot -- |
2262cfeef * Patch by Daniel... |
19 20 |
*----------------------------------------------------------------------------- */ |
54841ab50 Make sure that ar... |
21 |
int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2262cfeef * Patch by Daniel... |
22 23 24 25 |
{ char *name; char *ep; int size; |
6d0f6bcf3 rename CFG_ macro... |
26 |
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; |
8bde7f776 * Code cleanup: |
27 |
|
2262cfeef * Patch by Daniel... |
28 29 |
/* pre-set load_addr */ if ((ep = getenv("loadaddr")) != NULL) { |
8bde7f776 * Code cleanup: |
30 |
load_addr = simple_strtoul(ep, NULL, 16); |
2262cfeef * Patch by Daniel... |
31 32 33 34 |
} /* pre-set Boot file name */ if ((name = getenv("bootfile")) == NULL) { |
8bde7f776 * Code cleanup: |
35 |
name = "uImage"; |
2262cfeef * Patch by Daniel... |
36 37 38 39 |
} switch (argc) { case 1: |
8bde7f776 * Code cleanup: |
40 |
break; |
2262cfeef * Patch by Daniel... |
41 42 |
case 2: /* only one arg - accept two forms: |
8bde7f776 * Code cleanup: |
43 44 45 46 47 48 49 50 51 |
* 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; |
2262cfeef * Patch by Daniel... |
52 |
case 3: |
8bde7f776 * Code cleanup: |
53 54 55 |
load_addr = simple_strtoul(argv[1], NULL, 16); name = argv [2]; break; |
2262cfeef * Patch by Daniel... |
56 |
default: |
4c12eeb8b Convert cmd_usage... |
57 |
return CMD_RET_USAGE; |
2262cfeef * Patch by Daniel... |
58 59 60 61 |
} /* Init physical layer */ if (!fdc_fdos_init (drive)) { |
8bde7f776 * Code cleanup: |
62 |
return (-1); |
2262cfeef * Patch by Daniel... |
63 |
} |
8bde7f776 * Code cleanup: |
64 |
|
2262cfeef * Patch by Daniel... |
65 66 |
/* Open file */ if (dos_open (name) < 0) { |
8bde7f776 * Code cleanup: |
67 68 69 |
printf ("Unable to open %s ", name); return 1; |
2262cfeef * Patch by Daniel... |
70 71 |
} if ((size = dos_read (load_addr)) < 0) { |
8bde7f776 * Code cleanup: |
72 73 74 |
printf ("boot error "); return 1; |
2262cfeef * Patch by Daniel... |
75 76 |
} flush_cache (load_addr, size); |
41ef372c1 common: Use new n... |
77 |
setenv_hex("filesize", size); |
2262cfeef * Patch by Daniel... |
78 79 80 |
printf("Floppy DOS load complete: %d bytes loaded to 0x%lx ", |
8bde7f776 * Code cleanup: |
81 |
size, load_addr); |
67d668bf9 autostart: unify ... |
82 |
return bootm_maybe_autostart(cmdtp, argv[0]); |
2262cfeef * Patch by Daniel... |
83 84 85 |
} /*----------------------------------------------------------------------------- |
8bde7f776 * Code cleanup: |
86 |
* do_fdosls -- |
2262cfeef * Patch by Daniel... |
87 88 |
*----------------------------------------------------------------------------- */ |
54841ab50 Make sure that ar... |
89 |
int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2262cfeef * Patch by Daniel... |
90 91 |
{ char *path = ""; |
6d0f6bcf3 rename CFG_ macro... |
92 |
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; |
8bde7f776 * Code cleanup: |
93 |
|
2262cfeef * Patch by Daniel... |
94 95 |
switch (argc) { case 1: |
8bde7f776 * Code cleanup: |
96 |
break; |
2262cfeef * Patch by Daniel... |
97 |
case 2: |
8bde7f776 * Code cleanup: |
98 99 |
path = argv [1]; break; |
2262cfeef * Patch by Daniel... |
100 101 102 103 |
} /* Init physical layer */ if (!fdc_fdos_init (drive)) { |
8bde7f776 * Code cleanup: |
104 |
return (-1); |
2262cfeef * Patch by Daniel... |
105 106 107 |
} /* Open directory */ if (dos_open (path) < 0) { |
8bde7f776 * Code cleanup: |
108 109 110 |
printf ("Unable to open %s ", path); return 1; |
2262cfeef * Patch by Daniel... |
111 112 113 |
} return (dos_dir ()); } |
0d4983930 Patch by Kenneth ... |
114 115 |
U_BOOT_CMD( fdosboot, 3, 0, do_fdosboot, |
2fb2604d5 Command usage cle... |
116 |
"boot from a dos floppy file", |
a89c33db9 General help mess... |
117 |
"[loadAddr] [filename]" |
8bde7f776 * Code cleanup: |
118 |
); |
0d4983930 Patch by Kenneth ... |
119 120 |
U_BOOT_CMD( fdosls, 2, 0, do_fdosls, |
2fb2604d5 Command usage cle... |
121 |
"list files in a directory", |
a89c33db9 General help mess... |
122 |
"[directory]" |
8bde7f776 * Code cleanup: |
123 |
); |