grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / hidds / pci / pcitool / main.c
blob693d4f2d5a421256a36c903e92fe86c49e8625f5
1 /*
2 Copyright (C) 2003-2014, The AROS Development Team.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <exec/memory.h>
8 #include <libraries/mui.h>
9 #include <hidd/hidd.h>
10 #include <hidd/pci.h>
11 #include <utility/tagitem.h>
12 #include <utility/hooks.h>
14 #include <proto/alib.h>
15 #include <proto/exec.h>
16 #include <proto/muimaster.h>
17 #include <proto/oop.h>
18 #include <proto/utility.h>
19 #include <proto/intuition.h>
20 #include "pciids.h"
22 #include <aros/debug.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include "locale.h"
27 #include "support.h"
28 #include "saveinfo.h"
30 #define APPNAME "PCITool"
31 #define VERSION "PCITool 0.7 (12.3.2014)"
32 #define IDB_SAVE 10001
33 #define IDB_SAVEALL 10002
34 #define MAX_STRING_LENGTH 200
35 const char version[] = "$VER: " VERSION "\n";
37 struct Library *OOPBase = NULL;
38 struct Library *MUIMasterBase = NULL;
39 struct UtilityBase *UtilityBase = NULL;
40 struct PCIInfo SaveDeviceInfo;
42 OOP_AttrBase __IHidd_PCIDevice;
43 OOP_AttrBase __IHidd_PCIDriver;
44 OOP_AttrBase HiddAttrBase;
46 OOP_Object *pci;
48 int openLibs()
50 if ((OOPBase=OpenLibrary("oop.library", 0)) != NULL)
52 __IHidd_PCIDevice = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
53 __IHidd_PCIDriver = OOP_ObtainAttrBase(IID_Hidd_PCIDriver);
54 HiddAttrBase = OOP_ObtainAttrBase(IID_Hidd);
56 if ((MUIMasterBase=OpenLibrary("muimaster.library", 0)) != NULL)
58 if ((UtilityBase=(struct UtilityBase*)OpenLibrary("utility.library", 0)) != NULL)
60 pciids_Open();
61 return 1;
65 return 0;
68 void closeLibs()
70 pciids_Close();
72 if (pci)
73 OOP_DisposeObject(pci);
75 OOP_ReleaseAttrBase(IID_Hidd_PCIDevice);
76 OOP_ReleaseAttrBase(IID_Hidd_PCIDriver);
77 OOP_ReleaseAttrBase(IID_Hidd);
79 if (OOPBase != NULL)
80 CloseLibrary(OOPBase);
82 if (UtilityBase != NULL)
83 CloseLibrary((struct Library *)UtilityBase);
85 if (MUIMasterBase != NULL)
86 CloseLibrary(MUIMasterBase);
88 MUIMasterBase = NULL;
89 UtilityBase = NULL;
90 OOPBase = NULL;
93 void cleanup(CONST_STRPTR message)
95 Locale_Deinitialize();
97 if (message != NULL)
99 ShowError(NULL, NULL, message, TRUE);
100 exit(RETURN_FAIL);
102 else
104 exit(RETURN_OK);
108 Object *MakeLabel(STRPTR str)
110 return (MUI_MakeObject(MUIO_Label, str, 0));
113 LONG xget(Object * obj, ULONG attr)
115 LONG x = 0;
116 get(obj, attr, &x);
117 return x;
120 Object *app;
121 Object *MainWindow;
122 Object *DriverList;
123 Object *StrDriverName, *StrDriverHWName, *StrDriverDirect, *StrIOBase;
125 Object *StrDescription, *VendorID, *ProductID, *RevisionID;
126 Object *VendorName, *ProductName, *SubsystemName, *OwnerName;
127 Object *_Class, *SubClass, *Interface, *IRQLine;
128 Object *ROMBase, *ROMSize;
129 Object *RangeList;
130 Object *Status;
131 Object *SaveInfo, *SaveAllInfo;
133 Object *PCIeSerialNumber;
135 struct Hook pci_hook;
136 struct Hook display_hook;
137 struct Hook select_hook;
138 struct Hook save_hook;
139 struct Hook saveall_hook;
141 AROS_UFH3(void, pci_callback,
142 AROS_UFHA(struct Hook *, hook, A0),
143 AROS_UFHA(OOP_Object *, obj, A2),
144 AROS_UFHA(APTR, msg, A1))
146 AROS_USERFUNC_INIT
148 DoMethod(DriverList, MUIM_List_InsertSingle, (IPTR)obj, MUIV_List_Insert_Bottom);
150 AROS_USERFUNC_EXIT
153 AROS_UFH3(void, save_function,
154 AROS_UFHA(struct Hook *, hook, A0),
155 AROS_UFHA(Object *, obj, A2),
156 AROS_UFHA(APTR, msg, A1))
158 AROS_USERFUNC_INIT
160 LONG active = xget(DriverList, MUIA_List_Active);
161 if (active != MUIV_List_Active_Off)
163 /*Saves the Info of the Displayed Device to RamDisk*/
164 SaveToDisk(&SaveDeviceInfo);
166 else
168 // TODO: requester
169 PutStr("No active entry\n");
172 AROS_USERFUNC_EXIT
175 AROS_UFH3(void, saveall_function,
176 AROS_UFHA(struct Hook *, hook, A0),
177 AROS_UFHA(Object *, obj, A2),
178 AROS_UFHA(APTR, msg, A1))
180 AROS_USERFUNC_INIT
182 LONG entries, i;
184 /*Saves All PCITool Info to RamDisk*/
185 if (OpenPCIInfoFile())
187 entries = XGET(DriverList, MUIA_List_Entries);
188 for(i = 0 ; i < entries ; i++)
190 set(DriverList, MUIA_List_Active, i);
191 WriteToPCIInfoFile(&SaveDeviceInfo);
193 ClosePCIInfoFile();
196 AROS_USERFUNC_EXIT
199 AROS_UFH3(void, display_function,
200 AROS_UFHA(struct Hook *, h, A0),
201 AROS_UFHA(char **, strings, A2),
202 AROS_UFHA(OOP_Object *, obj, A1))
204 AROS_USERFUNC_INIT
206 static char buf[20];
207 IPTR bus, dev, sub;
209 if (obj)
211 OOP_GetAttr(obj, aHidd_PCIDevice_Bus, (APTR)&bus);
212 OOP_GetAttr(obj, aHidd_PCIDevice_Dev, (APTR)&dev);
213 OOP_GetAttr(obj, aHidd_PCIDevice_Sub, (APTR)&sub);
215 snprintf(buf, 19, "%02lx.%02lx.%01lx", bus, dev, sub);
216 strings[0] = buf;
219 AROS_USERFUNC_EXIT
222 void memoryPrint(STRPTR buffer, unsigned int bar, unsigned int base, unsigned int size, unsigned int type)
224 if(type & ADDRF_IO)
226 snprintf(buffer, 59, "Bar%d: %s%s at 0x%04x (size 0x%x)", bar,
227 (type & ADDRF_PREFETCH) ? "Prefetchable " :"",
228 (type & ADDRF_IO)?"I/O":"Memory",
229 base, size);
231 else
233 snprintf(buffer, 59, "Bar%d: %s%s at 0x%08x (size 0x%x)", bar,
234 (type & ADDRF_PREFETCH) ? "Prefetchable " :"",
235 (type & ADDRF_IO)?"I/O":"Memory",
236 base, size);
240 AROS_UFH3(void, select_function,
241 AROS_UFHA(struct Hook *, h, A0),
242 AROS_UFHA(Object *, object, A2),
243 AROS_UFHA(APTR, msg, A1))
245 AROS_USERFUNC_INIT
247 ULONG active;
248 OOP_Object *obj, *drv;
249 STRPTR class, subclass, interface, str, owner;
250 UWORD vendor, product, subvendor, subdevice;
252 active = xget(object, MUIA_List_Active);
253 if (active != MUIV_List_Active_Off)
255 IPTR val, val2, val3;
256 static char buf[MAX_STRING_LENGTH + 1];
258 static char ranges[6][60];
259 DoMethod(object, MUIM_List_GetEntry, active, (IPTR)&obj);
261 OOP_GetAttr(obj, aHidd_PCIDevice_Driver, (APTR)&drv);
262 OOP_GetAttr(drv, aHidd_Name, (APTR)&str);
263 set(StrDriverName, MUIA_Text_Contents, str);
264 strcpy(SaveDeviceInfo.Driver_name, str); //Save Debug Info
265 OOP_GetAttr(drv, aHidd_HardwareName, (APTR)&str);
266 set(StrDriverHWName, MUIA_Text_Contents, str);
267 strcpy(SaveDeviceInfo.Hardware_info, str); //Save Debug Info
268 OOP_GetAttr(drv, aHidd_PCIDriver_IOBase, &val);
269 snprintf(SaveDeviceInfo.IOBase, 10, "0x%08lx", val);
270 set(StrIOBase, MUIA_Text_Contents, SaveDeviceInfo.IOBase);
271 OOP_GetAttr(drv, aHidd_PCIDriver_DirectBus, (APTR)&val);
272 set(StrDriverDirect, MUIA_Text_Contents, (IPTR)((val)?_(MSG_YES):_(MSG_NO)));
273 strcpy(SaveDeviceInfo.Direct_bus, (val)?_(MSG_YES):_(MSG_NO)); //Save Debug Info
274 OOP_GetAttr(obj, aHidd_PCIDevice_ClassDesc, (APTR)&class);
275 OOP_GetAttr(obj, aHidd_PCIDevice_SubClassDesc, (APTR)&subclass);
276 OOP_GetAttr(obj, aHidd_PCIDevice_InterfaceDesc, (APTR)&interface);
277 snprintf(buf, MAX_STRING_LENGTH, "%s %s %s", class, subclass,
278 interface);
279 set(StrDescription, MUIA_Text_Contents, buf);
280 strcpy(SaveDeviceInfo.Description, buf); //Save Debug Info
281 OOP_GetAttr(obj, aHidd_PCIDevice_VendorID, (APTR)&val);
282 snprintf(buf, MAX_STRING_LENGTH, "0x%04lx", val);
283 set(VendorID, MUIA_Text_Contents, buf);
284 strcpy(SaveDeviceInfo.VendorID, buf);
285 set(VendorName, MUIA_Text_Contents, pciids_GetVendorName(val, buf,
286 MAX_STRING_LENGTH));
287 vendor = val;
288 strcpy(SaveDeviceInfo.Vendor_name,
289 pciids_GetVendorName(val, buf, MAX_STRING_LENGTH)); //Save Debug Info
290 OOP_GetAttr(obj, aHidd_PCIDevice_ProductID, (APTR)&val);
291 snprintf(buf, MAX_STRING_LENGTH, "0x%04lx", val);
292 set(ProductID, MUIA_Text_Contents, buf);
293 strcpy(SaveDeviceInfo.ProductID, buf); //Save Debug Info
294 set(ProductName, MUIA_Text_Contents,
295 pciids_GetDeviceName(vendor, val, buf, MAX_STRING_LENGTH));
296 product = val;
297 strcpy(SaveDeviceInfo.Product_name,
298 pciids_GetDeviceName(vendor, val, buf, MAX_STRING_LENGTH));
300 OOP_GetAttr(obj, aHidd_PCIDevice_SubsystemVendorID, (APTR)&val);
301 subvendor = val;
302 OOP_GetAttr(obj, aHidd_PCIDevice_SubsystemID, (APTR)&val);
303 subdevice = val;
304 set(SubsystemName, MUIA_Text_Contents,
305 pciids_GetSubDeviceName(vendor, product, subvendor, subdevice,
306 buf, MAX_STRING_LENGTH));
307 strcpy(SaveDeviceInfo.Subsystem, pciids_GetSubDeviceName(vendor,
308 product, subvendor, subdevice, buf, MAX_STRING_LENGTH));
310 OOP_GetAttr(obj, aHidd_PCIDevice_Owner, (IPTR *)&owner);
311 if (owner)
313 set(OwnerName, MUIA_Text_Contents, owner);
314 strcpy(SaveDeviceInfo.Owner, owner);
316 else
318 set(OwnerName, MUIA_Text_Contents, "");
319 SaveDeviceInfo.Owner[0] = 0;
322 OOP_GetAttr(obj, aHidd_PCIDevice_RevisionID, (APTR)&val);
323 snprintf(buf, MAX_STRING_LENGTH, "0x%02lx", val);
324 set(RevisionID, MUIA_Text_Contents, buf);
325 strcpy(SaveDeviceInfo.RevisionID, buf); //Save Debug Info
327 OOP_GetAttr(obj, aHidd_PCIDevice_Interface, (APTR)&val);
328 snprintf(buf, MAX_STRING_LENGTH, "0x%02lx", val);
329 set(Interface, MUIA_Text_Contents, buf);
330 strcpy(SaveDeviceInfo.Interface, buf); //Save Debug Info
332 OOP_GetAttr(obj, aHidd_PCIDevice_Class, (APTR)&val);
333 snprintf(buf, MAX_STRING_LENGTH, "0x%02lx", val);
334 set(_Class, MUIA_Text_Contents, buf);
335 strcpy(SaveDeviceInfo.Class, buf); //Save Debug Info
337 OOP_GetAttr(obj, aHidd_PCIDevice_SubClass, (APTR)&val);
338 snprintf(buf, MAX_STRING_LENGTH, "0x%02lx", val);
339 set(SubClass, MUIA_Text_Contents, buf);
340 strcpy(SaveDeviceInfo.Subclass, buf); //Save Debug Info
342 OOP_GetAttr(obj, aHidd_PCIDevice_IRQLine, (APTR)&val);
343 OOP_GetAttr(obj, aHidd_PCIDevice_INTLine, (APTR)&val2);
344 if (val)
346 snprintf(buf, MAX_STRING_LENGTH, "%ld (%c)", val2,
347 (int)val + 'A' - 1);
349 else strncpy(buf, _(MSG_NA), MAX_STRING_LENGTH);
350 buf[MAX_STRING_LENGTH] = 0;
351 set(IRQLine, MUIA_Text_Contents, buf);
352 strcpy(SaveDeviceInfo.IRQ, buf); //Save Debug Info
354 OOP_GetAttr(obj, aHidd_PCIDevice_RomBase, (APTR)&val);
355 OOP_GetAttr(obj, aHidd_PCIDevice_RomSize, (APTR)&val2);
356 snprintf(buf, MAX_STRING_LENGTH, "0x%08lx", val2);
357 if (val2)
359 set(ROMSize, MUIA_Text_Contents, buf);
360 strcpy(SaveDeviceInfo.ROM_Size, buf); //Save Debug Info
361 if (val)
363 snprintf(buf, MAX_STRING_LENGTH, "0x%08lx", val);
364 set(ROMBase, MUIA_Text_Contents, buf);
365 strcpy(SaveDeviceInfo.ROM_Base, buf); //Save Debug Info
367 else set(ROMBase, MUIA_Text_Contents, _(MSG_UNUSED));
369 else
371 set(ROMBase, MUIA_Text_Contents, _(MSG_NA));
372 strcpy(SaveDeviceInfo.ROM_Base, _(MSG_NA));
373 set(ROMSize, MUIA_Text_Contents, _(MSG_NA));
374 strcpy(SaveDeviceInfo.ROM_Size, _(MSG_NA));
377 OOP_GetAttr(obj, aHidd_PCIDevice_ExtendedCapabilitySerialNumber, (APTR)&val);
378 if(val)
380 val2 = HIDD_PCIDevice_ReadConfigLong(obj, val+4);
381 val3 = HIDD_PCIDevice_ReadConfigLong(obj, val+8);
382 snprintf(buf, MAX_STRING_LENGTH, "%08lx:%08lx", val3, val2);
383 set(PCIeSerialNumber, MUIA_Text_Contents, buf);
385 else set(PCIeSerialNumber, MUIA_Text_Contents, _(MSG_NA));
387 DoMethod(RangeList, MUIM_List_Clear);
389 OOP_GetAttr(obj, aHidd_PCIDevice_Base0, (APTR)&val);
390 OOP_GetAttr(obj, aHidd_PCIDevice_Size0, (APTR)&val2);
391 OOP_GetAttr(obj, aHidd_PCIDevice_Type0, (APTR)&val3);
393 if (val)
395 memoryPrint(ranges[0], 0, val, val2, val3);
396 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[0], MUIV_List_Insert_Bottom);
397 strcpy(SaveDeviceInfo.Rangelist_0, ranges[0]);
400 OOP_GetAttr(obj, aHidd_PCIDevice_Base1, (APTR)&val);
401 OOP_GetAttr(obj, aHidd_PCIDevice_Size1, (APTR)&val2);
402 OOP_GetAttr(obj, aHidd_PCIDevice_Type1, (APTR)&val3);
404 if (val)
406 memoryPrint(ranges[1], 1, val, val2, val3);
407 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[1], MUIV_List_Insert_Bottom);
408 strcpy(SaveDeviceInfo.Rangelist_1, ranges[1]);
411 OOP_GetAttr(obj, aHidd_PCIDevice_isBridge, (APTR)&val);
412 if (!val)
415 OOP_GetAttr(obj, aHidd_PCIDevice_Base2, (APTR)&val);
416 OOP_GetAttr(obj, aHidd_PCIDevice_Size2, (APTR)&val2);
417 OOP_GetAttr(obj, aHidd_PCIDevice_Type2, (APTR)&val3);
419 if (val)
421 memoryPrint(ranges[2], 2, val, val2, val3);
422 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[2], MUIV_List_Insert_Bottom);
423 strcpy(SaveDeviceInfo.Rangelist_2, ranges[2]);
426 OOP_GetAttr(obj, aHidd_PCIDevice_Base3, (APTR)&val);
427 OOP_GetAttr(obj, aHidd_PCIDevice_Size3, (APTR)&val2);
428 OOP_GetAttr(obj, aHidd_PCIDevice_Type3, (APTR)&val3);
430 if (val)
432 memoryPrint(ranges[3], 3, val, val2, val3);
433 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[3], MUIV_List_Insert_Bottom);
434 strcpy(SaveDeviceInfo.Rangelist_3, ranges[3]);
437 OOP_GetAttr(obj, aHidd_PCIDevice_Base4, (APTR)&val);
438 OOP_GetAttr(obj, aHidd_PCIDevice_Size4, (APTR)&val2);
439 OOP_GetAttr(obj, aHidd_PCIDevice_Type4, (APTR)&val3);
441 if (val)
443 memoryPrint(ranges[4], 4, val, val2, val3);
444 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[4], MUIV_List_Insert_Bottom);
445 strcpy(SaveDeviceInfo.Rangelist_4, ranges[4]);
448 OOP_GetAttr(obj, aHidd_PCIDevice_Base5, (APTR)&val);
449 OOP_GetAttr(obj, aHidd_PCIDevice_Size5, (APTR)&val2);
450 OOP_GetAttr(obj, aHidd_PCIDevice_Type5, (APTR)&val3);
452 if (val)
454 memoryPrint(ranges[5], 5, val, val2, val3);
455 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[5], MUIV_List_Insert_Bottom);
456 strcpy(SaveDeviceInfo.Rangelist_5, ranges[5]);
459 else
461 OOP_GetAttr(obj, aHidd_PCIDevice_SubBus, (APTR)&val);
462 OOP_GetAttr(obj, aHidd_PCIDevice_ISAEnable, (APTR)&val2);
463 OOP_GetAttr(obj, aHidd_PCIDevice_VGAEnable, (APTR)&val3);
465 snprintf(ranges[2], 59, _(MSG_BRIDGE),
466 val, (val2) ? (CONST_STRPTR)" " : _(MSG_NOT),
467 (val3) ? (CONST_STRPTR)" " : _(MSG_NOT));
468 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[2], MUIV_List_Insert_Bottom);
469 strcpy(SaveDeviceInfo.Rangelist_2, ranges[2]);
470 OOP_GetAttr(obj, aHidd_PCIDevice_MemoryBase, (APTR)&val);
471 OOP_GetAttr(obj, aHidd_PCIDevice_MemoryLimit, (APTR)&val2);
473 snprintf(ranges[3], 59, _(MSG_MEMORY_RANGE), val, val2);
474 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[3], MUIV_List_Insert_Bottom);
475 strcpy(SaveDeviceInfo.Rangelist_3, ranges[3]);
476 OOP_GetAttr(obj, aHidd_PCIDevice_PrefetchableBase, (APTR)&val);
477 OOP_GetAttr(obj, aHidd_PCIDevice_PrefetchableLimit, (APTR)&val2);
479 snprintf(ranges[4], 59, _(MSG_PREFETCHABLE_MEMORY), val, val2);
480 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[4], MUIV_List_Insert_Bottom);
481 strcpy(SaveDeviceInfo.Rangelist_4, ranges[4]);
482 OOP_GetAttr(obj, aHidd_PCIDevice_IOBase, (APTR)&val);
483 OOP_GetAttr(obj, aHidd_PCIDevice_IOLimit, (APTR)&val2);
485 snprintf(ranges[5], 59, _(MSG_IO_RANGE), val, val2);
486 DoMethod(RangeList, MUIM_List_InsertSingle, (IPTR)ranges[5], MUIV_List_Insert_Bottom);
487 strcpy(SaveDeviceInfo.Rangelist_5, ranges[5]);
490 IPTR io, mem, master, snoop, is66;
492 OOP_GetAttr(obj, aHidd_PCIDevice_isIO, (APTR)&io);
493 OOP_GetAttr(obj, aHidd_PCIDevice_isMEM, (APTR)&mem);
494 OOP_GetAttr(obj, aHidd_PCIDevice_isMaster, (APTR)&master);
495 OOP_GetAttr(obj, aHidd_PCIDevice_paletteSnoop, (APTR)&snoop);
496 OOP_GetAttr(obj, aHidd_PCIDevice_is66MHz, (APTR)&is66);
498 snprintf(buf, MAX_STRING_LENGTH, _(MSG_IO_MSG),
499 io ? _(MSG_YES):_(MSG_NO),
500 mem ? _(MSG_YES):_(MSG_NO),
501 master ? _(MSG_YES):_(MSG_NO),
502 snoop ? _(MSG_YES):_(MSG_NO),
503 is66 ? _(MSG_YES):_(MSG_NO));
504 set(Status, MUIA_Text_Contents, buf);
505 strcpy(SaveDeviceInfo.Status, buf);
509 AROS_USERFUNC_EXIT
512 BOOL GUIinit()
514 BOOL retval = FALSE;
516 app = ApplicationObject,
517 MUIA_Application_Title, (IPTR)APPNAME,
518 MUIA_Application_Version, (IPTR)VERSION,
519 MUIA_Application_Copyright, (IPTR)"(C) 2004-2014, The AROS Development Team",
520 MUIA_Application_Author, (IPTR)"Michal Schulz",
521 MUIA_Application_Base, (IPTR)APPNAME,
522 MUIA_Application_Description, __(MSG_DESCRIPTION),
524 SubWindow, MainWindow = WindowObject,
525 MUIA_Window_Title, __(MSG_WINTITLE),
526 // MUIA_Window_Height, MUIV_Window_Height_Visible(50),
527 // MUIA_Window_Width, MUIV_Window_Width_Visible(60),
529 WindowContents, HGroup,
530 MUIA_Group_SameWidth, FALSE,
532 Child, ListviewObject,
533 MUIA_Listview_List, DriverList = ListObject,
534 ReadListFrame,
535 MUIA_List_AdjustWidth, TRUE,
536 MUIA_List_DisplayHook, &display_hook,
537 End, // List
538 MUIA_CycleChain, 1,
539 End, // ListView
540 Child, VGroup,
541 Child, VGroup, GroupFrameT(_(MSG_DRIVER_INFO)),
542 Child, ColGroup(2),
543 Child, Label(_(MSG_DRIVER_NAME)),
544 Child, HGroup,
545 Child, StrDriverName = TextObject,
546 TextFrame,
547 MUIA_Background, MUII_TextBack,
548 MUIA_Text_SetMax, FALSE,
549 MUIA_Text_Contents, "",
550 End,
551 Child, Label(_(MSG_DIRECT_BUS)),
552 Child, StrDriverDirect = TextObject,
553 TextFrame,
554 MUIA_Background, MUII_TextBack,
555 MUIA_Text_SetMax, FALSE,
556 MUIA_Text_Contents, "",
557 End,
558 End,
559 Child, Label(_(MSG_IO_BASE)),
560 Child, HGroup,
561 Child, StrIOBase = TextObject,
562 TextFrame,
563 MUIA_Background, MUII_TextBack,
564 MUIA_Text_SetMax, FALSE,
565 MUIA_Text_Contents, "0x00000000",
566 End,
567 Child, HSpace(0),
568 End,
569 Child, Label(_(MSG_HARDWARE_INFO)),
570 Child, StrDriverHWName = TextObject,
571 TextFrame,
572 MUIA_Background, MUII_TextBack,
573 MUIA_Text_SetMax, FALSE,
574 MUIA_Text_Contents, "",
575 End,
576 End,
577 End, // HGroup
578 Child, VGroup, GroupFrameT(_(MSG_PCI_DEVICE_INFO)),
579 Child, ColGroup(2),
580 Child, Label(_(MSG_DEVICE_DESCRIPTION)),
581 Child, StrDescription = TextObject,
582 TextFrame,
583 MUIA_Background, MUII_TextBack,
584 MUIA_Text_SetMax, FALSE,
585 MUIA_Text_Contents, "",
586 End,
587 Child, Label(_(MSG_VENDORNAME)),
588 Child, VendorName = TextObject,
589 TextFrame,
590 MUIA_Background, MUII_TextBack,
591 MUIA_Text_SetMax, FALSE,
592 MUIA_Text_Contents, "",
593 End,
594 Child, Label(_(MSG_PRODUCTNAME)),
595 Child, ProductName = TextObject,
596 TextFrame,
597 MUIA_Background, MUII_TextBack,
598 MUIA_Text_SetMax, FALSE,
599 MUIA_Text_Contents, "",
600 End,
601 Child, Label(_(MSG_SUBSYSTEM)),
602 Child, SubsystemName = TextObject,
603 TextFrame,
604 MUIA_Background, MUII_TextBack,
605 MUIA_Text_SetMax, FALSE,
606 MUIA_Text_Contents, "",
607 End,
608 Child, Label(_(MSG_OWNER)),
609 Child, OwnerName = TextObject,
610 TextFrame,
611 MUIA_Background, MUII_TextBack,
612 MUIA_Text_SetMax, FALSE,
613 MUIA_Text_Contents, "",
614 End,
615 End,
616 Child, ColGroup(6),
617 Child, Label(_(MSG_VENDORID)),
618 Child, VendorID = TextObject,
619 TextFrame,
620 MUIA_Background, MUII_TextBack,
621 MUIA_Text_SetMax, FALSE,
622 MUIA_Text_Contents, "0x0000",
623 End,
624 Child, Label(_(MSG_PRODUCTID)),
625 Child, ProductID = TextObject,
626 TextFrame,
627 MUIA_Background, MUII_TextBack,
628 MUIA_Text_SetMax, FALSE,
629 MUIA_Text_Contents, "0x0000",
630 End,
631 Child, Label(_(MSG_REVISIONID)),
632 Child, RevisionID = TextObject,
633 TextFrame,
634 MUIA_Background, MUII_TextBack,
635 MUIA_Text_SetMax, FALSE,
636 MUIA_Text_Contents, "0x0000",
637 End,
638 Child, Label(_(MSG_CLASS)),
639 Child, _Class = TextObject,
640 TextFrame,
641 MUIA_Background, MUII_TextBack,
642 MUIA_Text_SetMax, FALSE,
643 MUIA_Text_Contents, "0x00",
644 End,
645 Child, Label(_(MSG_SUBCLASS)),
646 Child, SubClass = TextObject,
647 TextFrame,
648 MUIA_Background, MUII_TextBack,
649 MUIA_Text_SetMax, FALSE,
650 MUIA_Text_Contents, "0x00",
651 End,
652 Child, Label(_(MSG_INTERFACE)),
653 Child, Interface = TextObject,
654 TextFrame,
655 MUIA_Background, MUII_TextBack,
656 MUIA_Text_SetMax, FALSE,
657 MUIA_Text_Contents, "0x00",
658 End,
659 Child, Label(_(MSG_ROM_BASE)),
660 Child, ROMBase = TextObject,
661 TextFrame,
662 MUIA_Background, MUII_TextBack,
663 MUIA_Text_SetMax, FALSE,
664 MUIA_Text_Contents, "0x00000000",
665 End,
666 Child, Label(_(MSG_ROM_SIZE)),
667 Child, ROMSize = TextObject,
668 TextFrame,
669 MUIA_Background, MUII_TextBack,
670 MUIA_Text_SetMax, FALSE,
671 MUIA_Text_Contents, "0x00000000",
672 End,
673 Child, Label(_(MSG_IRQ)),
674 Child, IRQLine = TextObject,
675 TextFrame,
676 MUIA_Background, MUII_TextBack,
677 MUIA_Text_SetMax, FALSE,
678 MUIA_Text_Contents, "15",
679 End,
680 End,
681 Child, VGroup, GroupFrameT(_(MSG_PCIE_DEVICE_INFO)),
682 Child, ColGroup(2),
683 Child, Label(_(MSG_PCIE_SERIAL_NUMBER)),
684 Child, PCIeSerialNumber = TextObject,
685 TextFrame,
686 MUIA_Background, MUII_TextBack,
687 MUIA_Text_SetMax, FALSE,
688 MUIA_Text_Contents, "00000000:00000000",
689 End,
690 End,
691 End,
692 Child, HGroup,
693 Child, RangeList = ListviewObject,
694 MUIA_Listview_List, ListObject,
695 ReadListFrame,
696 MUIA_List_AdjustWidth, FALSE,
697 End, // List
698 End, // ListView
699 End,
700 Child, Status = TextObject,
701 TextFrame,
702 MUIA_Background, MUII_TextBack,
703 MUIA_Text_SetMax, FALSE,
704 End,
705 End,
706 /*Save the displayed info into a text file in RAM:*/
707 Child, SaveInfo = SimpleButton(_(MSG_SAVETORAMDISK) ),
708 Child, SaveAllInfo = SimpleButton(_(MSG_SAVEALLTORAMDISK) ),
709 End,
710 End, // WindowContents
711 End, // MainWindow
712 End; // ApplicationObject
714 if (app)
716 /* Quit application if the windowclosegadget or the esc key is pressed. */
717 DoMethod(MainWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
718 (IPTR)app, 2,
719 MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
721 DoMethod(DriverList, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime,
722 (IPTR)DriverList, 2,
723 MUIM_CallHook, (IPTR)&select_hook);
725 DoMethod(SaveInfo, MUIM_Notify, MUIA_Pressed, FALSE,
726 (IPTR)app, 2,
727 MUIM_CallHook, (IPTR)&save_hook);
729 DoMethod(SaveAllInfo, MUIM_Notify, MUIA_Pressed, FALSE,
730 (IPTR)app, 2,
731 MUIM_CallHook, (IPTR)&saveall_hook);
733 retval=TRUE;
736 return retval;
739 int main(void)
741 pci_hook.h_Entry = (APTR)pci_callback;
742 display_hook.h_Entry = (APTR)display_function;
743 select_hook.h_Entry = (APTR)select_function;
744 save_hook.h_Entry = (APTR)save_function;
745 saveall_hook.h_Entry = (APTR)saveall_function;
747 if (!Locale_Initialize())
748 cleanup(_(MSG_ERROR_LOCALE));
750 if(openLibs())
752 if(GUIinit())
754 pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL);
755 if (pci)
757 HIDD_PCI_EnumDevices(pci, &pci_hook, NULL);
760 set(DriverList, MUIA_List_Active, MUIV_List_Active_Top);
761 set(MainWindow, MUIA_Window_ActiveObject, DriverList);
762 set(MainWindow, MUIA_Window_Open, TRUE);
764 if(xget(MainWindow, MUIA_Window_Open))
766 DoMethod(app, MUIM_Application_Execute);
767 set(MainWindow, MUIA_Window_Open, FALSE);
770 DisposeObject(app);
774 closeLibs();
776 cleanup(NULL);
778 return 0;
779 } /* main(int argc, char *argv[]) */