1 /* usbms.c - USB Mass Storage Support. */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2008 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
23 #include <grub/scsi.h>
24 #include <grub/scsicmd.h>
25 #include <grub/misc.h>
27 GRUB_MOD_LICENSE ("GPLv3+");
29 #define GRUB_USBMS_DIRECTION_BIT 7
31 /* Length of CBI command should be always 12 bytes */
32 #define GRUB_USBMS_CBI_CMD_SIZE 12
33 /* CBI class-specific USB request ADSC - it sends CBI (scsi) command to
34 * device in DATA stage */
35 #define GRUB_USBMS_CBI_ADSC_REQ 0x00
37 /* The USB Mass Storage Command Block Wrapper. */
40 grub_uint32_t signature
;
42 grub_uint32_t transfer_length
;
46 grub_uint8_t cbwcb
[16];
51 grub_uint32_t signature
;
53 grub_uint32_t residue
;
59 struct grub_usb_device
*dev
;
65 struct grub_usb_desc_endp
*in
;
66 struct grub_usb_desc_endp
*out
;
70 struct grub_usb_desc_endp
*intrpt
;
72 typedef struct grub_usbms_dev
*grub_usbms_dev_t
;
74 /* FIXME: remove limit. */
75 #define MAX_USBMS_DEVICES 128
76 static grub_usbms_dev_t grub_usbms_devices
[MAX_USBMS_DEVICES
];
77 static int first_available_slot
= 0;
80 grub_usbms_cbi_cmd (grub_usb_device_t dev
, int interface
,
83 return grub_usb_control_msg (dev
,
84 GRUB_USB_REQTYPE_CLASS_INTERFACE_OUT
,
85 GRUB_USBMS_CBI_ADSC_REQ
, 0, interface
,
86 GRUB_USBMS_CBI_CMD_SIZE
, (char*)cbicb
);
90 grub_usbms_cbi_reset (grub_usb_device_t dev
, int interface
)
92 /* Prepare array with Command Block Reset (=CBR) */
93 /* CBI specific communication reset command should be send to device
94 * via CBI USB class specific request ADCS */
97 grub_uint8_t opcode
; /* 0x1d = SEND DIAGNOSTIC */
98 grub_uint8_t lun
; /* 7-5 LUN, 4-0 flags - for CBR always = 0x04 */
100 /* XXX: There is collision between CBI and UFI specifications:
101 * CBI says 0xff, UFI says 0x00 ... probably it does
102 * not matter ... (?) */
103 } cbicb
= { 0x1d, 0x04,
104 { 0xff, 0xff, 0xff, 0xff, 0xff,
105 0xff, 0xff, 0xff, 0xff, 0xff }
108 return grub_usbms_cbi_cmd (dev
, interface
, (grub_uint8_t
*)&cbicb
);
111 static grub_usb_err_t
112 grub_usbms_bo_reset (grub_usb_device_t dev
, int interface
)
114 return grub_usb_control_msg (dev
, 0x21, 255, 0, interface
, 0, 0);
117 static grub_usb_err_t
118 grub_usbms_reset (grub_usbms_dev_t dev
)
120 if (dev
->protocol
== GRUB_USBMS_PROTOCOL_BULK
)
121 return grub_usbms_bo_reset (dev
->dev
, dev
->interface
);
123 return grub_usbms_cbi_reset (dev
->dev
, dev
->interface
);
127 grub_usbms_detach (grub_usb_device_t usbdev
, int config
, int interface
)
130 for (i
= 0; i
< ARRAY_SIZE (grub_usbms_devices
); i
++)
131 if (grub_usbms_devices
[i
] && grub_usbms_devices
[i
]->dev
== usbdev
132 && grub_usbms_devices
[i
]->interface
== interface
133 && grub_usbms_devices
[i
]->config
== config
)
135 grub_free (grub_usbms_devices
[i
]);
136 grub_usbms_devices
[i
] = 0;
141 grub_usbms_attach (grub_usb_device_t usbdev
, int configno
, int interfno
)
143 struct grub_usb_desc_if
*interf
144 = usbdev
->config
[configno
].interf
[interfno
].descif
;
146 grub_uint8_t luns
= 0;
148 grub_usb_err_t err
= GRUB_USB_ERR_NONE
;
150 grub_boot_time ("Attaching USB mass storage");
152 if (first_available_slot
== ARRAY_SIZE (grub_usbms_devices
))
155 curnum
= first_available_slot
;
156 first_available_slot
++;
158 interf
= usbdev
->config
[configno
].interf
[interfno
].descif
;
160 if ((interf
->subclass
!= GRUB_USBMS_SUBCLASS_BULK
161 /* Experimental support of RBC, MMC-2, UFI, SFF-8070i devices */
162 && interf
->subclass
!= GRUB_USBMS_SUBCLASS_RBC
163 && interf
->subclass
!= GRUB_USBMS_SUBCLASS_MMC2
164 && interf
->subclass
!= GRUB_USBMS_SUBCLASS_UFI
165 && interf
->subclass
!= GRUB_USBMS_SUBCLASS_SFF8070
)
166 || (interf
->protocol
!= GRUB_USBMS_PROTOCOL_BULK
167 && interf
->protocol
!= GRUB_USBMS_PROTOCOL_CBI
168 && interf
->protocol
!= GRUB_USBMS_PROTOCOL_CB
))
171 grub_usbms_devices
[curnum
] = grub_zalloc (sizeof (struct grub_usbms_dev
));
172 if (! grub_usbms_devices
[curnum
])
175 grub_usbms_devices
[curnum
]->dev
= usbdev
;
176 grub_usbms_devices
[curnum
]->interface
= interfno
;
177 grub_usbms_devices
[curnum
]->subclass
= interf
->subclass
;
178 grub_usbms_devices
[curnum
]->protocol
= interf
->protocol
;
180 grub_dprintf ("usbms", "alive\n");
182 /* Iterate over all endpoints of this interface, at least a
183 IN and OUT bulk endpoint are required. */
184 for (j
= 0; j
< interf
->endpointcnt
; j
++)
186 struct grub_usb_desc_endp
*endp
;
187 endp
= &usbdev
->config
[0].interf
[interfno
].descendp
[j
];
189 if ((endp
->endp_addr
& 128) && (endp
->attrib
& 3) == 2)
190 /* Bulk IN endpoint. */
191 grub_usbms_devices
[curnum
]->in
= endp
;
192 else if (!(endp
->endp_addr
& 128) && (endp
->attrib
& 3) == 2)
193 /* Bulk OUT endpoint. */
194 grub_usbms_devices
[curnum
]->out
= endp
;
195 else if ((endp
->endp_addr
& 128) && (endp
->attrib
& 3) == 3)
196 /* Interrupt (IN) endpoint. */
197 grub_usbms_devices
[curnum
]->intrpt
= endp
;
200 if (!grub_usbms_devices
[curnum
]->in
|| !grub_usbms_devices
[curnum
]->out
201 || ((grub_usbms_devices
[curnum
]->protocol
== GRUB_USBMS_PROTOCOL_CBI
)
202 && !grub_usbms_devices
[curnum
]->intrpt
))
204 grub_free (grub_usbms_devices
[curnum
]);
205 grub_usbms_devices
[curnum
] = 0;
209 grub_dprintf ("usbms", "alive\n");
211 /* XXX: Activate the first configuration. */
212 grub_usb_set_configuration (usbdev
, 1);
214 /* Query the amount of LUNs. */
215 if (grub_usbms_devices
[curnum
]->protocol
== GRUB_USBMS_PROTOCOL_BULK
)
216 { /* Only Bulk only devices support Get Max LUN command */
217 err
= grub_usb_control_msg (usbdev
, 0xA1, 254, 0, interfno
, 1, (char *) &luns
);
221 /* In case of a stall, clear the stall. */
222 if (err
== GRUB_USB_ERR_STALL
)
224 grub_usb_clear_halt (usbdev
, grub_usbms_devices
[curnum
]->in
->endp_addr
);
225 grub_usb_clear_halt (usbdev
, grub_usbms_devices
[curnum
]->out
->endp_addr
);
227 /* Just set the amount of LUNs to one. */
228 grub_errno
= GRUB_ERR_NONE
;
229 grub_usbms_devices
[curnum
]->luns
= 1;
232 /* luns = 0 means one LUN with ID 0 present ! */
233 /* We get from device not number of LUNs but highest
234 * LUN number. LUNs are numbered from 0,
235 * i.e. number of LUNs is luns+1 ! */
236 grub_usbms_devices
[curnum
]->luns
= luns
+ 1;
239 /* XXX: Does CBI devices support multiple LUNs ?
240 * I.e., should we detect number of device's LUNs ? (How?) */
241 grub_usbms_devices
[curnum
]->luns
= 1;
243 grub_dprintf ("usbms", "alive\n");
245 usbdev
->config
[configno
].interf
[interfno
].detach_hook
= grub_usbms_detach
;
247 grub_boot_time ("Attached USB mass storage");
249 #if 0 /* All this part should be probably deleted.
250 * This make trouble on some devices if they are not in
251 * Phase Error state - and there they should be not in such state...
252 * Bulk only mass storage reset procedure should be used only
253 * on place and in time when it is really necessary. */
254 /* Reset recovery procedure */
255 /* Bulk-Only Mass Storage Reset, after the reset commands
257 grub_usbms_reset (usbdev
, i
);
258 grub_usb_clear_halt (usbdev
, usbms
->in
->endp_addr
);
259 grub_usb_clear_halt (usbdev
, usbms
->out
->endp_addr
);
268 grub_usbms_iterate (grub_scsi_dev_iterate_hook_t hook
, void *hook_data
,
269 grub_disk_pull_t pull
)
273 if (pull
!= GRUB_DISK_PULL_NONE
)
276 grub_usb_poll_devices (1);
278 for (i
= 0; i
< ARRAY_SIZE (grub_usbms_devices
); i
++)
279 if (grub_usbms_devices
[i
])
281 if (hook (GRUB_SCSI_SUBSYSTEM_USBMS
, i
, grub_usbms_devices
[i
]->luns
,
290 grub_usbms_transfer_bo (struct grub_scsi
*scsi
, grub_size_t cmdsize
, char *cmd
,
291 grub_size_t size
, char *buf
, int read_write
)
293 struct grub_usbms_cbw cbw
;
294 grub_usbms_dev_t dev
= (grub_usbms_dev_t
) scsi
->data
;
295 struct grub_usbms_csw status
;
296 static grub_uint32_t tag
= 0;
297 grub_usb_err_t err
= GRUB_USB_ERR_NONE
;
298 grub_usb_err_t errCSW
= GRUB_USB_ERR_NONE
;
299 int retrycnt
= 3 + 1;
306 return grub_error (GRUB_ERR_IO
, "USB Mass Storage stalled");
308 /* Setup the request. */
309 grub_memset (&cbw
, 0, sizeof (cbw
));
310 cbw
.signature
= grub_cpu_to_le32_compile_time (0x43425355);
312 cbw
.transfer_length
= grub_cpu_to_le32 (size
);
313 cbw
.flags
= (!read_write
) << GRUB_USBMS_DIRECTION_BIT
;
314 cbw
.lun
= scsi
->lun
; /* In USB MS CBW are LUN bits on another place than in SCSI CDB, both should be set correctly. */
315 cbw
.length
= cmdsize
;
316 grub_memcpy (cbw
.cbwcb
, cmd
, cmdsize
);
318 /* Debug print of CBW content. */
319 grub_dprintf ("usb", "CBW: sign=0x%08x tag=0x%08x len=0x%08x\n",
320 cbw
.signature
, cbw
.tag
, cbw
.transfer_length
);
321 grub_dprintf ("usb", "CBW: flags=0x%02x lun=0x%02x CB_len=0x%02x\n",
322 cbw
.flags
, cbw
.lun
, cbw
.length
);
323 grub_dprintf ("usb", "CBW: cmd:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
324 cbw
.cbwcb
[ 0], cbw
.cbwcb
[ 1], cbw
.cbwcb
[ 2], cbw
.cbwcb
[ 3],
325 cbw
.cbwcb
[ 4], cbw
.cbwcb
[ 5], cbw
.cbwcb
[ 6], cbw
.cbwcb
[ 7],
326 cbw
.cbwcb
[ 8], cbw
.cbwcb
[ 9], cbw
.cbwcb
[10], cbw
.cbwcb
[11],
327 cbw
.cbwcb
[12], cbw
.cbwcb
[13], cbw
.cbwcb
[14], cbw
.cbwcb
[15]);
329 /* Write the request.
330 * XXX: Error recovery is maybe still not fully correct. */
331 err
= grub_usb_bulk_write (dev
->dev
, dev
->out
,
332 sizeof (cbw
), (char *) &cbw
);
335 if (err
== GRUB_USB_ERR_STALL
)
337 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
343 /* Read/write the data, (maybe) according to specification. */
344 if (size
&& (read_write
== 0))
346 err
= grub_usb_bulk_read (dev
->dev
, dev
->in
, size
, buf
);
347 grub_dprintf ("usb", "read: %d %d\n", err
, GRUB_USB_ERR_STALL
);
350 if (err
== GRUB_USB_ERR_STALL
)
351 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
354 /* Debug print of received data. */
355 grub_dprintf ("usb", "buf:\n");
359 for (i
= 0; i
< size
; i
++)
360 grub_dprintf ("usb", "0x%02x: 0x%02x\n", i
, buf
[i
]);
363 grub_dprintf ("usb", "Too much data for debug print...\n");
367 err
= grub_usb_bulk_write (dev
->dev
, dev
->out
, size
, buf
);
368 grub_dprintf ("usb", "write: %d %d\n", err
, GRUB_USB_ERR_STALL
);
369 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",
370 buf
[ 0], buf
[ 1], buf
[ 2], buf
[ 3],
371 buf
[ 4], buf
[ 5], buf
[ 6], buf
[ 7],
372 buf
[ 8], buf
[ 9], buf
[10], buf
[11],
373 buf
[12], buf
[13], buf
[14], buf
[15]);
376 if (err
== GRUB_USB_ERR_STALL
)
377 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
380 /* Debug print of sent data. */
384 for (i
=0; i
<size
; i
++)
385 grub_dprintf ("usb", "0x%02x: 0x%02x\n", i
, buf
[i
]);
388 grub_dprintf ("usb", "Too much data for debug print...\n");
391 /* Read the status - (maybe) according to specification. */
393 errCSW
= grub_usb_bulk_read (dev
->dev
, dev
->in
,
394 sizeof (status
), (char *) &status
);
397 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
398 errCSW
= grub_usb_bulk_read (dev
->dev
, dev
->in
,
399 sizeof (status
), (char *) &status
);
401 { /* Bulk-only reset device. */
402 grub_dprintf ("usb", "Bulk-only reset device - errCSW\n");
403 grub_usbms_reset (dev
);
404 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
405 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
410 /* Debug print of CSW content. */
411 grub_dprintf ("usb", "CSW: sign=0x%08x tag=0x%08x resid=0x%08x\n",
412 status
.signature
, status
.tag
, status
.residue
);
413 grub_dprintf ("usb", "CSW: status=0x%02x\n", status
.status
);
415 /* If phase error or not valid signature, do bulk-only reset device. */
416 if ((status
.status
== 2) ||
417 (status
.signature
!= grub_cpu_to_le32_compile_time(0x53425355)))
418 { /* Bulk-only reset device. */
419 grub_dprintf ("usb", "Bulk-only reset device - bad status\n");
420 grub_usbms_reset (dev
);
421 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
422 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
427 /* If "command failed" status or data transfer failed -> error */
428 if ((status
.status
|| err
) && !read_write
)
429 return grub_error (GRUB_ERR_READ_ERROR
,
430 "error communication with USB Mass Storage device");
431 else if ((status
.status
|| err
) && read_write
)
432 return grub_error (GRUB_ERR_WRITE_ERROR
,
433 "error communication with USB Mass Storage device");
435 return GRUB_ERR_NONE
;
439 grub_usbms_transfer_cbi (struct grub_scsi
*scsi
, grub_size_t cmdsize
, char *cmd
,
440 grub_size_t size
, char *buf
, int read_write
)
442 grub_usbms_dev_t dev
= (grub_usbms_dev_t
) scsi
->data
;
443 int retrycnt
= 3 + 1;
444 grub_usb_err_t err
= GRUB_USB_ERR_NONE
;
445 grub_uint8_t cbicb
[GRUB_USBMS_CBI_CMD_SIZE
];
446 grub_uint16_t status
;
451 return grub_error (GRUB_ERR_IO
, "USB Mass Storage CBI failed");
453 /* Setup the request. */
454 grub_memset (cbicb
, 0, sizeof (cbicb
));
455 grub_memcpy (cbicb
, cmd
,
456 cmdsize
>= GRUB_USBMS_CBI_CMD_SIZE
457 ? GRUB_USBMS_CBI_CMD_SIZE
460 /* Debug print of CBIcb content. */
461 grub_dprintf ("usb", "cbicb:\n %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
462 cbicb
[ 0], cbicb
[ 1], cbicb
[ 2], cbicb
[ 3],
463 cbicb
[ 4], cbicb
[ 5], cbicb
[ 6], cbicb
[ 7],
464 cbicb
[ 8], cbicb
[ 9], cbicb
[10], cbicb
[11]);
466 /* Write the request.
467 * XXX: Error recovery is maybe not correct. */
468 err
= grub_usbms_cbi_cmd (dev
->dev
, dev
->interface
, cbicb
);
471 grub_dprintf ("usb", "CBI cmdcb setup err=%d\n", err
);
472 if (err
== GRUB_USB_ERR_STALL
)
474 /* Stall in this place probably means bad or unsupported
475 * command, so we will not try it again. */
476 return grub_error (GRUB_ERR_IO
, "USB Mass Storage CBI request failed");
478 else if (dev
->protocol
== GRUB_USBMS_PROTOCOL_CBI
)
480 /* Try to get status from interrupt pipe */
481 err
= grub_usb_bulk_read (dev
->dev
, dev
->intrpt
,
483 grub_dprintf ("usb", "CBI cmdcb setup status: err=%d, status=0x%x\n", err
, status
);
485 /* Any other error could be transport problem, try it again */
489 /* Read/write the data, (maybe) according to specification. */
490 if (size
&& (read_write
== 0))
492 err
= grub_usb_bulk_read (dev
->dev
, dev
->in
, size
, buf
);
493 grub_dprintf ("usb", "read: %d\n", err
);
496 if (err
== GRUB_USB_ERR_STALL
)
497 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
503 err
= grub_usb_bulk_write (dev
->dev
, dev
->out
, size
, buf
);
504 grub_dprintf ("usb", "write: %d\n", err
);
507 if (err
== GRUB_USB_ERR_STALL
)
508 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
513 /* XXX: It is not clear to me yet, how to check status of CBI
514 * data transfer on devices without interrupt pipe.
515 * AFAIK there is probably no status phase to indicate possibly
516 * bad transported data.
517 * Maybe we should do check on higher level, i.e. issue RequestSense
518 * command (we do it already in scsi.c) and check returned values
519 * (we do not it yet) - ? */
520 if (dev
->protocol
== GRUB_USBMS_PROTOCOL_CBI
)
521 { /* Check status in interrupt pipe */
522 err
= grub_usb_bulk_read (dev
->dev
, dev
->intrpt
,
524 grub_dprintf ("usb", "read status: %d\n", err
);
527 /* Try to reset device, because it is probably not standard
529 grub_usbms_reset (dev
);
530 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
531 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
532 grub_usb_clear_halt (dev
->dev
, dev
->intrpt
->endp_addr
);
535 if (dev
->subclass
== GRUB_USBMS_SUBCLASS_UFI
)
537 /* These devices should return bASC and bASCQ */
539 /* Some error, currently we don't care what it is... */
542 else if (dev
->subclass
== GRUB_USBMS_SUBCLASS_RBC
)
544 /* XXX: I don't understand what returns RBC subclass devices,
545 * so I don't check it - maybe somebody helps ? */
549 /* Any other device should return bType = 0 and some bValue */
551 return grub_error (GRUB_ERR_IO
, "USB Mass Storage CBI status type != 0");
552 status
= (status
& 0x0300) >> 8;
560 case 2 : /* Phase error */
561 case 3 : /* Persistent Failure */
562 grub_dprintf ("usb", "CBI reset device - phase error or persistent failure\n");
563 grub_usbms_reset (dev
);
564 grub_usb_clear_halt (dev
->dev
, dev
->in
->endp_addr
);
565 grub_usb_clear_halt (dev
->dev
, dev
->out
->endp_addr
);
566 grub_usb_clear_halt (dev
->dev
, dev
->intrpt
->endp_addr
);
574 return grub_error (GRUB_ERR_IO
, "USB error %d", err
);
576 return GRUB_ERR_NONE
;
581 grub_usbms_transfer (struct grub_scsi
*scsi
, grub_size_t cmdsize
, char *cmd
,
582 grub_size_t size
, char *buf
, int read_write
)
584 grub_usbms_dev_t dev
= (grub_usbms_dev_t
) scsi
->data
;
586 if (dev
->protocol
== GRUB_USBMS_PROTOCOL_BULK
)
587 return grub_usbms_transfer_bo (scsi
, cmdsize
, cmd
, size
, buf
,
590 return grub_usbms_transfer_cbi (scsi
, cmdsize
, cmd
, size
, buf
,
595 grub_usbms_read (struct grub_scsi
*scsi
, grub_size_t cmdsize
, char *cmd
,
596 grub_size_t size
, char *buf
)
598 return grub_usbms_transfer (scsi
, cmdsize
, cmd
, size
, buf
, 0);
602 grub_usbms_write (struct grub_scsi
*scsi
, grub_size_t cmdsize
, char *cmd
,
603 grub_size_t size
, const char *buf
)
605 return grub_usbms_transfer (scsi
, cmdsize
, cmd
, size
, (char *) buf
, 1);
609 grub_usbms_open (int id
, int devnum
, struct grub_scsi
*scsi
)
611 if (id
!= GRUB_SCSI_SUBSYSTEM_USBMS
)
612 return grub_error (GRUB_ERR_UNKNOWN_DEVICE
,
613 "not USB Mass Storage device");
615 if (!grub_usbms_devices
[devnum
])
616 grub_usb_poll_devices (1);
618 if (!grub_usbms_devices
[devnum
])
619 return grub_error (GRUB_ERR_UNKNOWN_DEVICE
,
620 "unknown USB Mass Storage device");
622 scsi
->data
= grub_usbms_devices
[devnum
];
623 scsi
->luns
= grub_usbms_devices
[devnum
]->luns
;
625 return GRUB_ERR_NONE
;
628 static struct grub_scsi_dev grub_usbms_dev
=
630 .iterate
= grub_usbms_iterate
,
631 .open
= grub_usbms_open
,
632 .read
= grub_usbms_read
,
633 .write
= grub_usbms_write
636 static struct grub_usb_attach_desc attach_hook
=
638 .class = GRUB_USB_CLASS_MASS_STORAGE
,
639 .hook
= grub_usbms_attach
644 grub_usb_register_attach_hook_class (&attach_hook
);
645 grub_scsi_dev_register (&grub_usbms_dev
);
651 for (i
= 0; i
< ARRAY_SIZE (grub_usbms_devices
); i
++)
653 grub_usbms_devices
[i
]->dev
->config
[grub_usbms_devices
[i
]->config
]
654 .interf
[grub_usbms_devices
[i
]->interface
].detach_hook
= 0;
655 grub_usbms_devices
[i
]->dev
->config
[grub_usbms_devices
[i
]->config
]
656 .interf
[grub_usbms_devices
[i
]->interface
].attached
= 0;
658 grub_usb_unregister_attach_hook_class (&attach_hook
);
659 grub_scsi_dev_unregister (&grub_usbms_dev
);