vaseboot/include/VasEBoot/scsicmd.h

207 lines
5.5 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* VasEBoot 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.
*
* VasEBoot 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 VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_SCSICMD_H
#define VasEBoot_SCSICMD_H 1
#include <VasEBoot/types.h>
#define VasEBoot_SCSI_DEVTYPE_MASK 31
#define VasEBoot_SCSI_REMOVABLE_BIT 7
#define VasEBoot_SCSI_LUN_SHIFT 5
struct VasEBoot_scsi_test_unit_ready
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
VasEBoot_uint8_t reserved1;
VasEBoot_uint8_t reserved2;
VasEBoot_uint8_t reserved3;
VasEBoot_uint8_t control;
VasEBoot_uint8_t pad[6]; /* To be ATAPI compatible */
} VasEBoot_PACKED;
struct VasEBoot_scsi_inquiry
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 EVPD */
VasEBoot_uint8_t page; /* page code if EVPD=1 */
VasEBoot_uint8_t reserved;
VasEBoot_uint8_t alloc_length;
VasEBoot_uint8_t control;
VasEBoot_uint8_t pad[6]; /* To be ATAPI compatible */
} VasEBoot_PACKED;
struct VasEBoot_scsi_inquiry_data
{
VasEBoot_uint8_t devtype;
VasEBoot_uint8_t rmb;
VasEBoot_uint16_t reserved;
VasEBoot_uint8_t length;
VasEBoot_uint8_t reserved2[3];
char vendor[8];
char prodid[16];
char prodrev[4];
} VasEBoot_PACKED;
struct VasEBoot_scsi_request_sense
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
VasEBoot_uint8_t reserved1;
VasEBoot_uint8_t reserved2;
VasEBoot_uint8_t alloc_length;
VasEBoot_uint8_t control;
VasEBoot_uint8_t pad[6]; /* To be ATAPI compatible */
} VasEBoot_PACKED;
struct VasEBoot_scsi_request_sense_data
{
VasEBoot_uint8_t error_code; /* 7 Valid, 6-0 Err. code */
VasEBoot_uint8_t segment_number;
VasEBoot_uint8_t sense_key; /*7 FileMark, 6 EndOfMedia, 5 ILI, 4-0 sense key */
VasEBoot_uint32_t information;
VasEBoot_uint8_t additional_sense_length;
VasEBoot_uint32_t cmd_specific_info;
VasEBoot_uint8_t additional_sense_code;
VasEBoot_uint8_t additional_sense_code_qualifier;
VasEBoot_uint8_t field_replaceable_unit_code;
VasEBoot_uint8_t sense_key_specific[3];
/* there can be additional sense field */
} VasEBoot_PACKED;
struct VasEBoot_scsi_read_capacity10
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 reserved */
VasEBoot_uint32_t logical_block_addr; /* only if PMI=1 */
VasEBoot_uint8_t reserved1;
VasEBoot_uint8_t reserved2;
VasEBoot_uint8_t PMI;
VasEBoot_uint8_t control;
VasEBoot_uint16_t pad; /* To be ATAPI compatible */
} VasEBoot_PACKED;
struct VasEBoot_scsi_read_capacity10_data
{
VasEBoot_uint32_t last_block;
VasEBoot_uint32_t blocksize;
} VasEBoot_PACKED;
struct VasEBoot_scsi_read_capacity16
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun; /* 7-5 LUN, 4-0 0x10 */
VasEBoot_uint64_t logical_block_addr; /* only if PMI=1 */
VasEBoot_uint32_t alloc_len;
VasEBoot_uint8_t PMI;
VasEBoot_uint8_t control;
} VasEBoot_PACKED;
struct VasEBoot_scsi_read_capacity16_data
{
VasEBoot_uint64_t last_block;
VasEBoot_uint32_t blocksize;
VasEBoot_uint8_t pad[20];
} VasEBoot_PACKED;
struct VasEBoot_scsi_read10
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint32_t lba;
VasEBoot_uint8_t reserved;
VasEBoot_uint16_t size;
VasEBoot_uint8_t reserved2;
VasEBoot_uint16_t pad;
} VasEBoot_PACKED;
struct VasEBoot_scsi_read12
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint32_t lba;
VasEBoot_uint32_t size;
VasEBoot_uint8_t reserved;
VasEBoot_uint8_t control;
} VasEBoot_PACKED;
struct VasEBoot_scsi_read16
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint64_t lba;
VasEBoot_uint32_t size;
VasEBoot_uint8_t reserved;
VasEBoot_uint8_t control;
} VasEBoot_PACKED;
struct VasEBoot_scsi_write10
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint32_t lba;
VasEBoot_uint8_t reserved;
VasEBoot_uint16_t size;
VasEBoot_uint8_t reserved2;
VasEBoot_uint16_t pad;
} VasEBoot_PACKED;
struct VasEBoot_scsi_write12
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint32_t lba;
VasEBoot_uint32_t size;
VasEBoot_uint8_t reserved;
VasEBoot_uint8_t control;
} VasEBoot_PACKED;
struct VasEBoot_scsi_write16
{
VasEBoot_uint8_t opcode;
VasEBoot_uint8_t lun;
VasEBoot_uint64_t lba;
VasEBoot_uint32_t size;
VasEBoot_uint8_t reserved;
VasEBoot_uint8_t control;
} VasEBoot_PACKED;
typedef enum
{
VasEBoot_scsi_cmd_test_unit_ready = 0x00,
VasEBoot_scsi_cmd_request_sense = 0x03,
VasEBoot_scsi_cmd_inquiry = 0x12,
VasEBoot_scsi_cmd_read_capacity10 = 0x25,
VasEBoot_scsi_cmd_read10 = 0x28,
VasEBoot_scsi_cmd_write10 = 0x2a,
VasEBoot_scsi_cmd_read16 = 0x88,
VasEBoot_scsi_cmd_write16 = 0x8a,
VasEBoot_scsi_cmd_read_capacity16 = 0x9e,
VasEBoot_scsi_cmd_read12 = 0xa8,
VasEBoot_scsi_cmd_write12 = 0xaa,
} VasEBoot_scsi_cmd_t;
typedef enum
{
VasEBoot_scsi_devtype_direct = 0x00,
VasEBoot_scsi_devtype_cdrom = 0x05
} VasEBoot_scsi_devtype_t;
#endif /* VasEBoot_SCSICMD_H */