Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
c05d9d49
Commit
c05d9d49
authored
Jul 26, 2013
by
Victor Kotlyar
Browse files
added LOG SELECT CDB structure and tests.
parent
333df69d
Changes
2
Hide whitespace changes
Inline
Side-by-side
SCSI/Structures.hh
View file @
c05d9d49
...
...
@@ -116,6 +116,41 @@ namespace SCSI {
unsigned
char
reserved2
[
22
];
unsigned
char
vendorSpecific2
[
1
];
}
inquiryData_t
;
/*
* LOG SELECT CDB as described in SPC-4.
*/
class
logSelectCDB_t
{
public:
// byte 0
unsigned
char
opCode
;
// OPERATION CODE (4Ch)
// byte 1
unsigned
char
SP
:
1
;
// the Save Parameters
unsigned
char
PCR
:
1
;
// the Parameter Code Reset
unsigned
char
:
6
;
// Reserved
// byte 2
unsigned
char
pageCode
:
6
;
// PAGE CODE
unsigned
char
PC
:
2
;
// the Page Control
// byte 3
unsigned
char
subPageCode
;
// SUBPAGE CODE (Reserved for T10000)
// bytes 4-6
unsigned
char
reserved
[
3
];
// Reserved
// bytes 7-8
unsigned
char
parameterListLength
[
2
];
// PARAMETER LIST LENGTH
// byte 9
unsigned
char
control
;
// CONTROL
logSelectCDB_t
()
{
memset
(
this
,
0
,
sizeof
(
*
this
));
opCode
=
SCSI
::
Commands
::
LOG_SELECT
;
}
};
template
<
size_t
n
>
std
::
string
toString
(
const
char
(
&
t
)[
n
])
{
...
...
SCSI/StructuresTest.cc
View file @
c05d9d49
...
...
@@ -125,4 +125,34 @@ namespace UnitTests {
buff
[
5
]
=
0xCA
;
ASSERT_EQ
(
0xCA
,
inqCDB
.
control
);
}
TEST
(
SCSI_Structures
,
logSelectCDB_t
)
{
SCSI
::
Structures
::
logSelectCDB_t
logSelectCDB
;
unsigned
char
*
buff
=
(
unsigned
char
*
)
&
logSelectCDB
;
/*
* Make sure this struct is a POD (plain old data without virtual table)
* (and has the right size).
*/
ASSERT_EQ
(
10
,
sizeof
(
logSelectCDB
));
ASSERT_EQ
(
SCSI
::
Commands
::
LOG_SELECT
,
logSelectCDB
.
opCode
);
buff
[
0
]
=
0xAB
;
ASSERT_EQ
(
0xAB
,
logSelectCDB
.
opCode
);
buff
[
1
]
|=
(
0x1
&
0x7
)
<<
0
;
ASSERT_EQ
(
1
,
logSelectCDB
.
SP
);
buff
[
1
]
|=
(
0x1
&
0xF
)
<<
1
;
ASSERT_EQ
(
1
,
logSelectCDB
.
PCR
);
buff
[
2
]
|=
0xAB
<<
2
>>
2
;
ASSERT_EQ
(
0x2B
,
logSelectCDB
.
pageCode
);
buff
[
2
]
|=
0x70
<<
1
;
ASSERT_EQ
(
0x3
,
logSelectCDB
.
PC
);
buff
[
3
]
|=
0xBC
;
ASSERT_EQ
(
0xBC
,
logSelectCDB
.
subPageCode
);
/* ... */
buff
[
7
]
|=
0xAB
;
buff
[
8
]
|=
0xCD
;
ASSERT_EQ
(
0xABCD
,
logSelectCDB
.
parameterListLength
[
0
]
<<
8
|
logSelectCDB
.
parameterListLength
[
1
]);
buff
[
9
]
|=
0xBC
;
ASSERT_EQ
(
0xBC
,
logSelectCDB
.
control
);
}
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment