Bus reset timeouts are now implemented with more coarse-grained sleeps
[tangerine.git] / rom / expansion / findconfigdev.c
blob04b688b02a140d8d011b1b42efd4cc2d338d630e
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: FindConfigDev() - Find a specific configurable device.
6 Lang: english
7 */
8 #include "expansion_intern.h"
10 /*****************************************************************************
12 NAME */
13 #include <proto/expansion.h>
15 AROS_LH3(struct ConfigDev *, FindConfigDev,
17 /* SYNOPSIS */
18 AROS_LHA(struct ConfigDev *, oldConfigDev, A0),
19 AROS_LHA(LONG , manufacturer, D0),
20 AROS_LHA(LONG , product, D1),
22 /* LOCATION */
23 struct ExpansionBase *, ExpansionBase, 12, Expansion)
25 /* FUNCTION
26 FindConfigDev() will search through the list of ConfigDevs and find
27 the one with the matching manufacturer and product identifiers.
29 The search will start with the ConfigDev after the oldConfigDev,
30 or at the beginning of oldConfigDev is NULL.
32 A manufacturer or product of -1 is treated as a wildcard and will
33 match any value.
35 INPUTS
36 oldConfigDev - The device to start the search after. If NULL
37 the search will start from the beginning of the
38 list.
39 manufacturer - The manufacturer id of the requested ConfigDev.
40 A value of -1 will match any device.
41 product - The product id of the ConfigDev. A value of -1
42 will match any device.
44 RESULT
45 The address of the first matching ConfigDev structure, or NULL if
46 none could be found.
48 NOTES
50 EXAMPLE
51 // Find all the config devs in the system
52 struct ConfigDev *cd = NULL;
54 while((cd = FindConfigDev(NULL, -1, -1)))
56 Printf("Found a device:\tMan = %5d\tProd = %d\n",
57 cd->cd_Rom.er_Manufacturer,
58 cd->cd_Rom.er_Product);
61 BUGS
63 SEE ALSO
65 INTERNALS
67 HISTORY
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 struct ConfigDev *cd = NULL;
75 /* Search through the list, we might as well lock it */
76 ObtainConfigBinding();
78 if( oldConfigDev == NULL )
79 cd = (struct ConfigDev *)
80 ((struct IntExpansionBase *)ExpansionBase)->eb_BoardList.lh_Head;
81 else
82 cd = oldConfigDev;
84 while( cd->cd_Node.ln_Succ != NULL )
88 ((manufacturer == -1) || (cd->cd_Rom.er_Manufacturer == manufacturer))
89 && ((product == -1) || (cd->cd_Rom.er_Product == product))
91 break;
93 cd = (struct ConfigDev *)cd->cd_Node.ln_Succ;
96 ReleaseConfigBinding();
97 return cd;
99 AROS_LIBFUNC_EXIT
100 } /* FindConfigDev */