FireBirdLib - Topfield TMS PVR TAP Programming Library
SendHDDCommand.c
Go to the documentation of this file.
1
#include "
FBLib_hdd.h
"
2
#include "
libFireBird.h
"
3
4
int
SendHDDCommand
(dword Command,
const
byte
*CommandBlock,
int
BufferSize
)
5
{
6
TRACEENTER
();
7
8
#include <sys/ioctl.h>
9
#include <unistd.h>
10
#include <linux/hdreg.h>
11
#include <fcntl.h>
12
#include <linux/fs.h>
13
14
int
fd, ret, i;
15
unsigned
short
int
*p;
16
17
//Open the hard drive
18
fd = open(
"/dev/sda"
, O_RDONLY | O_NONBLOCK);
19
//fd = open("/dev/sdb", O_RDONLY | O_NONBLOCK);
20
if
(fd < 0)
21
{
22
TRACEEXIT
();
23
return
1;
24
}
25
26
//DumpMemory(CommandBlock, 7, 16);
27
28
ret = ioctl(fd, Command, CommandBlock);
29
30
//DumpMemory(CommandBlock, 7, 16);
31
32
close(fd);
33
34
if
(ret)
35
{
36
TRACEEXIT
();
37
return
1;
38
}
39
40
//Swap endianess of the whole buffer
41
p = (
unsigned
short
int
*)&CommandBlock[4];
42
i =
BufferSize
;
43
while
(i > 0)
44
{
45
endian_swap_word
(p);
46
p++;
47
i -= 2;
48
}
49
50
TRACEEXIT
();
51
return
0;
52
}
FBLib_hdd.h
endian_swap_word
#define endian_swap_word(x)
Definition:
FBLib_hdd.h:59
BufferSize
dword BufferSize
Definition:
INIOpenFile.c:7
SendHDDCommand
int SendHDDCommand(dword Command, const byte *CommandBlock, int BufferSize)
Definition:
SendHDDCommand.c:4
libFireBird.h
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
hdd
SendHDDCommand.c
Generated on Fri Apr 29 2022 13:34:01 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3