2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
9 /******************************************************************************
26 Prints a list of all devices.
44 ******************************************************************************/
46 #include <exec/memory.h>
47 #include <exec/tasks.h>
48 #include <exec/execbase.h>
49 #include <exec/devices.h>
50 #include <proto/exec.h>
51 #include <dos/dosextens.h>
52 #include <proto/dos.h>
54 #if defined(__AROSPLATFORM_SMP__)
55 #include <aros/types/spinlock_s.h>
56 #include <proto/execlock.h>
57 #include <resources/execlock.h>
60 const TEXT version
[] = "$VER: DevList 41.1 (14.3.1997)\n";
72 static int adddev(struct Device
*dev
, struct dev
**l
, STRPTR
*e
)
77 (*l
)->version
= dev
->dd_Library
.lib_Version
;
78 (*l
)->revision
= dev
->dd_Library
.lib_Revision
;
79 (*l
)->opencnt
= dev
->dd_Library
.lib_OpenCnt
;
80 (*l
)->flags
= dev
->dd_Library
.lib_Flags
;
82 s1
= dev
->dd_Library
.lib_Node
.ln_Name
;
91 if(*e
<=(STRPTR
)(*l
+2))
105 static int fillbuffer(struct dev
**buffer
, IPTR size
)
107 STRPTR end
=(STRPTR
)*buffer
+size
;
109 #if defined(__AROSPLATFORM_SMP__)
110 void *ExecLockBase
= OpenResource("execlock.resource");
113 #if defined(__AROSPLATFORM_SMP__)
115 ObtainSystemLock(&SysBase
->DeviceList
, SPINLOCK_MODE_READ
, LOCKF_FORBID
);
121 for(dev
=(struct Device
*)SysBase
->DeviceList
.lh_Head
;
122 dev
->dd_Library
.lib_Node
.ln_Succ
!=NULL
;
123 dev
=(struct Device
*)dev
->dd_Library
.lib_Node
.ln_Succ
)
124 if(!adddev(dev
,buffer
,&end
))
126 #if defined(__AROSPLATFORM_SMP__)
128 ReleaseSystemLock(&SysBase
->DeviceList
, LOCKF_FORBID
);
136 #if defined(__AROSPLATFORM_SMP__)
138 ReleaseSystemLock(&SysBase
->DeviceList
, LOCKF_FORBID
);
147 int __nocommandline
= 1;
152 struct dev
*buffer
,*devs
,*devs2
;
153 LONG error
=RETURN_OK
;
155 for(size
=2048;;size
+=2048)
157 buffer
=AllocVec(size
,MEMF_ANY
);
160 FPuts(Output(),"Not Enough memory for device buffer\n");
164 if(fillbuffer(&devs
,size
))
166 #if (__WORDSIZE == 64)
167 FPuts(Output()," Address Version Rev OpenCnt Flags Name\n");
169 FPuts(Output()," Address Version Rev OpenCnt Flags Name\n");
171 for(devs2
=buffer
;devs2
<devs
;devs2
++)
173 #if (__WORDSIZE == 64)
174 Printf("0x%012.ix %7ld %4ld %7ld 0x%02lx %s\n",
176 Printf("0x%08.ix %7ld %4ld %7ld 0x%02lx %s\n",
178 devs2
->address
, devs2
->version
,
179 devs2
->revision
, devs2
->opencnt
,
180 devs2
->flags
, devs2
->name
);
181 if(SetSignal(0L,SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
)
184 SetIoErr(ERROR_BREAK
);
193 if (error
!= RETURN_OK
)
195 PrintFault(IoErr(), NULL
);