base
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
+2761
File diff suppressed because it is too large
Load Diff
+304
@@ -0,0 +1,304 @@
|
||||
#ifndef _ARCLIBS_H
|
||||
#define _ARCLIBS_H
|
||||
|
||||
/********************************************************/
|
||||
/*
|
||||
/* Data Structures & Function prototypes for S.M.A.R.T
|
||||
/*
|
||||
/********************************************************/
|
||||
|
||||
#include "arclib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
|
||||
#define MAX_DATA_LENGTH 512
|
||||
#define SHORT_SELF_TEST 1
|
||||
#define EXTENDED_SELF_TEST 2
|
||||
|
||||
/*
|
||||
Attribute ID Numbers
|
||||
Any non-zero value in the Attribute ID Number indicates an active attribute. The device supports the
|
||||
following Attribute ID Numbers.
|
||||
|
||||
ID Attribute Name
|
||||
=============================================
|
||||
199 Ultra DMA CRC Error Count
|
||||
198 Off-line Scan Uncorrectable Sector Count
|
||||
197 Current Pending Sector Count
|
||||
196 Reallocation Event Count
|
||||
194 Temperature
|
||||
193 Load Cycle Count
|
||||
192 Power-off Retract Count
|
||||
12 Device Power Cycle Count
|
||||
10 Spin Retry Count
|
||||
9 Power-on Hours Count
|
||||
8 Seek Time Performance
|
||||
7 Seek Error Rate
|
||||
5 Reallocated Sector Count
|
||||
4 Start/Stop Count
|
||||
3 Spin Up Time
|
||||
2 Throughput Performance
|
||||
1 Raw Read Error Rate
|
||||
0 Indicates that this entry in the data structure is not used
|
||||
|
||||
|
||||
Status Flag definitions
|
||||
Bit Definition
|
||||
0 Pre-failure/advisory bit
|
||||
0 An attribute value less than or equal to its corresponding attribute threshold indicates an
|
||||
advisory condition where the usage or age of the device has exceeded its intended
|
||||
design life period.
|
||||
1 An attribute value less than or equal to its corresponding attribute threshold indicates a
|
||||
pre-Failure condition where imminent loss of data is being predicted.
|
||||
1 On-line Collective bit
|
||||
0 The attribute value is updated only during Off-line testing.
|
||||
1 The attribute value is updated during On-line testing or during both On-line and Off-line
|
||||
testing.
|
||||
2 - 5 Vendor specific
|
||||
6 - 15 Reserved (0)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
The following defines the 12 bytes that make up the information for each Attribute entry in the Device
|
||||
Attribute Data Structure.
|
||||
*/
|
||||
typedef struct _DEVICE_ATTR_DATA // Individual Attribute Data Structure
|
||||
{
|
||||
BYTE id; // 0x00, Attribute ID Number (01h to FFh)
|
||||
BYTE status[2]; // 0x01, Status flags
|
||||
BYTE value; // 0x03, Attribute Value (valid values from 01h to FDh)
|
||||
BYTE vendor_spec[8]; // 0x04, Vendor Specific
|
||||
}sDEVICE_ATTR_DATA, *pDEVICE_ATTR_DATA; // total 12 bytes
|
||||
|
||||
/*
|
||||
The following defines the 512 bytes that make up the Attribute Value information. This data structure is
|
||||
accessed by the host in its entirety using the SMART Read Attribute Values subcommand. All multibyte
|
||||
fields shown in these data structures are in byte ordering, that is, the least significant byte occupies the
|
||||
lowest numbered byte address location in the field.
|
||||
*/
|
||||
typedef struct _SMART_ATTR_DATA // Device Attributes Data Structure
|
||||
{
|
||||
BYTE rev_num[2]; // 0x00 Data Structure Revision Number
|
||||
sDEVICE_ATTR_DATA device_attr_data[30]; // 0x02 Device Attribute, from 1st~30th
|
||||
BYTE dc_status; // 0x16A, Off¡Vline data collection status
|
||||
BYTE st_status; // 0x16B, Self¡Vtest execution status
|
||||
BYTE total_time_for_dc[2]; // 0x16C, Total time in seconds to complete off¡Vline data collection activity
|
||||
BYTE vendor_spec1; // 0x16E, Vendor specific
|
||||
BYTE dc_capability; // 0x16F, Off¡Vline data collection capability
|
||||
BYTE smart_cap[2]; // 0x170, SMART capability
|
||||
BYTE smart_error_log_cap; // 0x172, SMART device error logging capability
|
||||
BYTE st_failure_check_point; // 0x173, Self¡Vtest failure check point
|
||||
BYTE short_st_completion_time; // 0x174, Short self¡Vtest completion time in minutes
|
||||
BYTE extended_st_completion_time; // 0x175, Extended self¡Vtest completion time in minutes
|
||||
BYTE reserved[12]; // 0x176, Reserved
|
||||
BYTE vendor_spec2[125]; // 0x182, Vendor specific
|
||||
BYTE checksum; // 0x1FF, Data structure checksum
|
||||
|
||||
}sSMART_ATTR_DATA, *pSMART_ATTR_DATA; // total 512 bytes
|
||||
|
||||
/*
|
||||
The following defines the 12 bytes that make up the information for each Threshold entry in the Device
|
||||
Attribute Thresholds Data Structure. Attribute entries in the Individual Threshold Data Structure is in the
|
||||
same order and correspond to the entries in the Individual Attribute Data Structure.
|
||||
*/
|
||||
typedef struct _DEVICE_ATTR_THRE_DATA // Individual Thresholds Data Structure
|
||||
{
|
||||
BYTE id; // 0x00, Attribute ID Number (01h to FFh)
|
||||
BYTE threshold; // 0x01, Attribute Threshold
|
||||
BYTE reserved[10]; // 0x02, Reserved (00h)
|
||||
}sDEVICE_ATTR_THRE_DATA, *pDEVICE_ATTR_THRE_DATA; // total 12 bytes
|
||||
|
||||
/*
|
||||
The following defines the 512 bytes that make up the Attribute Threshold information. This data structure
|
||||
is accessed by the host in its entirety using the SMART Read Attribute Thresholds. All multibyte fields
|
||||
shown in these data structures are in byte ordering, that is, the least significant byte occupies the lowest
|
||||
numbered byte address location in the field.
|
||||
The sequence of active Attribute Thresholds will appear in the same order as their corresponding
|
||||
Attribute Values.
|
||||
*/
|
||||
typedef struct _SMART_ATTR_THRE_DATA // Device Attribute Thresholds Data Structure
|
||||
{
|
||||
BYTE rev_num[2]; // 0x00, Data Structure Revision Number
|
||||
sDEVICE_ATTR_THRE_DATA device_attr_data[30]; // 0x02, Device Attribute, from 1st~30th
|
||||
BYTE reserved[18]; // 0x16A, Reserved
|
||||
BYTE vendor_spec[131]; // 0x17C, Vendor specific
|
||||
BYTE checksum; // 0x1FF, Data structure checksum
|
||||
}sSMART_ATTR_THRE_DATA, *pSMART_ATTR_THRE_THRE_DATA; // total 512 bytes
|
||||
|
||||
|
||||
/*
|
||||
Command data structure
|
||||
Data format of each command data structure is shown below.
|
||||
*/
|
||||
typedef struct _COMMAND_DATA
|
||||
{
|
||||
BYTE dev_control_reg; // 0x00, Device Control register
|
||||
BYTE features_reg; // 0x01, Features register
|
||||
BYTE sector_count_reg; // 0x02, Sector count register
|
||||
BYTE sector_number_reg; // 0x03, Sector number register
|
||||
BYTE cylinder_low_reg; // 0x04, Cylinder Low register
|
||||
BYTE cylinder_high_reg; // 0x05, Cylinder High register
|
||||
BYTE head_reg; // 0x06, Device/Head register
|
||||
BYTE command_reg; // 0x07, Command register
|
||||
BYTE time_stamp[4]; // 0x08, Timestamp(ms from Power On)
|
||||
}sCOMMAND_DATA, *pCOMMAND_DATA; // total 12 bytes
|
||||
|
||||
/*
|
||||
Error data structure:
|
||||
Data format of error data structure is shown below.
|
||||
The state field contains a value indicating the device state when the command was issued to the device.
|
||||
xBh-xFh Vendor specific
|
||||
x5h-xAh Reserved
|
||||
x4h SMART Off-line or Self-test
|
||||
x3h Active/Idle
|
||||
x2h Standby
|
||||
x1h Sleep
|
||||
x0h Unknown
|
||||
Value
|
||||
*/
|
||||
|
||||
typedef struct _ERROR_DATA
|
||||
{
|
||||
BYTE reserved; // 0x00, Reserved
|
||||
BYTE error_reg; // 0x01, Error register
|
||||
BYTE sector_count_reg; // 0x02, Sector count register
|
||||
BYTE sector_number_reg; // 0x03, Sector number register
|
||||
BYTE cylinder_low_reg; // 0x04, Cylinder Low register
|
||||
BYTE cylinder_high_reg; // 0x05, Cylinder High register
|
||||
BYTE head_reg; // 0x06, Device/Head register
|
||||
BYTE status_reg; // 0x07, Status register
|
||||
BYTE extended_error_data[19]; //0x08, Extended error data (vendor specific)
|
||||
BYTE state; // 0x1B, State
|
||||
BYTE life_timestamp[2]; // 0x1C Life timestamp (hours)
|
||||
}sERROR_DATA, *pERROR_DATA; // total 30 bytes
|
||||
|
||||
|
||||
/*
|
||||
Error log data structure
|
||||
Data format of error data structure is shown below.
|
||||
*/
|
||||
typedef struct _ERROR_LOG_DATA
|
||||
{
|
||||
sCOMMAND_DATA command_data[5]; // 0x00, Command data structure, from 1~5
|
||||
sERROR_DATA error_data; // 0x3C, Error data structure
|
||||
}sERROR_LOG_DATA, *pERROR_LOG_DATA; // total 90 bytes
|
||||
|
||||
|
||||
/*
|
||||
The following figure defines the 512 bytes that make up the SMART error log sector. All multibyte fields
|
||||
shown in these data structures are in byte ordering.
|
||||
*/
|
||||
typedef struct _SMART_ERROR_LOG_SECTOR
|
||||
{
|
||||
BYTE version; // 0x00, SMART error log version
|
||||
BYTE pointer; // 0x01, Error log pointer
|
||||
sERROR_LOG_DATA log_data[5]; // 0x02, 1st~5th error log data structure
|
||||
BYTE device_error_count[2]; // 0x1C4, Device error count
|
||||
BYTE reserved[57]; // 0x1C6, Reserved
|
||||
BYTE checksum; // 0x1FF, Data structure checksum
|
||||
|
||||
}sSMART_ERROR_LOG_SECTOR, *pSMART_ERROR_LOG_SECTOR; // total 512 bytes
|
||||
|
||||
|
||||
/*
|
||||
The data structure contains the descriptor of Self-test that the device has performed. Each descriptor is
|
||||
24 bytes long and the self-test data structure is capable of containing up to 21 descriptors.
|
||||
After 21 descriptors have been recorded, the oldest descriptor will be overwritten with a new descriptor.
|
||||
The self-test log pointer points to the most recent descriptor. When there is no descriptor, the value is 0.
|
||||
When there is descriptor(s) the value is 1 through 21.
|
||||
*/
|
||||
typedef struct _SELF_TEST_LOG_DESCRIPTOR
|
||||
{
|
||||
BYTE number; // 0x00, Self-test number
|
||||
BYTE exe_status; // 0x01, Self-test execution status
|
||||
BYTE life_time[2]; // 0x02, Life time power on hours
|
||||
BYTE st_failure_check_point; // 0x04, Self-test failure check point
|
||||
BYTE lba_of_first_failure[4];// 0x05, LBA of first failure
|
||||
BYTE vendor_spec[15]; // 0x06, Vendor specific
|
||||
|
||||
}sSELF_TEST_LOG_DESCRIPTOR, *pSELF_TEST_LOG_DESCRIPTOR; // total 24 bytes
|
||||
|
||||
|
||||
/*
|
||||
Self-test log data structure
|
||||
The following figure defines the 512 bytes that make up the Self-test log sector. All multibyte fields shown
|
||||
in these data structures are in byte ordering.
|
||||
*/
|
||||
|
||||
typedef struct _SELF_TEST_LOG_DATA
|
||||
{
|
||||
BYTE reversion[2]; // 0x00, Data structure revision
|
||||
sSELF_TEST_LOG_DESCRIPTOR descriptor[21]; // 0x02, descriptors
|
||||
BYTE vendor_spec[2]; // 0x1FA, Vendor specific
|
||||
BYTE pointer; // 0x1FC, Self-test log pointer
|
||||
BYTE reserved[2]; // 0x1FD, Reserved
|
||||
BYTE checksum; // 0x1FF, Data structure checksum
|
||||
}sSELF_TEST_LOG_DATA, *pSELF_TEST_LOG_DATA; // total 512 bytes
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API CArclibSMART : public CArclib
|
||||
{
|
||||
#else
|
||||
class CArclibSMART : public CArclib
|
||||
{
|
||||
#endif
|
||||
public:
|
||||
|
||||
// (O): Implemented
|
||||
// (X): Not Implemented
|
||||
enum
|
||||
{
|
||||
R_SMART_DATA = 0, // (O)Read smart data
|
||||
R_THLD_DATA, // (O)Read threshold data
|
||||
ED_AUTOSAVE, // (X)Enable/disable autosave
|
||||
S_ATTR, // (X)Save attribute
|
||||
EXE_OFFLINE, // (O)Execute offline
|
||||
R_LOG, // (X)Read log
|
||||
W_LOG, // (X)Write log
|
||||
RESERVED1,
|
||||
E_SMART, // (O)Enable SMART
|
||||
D_SMART, // (O)Disable SMART
|
||||
RET_SMART_STATUS, // (X)Return SMART status
|
||||
ED_AUTO_OFFLINE, // (X)Enable/Disable automatic offline
|
||||
RESERVED2,
|
||||
RESERVED3,
|
||||
RESERVED4,
|
||||
RESERVED5,
|
||||
RW_TEST, // (O)Read/Write test
|
||||
STOP_RW_TEST, // (O)Stop Read/Write test
|
||||
CHECK_RW_RESULT, // (O)Check Read/Write Result
|
||||
RESERVED6
|
||||
};
|
||||
|
||||
//################################################################################################
|
||||
// Function: ArcExeSMART
|
||||
// Parameters: (i) cmd: the commands listed above
|
||||
// (i) drv: drive# where the SMART command is being executed
|
||||
// (i) params: The options for EXE_OFFLINE, RW_TEST only.
|
||||
// for EXE_OFFLINE: value SHORT_SELF_TEST indicates short self-test
|
||||
// value EXTENDED_SELF_TEST indicates extended self-test
|
||||
// for RW_TEST: percentage of RW_TEST
|
||||
// (o) data: The option for R_SMART_DATA, R_THLD_DATA, CHECK_RW_RESULT only.
|
||||
// the SMART data returned from the drive that indicates by drv,
|
||||
// the memory allocation of 'data' is the responsibility of the
|
||||
// calling thread, and it's size should be >= 512 bytes
|
||||
//################################################################################################
|
||||
ARC_STATUS ArcExeSMART(int cmd, BYTE drv, BYTE params, PBYTE data);
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
#ifndef _COMMDEF_H_
|
||||
#define _COMMDEF_H_
|
||||
|
||||
#if !defined(__solaris__) && defined(__sun__)
|
||||
#define __solaris__
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef ARCLIB_EXPORTS
|
||||
#define ARCLIB_API
|
||||
#else
|
||||
#define ARCLIB_API
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef int8_t
|
||||
typedef signed char int8_t;
|
||||
#endif
|
||||
#ifndef u_int8_t
|
||||
typedef unsigned char u_int8_t;
|
||||
#endif
|
||||
#ifndef int16_t
|
||||
typedef signed short int16_t;
|
||||
#endif
|
||||
#ifndef u_int16_t
|
||||
typedef unsigned short u_int16_t;
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
typedef signed int int32_t;
|
||||
#endif
|
||||
#ifndef u_int32_t
|
||||
typedef unsigned int u_int32_t;
|
||||
#endif
|
||||
#ifndef int64_t
|
||||
typedef long long int64_t;
|
||||
#endif
|
||||
#ifndef u_int64_t
|
||||
typedef unsigned long long u_int64_t;
|
||||
#endif
|
||||
#endif // end of _WIN32
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__)
|
||||
#define __unix_like__ 1
|
||||
#include <stdio.h> //Standard input/output definitions
|
||||
#include <string.h> //String function definitions
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h> //waitpid() and wait()
|
||||
#ifdef __linux__
|
||||
#include <linux/serial.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h> // File control definitions
|
||||
#include <errno.h> // Error number definitions
|
||||
#include <termios.h> // POSIX terminal control definitions
|
||||
#include <unistd.h> // fork()
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> // inet_addr(...)
|
||||
#include <netdb.h>
|
||||
#include <strings.h>
|
||||
#include <syslog.h>
|
||||
#endif // end of defined(__linux__) || defined(__FreeBSD__) || defined(__sun__) || defined(__APPLE__)
|
||||
|
||||
#ifdef __solaris__
|
||||
typedef unsigned char u_int8_t;
|
||||
typedef unsigned short u_int16_t;
|
||||
typedef unsigned long u_int32_t;
|
||||
typedef unsigned long long u_int64_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef _DOS
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <conio.h>
|
||||
#include <dos.h>
|
||||
#include <memory.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#ifndef int8_t
|
||||
typedef signed char int8_t;
|
||||
#endif
|
||||
#ifndef u_int8_t
|
||||
typedef unsigned char u_int8_t;
|
||||
#endif
|
||||
#ifndef int16_t
|
||||
typedef signed int int16_t;
|
||||
#endif
|
||||
#ifndef u_int16_t
|
||||
typedef unsigned int u_int16_t;
|
||||
#endif
|
||||
#ifndef int32_t
|
||||
typedef signed long int32_t;
|
||||
#endif
|
||||
#ifndef u_int32_t
|
||||
typedef unsigned long u_int32_t;
|
||||
#endif
|
||||
#endif // end of _DOS
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifndef IN
|
||||
#define IN
|
||||
#endif
|
||||
#ifndef OUT
|
||||
#define OUT
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef BOOL
|
||||
#define BOOL int8_t
|
||||
#endif
|
||||
#ifndef CHAR
|
||||
#define CHAR int8_t
|
||||
#endif
|
||||
#ifndef UCHAR
|
||||
#define UCHAR u_int8_t
|
||||
#endif
|
||||
#ifndef BYTE
|
||||
#define BYTE u_int8_t
|
||||
#endif
|
||||
#ifndef PBYTE
|
||||
#define PBYTE u_int8_t *
|
||||
#endif
|
||||
#ifndef WORD
|
||||
#define WORD u_int16_t
|
||||
#endif
|
||||
#ifndef DWORD
|
||||
#define DWORD u_int32_t
|
||||
#endif
|
||||
#ifndef LONG
|
||||
#define LONG int32_t
|
||||
#endif
|
||||
#ifndef ULONG
|
||||
#define ULONG uint32_t
|
||||
#endif
|
||||
#ifndef LVOID
|
||||
#define LVOID void *
|
||||
#endif
|
||||
#ifndef LPVOID
|
||||
#define LPVOID void *
|
||||
#endif
|
||||
#ifndef HANDLE
|
||||
#define HANDLE int
|
||||
#endif
|
||||
#ifndef SOCKET
|
||||
#define SOCKET int
|
||||
#endif
|
||||
#ifndef SOCKET_ERROR
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
#endif // end of _WIN32
|
||||
#endif //end of _COMMDEF_H_
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// @APPLE_LICENSE_HEADER_START@
|
||||
//
|
||||
// Copyright (c) 2005, 2006 Apple Computer, Inc. All Rights Reserved.
|
||||
//
|
||||
// This file contains Original Code and/or Modifications of Original Code
|
||||
// as defined in and that are subject to the Apple Public Source License
|
||||
// Version 2.0 (the 'License'). You may not use this file except in
|
||||
// compliance with the License. Please obtain a copy of the License at
|
||||
// http://www.opensource.apple.com/apsl/ and read it before using this
|
||||
// file.
|
||||
//
|
||||
// The Original Code and all software distributed under the License are
|
||||
// distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
||||
// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
||||
// Please see the License for the specific language governing rights and
|
||||
// limitations under the License.
|
||||
//
|
||||
// @APPLE_LICENSE_HEADER_END@
|
||||
|
||||
// $Id: darwin_userclient.h,v 1.3 2006/01/15 21:19:30 msmith Exp $
|
||||
|
||||
#ifndef __DARWINUSERCLIENT_H__
|
||||
#define __DARWINUSERCLIENT_H__
|
||||
|
||||
// XXX trim these includes
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#include <IOKit/IOKitLib.h>
|
||||
|
||||
class DarwinUserClientInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
DarwinUserClientInterface();
|
||||
~DarwinUserClientInterface();
|
||||
|
||||
bool init(const int nPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
bool ClearReadBuffer();
|
||||
bool ClearWriteBuffer();
|
||||
bool ClearReadWriteBuffer();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
private:
|
||||
io_connect_t connectionPort;
|
||||
bool controllerIsOpen;
|
||||
pthread_mutex_t mtx;
|
||||
};
|
||||
|
||||
#endif // __DARWINUSERCLIENT_H__
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#ifndef _DOSPCI_H_
|
||||
#define _DOSPCI_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "commdef.h"
|
||||
#include "if.h"
|
||||
#include "stdio.h"
|
||||
#include "memory.h"
|
||||
|
||||
|
||||
extern int ttchk( void ); /* Return count of received characters */
|
||||
extern void ttos(unsigned char ptr[], int len);
|
||||
extern int ttinc( void ); /* Input a character from circular buffer */
|
||||
extern void serini( void ); /* Initialize the com port for interrupts */
|
||||
extern unsigned long GetDword(unsigned);
|
||||
extern void SetDword(unsigned, unsigned long);
|
||||
extern InProtectedMode();
|
||||
extern find_lindsay();
|
||||
extern SetA20();
|
||||
|
||||
|
||||
class DosPciInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
DosPciInterface();
|
||||
~DosPciInterface();
|
||||
int init(const char nPortNum);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void *getDeviceHandle();
|
||||
int getMTU();
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
void setTimeOut(int nSec);
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int nTimeOut; // in seconds
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _ETHERNET_H_
|
||||
#define _ETHERNET_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Winsock2.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API EthernetInterface : public ArcInterface
|
||||
#else
|
||||
class EthernetInterface : public ArcInterface
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
EthernetInterface();
|
||||
~EthernetInterface();
|
||||
bool init(const char *szIPAddr, short nPort = 7890);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
|
||||
// helper functions
|
||||
public:
|
||||
void *getDeviceHandle();
|
||||
SOCKET getSocket();
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int WaitForReply(SOCKET s, long time_sec, long time_usec);
|
||||
SOCKET m_socket;
|
||||
#ifdef _WIN32
|
||||
CRITICAL_SECTION m_cs;
|
||||
void requirelock()
|
||||
{
|
||||
EnterCriticalSection(&m_cs);
|
||||
}
|
||||
void releaselock()
|
||||
{
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
#elif defined(__unix_like__)
|
||||
|
||||
#endif
|
||||
struct sockaddr_in agentaddr;
|
||||
struct sockaddr_in manager_addr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
#ifndef __FREEBSDSCSI_H__
|
||||
#define __FREEBSDSCSI_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_debug.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
#include <cam/scsi/scsi_all.h>
|
||||
#include <cam/scsi/scsi_da.h>
|
||||
#include <cam/scsi/scsi_pass.h>
|
||||
#include <cam/scsi/scsi_message.h>
|
||||
#include <camlib.h>
|
||||
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
#include "arclib.h"
|
||||
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_WRITE_BUF 0x3B
|
||||
#define SCSI_READ_BUF 0x3C
|
||||
#define SENSE_LEN 14
|
||||
#define CDB_SIZE 10
|
||||
#define BUF_SIZE 2048
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE ErrorCode; // Error Code (70H or 71H)
|
||||
BYTE SegmentNum; // Number of current segment descriptor
|
||||
BYTE SenseKey; // Sense Key(See bit definitions too)
|
||||
BYTE InfoByte0; // Information MSB
|
||||
BYTE InfoByte1; // Information MID
|
||||
BYTE InfoByte2; // Information MID
|
||||
BYTE InfoByte3; // Information LSB
|
||||
BYTE AddSenLen; // Additional Sense Length
|
||||
BYTE ComSpecInf0; // Command Specific Information MSB
|
||||
BYTE ComSpecInf1; // Command Specific Information MID
|
||||
BYTE ComSpecInf2; // Command Specific Information MID
|
||||
BYTE ComSpecInf3; // Command Specific Information LSB
|
||||
BYTE AddSenseCode; // Additional Sense Code
|
||||
BYTE AddSenQual; // Additional Sense Code Qualifier
|
||||
BYTE FieldRepUCode; // Field Replaceable Unit Code
|
||||
BYTE SenKeySpec15; // Sense Key Specific 15th byte
|
||||
BYTE SenKeySpec16; // Sense Key Specific 16th byte
|
||||
BYTE SenKeySpec17; // Sense Key Specific 17th byte
|
||||
BYTE AddSenseBytes; // Additional Sense Bytes
|
||||
} sSENSE_DATA_FMT, *pSENSE_DATA_FMT;
|
||||
|
||||
class FreeBSDSCSIInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
FreeBSDSCSIInterface();
|
||||
~FreeBSDSCSIInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(const char *outBuf, int outLen, char *inBuf, int inLen, void *extdata = 0);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
private:
|
||||
HANDLE m_hScsi;
|
||||
cam_device *arc_device;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
Vendored
+308
@@ -0,0 +1,308 @@
|
||||
#ifndef _INTERFACE_H_
|
||||
#define _INTERFACE_H_
|
||||
|
||||
#include "commdef.h"
|
||||
|
||||
// the error code the INTERFACE returned,
|
||||
// if no error occurred, return the bytes sent or read
|
||||
//
|
||||
#define IF_OK (0)
|
||||
#define IF_MORE_DATA (-1)
|
||||
#define IF_FAIL_READ (-2)
|
||||
#define IF_FAIL_WRITE (-3)
|
||||
#define IF_NEED_RETRY (-4)
|
||||
#define IF_OVER_MTU_SIZE (-5)
|
||||
#define IF_FAIL_PARAMETER (-6)
|
||||
#define IF_READ_TIMEOUT (-7)
|
||||
#define IF_WRITE_TIMEOUT (-8)
|
||||
#define IF_CTLR_FAILED (-9)
|
||||
|
||||
|
||||
// rwflag
|
||||
#define IF_WRITE_ONLY 0x01 // just do the operation of send
|
||||
#define IF_READ_ONLY 0x02 // just do the operation of read
|
||||
#define IF_RAW_READ 0x04
|
||||
#define IF_RAW_WRITE 0x08
|
||||
#define IF_SAS 0x10
|
||||
|
||||
|
||||
// THE BELOW BLOCK IS ONLY FOR INTERNAL USE
|
||||
/************************************************************************************/
|
||||
enum
|
||||
{
|
||||
GUI_SET_SERIAL = 0x10,
|
||||
GUI_SET_VENDOR,
|
||||
GUI_SET_MODEL,
|
||||
GUI_IDENTIFY,
|
||||
GUI_CHECK_PASSWORD,
|
||||
GUI_LOGOUT,
|
||||
GUI_HTTP,
|
||||
GUI_SET_ETHERNET_ADDR,
|
||||
GUI_SET_LOGO,
|
||||
GUI_POLL_EVENT,
|
||||
GUI_GET_EVENT,
|
||||
GUI_GET_HW_MONITOR,
|
||||
GUI_SMART_TEST,
|
||||
GUI_SET_TIME,
|
||||
GUI_SNMP,
|
||||
GUI_MISC, // 0x1F
|
||||
|
||||
GUI_GET_INFO_R = 0x20,
|
||||
GUI_GET_INFO_V,
|
||||
GUI_GET_INFO_P,
|
||||
GUI_GET_INFO_S,
|
||||
GUI_CLEAR_EVENT,
|
||||
|
||||
GUI_MUTE_BEEPER = 0x30,
|
||||
GUI_BEEPER_SETTING,
|
||||
GUI_SET_PASSWORD,
|
||||
GUI_HOST_INTERFACE_MODE,
|
||||
GUI_REBUILD_PRIORITY,
|
||||
GUI_MAX_ATA_MODE,
|
||||
GUI_RESET_CONTROLLER,
|
||||
GUI_COM_PORT_SETTING,
|
||||
GUI_NO_OPERATION,
|
||||
GUI_DHCP_IP,
|
||||
|
||||
GUI_CREATE_PASS_THROUGH = 0x40,
|
||||
GUI_MODIFY_PASS_THROUGH,
|
||||
GUI_DELETE_PASS_THROUGH,
|
||||
GUI_IDENTIFY_DEVICE,
|
||||
|
||||
GUI_CREATE_RAIDSET = 0x50,
|
||||
GUI_DELETE_RAIDSET,
|
||||
GUI_EXPAND_RAIDSET,
|
||||
GUI_ACTIVATE_RAIDSET,
|
||||
GUI_CREATE_HOT_SPARE,
|
||||
GUI_DELETE_HOT_SPARE,
|
||||
|
||||
GUI_CREATE_VOLUME = 0x60,
|
||||
GUI_MODIFY_VOLUME,
|
||||
GUI_DELETE_VOLUME,
|
||||
GUI_START_CHECK_VOLUME,
|
||||
GUI_STOP_CHECK_VOLUME
|
||||
};
|
||||
|
||||
// Application specific
|
||||
enum
|
||||
{
|
||||
GUI_RAW_READ_WRITE = 0xEC,
|
||||
GUI_RAW_READ = 0xED,
|
||||
GUI_RAW_WRITE = 0xEE,
|
||||
GUI_SET_ENCLOSURE_UNIT_SERIAL,
|
||||
GUI_GET_TCPPORT,
|
||||
GUI_GET_COMATTR,
|
||||
|
||||
// status code
|
||||
GUI_WOULDBLOCK,
|
||||
GUI_TIMEOUT
|
||||
};
|
||||
/****************************************************************************************/
|
||||
|
||||
//
|
||||
// Library returned status
|
||||
//
|
||||
#define ARC_STATUS int
|
||||
#define ARC_SUCCESS 0x00 // Operation succeeded
|
||||
#define ARC_FAILURE 0x01 // Operation failed
|
||||
#define ARC_RETURN_FRAME_ERROR 0x02 // The library does not recognize the returned data
|
||||
// (including invalid data header, length or checksum, etc...)
|
||||
#define ARC_INVALID_COM_HANDLE 0x03 // Invalid RS-232 handle
|
||||
#define ARC_DATA_TRANSMIT_ERROR 0x04 // Failed to write to media
|
||||
#define ARC_DATA_RECEIVE_ERROR 0x05 // Failed to read from media( no response from raid subsystem)
|
||||
#define ARC_PARAMETER_ERROR 0x06 // The wrong parameter(s)
|
||||
#define ARC_OPENFILE_ERROR 0x07 // Failed to open file
|
||||
#define ARC_PASSWORD_REQUIRED 0x08 // Password required
|
||||
#define ARC_INVALID_PASSWORD 0x09 // Wrong password
|
||||
#define ARC_INSUFFICIENT_MEM 0x0A // Memory too small
|
||||
#define ARC_CANT_ALLOC_MEM 0x0B // Failed to allocate necessary memory
|
||||
#define ARC_BUFFER_TOO_SMALL 0x0C // The buffer is too small to put the returned data
|
||||
#define ARC_SOCKET_ERROR 0x0D // Socket error
|
||||
#define ARC_INVALID_SOCKET 0x0E // Invalid socket
|
||||
#define ARC_INIT_COM_ERROR 0x0F // Failed to open COM port
|
||||
#define ARC_SOCKET_STARTUP_ERROR 0x10 // Failed to init socket
|
||||
#define ARC_INVALID_INTERFACE 0x11 // Invalid interface
|
||||
#define ARC_NO_SUCH_DEVICE 0x12 // Device not found( including raidset, volumeset, physical drive )
|
||||
#define ARC_DATA_TRANSMIT_TIMEOUT 0x13 // Failed to write to media in a given time
|
||||
#define ARC_DATA_RECEIVE_TIMEOUT 0x14 // Failed to read from media in a given time
|
||||
#define ARC_CTLR_FAILURE 0x15 // Controller failure or inactive
|
||||
#define ARC_UNKNOWN_ERROR 0x3F // Unknown error
|
||||
|
||||
// RAID controller returned status
|
||||
#define GUI_OK 0x41 // Operation successed
|
||||
#define GUI_RAIDSET_NOT_NORMAL 0x42
|
||||
#define GUI_VOLUMESET_NOT_NORMAL 0x43
|
||||
#define GUI_NO_RAIDSET 0x44
|
||||
#define GUI_NO_VOLUMESET 0x45
|
||||
#define GUI_NO_PHYSICAL_DRIVE 0x46
|
||||
#define GUI_PARAMETER_ERROR 0x47
|
||||
#define GUI_UNSUPPORTED_COMMAND 0x48
|
||||
#define GUI_DISK_CONFIG_CHANGED 0x49
|
||||
#define GUI_INVALID_PASSWORD 0x4a
|
||||
#define GUI_NO_DISK_SPACE 0x4b
|
||||
#define GUI_CHECKSUM_ERROR 0x4c
|
||||
#define GUI_PASSWORD_REQUIRED 0x4d
|
||||
#define GUI_NO_MORE_DATA 0x4e // Internal use only
|
||||
#define GUI_INTERNAL_ERROR 0x4f
|
||||
#define GUI_FIRMWARE_CRC_ERROR 0x50
|
||||
#define GUI_FIRMWARE_INVALID 0x51
|
||||
#define GUI_FIRMWARE_UPDATE_FAILED 0x52
|
||||
#define GUI_FIRMWARE_NO_HDD 0x53
|
||||
#define GUI_END_OF_DATA 0x54
|
||||
|
||||
typedef int (*fn_decode_frame)(unsigned char *buf, int len);
|
||||
typedef unsigned char (*fn_decode_cs)(unsigned char *buf, int len);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// for internal use only
|
||||
//
|
||||
typedef struct _IF_CMD_BLOCK
|
||||
{
|
||||
unsigned long timeout; // [in]in milliseconds
|
||||
unsigned long rwflag; // [in]the flag which control the behavior of read/write
|
||||
const char *outBuf; // [in] the output data buffer to be sent
|
||||
unsigned long outLen; // [in] the output data buffer size
|
||||
char *inBuf; // [out] the input data buffer to put the firmware returned data
|
||||
unsigned long inLen; // [out] the input data buffer size
|
||||
unsigned long io_status;// [out] the status of i/o
|
||||
fn_decode_frame df; // [in]
|
||||
fn_decode_cs dc; // [in]
|
||||
}sIF_CMD_BLOCK, *pIF_CMD_BLOCK;
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API ArcInterface
|
||||
#else
|
||||
class ArcInterface
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
virtual ~ArcInterface()
|
||||
{
|
||||
}
|
||||
virtual int send(sIF_CMD_BLOCK *ifData) = 0;
|
||||
virtual int recv(sIF_CMD_BLOCK *ifData) = 0;
|
||||
virtual int syncSend(sIF_CMD_BLOCK *ifData) = 0;
|
||||
|
||||
//
|
||||
// MTU: Maximum transmission unit
|
||||
// the size (in bytes) of the largest packet that this layer can carry out.
|
||||
//
|
||||
virtual int getMTU() = 0;
|
||||
virtual void *getDeviceHandle() = 0;
|
||||
|
||||
// These two member functions will be called by the syncSend() member function
|
||||
// to ensure the synchronization of send() and recv() to the single controller.
|
||||
// The requirelock() will be called before the send(),
|
||||
// and releaselock() will be called after the recv().
|
||||
virtual void requirelock(){}
|
||||
virtual void releaselock(){}
|
||||
|
||||
virtual int getFirmSpec()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// set the timeout for interface read operation
|
||||
void setTimeOut(int nSec)
|
||||
{
|
||||
if(nSec > 0)
|
||||
{
|
||||
nTimeOut = nSec;
|
||||
}
|
||||
}
|
||||
|
||||
int getTimeOut()
|
||||
{
|
||||
return nTimeOut;
|
||||
}
|
||||
|
||||
private:
|
||||
int nTimeOut;
|
||||
};
|
||||
|
||||
|
||||
typedef void (*CMD_CALLBACK)(void *data);
|
||||
|
||||
|
||||
typedef enum _SRC_SOURCE
|
||||
{
|
||||
SRC_UNKNOWN = -1,
|
||||
SRC_COMM = 0,
|
||||
SRC_DRIVER,
|
||||
SRC_INBAND,
|
||||
SRC_ETHERNET,
|
||||
SRC_DRIVER_ODIN,
|
||||
SRC_TOTAL
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API CArclibObj
|
||||
#else
|
||||
class CArclibObj
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
CArclibObj()
|
||||
{
|
||||
m_Source = SRC_UNKNOWN;
|
||||
}
|
||||
|
||||
virtual ~CArclibObj() {}
|
||||
public:
|
||||
unsigned long m_Source;
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API CArclibBase : public CArclibObj
|
||||
#else
|
||||
class CArclibBase : public CArclibObj
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
CArclibBase()
|
||||
{
|
||||
m_Interface = NULL;
|
||||
m_CallBackFunc = NULL;
|
||||
}
|
||||
|
||||
virtual ~CArclibBase()
|
||||
{
|
||||
if(m_Interface)
|
||||
{
|
||||
delete m_Interface;
|
||||
m_Interface = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void ArcSetCallBack(CMD_CALLBACK pFunc)
|
||||
{
|
||||
m_CallBackFunc = pFunc;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
Function Name: ArcInitSession
|
||||
Function: Startup areca library by assigning an interface to it
|
||||
Input: 1. ArcInterface
|
||||
Output: None.
|
||||
Return Values: 1. ARC_STATUS
|
||||
Note: This function should be called before any member functions be called
|
||||
************************************************************************************/
|
||||
virtual ARC_STATUS ArcInitSession(ArcInterface *Interface)
|
||||
{
|
||||
m_Interface = Interface;
|
||||
return ARC_SUCCESS;
|
||||
}
|
||||
|
||||
protected:
|
||||
ArcInterface *m_Interface; // The communication path to the raid-subsystem
|
||||
CMD_CALLBACK m_CallBackFunc;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#ifndef _INTERFACE_H_
|
||||
#define _INTERFACE_H_
|
||||
|
||||
#include "commdef.h"
|
||||
|
||||
// the error code the INTERFACE returned,
|
||||
// if no error occurred, return the bytes sent or read
|
||||
//
|
||||
#define IF_OK (0)
|
||||
#define IF_MORE_DATA (-1)
|
||||
#define IF_FAIL_READ (-2)
|
||||
#define IF_FAIL_WRITE (-3)
|
||||
#define IF_NEED_RETRY (-4)
|
||||
#define IF_OVER_MTU_SIZE (-5)
|
||||
#define IF_FAIL_PARAMETER (-6)
|
||||
#define IF_READ_TIMEOUT (-7)
|
||||
#define IF_WRITE_TIMEOUT (-8)
|
||||
|
||||
|
||||
// rwflag
|
||||
#define IF_WRITE_ONLY 0x01 // just do the operation of send
|
||||
#define IF_READ_ONLY 0x02 // just do the operation of read
|
||||
#define IF_RAW_READ_WRITE 0x04 // do the raw data r/w
|
||||
#define IF_SAS 0x08
|
||||
|
||||
|
||||
typedef int (*fn_decode_frame)(unsigned char *buf, int len);
|
||||
typedef unsigned char (*fn_decode_cs)(unsigned char *buf, int len);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// for internal use only
|
||||
//
|
||||
typedef struct _IF_CMD_BLOCK
|
||||
{
|
||||
unsigned long timeout; // [in]in milliseconds
|
||||
unsigned long rwflag; // [in]the flag which control the behavior of read/write
|
||||
const char *outBuf; // [in] the output data buffer to be sent
|
||||
unsigned long outLen; // [in] the output data buffer size
|
||||
char *inBuf; // [out] the input data buffer to put the firmware returned data
|
||||
unsigned long inLen; // [out] the input data buffer size
|
||||
fn_decode_frame df; // [in]
|
||||
fn_decode_cs dc; // [in]
|
||||
}sIF_CMD_BLOCK, *pIF_CMD_BLOCK;
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
class ARCLIB_API ArcInterface
|
||||
#else
|
||||
class ArcInterface
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
virtual ~ArcInterface()
|
||||
{
|
||||
}
|
||||
virtual int send(sIF_CMD_BLOCK *ifData) = 0;
|
||||
virtual int recv(sIF_CMD_BLOCK *ifData) = 0;
|
||||
virtual int syncSend(sIF_CMD_BLOCK *ifData) = 0;
|
||||
|
||||
//
|
||||
// MTU: Maximum transmission unit
|
||||
// the size (in bytes) of the largest packet that this layer can carry out.
|
||||
//
|
||||
virtual int getMTU() = 0;
|
||||
virtual void *getDeviceHandle() = 0;
|
||||
|
||||
// These two member functions will be called by the syncSend() member function
|
||||
// to ensure the synchronization of send() and recv() to the single controller.
|
||||
// The requirelock() will be called before the send() called,
|
||||
// and releaselock() will be called after the recv() called.
|
||||
virtual void requirelock(){}
|
||||
virtual void releaselock(){}
|
||||
|
||||
|
||||
// set the timeout for interface read operation
|
||||
void setTimeOut(int nSec)
|
||||
{
|
||||
if(nSec > 0)
|
||||
{
|
||||
nTimeOut = nSec;
|
||||
}
|
||||
}
|
||||
|
||||
int getTimeOut()
|
||||
{
|
||||
return nTimeOut;
|
||||
}
|
||||
|
||||
private:
|
||||
int nTimeOut;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#ifndef _LINUXCOMM_H_
|
||||
#define _LINUXCOMM_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class LinuxCommInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
LinuxCommInterface();
|
||||
~LinuxCommInterface();
|
||||
bool init(const char nPortNum, char nBaudRate = 7, char nStopBit = 0);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
public:
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int m_hComm;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#ifndef __LINUXIOCTL_H__
|
||||
#define __LINUXIOCTL_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __linux__
|
||||
#include <scsi/sg.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
|
||||
/*DeviceType*/
|
||||
#define ARECA_SATA_RAID 0x90000000
|
||||
/*FunctionCode*/
|
||||
#define FUNCTION_READ_RQBUFFER 0x0801
|
||||
#define FUNCTION_WRITE_WQBUFFER 0x0802
|
||||
#define FUNCTION_CLEAR_RQBUFFER 0x0803
|
||||
#define FUNCTION_CLEAR_WQBUFFER 0x0804
|
||||
#define FUNCTION_CLEAR_ALLQBUFFER 0x0805
|
||||
#define FUNCTION_RETURN_CODE_3F 0x0806
|
||||
#define FUNCTION_SAY_HELLO 0x0807
|
||||
|
||||
#if defined(__linux__) || defined (__solaris__)
|
||||
/* ARECA IO CONTROL CODE*/
|
||||
#define ARCMSR_IOCTL_READ_RQBUFFER ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER
|
||||
#define ARCMSR_IOCTL_WRITE_WQBUFFER ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_RQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_WQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_ALLQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_ALLQBUFFER
|
||||
#define ARCMSR_IOCTL_RETURN_CODE_3F ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F
|
||||
#define ARCMSR_IOCTL_SAY_HELLO ARECA_SATA_RAID | FUNCTION_SAY_HELLO
|
||||
#elif __FreeBSD__
|
||||
#define ARCMSR_IOCTL_READ_RQBUFFER _IOWR('F', FUNCTION_READ_RQBUFFER, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_WRITE_WQBUFFER _IOWR('F', FUNCTION_WRITE_WQBUFFER, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_CLEAR_RQBUFFER _IOWR('F', FUNCTION_CLEAR_RQBUFFER, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_CLEAR_WQBUFFER _IOWR('F', FUNCTION_CLEAR_WQBUFFER, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_CLEAR_ALLQBUFFER _IOWR('F', FUNCTION_CLEAR_ALLQBUFFER, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_RETURN_CODE_3F _IOWR('F', FUNCTION_RETURN_CODE_3F, sSRB_BUFFER)
|
||||
#define ARCMSR_IOCTL_SAY_HELLO _IOWR('F', FUNCTION_SAY_HELLO, sSRB_BUFFER)
|
||||
#endif
|
||||
|
||||
|
||||
/* ARECA IOCTL ReturnCode */
|
||||
#define ARCMSR_IOCTL_RETURNCODE_OK 0x01
|
||||
#define ARCMSR_IOCTL_RETURNCODE_ERROR 0x06
|
||||
#define ARCMSR_IOCTL_RETURNCODE_3F 0x3F
|
||||
|
||||
|
||||
typedef struct _SRB_IO_CONTROL
|
||||
{
|
||||
unsigned int HeaderLength;
|
||||
UCHAR Signature[8];
|
||||
unsigned int Timeout;
|
||||
unsigned int ControlCode;
|
||||
unsigned int ReturnCode;
|
||||
unsigned int Length;
|
||||
} sSRB_IO_CONTROL, *pSRB_IO_CONTROL;
|
||||
|
||||
typedef struct _SRB_BUFFER
|
||||
{
|
||||
sSRB_IO_CONTROL srbioctl; // ioctl header
|
||||
UCHAR ioctldatabuffer[1032]; // areca gui program does not accept more than 1031 byte
|
||||
} sSRB_BUFFER, *pSRB_BUFFER;
|
||||
|
||||
|
||||
class LinuxIoctlInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
LinuxIoctlInterface();
|
||||
~LinuxIoctlInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
HANDLE m_hScsi;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef __LINUX_PASS_IOCTL_H__
|
||||
#define __LINUX_PASS_IOCTL_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __linux__
|
||||
#include <scsi/sg.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_ioctl.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
#include "arclib.h"
|
||||
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_WRITE_BUF 0x3B
|
||||
#define SCSI_READ_BUF 0x3C
|
||||
#define SENSE_LEN 14
|
||||
#define CDB_SIZE 10
|
||||
#define BUF_SIZE 2048
|
||||
|
||||
|
||||
|
||||
class LinuxPassIoctlInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
LinuxPassIoctlInterface();
|
||||
~LinuxPassIoctlInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
public:
|
||||
HANDLE m_hScsi;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
#ifndef __LINUXSCSI_H__
|
||||
#define __LINUXSCSI_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __linux__
|
||||
#include <scsi/sg.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_ioctl.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
#include "arclib.h"
|
||||
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_WRITE_BUF 0x3B
|
||||
#define SCSI_READ_BUF 0x3C
|
||||
#define SENSE_LEN 14
|
||||
#define CDB_SIZE 10
|
||||
#define BUF_SIZE 2048
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int inlen; // [i] Length of data written to device
|
||||
int outlen; // [i] Length of data read from device
|
||||
char cdb[CDB_SIZE]; // [i] SCSI command (6 <= x <= 16)
|
||||
// [o] Data read from device starts here
|
||||
// [o] On error, sense buffer starts here
|
||||
char buf[4100]; // [i] Data written to device starts here
|
||||
}sSRB_BUF, *pSRB_BUF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE ErrorCode; // Error Code (70H or 71H)
|
||||
BYTE SegmentNum; // Number of current segment descriptor
|
||||
BYTE SenseKey; // Sense Key(See bit definitions too)
|
||||
BYTE InfoByte0; // Information MSB
|
||||
BYTE InfoByte1; // Information MID
|
||||
BYTE InfoByte2; // Information MID
|
||||
BYTE InfoByte3; // Information LSB
|
||||
BYTE AddSenLen; // Additional Sense Length
|
||||
BYTE ComSpecInf0; // Command Specific Information MSB
|
||||
BYTE ComSpecInf1; // Command Specific Information MID
|
||||
BYTE ComSpecInf2; // Command Specific Information MID
|
||||
BYTE ComSpecInf3; // Command Specific Information LSB
|
||||
BYTE AddSenseCode; // Additional Sense Code
|
||||
BYTE AddSenQual; // Additional Sense Code Qualifier
|
||||
BYTE FieldRepUCode; // Field Replaceable Unit Code
|
||||
BYTE SenKeySpec15; // Sense Key Specific 15th byte
|
||||
BYTE SenKeySpec16; // Sense Key Specific 16th byte
|
||||
BYTE SenKeySpec17; // Sense Key Specific 17th byte
|
||||
BYTE AddSenseBytes; // Additional Sense Bytes
|
||||
} sSENSE_DATA_FMT, *pSENSE_DATA_FMT;
|
||||
|
||||
class LinuxSCSIInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
LinuxSCSIInterface();
|
||||
~LinuxSCSIInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
public:
|
||||
HANDLE m_hScsi;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
#ifndef _SASBASE_H
|
||||
#define _SASBASE_H
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
enum _SAS_ATTRIBUTE_ITEMS
|
||||
{
|
||||
SAS_READ_RECOVERED_WO_DELAY,
|
||||
SAS_READ_RECOVERED_W_DELAY,
|
||||
SAS_READ_RECOVERED_W_RETRY,
|
||||
SAS_READ_RECOVERED,
|
||||
SAS_READ_TOTAL_BYTES,
|
||||
SAS_READ_UNRECOVERED,
|
||||
SAS_WRITE_RECOVERED_WO_DELAY,
|
||||
SAS_WRITE_RECOVERED_W_DELAY,
|
||||
SAS_WRITE_RECOVERED_W_RETRY,
|
||||
SAS_WRITE_RECOVERED,
|
||||
SAS_WRITE_TOTAL_BYTES,
|
||||
SAS_WRITE_UNRECOVERED,
|
||||
SAS_VERIFY_RECOVERED_WO_DELAY,
|
||||
SAS_VERIFY_RECOVERED_W_DELAY,
|
||||
SAS_VERIFY_RECOVERED_W_RETRY,
|
||||
SAS_VERIFY_RECOVERED,
|
||||
SAS_VERIFY_UNRECOVERED,
|
||||
SAS_NON_MEDIUM_ERRORS,
|
||||
TOTAL_SAS_ATTR_ITEMS
|
||||
};
|
||||
|
||||
enum _SMART_ITEMS
|
||||
{
|
||||
SMART_READ_ERROR_RATE_1, // read error rate
|
||||
SMART_SPINUP_TIME_3, // spinup time
|
||||
SMART_REALLOCATION_5, // reallocation
|
||||
SMART_SEEK_ERROR_RATE_7, // seek error rate
|
||||
SMART_SPINUP_RETRY_10, // spinup retry
|
||||
SMART_CALIBRATION_RETRY_11, // calibration retry
|
||||
SMART_TEMPERATURE_194, // temperature
|
||||
TOTAL_SMART_ITEMS,
|
||||
};
|
||||
|
||||
enum _SAS_HW
|
||||
{
|
||||
SAS_HW_DISK, // disks
|
||||
SAS_HW_VOLTAGE, // voltages
|
||||
SAS_HW_FAN, // fans
|
||||
SAS_HW_POWER, // powers
|
||||
SAS_HW_TEMPERATURE, // temperatures
|
||||
TOTAL_SAS_HW
|
||||
};
|
||||
|
||||
typedef struct sSMART_DATA
|
||||
{
|
||||
WORD smIndex;
|
||||
BYTE smStatus;
|
||||
BYTE smThreshold;
|
||||
} sSMART_DATA, *pSMART_DATA;
|
||||
|
||||
// SCSI attribtes
|
||||
typedef struct sSCSI_ATTR
|
||||
{
|
||||
BYTE scsiChannel; // channel for SCSI target (0/1)
|
||||
BYTE scsiId; // SCSI ID for the volume
|
||||
BYTE scsiLun; // LUN (0 if target is IDE)
|
||||
BYTE scsiTaggedQueuing; // 1 --> queue enabled
|
||||
BYTE scsiCacheMode; // 1 --> Cache enabled
|
||||
BYTE scsiSpeed; // IDE(0:ATA33/1:ATA66/2:ATA100/3:ATA133)
|
||||
} sSCSI_ATTR, *pSCSI_ATTR;
|
||||
|
||||
|
||||
typedef struct sGUI_ENC_PROPERTY
|
||||
{
|
||||
BYTE gepVendor[8]; // vendor name
|
||||
BYTE gepProduct[16]; // product name
|
||||
BYTE gepRev[4]; // reversion
|
||||
BYTE gepEncType; // enclosure type
|
||||
BYTE gepEncnumber; // enclosure#
|
||||
BYTE gepEncDisks; // number of disks
|
||||
BYTE gepEncVoltages; // number of voltages
|
||||
BYTE gepEncFans; // number of fans
|
||||
BYTE gepEncPowers; // number of powers
|
||||
BYTE gepEncTemperatures; // number of temperatures
|
||||
BYTE gepRes[0x1D]; // reserved
|
||||
} sGUI_ENC_PROPERTY, *pGUI_ENC_PROPERTY;
|
||||
|
||||
|
||||
#define MAX_ENCLOSURES 8
|
||||
#define MAX_PHY_PER_ENCLOSURE 32
|
||||
#define MAX_DEV_PER_ENCLOSURE 32
|
||||
|
||||
enum
|
||||
{
|
||||
ENC_TYPE_NOT_INSTALLED, // not installed
|
||||
ENC_TYPE_INTERNAL, // built-in enclosure
|
||||
ENC_TYPE_SES2, // ses2
|
||||
ENC_TYPE_SMP, // smp
|
||||
ENC_TYPE_CTRL // controller
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define MAX_ELEMENT_STR_LEN 24
|
||||
#define MAX_SENSORS 32
|
||||
|
||||
|
||||
|
||||
// constant of SES element definitions
|
||||
// common status
|
||||
#define SES_COMMON_STATUS_OK 0x00000001
|
||||
#define SES_COMMON_STATUS_CRITICAL 0x00000002
|
||||
|
||||
// power
|
||||
#define SES_POWER_FAIL 0x40000000
|
||||
|
||||
// fan(cooling)
|
||||
#define SES_FAN_FAIL 0x40000000
|
||||
|
||||
// temperature
|
||||
#define SES_OVER_TEMPERATURE 0x08000000
|
||||
|
||||
// voltage
|
||||
#define SES_OVER_VOLTAGE 0x00000200
|
||||
#define SES_UNDER_VOLTAGE 0x00000100
|
||||
|
||||
#define SES_STATUS_OK(x) (x & SES_COMMON_STATUS_OK)
|
||||
#define SES_STATUS_CRITICAL(x) (x & SES_COMMON_STATUS_CRITICAL)
|
||||
|
||||
|
||||
typedef struct sELEMENT
|
||||
{
|
||||
BYTE snNumberOfSensors; // number of elements
|
||||
BYTE snElementStr[MAX_SENSORS][MAX_ELEMENT_STR_LEN]; // description of elements
|
||||
LONG snValue[MAX_SENSORS]; // the value of sensor
|
||||
DWORD snRawValue[MAX_SENSORS]; // the SES RAW value of sensor
|
||||
}sELEMENT, *pELEMENT;
|
||||
|
||||
typedef struct sDISK_ELEMENT
|
||||
{
|
||||
BYTE snNumberOfElements; // number of elements
|
||||
BYTE snElementStr[MAX_SENSORS][MAX_ELEMENT_STR_LEN]; // description of elements
|
||||
}sDISK_ELEMENT, *pDISK_ELEMENT;
|
||||
|
||||
typedef struct sSENSORS
|
||||
{
|
||||
sDISK_ELEMENT disk;
|
||||
sELEMENT voltage;
|
||||
sELEMENT fan;
|
||||
sELEMENT power;
|
||||
sELEMENT temperature;
|
||||
sELEMENT battery;
|
||||
} sSENSORS, *pSENSORS;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#ifndef _SOLARISCOMM_H_
|
||||
#define _SOLARISCOMM_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class SolarisCommInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
SolarisCommInterface();
|
||||
~SolarisCommInterface();
|
||||
bool init(const char nPortNum, char nBaudRate = 7, char nStopBit = 0);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
|
||||
private:
|
||||
int m_hComm;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#ifndef __SOLARISIOCTL_H__
|
||||
#define __SOLARISIOCTL_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <ftw.h>
|
||||
|
||||
#include <sys/mhd.h>
|
||||
#include <sys/scsi/impl/uscsi.h>
|
||||
#include <sys/scsi/generic/commands.h>
|
||||
#include <sys/scsi/generic/inquiry.h>
|
||||
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
typedef struct _SRB_IO_CONTROL sSRB_IO_CONTROL, *pSRB_IO_CONTROL;
|
||||
typedef struct _SRB_BUFFER sSRB_BUFFER, *pSRB_BUFFER;
|
||||
|
||||
|
||||
/*DeviceType*/
|
||||
#define ARECA_SATA_RAID 0x90000000
|
||||
/*FunctionCode*/
|
||||
#define FUNCTION_READ_RQBUFFER 0x0801
|
||||
#define FUNCTION_WRITE_WQBUFFER 0x0802
|
||||
#define FUNCTION_CLEAR_RQBUFFER 0x0803
|
||||
#define FUNCTION_CLEAR_WQBUFFER 0x0804
|
||||
#define FUNCTION_CLEAR_ALLQBUFFER 0x0805
|
||||
#define FUNCTION_RETURN_CODE_3F 0x0806
|
||||
#define FUNCTION_SAY_HELLO 0x0807
|
||||
#define FUNCTION_SAY_GOODBYE 0x0808
|
||||
/* ARECA IO CONTROL CODE*/
|
||||
#define ARCMSR_IOCTL_READ_RQBUFFER ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER
|
||||
#define ARCMSR_IOCTL_WRITE_WQBUFFER ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_RQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_WQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER
|
||||
#define ARCMSR_IOCTL_CLEAR_ALLQBUFFER ARECA_SATA_RAID | FUNCTION_CLEAR_ALLQBUFFER
|
||||
#define ARCMSR_IOCTL_RETURN_CODE_3F ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F
|
||||
#define ARCMSR_IOCTL_SAY_HELLO ARECA_SATA_RAID | FUNCTION_SAY_HELLO
|
||||
#define ARCMSR_IOCTL_SAY_GOODBYE ARECA_SATA_RAID | FUNCTION_SAY_GOODBYE
|
||||
/* ARECA IOCTL ReturnCode */
|
||||
#define ARCMSR_IOCTL_RETURNCODE_OK 0x00000001
|
||||
#define ARCMSR_IOCTL_RETURNCODE_ERROR 0x00000006
|
||||
#define ARCMSR_IOCTL_RETURNCODE_3F 0x0000003F
|
||||
#define SYSERR (-1)
|
||||
|
||||
typedef struct _SRB_IO_CONTROL
|
||||
{
|
||||
unsigned int HeaderLength;
|
||||
UCHAR Signature[8];
|
||||
unsigned int Timeout;
|
||||
unsigned int ControlCode;
|
||||
unsigned int ReturnCode;
|
||||
unsigned int Length;
|
||||
};
|
||||
|
||||
|
||||
typedef struct _SRB_BUFFER
|
||||
{
|
||||
sSRB_IO_CONTROL srbioctl; /*ioctl header*/
|
||||
UCHAR ioctldatabuffer[224];/*areca gui program does not accept more than 1031 byte*/
|
||||
};
|
||||
|
||||
|
||||
class SolarisIoctlInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
SolarisIoctlInterface();
|
||||
~SolarisIoctlInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
void *getDeviceHandle();
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
int getMTU();
|
||||
private:
|
||||
HANDLE m_hScsi;
|
||||
int fd;
|
||||
pthread_mutex_t mut;
|
||||
};
|
||||
|
||||
#endif
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
#ifndef __SOLARISSCSI_H__
|
||||
#define __SOLARISSCSI_H__
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <unistd.h> /* fork() */
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#ifdef __linux__
|
||||
#include <scsi/sg.h>
|
||||
#include <scsi/scsi.h>
|
||||
#include <scsi/scsi_ioctl.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
#include "arclib.h"
|
||||
|
||||
#define SCSI_INQUIRY 0x12
|
||||
#define SCSI_WRITE_BUF 0x3B
|
||||
#define SCSI_READ_BUF 0x3C
|
||||
#define SENSE_LEN 14
|
||||
#define CDB_SIZE 10
|
||||
#define BUF_SIZE 2048
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int inlen; // [i] Length of data written to device
|
||||
int outlen; // [i] Length of data read from device
|
||||
char cdb[CDB_SIZE]; // [i] SCSI command (6 <= x <= 16)
|
||||
// [o] Data read from device starts here
|
||||
// [o] On error, sense buffer starts here
|
||||
char buf[4100]; // [i] Data written to device starts here
|
||||
}sSRB_BUF, *pSRB_BUF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BYTE ErrorCode; // Error Code (70H or 71H)
|
||||
BYTE SegmentNum; // Number of current segment descriptor
|
||||
BYTE SenseKey; // Sense Key(See bit definitions too)
|
||||
BYTE InfoByte0; // Information MSB
|
||||
BYTE InfoByte1; // Information MID
|
||||
BYTE InfoByte2; // Information MID
|
||||
BYTE InfoByte3; // Information LSB
|
||||
BYTE AddSenLen; // Additional Sense Length
|
||||
BYTE ComSpecInf0; // Command Specific Information MSB
|
||||
BYTE ComSpecInf1; // Command Specific Information MID
|
||||
BYTE ComSpecInf2; // Command Specific Information MID
|
||||
BYTE ComSpecInf3; // Command Specific Information LSB
|
||||
BYTE AddSenseCode; // Additional Sense Code
|
||||
BYTE AddSenQual; // Additional Sense Code Qualifier
|
||||
BYTE FieldRepUCode; // Field Replaceable Unit Code
|
||||
BYTE SenKeySpec15; // Sense Key Specific 15th byte
|
||||
BYTE SenKeySpec16; // Sense Key Specific 16th byte
|
||||
BYTE SenKeySpec17; // Sense Key Specific 17th byte
|
||||
BYTE AddSenseBytes; // Additional Sense Bytes
|
||||
} sSENSE_DATA_FMT, *pSENSE_DATA_FMT;
|
||||
|
||||
class SolarisSCSIInterface : public ArcInterface
|
||||
{
|
||||
public:
|
||||
SolarisSCSIInterface();
|
||||
~SolarisSCSIInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
private:
|
||||
|
||||
HANDLE m_hScsi;
|
||||
//pthread_mutex_t *m_LOCK;
|
||||
int fd;
|
||||
};
|
||||
|
||||
#endif
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#ifndef _WINCOMM_H_
|
||||
#define _WINCOMM_H_
|
||||
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
// TODO: reference additional headers your program requires here
|
||||
#include <wtypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
|
||||
class ARCLIB_API WinCommInterface : public ArcInterface
|
||||
{
|
||||
friend class CArclib;
|
||||
public:
|
||||
WinCommInterface();
|
||||
~WinCommInterface();
|
||||
bool init(const char nPortNum, char nBaudRate = 7, char nStopBit = 0);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
HANDLE m_hComm;
|
||||
HANDLE m_hSyncComm;
|
||||
PSECURITY_DESCRIPTOR pSD;
|
||||
};
|
||||
|
||||
#endif
|
||||
BIN
Binary file not shown.
+132
@@ -0,0 +1,132 @@
|
||||
#ifndef _WIN_PASS_IOCTL_H_
|
||||
#define _WIN_PASS_IOCTL_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
#include <wtypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#define FILE_DEVICE_CONTROLLER 0x00000004
|
||||
|
||||
#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
|
||||
#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) //0x0004D008 see NTDDSCSI.H for definition
|
||||
#define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define ARCMSR_IOCTL_READ_RQBUFFER 0x90002004
|
||||
#define ARCMSR_IOCTL_WRITE_WQBUFFER 0x90002008
|
||||
#define ARCMSR_IOCTL_CLEAR_RQBUFFER 0x9000200C
|
||||
#define ARCMSR_IOCTL_CLEAR_WQBUFFER 0x90002010
|
||||
#define ARCMSR_IOCTL_CLEAR_ALLQBUFFER 0x90002014
|
||||
#define ARCMSR_IOCTL_RETURN_CODE_3F 0x90002018
|
||||
#define ARCMSR_IOCTL_SAY_HELLO 0x9000201C
|
||||
|
||||
|
||||
// return code
|
||||
#define SRB_STATUS_SUCCESS 0x01
|
||||
#define SRB_STATUS_INVALID_REQUEST 0x06
|
||||
|
||||
|
||||
class ARCLIB_API WinPassIoctlInterface : public ArcInterface
|
||||
{
|
||||
friend class CArclib;
|
||||
|
||||
public:
|
||||
WinPassIoctlInterface();
|
||||
~WinPassIoctlInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
HANDLE m_hScsi;
|
||||
HANDLE m_hSyncIm;
|
||||
PSECURITY_DESCRIPTOR pSD;
|
||||
};
|
||||
|
||||
//
|
||||
// SCSI CDB operation codes
|
||||
//
|
||||
|
||||
#define SCSIOP_TEST_UNIT_READY 0x00
|
||||
#define SCSIOP_REZERO_UNIT 0x01
|
||||
#define SCSIOP_REWIND 0x01
|
||||
#define SCSIOP_REQUEST_BLOCK_ADDR 0x02
|
||||
#define SCSIOP_REQUEST_SENSE 0x03
|
||||
#define SCSIOP_FORMAT_UNIT 0x04
|
||||
#define SCSIOP_READ_BLOCK_LIMITS 0x05
|
||||
#define SCSIOP_REASSIGN_BLOCKS 0x07
|
||||
#define SCSIOP_READ6 0x08
|
||||
#define SCSIOP_RECEIVE 0x08
|
||||
#define SCSIOP_WRITE6 0x0A
|
||||
#define SCSIOP_PRINT 0x0A
|
||||
#define SCSIOP_SEND 0x0A
|
||||
#define SCSIOP_SEEK6 0x0B
|
||||
#define SCSIOP_TRACK_SELECT 0x0B
|
||||
#define SCSIOP_SLEW_PRINT 0x0B
|
||||
#define SCSIOP_SEEK_BLOCK 0x0C
|
||||
#define SCSIOP_PARTITION 0x0D
|
||||
#define SCSIOP_READ_REVERSE 0x0F
|
||||
#define SCSIOP_WRITE_FILEMARKS 0x10
|
||||
#define SCSIOP_FLUSH_BUFFER 0x10
|
||||
#define SCSIOP_SPACE 0x11
|
||||
#define SCSIOP_INQUIRY 0x12
|
||||
#define SCSIOP_VERIFY6 0x13
|
||||
#define SCSIOP_RECOVER_BUF_DATA 0x14
|
||||
#define SCSIOP_MODE_SELECT 0x15
|
||||
#define SCSIOP_RESERVE_UNIT 0x16
|
||||
#define SCSIOP_RELEASE_UNIT 0x17
|
||||
#define SCSIOP_COPY 0x18
|
||||
#define SCSIOP_ERASE 0x19
|
||||
#define SCSIOP_MODE_SENSE 0x1A
|
||||
#define SCSIOP_START_STOP_UNIT 0x1B
|
||||
#define SCSIOP_STOP_PRINT 0x1B
|
||||
#define SCSIOP_LOAD_UNLOAD 0x1B
|
||||
#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
|
||||
#define SCSIOP_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSIOP_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSIOP_READ_CAPACITY 0x25
|
||||
#define SCSIOP_READ 0x28
|
||||
#define SCSIOP_WRITE 0x2A
|
||||
#define SCSIOP_SEEK 0x2B
|
||||
#define SCSIOP_LOCATE 0x2B
|
||||
#define SCSIOP_WRITE_VERIFY 0x2E
|
||||
#define SCSIOP_VERIFY 0x2F
|
||||
#define SCSIOP_SEARCH_DATA_HIGH 0x30
|
||||
#define SCSIOP_SEARCH_DATA_EQUAL 0x31
|
||||
#define SCSIOP_SEARCH_DATA_LOW 0x32
|
||||
#define SCSIOP_SET_LIMITS 0x33
|
||||
#define SCSIOP_READ_POSITION 0x34
|
||||
#define SCSIOP_SYNCHRONIZE_CACHE 0x35
|
||||
#define SCSIOP_COMPARE 0x39
|
||||
#define SCSIOP_COPY_COMPARE 0x3A
|
||||
#define SCSIOP_WRITE_DATA_BUFF 0x3B
|
||||
#define SCSIOP_READ_DATA_BUFF 0x3C
|
||||
#define SCSIOP_CHANGE_DEFINITION 0x40
|
||||
#define SCSIOP_READ_SUB_CHANNEL 0x42
|
||||
#define SCSIOP_READ_TOC 0x43
|
||||
#define SCSIOP_READ_HEADER 0x44
|
||||
#define SCSIOP_PLAY_AUDIO 0x45
|
||||
#define SCSIOP_PLAY_AUDIO_MSF 0x47
|
||||
#define SCSIOP_PLAY_TRACK_INDEX 0x48
|
||||
#define SCSIOP_PLAY_TRACK_RELATIVE 0x49
|
||||
#define SCSIOP_PAUSE_RESUME 0x4B
|
||||
#define SCSIOP_LOG_SELECT 0x4C
|
||||
#define SCSIOP_LOG_SENSE 0x4D
|
||||
|
||||
#endif
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
#ifndef _WIN_PASS_IOCTL_ODIN_H_
|
||||
#define _WIN_PASS_IOCTL_ODIN_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "if.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
#include <wtypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <winioctl.h>
|
||||
|
||||
#define FILE_DEVICE_CONTROLLER 0x00000004
|
||||
|
||||
#define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
|
||||
#define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) //0x0004D008 see NTDDSCSI.H for definition
|
||||
#define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
|
||||
|
||||
#define ARCMSR_IOCTL_READ_RQBUFFER 0x90002004
|
||||
#define ARCMSR_IOCTL_WRITE_WQBUFFER 0x90002008
|
||||
#define ARCMSR_IOCTL_CLEAR_RQBUFFER 0x9000200C
|
||||
#define ARCMSR_IOCTL_CLEAR_WQBUFFER 0x90002010
|
||||
#define ARCMSR_IOCTL_CLEAR_ALLQBUFFER 0x90002014
|
||||
#define ARCMSR_IOCTL_RETURN_CODE_3F 0x90002018
|
||||
#define ARCMSR_IOCTL_SAY_HELLO 0x9000201C
|
||||
|
||||
|
||||
// return code
|
||||
#define SRB_STATUS_SUCCESS 0x01
|
||||
#define SRB_STATUS_INVALID_REQUEST 0x06
|
||||
|
||||
|
||||
class ARCLIB_API WinPassIoctlOdinInterface : public ArcInterface
|
||||
{
|
||||
friend class CArclibOdin;
|
||||
|
||||
public:
|
||||
WinPassIoctlOdinInterface();
|
||||
~WinPassIoctlOdinInterface();
|
||||
bool init(const int nScsiPort);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
void requirelock();
|
||||
void releaselock();
|
||||
|
||||
private:
|
||||
BOOL ClearReadBuffer();
|
||||
BOOL ClearWriteBuffer();
|
||||
BOOL ClearReadWriteBuffer();
|
||||
HANDLE m_hScsi;
|
||||
HANDLE m_hSyncIm;
|
||||
PSECURITY_DESCRIPTOR pSD;
|
||||
};
|
||||
|
||||
//
|
||||
// SCSI CDB operation codes
|
||||
//
|
||||
|
||||
#define SCSIOP_TEST_UNIT_READY 0x00
|
||||
#define SCSIOP_REZERO_UNIT 0x01
|
||||
#define SCSIOP_REWIND 0x01
|
||||
#define SCSIOP_REQUEST_BLOCK_ADDR 0x02
|
||||
#define SCSIOP_REQUEST_SENSE 0x03
|
||||
#define SCSIOP_FORMAT_UNIT 0x04
|
||||
#define SCSIOP_READ_BLOCK_LIMITS 0x05
|
||||
#define SCSIOP_REASSIGN_BLOCKS 0x07
|
||||
#define SCSIOP_READ6 0x08
|
||||
#define SCSIOP_RECEIVE 0x08
|
||||
#define SCSIOP_WRITE6 0x0A
|
||||
#define SCSIOP_PRINT 0x0A
|
||||
#define SCSIOP_SEND 0x0A
|
||||
#define SCSIOP_SEEK6 0x0B
|
||||
#define SCSIOP_TRACK_SELECT 0x0B
|
||||
#define SCSIOP_SLEW_PRINT 0x0B
|
||||
#define SCSIOP_SEEK_BLOCK 0x0C
|
||||
#define SCSIOP_PARTITION 0x0D
|
||||
#define SCSIOP_READ_REVERSE 0x0F
|
||||
#define SCSIOP_WRITE_FILEMARKS 0x10
|
||||
#define SCSIOP_FLUSH_BUFFER 0x10
|
||||
#define SCSIOP_SPACE 0x11
|
||||
#define SCSIOP_INQUIRY 0x12
|
||||
#define SCSIOP_VERIFY6 0x13
|
||||
#define SCSIOP_RECOVER_BUF_DATA 0x14
|
||||
#define SCSIOP_MODE_SELECT 0x15
|
||||
#define SCSIOP_RESERVE_UNIT 0x16
|
||||
#define SCSIOP_RELEASE_UNIT 0x17
|
||||
#define SCSIOP_COPY 0x18
|
||||
#define SCSIOP_ERASE 0x19
|
||||
#define SCSIOP_MODE_SENSE 0x1A
|
||||
#define SCSIOP_START_STOP_UNIT 0x1B
|
||||
#define SCSIOP_STOP_PRINT 0x1B
|
||||
#define SCSIOP_LOAD_UNLOAD 0x1B
|
||||
#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
|
||||
#define SCSIOP_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSIOP_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSIOP_READ_CAPACITY 0x25
|
||||
#define SCSIOP_READ 0x28
|
||||
#define SCSIOP_WRITE 0x2A
|
||||
#define SCSIOP_SEEK 0x2B
|
||||
#define SCSIOP_LOCATE 0x2B
|
||||
#define SCSIOP_WRITE_VERIFY 0x2E
|
||||
#define SCSIOP_VERIFY 0x2F
|
||||
#define SCSIOP_SEARCH_DATA_HIGH 0x30
|
||||
#define SCSIOP_SEARCH_DATA_EQUAL 0x31
|
||||
#define SCSIOP_SEARCH_DATA_LOW 0x32
|
||||
#define SCSIOP_SET_LIMITS 0x33
|
||||
#define SCSIOP_READ_POSITION 0x34
|
||||
#define SCSIOP_SYNCHRONIZE_CACHE 0x35
|
||||
#define SCSIOP_COMPARE 0x39
|
||||
#define SCSIOP_COPY_COMPARE 0x3A
|
||||
#define SCSIOP_WRITE_DATA_BUFF 0x3B
|
||||
#define SCSIOP_READ_DATA_BUFF 0x3C
|
||||
#define SCSIOP_CHANGE_DEFINITION 0x40
|
||||
#define SCSIOP_READ_SUB_CHANNEL 0x42
|
||||
#define SCSIOP_READ_TOC 0x43
|
||||
#define SCSIOP_READ_HEADER 0x44
|
||||
#define SCSIOP_PLAY_AUDIO 0x45
|
||||
#define SCSIOP_PLAY_AUDIO_MSF 0x47
|
||||
#define SCSIOP_PLAY_TRACK_INDEX 0x48
|
||||
#define SCSIOP_PLAY_TRACK_RELATIVE 0x49
|
||||
#define SCSIOP_PAUSE_RESUME 0x4B
|
||||
#define SCSIOP_LOG_SELECT 0x4C
|
||||
#define SCSIOP_LOG_SENSE 0x4D
|
||||
|
||||
#endif
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
#ifndef _WINSCSI_H_
|
||||
#define _WINSCSI_H_
|
||||
|
||||
#include "commdef.h"
|
||||
#include "interface.h"
|
||||
#include "arclib.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <tchar.h>
|
||||
#include <wtypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define MAX_SCSI_DEV 10
|
||||
#define MAX_SCSI_CH 2
|
||||
#define MAX_SCSI_TARGETID 127 // older value is 15, modify for SAS, upgrade to 127, 2008/03/11
|
||||
#define MAX_SCSI_LUN 7
|
||||
|
||||
//
|
||||
// SCSI CDB operation codes
|
||||
//
|
||||
|
||||
#define SCSIOP_TEST_UNIT_READY 0x00
|
||||
#define SCSIOP_REZERO_UNIT 0x01
|
||||
#define SCSIOP_REWIND 0x01
|
||||
#define SCSIOP_REQUEST_BLOCK_ADDR 0x02
|
||||
#define SCSIOP_REQUEST_SENSE 0x03
|
||||
#define SCSIOP_FORMAT_UNIT 0x04
|
||||
#define SCSIOP_READ_BLOCK_LIMITS 0x05
|
||||
#define SCSIOP_REASSIGN_BLOCKS 0x07
|
||||
#define SCSIOP_READ6 0x08
|
||||
#define SCSIOP_RECEIVE 0x08
|
||||
#define SCSIOP_WRITE6 0x0A
|
||||
#define SCSIOP_PRINT 0x0A
|
||||
#define SCSIOP_SEND 0x0A
|
||||
#define SCSIOP_SEEK6 0x0B
|
||||
#define SCSIOP_TRACK_SELECT 0x0B
|
||||
#define SCSIOP_SLEW_PRINT 0x0B
|
||||
#define SCSIOP_SEEK_BLOCK 0x0C
|
||||
#define SCSIOP_PARTITION 0x0D
|
||||
#define SCSIOP_READ_REVERSE 0x0F
|
||||
#define SCSIOP_WRITE_FILEMARKS 0x10
|
||||
#define SCSIOP_FLUSH_BUFFER 0x10
|
||||
#define SCSIOP_SPACE 0x11
|
||||
#define SCSIOP_INQUIRY 0x12
|
||||
#define SCSIOP_VERIFY6 0x13
|
||||
#define SCSIOP_RECOVER_BUF_DATA 0x14
|
||||
#define SCSIOP_MODE_SELECT 0x15
|
||||
#define SCSIOP_RESERVE_UNIT 0x16
|
||||
#define SCSIOP_RELEASE_UNIT 0x17
|
||||
#define SCSIOP_COPY 0x18
|
||||
#define SCSIOP_ERASE 0x19
|
||||
#define SCSIOP_MODE_SENSE 0x1A
|
||||
#define SCSIOP_START_STOP_UNIT 0x1B
|
||||
#define SCSIOP_STOP_PRINT 0x1B
|
||||
#define SCSIOP_LOAD_UNLOAD 0x1B
|
||||
#define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
|
||||
#define SCSIOP_SEND_DIAGNOSTIC 0x1D
|
||||
#define SCSIOP_MEDIUM_REMOVAL 0x1E
|
||||
#define SCSIOP_READ_CAPACITY 0x25
|
||||
#define SCSIOP_READ 0x28
|
||||
#define SCSIOP_WRITE 0x2A
|
||||
#define SCSIOP_SEEK 0x2B
|
||||
#define SCSIOP_LOCATE 0x2B
|
||||
#define SCSIOP_WRITE_VERIFY 0x2E
|
||||
#define SCSIOP_VERIFY 0x2F
|
||||
#define SCSIOP_SEARCH_DATA_HIGH 0x30
|
||||
#define SCSIOP_SEARCH_DATA_EQUAL 0x31
|
||||
#define SCSIOP_SEARCH_DATA_LOW 0x32
|
||||
#define SCSIOP_SET_LIMITS 0x33
|
||||
#define SCSIOP_READ_POSITION 0x34
|
||||
#define SCSIOP_SYNCHRONIZE_CACHE 0x35
|
||||
#define SCSIOP_COMPARE 0x39
|
||||
#define SCSIOP_COPY_COMPARE 0x3A
|
||||
#define SCSIOP_WRITE_DATA_BUFF 0x3B
|
||||
#define SCSIOP_READ_DATA_BUFF 0x3C
|
||||
#define SCSIOP_CHANGE_DEFINITION 0x40
|
||||
#define SCSIOP_READ_SUB_CHANNEL 0x42
|
||||
#define SCSIOP_READ_TOC 0x43
|
||||
#define SCSIOP_READ_HEADER 0x44
|
||||
#define SCSIOP_PLAY_AUDIO 0x45
|
||||
#define SCSIOP_PLAY_AUDIO_MSF 0x47
|
||||
#define SCSIOP_PLAY_TRACK_INDEX 0x48
|
||||
#define SCSIOP_PLAY_TRACK_RELATIVE 0x49
|
||||
#define SCSIOP_PAUSE_RESUME 0x4B
|
||||
#define SCSIOP_LOG_SELECT 0x4C
|
||||
#define SCSIOP_LOG_SENSE 0x4D
|
||||
|
||||
|
||||
class ARCLIB_API WinScsiInterface : public ArcInterface
|
||||
{
|
||||
friend class CArclib;
|
||||
public:
|
||||
WinScsiInterface();
|
||||
~WinScsiInterface();
|
||||
bool init_physical_drive(const int pd);
|
||||
bool init(const int scsi,const int ch = 0, const int id = 0, const int lun = 0);
|
||||
int send(sIF_CMD_BLOCK *ifData);
|
||||
int recv(sIF_CMD_BLOCK *ifData);
|
||||
int syncSend(sIF_CMD_BLOCK *ifData);
|
||||
int getMTU();
|
||||
void *getDeviceHandle();
|
||||
|
||||
private:
|
||||
HANDLE m_hScsi;
|
||||
unsigned int nAddress;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user