2009-07-20 Joe Auricchio <jauricchio@gmail.com>
[grub2/phcoder.git] / include / grub / scsi.h
blobfbe4582ca433b574320fce72b49946a5ed3d3f7f
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_SCSI_H
20 #define GRUB_SCSI_H 1
22 typedef struct grub_scsi_dev *grub_scsi_dev_t;
24 void grub_scsi_dev_register (grub_scsi_dev_t dev);
25 void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
27 struct grub_scsi;
29 struct grub_scsi_dev
31 /* The device name. */
32 const char *name;
34 /* Call HOOK with each device name, until HOOK returns non-zero. */
35 int (*iterate) (int (*hook) (const char *name, int luns));
37 /* Open the device named NAME, and set up SCSI. */
38 grub_err_t (*open) (const char *name, struct grub_scsi *scsi);
40 /* Close the scsi device SCSI. */
41 void (*close) (struct grub_scsi *scsi);
43 /* Read SIZE bytes from the device SCSI into BUF after sending the
44 command CMD of size CMDSIZE. */
45 grub_err_t (*read) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
46 grub_size_t size, char *buf);
48 /* Write SIZE bytes from BUF to the device SCSI after sending the
49 command CMD of size CMDSIZE. */
50 grub_err_t (*write) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
51 grub_size_t size, char *buf);
53 /* The next scsi device. */
54 struct grub_scsi_dev *next;
57 struct grub_scsi
59 /* The scsi device name. */
60 char *name;
62 /* The underlying scsi device. */
63 grub_scsi_dev_t dev;
65 /* Type of SCSI device. XXX: Make enum. */
66 grub_uint8_t devtype;
68 /* Number of LUNs. */
69 int luns;
71 /* LUN for this `struct grub_scsi'. */
72 int lun;
74 /* Set to 0 when not removable, 1 when removable. */
75 int removable;
77 /* Size of the device in blocks. */
78 int size;
80 /* Size of one block. */
81 int blocksize;
83 /* Device-specific data. */
84 void *data;
86 typedef struct grub_scsi *grub_scsi_t;
88 #endif /* GRUB_SCSI_H */