- Fixed mix-up of return codes and error codes, and calling of SetIoErr()
[AROS.git] / test / pcilist.c
blobef92d067f8c94675ccd373aba77429e0f8354995
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 struct Library *DOSBase;
20 struct Library *OOPBase;
21 OOP_AttrBase HiddPCIDeviceAttrBase;
23 #define PATTR(tag) ({ IPTR _val = ~0; \
24 OOP_GetAttr(obj, aHidd_PCIDevice_##tag, &_val); \
25 _val; })
27 AROS_UFH3(void, Callback,
28 AROS_UFHA(struct Hook *, hook, A0),
29 AROS_UFHA(OOP_Object *, obj, A2),
30 AROS_UFHA(APTR, msg, A1))
32 AROS_USERFUNC_INIT
34 Printf("%lx: %ld:%ld.%ld %04lx:%04lx, INT %ld, IRQ %ld\n",
35 PATTR(Driver), PATTR(Bus), PATTR(Dev), PATTR(Sub),
36 PATTR(VendorID), PATTR(ProductID),
37 PATTR(INTLine), PATTR(IRQLine));
39 AROS_USERFUNC_EXIT
42 struct Hook PCIHook = {
43 .h_Entry = (APTR)Callback,
46 int __startup _main(void)
48 int ret = RETURN_FAIL;
50 if ((DOSBase = OpenLibrary("dos.library", 0))) {
52 if ((OOPBase = OpenLibrary("oop.library", 0))) {
53 OOP_Object *pci;
55 if ((pci = OOP_NewObject(NULL, CLID_Hidd_PCI, NULL))) {
56 struct pHidd_PCI_EnumDevices msg;
57 Printf("PCI Devices:\n");
58 HiddPCIDeviceAttrBase = OOP_ObtainAttrBase(IID_Hidd_PCIDevice);
60 msg.mID = OOP_GetMethodID(IID_Hidd_PCI, moHidd_PCI_EnumDevices);
61 msg.callback = &PCIHook;
62 msg.requirements = NULL;
64 OOP_DoMethod(pci, (OOP_Msg)&msg);
65 OOP_DisposeObject(pci);
66 ret = RETURN_OK;
67 } else {
68 Printf("Can't open pci.hidd\n");
70 CloseLibrary(OOPBase);
71 } else {
72 Printf("Can't open oop.library\n");
74 CloseLibrary(DOSBase);
77 return ret;