Blame view
common/cmd_fdos.c
3.57 KB
2262cfeef
|
1 2 |
/* * (C) Copyright 2002 |
fa82f871c
|
3 |
* Stäubli Faverges - <www.staubli.com> |
2262cfeef
|
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
* Pierre AUBERT p.aubert@staubli.com * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * Dos floppy support */ #include <common.h> #include <config.h> #include <command.h> #include <fdc.h> |
2262cfeef
|
33 |
/*----------------------------------------------------------------------------- |
8bde7f776
|
34 |
* do_fdosboot -- |
2262cfeef
|
35 36 |
*----------------------------------------------------------------------------- */ |
54841ab50
|
37 |
int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2262cfeef
|
38 39 40 41 |
{ char *name; char *ep; int size; |
fbe4b5cbd
|
42 |
char buf [12]; |
6d0f6bcf3
|
43 |
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; |
8bde7f776
|
44 |
|
2262cfeef
|
45 46 |
/* pre-set load_addr */ if ((ep = getenv("loadaddr")) != NULL) { |
8bde7f776
|
47 |
load_addr = simple_strtoul(ep, NULL, 16); |
2262cfeef
|
48 49 50 51 |
} /* pre-set Boot file name */ if ((name = getenv("bootfile")) == NULL) { |
8bde7f776
|
52 |
name = "uImage"; |
2262cfeef
|
53 54 55 56 |
} switch (argc) { case 1: |
8bde7f776
|
57 |
break; |
2262cfeef
|
58 59 |
case 2: /* only one arg - accept two forms: |
8bde7f776
|
60 61 62 63 64 65 66 67 68 |
* 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
|
69 |
case 3: |
8bde7f776
|
70 71 72 |
load_addr = simple_strtoul(argv[1], NULL, 16); name = argv [2]; break; |
2262cfeef
|
73 |
default: |
4c12eeb8b
|
74 |
return CMD_RET_USAGE; |
2262cfeef
|
75 76 77 78 |
} /* Init physical layer */ if (!fdc_fdos_init (drive)) { |
8bde7f776
|
79 |
return (-1); |
2262cfeef
|
80 |
} |
8bde7f776
|
81 |
|
2262cfeef
|
82 83 |
/* Open file */ if (dos_open (name) < 0) { |
8bde7f776
|
84 85 86 |
printf ("Unable to open %s ", name); return 1; |
2262cfeef
|
87 88 |
} if ((size = dos_read (load_addr)) < 0) { |
8bde7f776
|
89 90 91 |
printf ("boot error "); return 1; |
2262cfeef
|
92 93 94 95 96 97 98 99 |
} flush_cache (load_addr, size); sprintf(buf, "%x", size); setenv("filesize", buf); printf("Floppy DOS load complete: %d bytes loaded to 0x%lx ", |
8bde7f776
|
100 |
size, load_addr); |
67d668bf9
|
101 |
return bootm_maybe_autostart(cmdtp, argv[0]); |
2262cfeef
|
102 103 104 |
} /*----------------------------------------------------------------------------- |
8bde7f776
|
105 |
* do_fdosls -- |
2262cfeef
|
106 107 |
*----------------------------------------------------------------------------- */ |
54841ab50
|
108 |
int do_fdosls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2262cfeef
|
109 110 |
{ char *path = ""; |
6d0f6bcf3
|
111 |
int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; |
8bde7f776
|
112 |
|
2262cfeef
|
113 114 |
switch (argc) { case 1: |
8bde7f776
|
115 |
break; |
2262cfeef
|
116 |
case 2: |
8bde7f776
|
117 118 |
path = argv [1]; break; |
2262cfeef
|
119 120 121 122 |
} /* Init physical layer */ if (!fdc_fdos_init (drive)) { |
8bde7f776
|
123 |
return (-1); |
2262cfeef
|
124 125 126 |
} /* Open directory */ if (dos_open (path) < 0) { |
8bde7f776
|
127 128 129 |
printf ("Unable to open %s ", path); return 1; |
2262cfeef
|
130 131 132 |
} return (dos_dir ()); } |
0d4983930
|
133 134 |
U_BOOT_CMD( fdosboot, 3, 0, do_fdosboot, |
2fb2604d5
|
135 |
"boot from a dos floppy file", |
a89c33db9
|
136 |
"[loadAddr] [filename]" |
8bde7f776
|
137 |
); |
0d4983930
|
138 139 |
U_BOOT_CMD( fdosls, 2, 0, do_fdosls, |
2fb2604d5
|
140 |
"list files in a directory", |
a89c33db9
|
141 |
"[directory]" |
8bde7f776
|
142 |
); |