Blame view
cmd/ide.c
4 KB
c609719b8
|
1 |
/* |
34c202c7e
|
2 |
* (C) Copyright 2000-2011 |
c609719b8
|
3 4 |
* Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601
|
5 |
* SPDX-License-Identifier: GPL-2.0+ |
c609719b8
|
6 7 8 9 10 |
*/ /* * IDE support */ |
113bfe48b
|
11 |
|
c609719b8
|
12 |
#include <common.h> |
2a981dc2c
|
13 |
#include <blk.h> |
c609719b8
|
14 15 16 17 18 |
#include <config.h> #include <watchdog.h> #include <command.h> #include <image.h> #include <asm/byteorder.h> |
f98984cb1
|
19 |
#include <asm/io.h> |
735dd97b1
|
20 |
|
c609719b8
|
21 22 23 |
#if defined(CONFIG_IDE_8xx_DIRECT) || defined(CONFIG_IDE_PCMCIA) # include <pcmcia.h> #endif |
735dd97b1
|
24 |
|
c609719b8
|
25 26 |
#include <ide.h> #include <ata.h> |
735dd97b1
|
27 |
|
c609719b8
|
28 29 30 |
#ifdef CONFIG_STATUS_LED # include <status_led.h> #endif |
735dd97b1
|
31 |
|
c609719b8
|
32 33 |
/* Current I/O Device */ static int curr_device = -1; |
ed73508de
|
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int rcode = 0; switch (argc) { case 0: case 1: return CMD_RET_USAGE; case 2: if (strncmp(argv[1], "res", 3) == 0) { puts(" Reset IDE" #ifdef CONFIG_IDE_8xx_DIRECT " on PCMCIA " PCMCIA_SLOT_MSG #endif ": "); ide_init(); return 0; } else if (strncmp(argv[1], "inf", 3) == 0) { |
e9be1ee75
|
54 |
blk_list_devices(IF_TYPE_IDE); |
ed73508de
|
55 56 57 |
return 0; } else if (strncmp(argv[1], "dev", 3) == 0) { |
e9be1ee75
|
58 59 60 61 62 |
if (blk_print_device_num(IF_TYPE_IDE, curr_device)) { printf(" no IDE devices available "); return CMD_RET_FAILURE; |
ed73508de
|
63 |
} |
e9be1ee75
|
64 |
|
ed73508de
|
65 66 |
return 0; } else if (strncmp(argv[1], "part", 4) == 0) { |
e9be1ee75
|
67 68 69 70 71 |
if (blk_list_part(IF_TYPE_IDE)) printf(" no IDE devices available "); return 1; |
ed73508de
|
72 73 74 75 76 |
} return CMD_RET_USAGE; case 3: if (strncmp(argv[1], "dev", 3) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); |
c609719b8
|
77 |
|
e9be1ee75
|
78 79 80 81 82 83 |
if (!blk_show_device(IF_TYPE_IDE, dev)) { curr_device = dev; printf("... is now current device "); } else { return CMD_RET_FAILURE; |
ed73508de
|
84 |
} |
ed73508de
|
85 86 87 |
return 0; } else if (strncmp(argv[1], "part", 4) == 0) { int dev = (int)simple_strtoul(argv[2], NULL, 10); |
c609719b8
|
88 |
|
e9be1ee75
|
89 90 91 92 93 |
if (blk_print_part_devnum(IF_TYPE_IDE, dev)) { printf(" IDE device %d not available ", dev); return CMD_RET_FAILURE; |
ed73508de
|
94 |
} |
e9be1ee75
|
95 |
return 1; |
ed73508de
|
96 |
} |
c609719b8
|
97 |
|
ed73508de
|
98 99 100 |
return CMD_RET_USAGE; default: /* at least 4 args */ |
c609719b8
|
101 |
|
ed73508de
|
102 103 104 |
if (strcmp(argv[1], "read") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); |
ed73508de
|
105 |
ulong n; |
c609719b8
|
106 |
|
ed73508de
|
107 108 |
#ifdef CONFIG_SYS_64BIT_LBA lbaint_t blk = simple_strtoull(argv[3], NULL, 16); |
c609719b8
|
109 |
|
ed73508de
|
110 111 112 113 114 |
printf(" IDE read: device %d block # %lld, count %ld...", curr_device, blk, cnt); #else lbaint_t blk = simple_strtoul(argv[3], NULL, 16); |
c609719b8
|
115 |
|
ed73508de
|
116 117 118 119 |
printf(" IDE read: device %d block # %ld, count %ld...", curr_device, blk, cnt); #endif |
c609719b8
|
120 |
|
e9be1ee75
|
121 122 |
n = blk_read_devnum(IF_TYPE_IDE, curr_device, blk, cnt, (ulong *)addr); |
c609719b8
|
123 |
|
ed73508de
|
124 125 126 127 128 129 130 131 132 133 134 |
printf("%ld blocks read: %s ", n, (n == cnt) ? "OK" : "ERROR"); if (n == cnt) return 0; else return 1; } else if (strcmp(argv[1], "write") == 0) { ulong addr = simple_strtoul(argv[2], NULL, 16); ulong cnt = simple_strtoul(argv[4], NULL, 16); ulong n; |
c609719b8
|
135 |
|
6d0f6bcf3
|
136 |
#ifdef CONFIG_SYS_64BIT_LBA |
ed73508de
|
137 138 139 140 141 |
lbaint_t blk = simple_strtoull(argv[3], NULL, 16); printf(" IDE write: device %d block # %lld, count %ld...", curr_device, blk, cnt); |
413bf5862
|
142 |
#else |
ed73508de
|
143 144 145 146 147 |
lbaint_t blk = simple_strtoul(argv[3], NULL, 16); printf(" IDE write: device %d block # %ld, count %ld...", curr_device, blk, cnt); |
413bf5862
|
148 |
#endif |
e9be1ee75
|
149 150 |
n = blk_write_devnum(IF_TYPE_IDE, curr_device, blk, cnt, (ulong *)addr); |
ed73508de
|
151 152 153 154 155 156 157 158 159 160 |
printf("%ld blocks written: %s ", n, n == cnt ? "OK" : "ERROR"); if (n == cnt) return 0; else return 1; } else { return CMD_RET_USAGE; |
c40b29568
|
161 |
} |
c40b29568
|
162 |
|
ed73508de
|
163 164 165 |
return rcode; } } |
c40b29568
|
166 |
|
ed73508de
|
167 168 169 170 |
int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { return common_diskboot(cmdtp, "ide", argc, argv); } |
c609719b8
|
171 |
|
34c202c7e
|
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
U_BOOT_CMD(ide, 5, 1, do_ide, "IDE sub-system", "reset - reset IDE controller " "ide info - show available IDE devices " "ide device [dev] - show or set current device " "ide part [dev] - print partition table of one or all IDE devices " "ide read addr blk# cnt " "ide write addr blk# cnt - read/write `cnt'" " blocks starting at block `blk#' " " to/from memory address `addr'"); U_BOOT_CMD(diskboot, 3, 1, do_diskboot, "boot from IDE device", "loadAddr dev:part"); |