-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
60 lines (51 loc) · 1.41 KB
/
main.c
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
#include "helper.h"
#include "vendor.h"
#include "intel.h"
#include "amd.h"
int CheckChipset()
{
// Check the vendor ID of the root complex to determine the
// system's chipset.
uint32_t tmp = readpci(0, 0, 0, 0x00);
uint32_t ven = tmp & 0x0000FFFF;
switch (ven)
{
case VEN_INTEL_LONG:
printf("Detected Intel chipset.\n");
return IS_INTEL_CHIPSET;
case VEN_AMD_LONG:
case VEN_AMD_ATI_LONG:
printf("Detected AMD chipset.\n");
return IS_AMD_CHIPSET;
default:
printf("Detected unsupported chipset. Vendor ID: %04lX\n", ven);
return CHIPSET_UNSUPPORTED;
}
}
int main(int argc, char* argv[])
{
// Usage : lpcisa [base1 mask1] [base2 mask2] [base3 mask3] [base4 mask4]
// For Intel: up to 4 ranges and masks can be accepted.
// For AMD: up to 3 ranges and masks can be accepted. However, masks behave differently.
int chipset = CheckChipset();
int ret;
switch (chipset)
{
case IS_INTEL_CHIPSET:
ret = main_intel(argc, argv);
break;
case IS_AMD_CHIPSET:
ret = main_amd(argc, argv);
break;
default:
return 8;
}
if (ret)
{
// The chipset-specific routine failed to complete.
return ret;
}
printf("Resetting DMA registers...\n");
dma_reset();
return 0;
}