-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPCILookUpSingle.ZC
executable file
·140 lines (129 loc) · 2.95 KB
/
PCILookUpSingle.ZC
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#help_index "PCI;Processor;Devices;Info"
//The file was downloaded from
//http://pci-ids.ucw.cz/v2.2/pci.ids
#define PCI_DEV_FILE "::/Misc/PCIDevices.DD"
/****
//1) Download http://pci-ids.ucw.cz/v2.2/pci.ids
//2) Rename to ::/Misc/PCIDevices.DD
//3) ToDolDoc("::/Misc/PCIDevices.DD");
//4) Edit and remove file tail (Class Codes List)
//5) Text find-and-replace "=0A=" with "". (Doesn't seem necessary anmore.)
//6) Run PCIDevFileGen(). (Doesn't seem necessary anmore.)
public U0 PCIDevFileGen()
{
Bool first=TRUE,del=FALSE,del2=FALSE,cont=FALSE;
CDoc *doc=DocRead(PCI_DEV_FILE,
DOCF_PLAIN_TEXT|DOCF_DBL_DOLLARS|DOCF_NO_CURSOR);
CDocEntry *doc_e=doc->head.next,*doc_e2;
while (doc_e!=doc) {
doc_e2=doc_e->next;
if (first) {
if (doc_e->type_u8==DOCT_TEXT) {
if (doc_e->tag[0]==';')
del=TRUE;
}
first=FALSE;
}
if (doc_e->type_u8==DOCT_TEXT && doc_e->tag[StrLen(doc_e->tag)-1]=='=' &&
doc_e2->type_u8==DOCT_NEW_LINE) {
doc_e->tag[StrLen(doc_e->tag)-1]=CH_SPACE;
cont=TRUE;
}
del2=del;
if (doc_e->type_u8==DOCT_NEW_LINE) {
first=TRUE;
del2=FALSE;
if (cont) {
del=TRUE;
cont=FALSE;
}
}
if (del)
DocEntryDel(doc,doc_e);
del=del2;
doc_e=doc_e2;
}
DocWrite(doc);
}
****/
//$LK,"::/Misc/PCIDevices.DD",A="PI:::/Misc/PCIDevices.DD"$
U0 PCILookUpSingle(CDoc *doc, I64 m, I64 d, U8 **_vendor, U8 **_dev)
{
Bool first = TRUE;
U8 buf[8], *vendor = NULL, *dev = NULL;
CDocEntry *doc_e = doc->head.next;
while (doc_e != doc)
{
if (first)
{
if (doc_e->type_u8 == DOCT_TEXT && doc_e->tag[0] != ';' && doc_e->tag[0] != '#' && StrLen(doc_e->tag) >= 4)
{
buf[0](U16) = '0x';
buf[2](U32) = doc_e->tag(U32 *)[0];
buf[6] = '\0';
if (Str2I64(buf) == m)
{
vendor = SysStrNew(doc_e->tag + 6);
first = FALSE;
break;
/* doc_e = doc_e->next->next->next;
if (doc_e->type_u8 == DOCT_TEXT)
{
vendor = SysStrNew(doc_e->tag);
first = FALSE;
break;
}
*/ }
}
first=FALSE;
}
if (doc_e->type_u8 == DOCT_NEW_LINE)
first = TRUE;
doc_e = doc_e->next;
}
if (vendor)
{
while (doc_e != doc)
{
if (first)
{
if (doc_e->type_u8 == DOCT_TAB)
{
// doc_e = doc_e->next->next->next->next;
doc_e = doc_e->next;
if (doc_e->type_u8 == DOCT_TEXT && StrLen(doc_e->tag) >= 4)
{
buf[0](U16) = '0x';
buf[2](U32) = doc_e->tag(U32 *)[0];
buf[6] = '\0';
if (Str2I64(buf) == d)
{
dev = SysStrNew(doc_e->tag + 6);
break;
/* doc_e = doc_e->next->next->next;
if (doc_e->type_u8 == DOCT_TEXT)
{
dev = SysStrNew(doc_e->tag);
break;
}
*/ }
}
}
else if (doc_e->tag[0] != '#')
break;
first = FALSE;
}
if (doc_e->type_u8 == DOCT_NEW_LINE)
first = TRUE;
doc_e = doc_e->next;
}
}
if (vendor)
*_vendor = vendor;
else
*_vendor = SysStrNew("Unknown");
if (dev)
*_dev = dev;
else
*_dev = SysStrNew("Unknown");
}