2N/A * GRUB -- GRand Unified Bootloader 2N/A * Copyright (C) 2008 Free Software Foundation, Inc. 2N/A * GRUB is free software: you can redistribute it and/or modify 2N/A * it under the terms of the GNU General Public License as published by 2N/A * the Free Software Foundation, either version 3 of the License, or 2N/A * (at your option) any later version. 2N/A * GRUB is distributed in the hope that it will be useful, 2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2N/A * GNU General Public License for more details. 2N/A * You should have received a copy of the GNU General Public License 2N/A/* The USB Mass Storage Command Block Wrapper. */ 2N/A/* FIXME: remove limit. */ 2N/A /* Experimental support of RBC, MMC-2, UFI, SFF-8070i devices */ 2N/A /* Iterate over all endpoints of this interface, at least a 2N/A IN and OUT bulk endpoint are required. */ 2N/A /* Bulk IN endpoint. */ 2N/A /* Clear Halt is not possible yet! */ 2N/A /* grub_usb_clear_halt (usbdev, endp->endp_addr); */ 2N/A /* Bulk OUT endpoint. */ 2N/A /* Clear Halt is not possible yet! */ 2N/A /* grub_usb_clear_halt (usbdev, endp->endp_addr); */ 2N/A /* XXX: Activate the first configuration. */ 2N/A /* Query the amount of LUNs. */ 2N/A /* In case of a stall, clear the stall. */ 2N/A /* Just set the amount of LUNs to one. */ 2N/A /* luns = 0 means one LUN with ID 0 present ! */ 2N/A /* We get from device not number of LUNs but highest 2N/A * LUN number. LUNs are numbered from 0, 2N/A * i.e. number of LUNs is luns+1 ! */ 2N/A#
if 0
/* All this part should be probably deleted. 2N/A * This make trouble on some devices if they are not in 2N/A * Phase Error state - and there they should be not in such state... 2N/A * Bulk only mass storage reset procedure should be used only 2N/A * on place and in time when it is really necessary. */ 2N/A /* Reset recovery procedure */ 2N/A /* Bulk-Only Mass Storage Reset, after the reset commands 2N/A will be accepted. */ 2N/A /* Setup the request. */ 2N/A cbw.
lun =
scsi->
lun;
/* In USB MS CBW are LUN bits on another place than in SCSI CDB, both should be set correctly. */ 2N/A /* Debug print of CBW content. */ 2N/A grub_dprintf (
"usb",
"CBW: cmd:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
2N/A /* Write the request. 2N/A * XXX: Error recovery is maybe still not fully correct. */ 2N/A /* Read/write the data, (maybe) according to specification. */ 2N/A /* Debug print of received data. */ 2N/A grub_dprintf (
"usb",
"First 16 bytes of sent data:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
2N/A /* Debug print of sent data. */ 2N/A /* Read the status - (maybe) according to specification. */ 2N/A {
/* Bulk-only reset device. */ 2N/A /* Debug print of CSW content. */ 2N/A /* If phase error or not valid signature, do bulk-only reset device. */ 2N/A {
/* Bulk-only reset device. */ 2N/A /* If "command failed" status or data transfer failed -> error */ 2N/A "error communication with USB Mass Storage device");
2N/A "error communication with USB Mass Storage device");
2N/A "not USB Mass Storage device");
2N/A "unknown USB Mass Storage device");