/* * twa.h: * * Copyright (c) 2017 James McKenzie , * All rights reserved. * */ #ifndef _TWA_H_ #define _TWA_H_ #define TWA_PACKED __attribute__ (( packed )) typedef uint64_t dma_addr_t; #define TW_SENSE_DATA_LENGTH 18 #define TW_COMMAND_SIZE (sizeof(dma_addr_t) > 4 ? 5 : 4) #define TW_APACHE_MAX_SGL_LENGTH (sizeof(dma_addr_t) > 4 ? 72 : 109) #define TW_ESCALADE_MAX_SGL_LENGTH (sizeof(dma_addr_t) > 4 ? 41 : 62) #define TW_PADDING_LENGTH (sizeof(dma_addr_t) > 4 ? 8 : 0) typedef struct TWA_PACKED TAG_TW_SG_Entry { dma_addr_t address; uint32_t length; } TW_SG_Entry; typedef struct TWA_PACKED TAG_TW_Command_Apache_Header { unsigned char sense_data[TW_SENSE_DATA_LENGTH]; struct TWA_PACKED { char reserved[4]; unsigned short error; unsigned char padding; unsigned char severity__reserved; } status_block; unsigned char err_specific_desc[98]; struct TWA_PACKED { unsigned char size_header; unsigned short reserved; unsigned char size_sense; } header_desc; } TW_Command_Apache_Header; /* Command Packet */ typedef struct TWA_PACKED TW_Command { /* First DWORD */ struct TWA_PACKED { unsigned char opcode:5; unsigned char sgl_offset:3; } byte0; unsigned char size; unsigned char request_id; struct TWA_PACKED { unsigned char unit:4; unsigned char host_id:4; } byte3; /* Second DWORD */ unsigned char status; unsigned char flags; union { unsigned short block_count; unsigned short parameter_count; unsigned short message_credits; } byte6; union { struct TWA_PACKED { uint32_t lba; TW_SG_Entry sgl[TW_ESCALADE_MAX_SGL_LENGTH]; dma_addr_t padding; } io; struct { TW_SG_Entry sgl[TW_ESCALADE_MAX_SGL_LENGTH]; uint32_t padding; dma_addr_t padding2; } param; } byte8_offset; } TW_Command; typedef struct TWA_PACKED TAG_TW_Command_Apache { unsigned char opcode__reserved; unsigned char unit; unsigned short request_id__lunl; unsigned char status; unsigned char sgl_offset; unsigned short sgl_entries__lunh; unsigned char cdb[16]; TW_SG_Entry sg_list[TW_APACHE_MAX_SGL_LENGTH]; unsigned char padding[TW_PADDING_LENGTH]; } TW_Command_Apache; typedef struct TWA_PACKED TAG_TW_Command_Full { TW_Command_Apache_Header header; union { TW_Command oldcommand; TW_Command_Apache newcommand; } command; } TW_Command_Full; typedef struct TWA_PACKED TAG_TW_Ioctl_Driver_Command { unsigned int control_code; unsigned int status; unsigned int unique_id; unsigned int sequence_id; unsigned int os_specific; unsigned int buffer_length; } TW_Ioctl_Driver_Command; typedef struct TWA_PACKED TAG_TW_Ioctl_Apache { TW_Ioctl_Driver_Command driver_command; char padding[488]; TW_Command_Full firmware_command; char data_buffer[0]; } TW_Ioctl_Buf_Apache; typedef struct TWA_PACKED { unsigned short table_id; unsigned short parameter_id; unsigned short parameter_size_bytes; unsigned short actual_parameter_size_bytes; unsigned char data[0]; } TW_Param_Apache, *PTW_Param_Apache; typedef struct { uint8_t resv; uint8_t tw_sec; uint8_t tw_min; uint8_t tw_hour; uint8_t tw_day; uint8_t tw_month; uint16_t tw_year; } TW_DateTime; #define TW_IOCTL_FIRMWARE_PASS_THROUGH 0x108 #define TW_OP_GET_PARAM 0x12 #define TW_OP_SET_PARAM 0x13 #define TW_TIMEKEEP_TABLE 0x040A #define TW_TIMEKEEP_DATETIME 0x4 #endif /* _TWA_H_ */