grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / hidds / pci / pcitool / saveinfo.c
blob032f1de0ae9902aadfef65539de4800789b33c71
1 /*
2 Copyright (C) 2003-2013, The AROS Development Team.
3 $Id$
4 */
7 #include "saveinfo.h"
9 BPTR DeviceInfoFile;
11 /*Save only the displayed PCI Information to RAM Disk*/
12 void SaveToDisk(struct PCIInfo *DeviceInfo)
14 DeviceInfoFile = Open( "RAM:PCIToolInfo.txt", MODE_NEWFILE );
15 if (DeviceInfoFile)
17 FPuts( DeviceInfoFile, "Driver Name: ");
18 FPuts( DeviceInfoFile, DeviceInfo->Driver_name );
19 FPuts( DeviceInfoFile, "\n" );
21 FPuts( DeviceInfoFile, "Direct bus: ");
22 FPuts( DeviceInfoFile, DeviceInfo->Direct_bus );
23 FPuts( DeviceInfoFile, "\n" );
25 FPuts( DeviceInfoFile, "IÒ base: ");
26 FPuts( DeviceInfoFile, DeviceInfo->IOBase );
27 FPuts( DeviceInfoFile, "\n" );
29 FPuts( DeviceInfoFile, "Hardware info: ");
30 FPuts( DeviceInfoFile, DeviceInfo->Hardware_info );
31 FPuts( DeviceInfoFile, "\n" );
33 FPuts( DeviceInfoFile, "Description: ");
34 FPuts( DeviceInfoFile, DeviceInfo->Description );
35 FPuts( DeviceInfoFile, "\n" );
37 FPuts( DeviceInfoFile, "Vendor name: ");
38 FPuts( DeviceInfoFile, DeviceInfo->Vendor_name );
39 FPuts( DeviceInfoFile, "\n" );
41 FPuts( DeviceInfoFile, "Product name: ");
42 FPuts( DeviceInfoFile, DeviceInfo->Product_name );
43 FPuts( DeviceInfoFile, "\n" );
45 FPuts( DeviceInfoFile, "Subsystem: ");
46 FPuts( DeviceInfoFile, DeviceInfo->Subsystem );
47 FPuts( DeviceInfoFile, "\n" );
49 FPuts( DeviceInfoFile, "Used by: ");
50 FPuts( DeviceInfoFile, DeviceInfo->Owner );
51 FPuts( DeviceInfoFile, "\n" );
53 FPuts( DeviceInfoFile, "VendorID: ");
54 FPuts( DeviceInfoFile, DeviceInfo->VendorID );
55 FPuts( DeviceInfoFile, "\n" );
57 FPuts( DeviceInfoFile, "ProductID: ");
58 FPuts( DeviceInfoFile, DeviceInfo->ProductID );
59 FPuts( DeviceInfoFile, "\n" );
61 FPuts( DeviceInfoFile, "RevisionID: ");
62 FPuts( DeviceInfoFile, DeviceInfo->RevisionID );
63 FPuts( DeviceInfoFile, "\n" );
65 FPuts( DeviceInfoFile, "Class: ");
66 FPuts( DeviceInfoFile, DeviceInfo->Class );
67 FPuts( DeviceInfoFile, "\n" );
69 FPuts( DeviceInfoFile, "Subclass: ");
70 FPuts( DeviceInfoFile, DeviceInfo->Subclass );
71 FPuts( DeviceInfoFile, "\n" );
73 FPuts( DeviceInfoFile, "Interface: ");
74 FPuts( DeviceInfoFile, DeviceInfo->Interface );
75 FPuts( DeviceInfoFile, "\n" );
77 FPuts( DeviceInfoFile, "ROM Base: ");
78 FPuts( DeviceInfoFile, DeviceInfo->ROM_Base );
79 FPuts( DeviceInfoFile, "\n" );
81 FPuts( DeviceInfoFile, "ROM Size: ");
82 FPuts( DeviceInfoFile, DeviceInfo->ROM_Size );
83 FPuts( DeviceInfoFile, "\n" );
85 FPuts( DeviceInfoFile, "IRQ: ");
86 FPuts( DeviceInfoFile, DeviceInfo->IRQ );
87 FPuts( DeviceInfoFile, "\n" );
89 FPuts( DeviceInfoFile, "Status: ");
90 FPuts( DeviceInfoFile, DeviceInfo->Status );
91 FPuts( DeviceInfoFile, "\n" );
93 FPuts( DeviceInfoFile, "RangeList_0: ");
94 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_0 );
95 FPuts( DeviceInfoFile, "\n" );
97 FPuts( DeviceInfoFile, "RangeList_1: ");
98 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_1 );
99 FPuts( DeviceInfoFile, "\n" );
101 FPuts( DeviceInfoFile, "RangeList_2: ");
102 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_2 );
103 FPuts( DeviceInfoFile, "\n" );
105 FPuts( DeviceInfoFile, "RangeList_3: ");
106 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_3 );
107 FPuts( DeviceInfoFile, "\n" );
109 FPuts( DeviceInfoFile, "RangeList_4: ");
110 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_4 );
111 FPuts( DeviceInfoFile, "\n" );
113 FPuts( DeviceInfoFile, "RangeList_5: ");
114 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_5 );
115 FPuts( DeviceInfoFile, "\n" );
117 /*Clean up the Device Values*/
118 CleanUpPCIToolInfo(DeviceInfo);
120 Close( DeviceInfoFile );
122 else
124 // TODO: Requester
125 PutStr("Can't open file for output\n");
129 /*Just Open a new Textfile in RAM Disk. No writing yet*/
130 BOOL OpenPCIInfoFile(void)
132 DeviceInfoFile = Open( "RAM:PCIToolInfo.txt", MODE_NEWFILE );
134 if(DeviceInfoFile)
136 return TRUE;
138 else
140 return FALSE;
144 /*Closes the file opened by OpenPCIInfoFile*/
145 void ClosePCIInfoFile(void)
147 if(DeviceInfoFile)
149 Close(DeviceInfoFile);
153 /*Writes a set of PCI Information to the Opened file*/
154 void WriteToPCIInfoFile(struct PCIInfo *DeviceInfo)
156 if(DeviceInfoFile)
158 FPuts( DeviceInfoFile, "\n" );
159 FPuts( DeviceInfoFile, "Driver Name: ");
160 FPuts( DeviceInfoFile, DeviceInfo->Driver_name );
161 FPuts( DeviceInfoFile, "\n" );
163 FPuts( DeviceInfoFile, "Direct bus: ");
164 FPuts( DeviceInfoFile, DeviceInfo->Direct_bus );
165 FPuts( DeviceInfoFile, "\n" );
167 FPuts( DeviceInfoFile, "Hardware info: ");
168 FPuts( DeviceInfoFile, DeviceInfo->Hardware_info );
169 FPuts( DeviceInfoFile, "\n" );
171 FPuts( DeviceInfoFile, "Description: ");
172 FPuts( DeviceInfoFile, DeviceInfo->Description );
173 FPuts( DeviceInfoFile, "\n" );
175 FPuts( DeviceInfoFile, "Vendor name: ");
176 FPuts( DeviceInfoFile, DeviceInfo->Vendor_name );
177 FPuts( DeviceInfoFile, "\n" );
179 FPuts( DeviceInfoFile, "Product name: ");
180 FPuts( DeviceInfoFile, DeviceInfo->Product_name );
181 FPuts( DeviceInfoFile, "\n" );
183 FPuts( DeviceInfoFile, "Subsystem: ");
184 FPuts( DeviceInfoFile, DeviceInfo->Subsystem );
185 FPuts( DeviceInfoFile, "\n" );
187 FPuts( DeviceInfoFile, "VendorID: ");
188 FPuts( DeviceInfoFile, DeviceInfo->VendorID );
189 FPuts( DeviceInfoFile, "\n" );
191 FPuts( DeviceInfoFile, "ProductID: ");
192 FPuts( DeviceInfoFile, DeviceInfo->ProductID );
193 FPuts( DeviceInfoFile, "\n" );
195 FPuts( DeviceInfoFile, "RevisionID: ");
196 FPuts( DeviceInfoFile, DeviceInfo->RevisionID );
197 FPuts( DeviceInfoFile, "\n" );
199 FPuts( DeviceInfoFile, "Class: ");
200 FPuts( DeviceInfoFile, DeviceInfo->Class );
201 FPuts( DeviceInfoFile, "\n" );
203 FPuts( DeviceInfoFile, "Subclass: ");
204 FPuts( DeviceInfoFile, DeviceInfo->Subclass );
205 FPuts( DeviceInfoFile, "\n" );
207 FPuts( DeviceInfoFile, "Interface: ");
208 FPuts( DeviceInfoFile, DeviceInfo->Interface );
209 FPuts( DeviceInfoFile, "\n" );
211 FPuts( DeviceInfoFile, "ROM Base: ");
212 FPuts( DeviceInfoFile, DeviceInfo->ROM_Base );
213 FPuts( DeviceInfoFile, "\n" );
215 FPuts( DeviceInfoFile, "ROM Size: ");
216 FPuts( DeviceInfoFile, DeviceInfo->ROM_Size );
217 FPuts( DeviceInfoFile, "\n" );
219 FPuts( DeviceInfoFile, "IRQ: ");
220 FPuts( DeviceInfoFile, DeviceInfo->IRQ );
221 FPuts( DeviceInfoFile, "\n" );
223 FPuts( DeviceInfoFile, "Status: ");
224 FPuts( DeviceInfoFile, DeviceInfo->Status );
225 FPuts( DeviceInfoFile, "\n" );
227 FPuts( DeviceInfoFile, "RangeList_0: ");
228 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_0 );
229 FPuts( DeviceInfoFile, "\n" );
231 FPuts( DeviceInfoFile, "RangeList_1: ");
232 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_1 );
233 FPuts( DeviceInfoFile, "\n" );
235 FPuts( DeviceInfoFile, "RangeList_2: ");
236 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_2 );
237 FPuts( DeviceInfoFile, "\n" );
239 FPuts( DeviceInfoFile, "RangeList_3: ");
240 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_3 );
241 FPuts( DeviceInfoFile, "\n" );
243 FPuts( DeviceInfoFile, "RangeList_4: ");
244 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_4 );
245 FPuts( DeviceInfoFile, "\n" );
247 FPuts( DeviceInfoFile, "RangeList_5: ");
248 FPuts( DeviceInfoFile, DeviceInfo->Rangelist_5 );
249 FPuts( DeviceInfoFile, "\n" );
250 FPuts( DeviceInfoFile, "\n" );
251 /*Clean up the Device Values*/
252 CleanUpPCIToolInfo(DeviceInfo);
256 void CleanUpPCIToolInfo(struct PCIInfo *DeviceInfo)
258 DeviceInfo->Driver_name[0] = '\0';
259 DeviceInfo->Direct_bus[0] = '\0';
260 DeviceInfo->Hardware_info[0] = '\0';
261 DeviceInfo->Description[0] = '\0';
262 DeviceInfo->Vendor_name[0] = '\0';
263 DeviceInfo->Product_name[0] = '\0';
264 DeviceInfo->Subsystem[0] = '\0';
265 DeviceInfo->VendorID[0] = '\0';
266 DeviceInfo->ProductID[0] = '\0';
267 DeviceInfo->RevisionID[0] = '\0';
268 DeviceInfo->Class[0] = '\0';
269 DeviceInfo->Subclass[0] = '\0';
270 DeviceInfo->Interface[0] = '\0';
271 DeviceInfo->ROM_Base[0] = '\0';
272 DeviceInfo->ROM_Size[0] = '\0';
273 DeviceInfo->IRQ[0] = '0';
274 DeviceInfo->Status[0] = '\0';
275 DeviceInfo->Rangelist_0[0] = '\0';
276 DeviceInfo->Rangelist_1[0] = '\0';
277 DeviceInfo->Rangelist_2[0] = '\0';
278 DeviceInfo->Rangelist_3[0] = '\0';
279 DeviceInfo->Rangelist_4[0] = '\0';
280 DeviceInfo->Rangelist_5[0] = '\0';