-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsysdep-linux.cpp
90 lines (73 loc) · 1.56 KB
/
sysdep-linux.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <term.h>
#include <curses.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include "cpuPrimitives.h"
bool initializeCore()
{
int fd;
fd = open("/dev/cpu/0/cpuid", O_RDONLY);
if (fd == -1) {
printf("ERROR: couldn't open /dev/cpu/0/cpuid (%s).", strerror(errno));
if (errno == ENXIO || errno == ENOENT) {
printf(" Make sure that cpuid module is loaded.\n");
return false;
}
if (errno == EACCES) {
printf(" Not root?.\n");
return false;
}
printf("\n");
return false;
}
close(fd);
fd = open("/dev/cpu/0/msr", O_RDWR);
if (fd == -1) {
printf("ERROR: couldn't open /dev/cpu/0/msr (%s).", strerror(errno));
if (errno == ENXIO || errno == ENOENT) {
printf(" Make sure that msr module is loaded.\n");
return false;
}
if (errno == EACCES) {
printf(" Not root?.\n");
return false;
}
printf("\n");
return false;
}
close(fd);
signal(SIGPIPE, SIG_IGN);
return true;
}
bool deinitializeCore()
{
return true;
}
void ClearScreen(unsigned int flags)
{
static char *clearstr;
if (!clearstr) {
if (!cur_term) {
int ret;
if (setupterm(NULL, 1, &ret) == ERR) {
return;
}
}
clearstr = tigetstr("clear");
if (!clearstr) {
return;
}
}
putp(clearstr);
}
BOOL SysReadPciConfigDwordEx(DWORD pciAddress, DWORD regAddress, PDWORD value)
{
return ReadPciConfigDwordEx(pciAddress, regAddress, value);
}
BOOL SysWritePciConfigDwordEx(DWORD pciAddress, DWORD regAddress, DWORD value)
{
return WritePciConfigDwordEx(pciAddress, regAddress, value);
}