Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / scsi.h
blob13300ca1516215eb9790cec4649b895507baf0ca
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 #include <grub/disk.h>
24 typedef struct grub_scsi_dev *grub_scsi_dev_t;
26 void grub_scsi_dev_register (grub_scsi_dev_t dev);
27 void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
29 struct grub_scsi;
31 enum
33 GRUB_SCSI_SUBSYSTEM_USBMS,
34 GRUB_SCSI_SUBSYSTEM_PATA,
35 GRUB_SCSI_SUBSYSTEM_AHCI,
36 GRUB_SCSI_NUM_SUBSYSTEMS
39 extern const char grub_scsi_names[GRUB_SCSI_NUM_SUBSYSTEMS][5];
41 #define GRUB_SCSI_ID_SUBSYSTEM_SHIFT 24
42 #define GRUB_SCSI_ID_BUS_SHIFT 8
43 #define GRUB_SCSI_ID_LUN_SHIFT 0
45 static inline grub_uint32_t
46 grub_make_scsi_id (int subsystem, int bus, int lun)
48 return (subsystem << GRUB_SCSI_ID_SUBSYSTEM_SHIFT)
49 | (bus << GRUB_SCSI_ID_BUS_SHIFT) | (lun << GRUB_SCSI_ID_LUN_SHIFT);
52 struct grub_scsi_dev
54 /* Call HOOK with each device name, until HOOK returns non-zero. */
55 int (*iterate) (int NESTED_FUNC_ATTR (*hook) (int id, int bus, int luns),
56 grub_disk_pull_t pull);
58 /* Open the device named NAME, and set up SCSI. */
59 grub_err_t (*open) (int id, int bus, struct grub_scsi *scsi);
61 /* Close the scsi device SCSI. */
62 void (*close) (struct grub_scsi *scsi);
64 /* Read SIZE bytes from the device SCSI into BUF after sending the
65 command CMD of size CMDSIZE. */
66 grub_err_t (*read) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
67 grub_size_t size, char *buf);
69 /* Write SIZE bytes from BUF to the device SCSI after sending the
70 command CMD of size CMDSIZE. */
71 grub_err_t (*write) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
72 grub_size_t size, const char *buf);
74 /* The next scsi device. */
75 struct grub_scsi_dev *next;
78 struct grub_scsi
80 /* The underlying scsi device. */
81 grub_scsi_dev_t dev;
83 /* Type of SCSI device. XXX: Make enum. */
84 grub_uint8_t devtype;
86 int bus;
88 /* Number of LUNs. */
89 int luns;
91 /* LUN for this `struct grub_scsi'. */
92 int lun;
94 /* Set to 0 when not removable, 1 when removable. */
95 int removable;
97 /* Size of the device in blocks - 1. */
98 grub_uint64_t last_block;
100 /* Size of one block. */
101 grub_uint32_t blocksize;
103 /* Device-specific data. */
104 void *data;
106 typedef struct grub_scsi *grub_scsi_t;
108 #endif /* GRUB_SCSI_H */