2008-08-27 Marco Gerards <marco@gnu.org>
* conf/common.rmk (pkglib_MODULES): Add scsi.mod. (scsi_mod_SOURCES): New variable. (scsi_mod_CFLAGS): Likewise (scsi_mod_LDFLAGS): Likewise. * disk/scsi.c: New file. * include/grub/scsi.h: Likewise. * include/grub/scsicmd.h: Likewise. * disk/ata.c: Include <grub/scsi.h>. (grub_atapi_packet): Do not use grub_ata_cmd, use registers instead. (grub_ata_iterate): Skip ATAPI devices. (grub_ata_open): Only handle ATAPI devices. (struct grub_atapi_read): Removed. (grub_atapi_readsector): Likewise. (grub_ata_read): No longer handle ATAPI devices. (grub_ata_write): Likewise. (grub_atapi_iterate): New function. (grub_atapi_read): Likewise. (grub_atapi_write): Likewise. (grub_atapi_open): Likewise. (grub_atapi_close): Likewise. (grub_atapi_dev): New variable. (GRUB_MOD_INIT(ata)): Register ATAPI as SCSI device. (GRUB_MOD_FINI(ata)): Unregister ATAPI. * include/grub/disk.h (enum grub_disk_dev_id): Add `GRUB_DISK_DEVICE_SCSI_ID'.
This commit is contained in:
parent
c07ae501cb
commit
965c75ca69
8 changed files with 814 additions and 82 deletions
|
@ -40,6 +40,7 @@ enum grub_disk_dev_id
|
|||
GRUB_DISK_DEVICE_NAND_ID,
|
||||
GRUB_DISK_DEVICE_UUID_ID,
|
||||
GRUB_DISK_DEVICE_PXE_ID,
|
||||
GRUB_DISK_DEVICE_SCSI_ID,
|
||||
};
|
||||
|
||||
struct grub_disk;
|
||||
|
|
88
include/grub/scsi.h
Normal file
88
include/grub/scsi.h
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_SCSI_H
|
||||
#define GRUB_SCSI_H 1
|
||||
|
||||
typedef struct grub_scsi_dev *grub_scsi_dev_t;
|
||||
|
||||
void grub_scsi_dev_register (grub_scsi_dev_t dev);
|
||||
void grub_scsi_dev_unregister (grub_scsi_dev_t dev);
|
||||
|
||||
struct grub_scsi;
|
||||
|
||||
struct grub_scsi_dev
|
||||
{
|
||||
/* The device name. */
|
||||
const char *name;
|
||||
|
||||
/* Call HOOK with each device name, until HOOK returns non-zero. */
|
||||
int (*iterate) (int (*hook) (const char *name, int luns));
|
||||
|
||||
/* Open the device named NAME, and set up SCSI. */
|
||||
grub_err_t (*open) (const char *name, struct grub_scsi *scsi);
|
||||
|
||||
/* Close the scsi device SCSI. */
|
||||
void (*close) (struct grub_scsi *scsi);
|
||||
|
||||
/* Read SIZE bytes from the device SCSI into BUF after sending the
|
||||
command CMD of size CMDSIZE. */
|
||||
grub_err_t (*read) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
/* Write SIZE bytes from BUF to the device SCSI after sending the
|
||||
command CMD of size CMDSIZE. */
|
||||
grub_err_t (*write) (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
|
||||
grub_size_t size, char *buf);
|
||||
|
||||
/* The next scsi device. */
|
||||
struct grub_scsi_dev *next;
|
||||
};
|
||||
|
||||
struct grub_scsi
|
||||
{
|
||||
/* The scsi device name. */
|
||||
char *name;
|
||||
|
||||
/* The underlying scsi device. */
|
||||
grub_scsi_dev_t dev;
|
||||
|
||||
/* Type of SCSI device. XXX: Make enum. */
|
||||
grub_uint8_t devtype;
|
||||
|
||||
/* Number of LUNs. */
|
||||
int luns;
|
||||
|
||||
/* LUN for this `struct grub_scsi'. */
|
||||
int lun;
|
||||
|
||||
/* Set to 0 when not removable, 1 when removable. */
|
||||
int removable;
|
||||
|
||||
/* Size of the device in blocks. */
|
||||
int size;
|
||||
|
||||
/* Size of one block. */
|
||||
int blocksize;
|
||||
|
||||
/* Device-specific data. */
|
||||
void *data;
|
||||
};
|
||||
typedef struct grub_scsi *grub_scsi_t;
|
||||
|
||||
#endif /* GRUB_SCSI_H */
|
122
include/grub/scsicmd.h
Normal file
122
include/grub/scsicmd.h
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_SCSICMD_H
|
||||
#define GRUB_SCSICMD_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
|
||||
#define GRUB_SCSI_DEVTYPE_MASK 31
|
||||
#define GRUB_SCSI_REMOVABLE_BIT 7
|
||||
#define GRUB_SCSI_LUN_SHIFT 5
|
||||
|
||||
struct grub_scsi_inquiry
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint16_t reserved;
|
||||
grub_uint16_t alloc_length;
|
||||
grub_uint8_t reserved2;
|
||||
grub_uint8_t pad[5];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_inquiry_data
|
||||
{
|
||||
grub_uint8_t devtype;
|
||||
grub_uint8_t rmb;
|
||||
grub_uint16_t reserved;
|
||||
grub_uint8_t length;
|
||||
grub_uint8_t reserved2[3];
|
||||
char vendor[8];
|
||||
char prodid[16];
|
||||
char prodrev[4];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_read_capacity
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint8_t reserved[8];
|
||||
grub_uint8_t pad[2];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_read_capacity_data
|
||||
{
|
||||
grub_uint32_t size;
|
||||
grub_uint32_t blocksize;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_read10
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint32_t lba;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint16_t size;
|
||||
grub_uint8_t reserved2;
|
||||
grub_uint16_t pad;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_read12
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint32_t lba;
|
||||
grub_uint32_t size;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint8_t control;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_write10
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint32_t lba;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint16_t size;
|
||||
grub_uint8_t reserved2;
|
||||
grub_uint16_t pad;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct grub_scsi_write12
|
||||
{
|
||||
grub_uint8_t opcode;
|
||||
grub_uint8_t lun;
|
||||
grub_uint32_t lba;
|
||||
grub_uint32_t size;
|
||||
grub_uint8_t reserved;
|
||||
grub_uint8_t control;
|
||||
} __attribute__((packed));
|
||||
|
||||
typedef enum
|
||||
{
|
||||
grub_scsi_cmd_inquiry = 0x12,
|
||||
grub_scsi_cmd_read_capacity = 0x25,
|
||||
grub_scsi_cmd_read10 = 0x28,
|
||||
grub_scsi_cmd_write10 = 0x2a,
|
||||
grub_scsi_cmd_read12 = 0xa8,
|
||||
grub_scsi_cmd_write12 = 0xaa
|
||||
} grub_scsi_cmd_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
grub_scsi_devtype_direct = 0x00,
|
||||
grub_scsi_devtype_cdrom = 0x05
|
||||
} grub_scsi_devtype_t;
|
||||
|
||||
#endif /* GRUB_SCSICMD_H */
|
Loading…
Add table
Add a link
Reference in a new issue