3 * Denis Peter, MPL AG Switzerland
5 * SPDX-License-Identifier: GPL-2.0+
15 static int scsi_curr_dev; /* current device */
18 * scsi boot command intepreter. Derived from diskboot
20 int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
22 return common_diskboot(cmdtp, "scsi", argc, argv);
26 * scsi command intepreter
28 int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
35 if (strncmp(argv[1], "res", 3) == 0) {
36 printf("\nReset SCSI\n");
41 if (strncmp(argv[1], "inf", 3) == 0) {
42 blk_list_devices(IF_TYPE_SCSI);
45 if (strncmp(argv[1], "dev", 3) == 0) {
46 if (blk_print_device_num(IF_TYPE_SCSI, scsi_curr_dev)) {
47 printf("\nno SCSI devices available\n");
48 return CMD_RET_FAILURE;
53 if (strncmp(argv[1], "scan", 4) == 0) {
57 if (strncmp(argv[1], "part", 4) == 0) {
58 if (blk_list_part(IF_TYPE_SCSI))
59 printf("\nno SCSI devices available\n");
64 if (strncmp(argv[1], "dev", 3) == 0) {
65 int dev = (int)simple_strtoul(argv[2], NULL, 10);
67 if (!blk_show_device(IF_TYPE_SCSI, dev)) {
69 printf("... is now current device\n");
71 return CMD_RET_FAILURE;
75 if (strncmp(argv[1], "part", 4) == 0) {
76 int dev = (int)simple_strtoul(argv[2], NULL, 10);
78 if (blk_print_part_devnum(IF_TYPE_SCSI, dev)) {
79 printf("\nSCSI device %d not available\n",
81 return CMD_RET_FAILURE;
88 if (strcmp(argv[1], "read") == 0) {
89 ulong addr = simple_strtoul(argv[2], NULL, 16);
90 ulong blk = simple_strtoul(argv[3], NULL, 16);
91 ulong cnt = simple_strtoul(argv[4], NULL, 16);
94 printf("\nSCSI read: device %d block # %ld, count %ld ... ",
95 scsi_curr_dev, blk, cnt);
96 n = blk_read_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk,
98 printf("%ld blocks read: %s\n", n,
99 n == cnt ? "OK" : "ERROR");
101 } else if (strcmp(argv[1], "write") == 0) {
102 ulong addr = simple_strtoul(argv[2], NULL, 16);
103 ulong blk = simple_strtoul(argv[3], NULL, 16);
104 ulong cnt = simple_strtoul(argv[4], NULL, 16);
107 printf("\nSCSI write: device %d block # %ld, count %ld ... ",
108 scsi_curr_dev, blk, cnt);
109 n = blk_write_devnum(IF_TYPE_SCSI, scsi_curr_dev, blk,
111 printf("%ld blocks written: %s\n", n,
112 n == cnt ? "OK" : "ERROR");
116 return CMD_RET_USAGE;
122 "reset - reset SCSI controller\n"
123 "scsi info - show available SCSI devices\n"
124 "scsi scan - (re-)scan SCSI bus\n"
125 "scsi device [dev] - show or set current device\n"
126 "scsi part [dev] - print partition table of one or all SCSI devices\n"
127 "scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
128 " to memory address `addr'\n"
129 "scsi write addr blk# cnt - write `cnt' blocks starting at block\n"
130 " `blk#' from memory address `addr'"
134 scsiboot, 3, 1, do_scsiboot,
135 "boot from SCSI device",