emul-handler: fh_Arg1 should be the only element of struct FileHandle touched during...
[AROS.git] / test / pcilist.c
blob8f77cf2a034b4578abd73bef058380bc5a0afbfb
1 /*
2 * Copyright (C) 2012, The AROS Development Team
3 * All right reserved.
4 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
6 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
7 */
9 #define __DOS_STDLIBBASE__
10 #define __OOP_STDLIBBASE__
12 #include <aros/system.h>
13 #include <hidd/pci.h>
15 #include <proto/exec.h>
16 #include <proto/oop.h>
17 #include <proto/dos.h>
19 #include <aros/shcommands.h>
21 struct Library *DOSBase;
22 struct Library *OOPBase;
23 OOP_AttrBase HiddPCIDeviceAttrBase;
25 #define PATTR(tag) ({ IPTR _val = ~0; \
26 OOP_GetAttr(obj, aHidd_PCIDevice_##tag, &_val); \
27 _val; })
29 AROS_UFH3(void, Callback,
30 AROS_UFHA(struct Hook *, hook, A0),
31 AROS_UFHA(OOP_Object *, obj, A2),
32 AROS_UFHA(APTR, msg, A1))
34 AROS_USERFUNC_INIT
36 Printf("%lx: %ld:%ld.%ld %04lx:%04lx, INT %ld, IRQ %ld\n",
37 PATTR(Driver), PATTR(Bus), PATTR(Dev), PATTR(Sub),
38 PATTR(VendorID), PATTR(ProductID),
39 PATTR(INTLine), PATTR(IRQLine));
41 AROS_USERFUNC_EXIT
44 struct Hook PCIHook = {
45 .h_Entry = (APTR)Callback,
48 AROS_SH0(pcilist, 0.0)
50 AROS_SHCOMMAND_INIT
52 int ret = RETURN_FAIL;
54 if ((OOPBase = OpenLibrary("oop.library", 0))) {
55 OOP_Object *pci;
57 if ((pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL))) {
58 struct pHidd_PCI_EnumDevices msg;
59 Printf("PCI Devices:\n");
60 HiddPCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
62 msg.mID = OOP_GetMethodID(IID_Hidd_PCI, moHidd_PCI_EnumDevices);
63 msg.callback = &PCIHook;
64 msg.requirements = NULL;
66 OOP_DoMethod(pci, (OOP_Msg)&msg);
67 OOP_DisposeObject(pci);
68 ret = RETURN_OK;
69 } else {
70 Printf("Can't open pci.hidd\n");
72 CloseLibrary(OOPBase);
73 } else {
74 Printf("Can't open oop.library\n");
77 return ret;
79 AROS_SHCOMMAND_EXIT