2 * Copyright (c) 2010-2011 Matthias Rustler
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include <proto/utility.h>
26 #include <clib/alib_protos.h>
30 #include "identify_intern.h"
33 /*****************************************************************************
36 #include <proto/identify.h>
38 AROS_LH1(LONG
, IdExpansion
,
41 AROS_LHA(struct TagItem
*, taglist
, A0
),
44 struct IdentifyBaseIntern
*, IdentifyBase
, 5, Identify
)
47 Gets the name and class of the expansion and it's manufacturer.
50 TagList -- (struct TagItem *) tags that describe further options.
53 Error -- (LONG) error code, or 0 if everything went fine.
55 IDERR_NOLENGTH -- IDTAG_StrLength has been set to 0!
56 IDERR_BADID -- IDTAG_ManufID and IDTAG_ProdID were
57 out of range or one of them was missing.
58 IDERR_DONE -- Checked all expansions using the
59 IDTAG_Expansion tag. This is not really an error.
60 IDERR_SECONDARY -- This expansion is secondary to a primary
64 IDTAG_ConfigDev -- (struct ConfigDev *) ConfigDev structure
65 containing all information. You should use this tag if ever
66 possible, since there are more possibilities to recognize and
67 distinguish between a board.
69 IDTAG_ManufID -- (UWORD) Manufacturer ID if ConfigDev is not
70 provided. You must also provide IDTAG_ProdID!
72 IDTAG_ProdID -- (UBYTE) Product ID if ConfigDev is not
73 provided. You must also provide IDTAG_ManufID!
75 IDTAG_ManufStr -- (STRPTR) Pointer to a buffer space for the
76 manufacturer name. You may skip this tag if you do not want
79 IDTAG_ProdStr -- (STRPTR) Pointer to a buffer space for the
80 product name. You may skip this tag if you do not want
83 IDTAG_ClassStr -- (STRPTR) Pointer to a buffer space for the
84 product class. You may skip this tag if you do not want to get
87 IDTAG_StrLength -- (UWORD) Buffer length, including
88 termination. Defaults to 50.
90 IDTAG_Expansion -- [V6] (struct ConfigDev **) Use this tag to
91 easily traverse through the expansion board list. Init the
92 pointed variable with NULL. After each call, you will find
93 the current ConfigDev pointer in this variable. If you are
94 done, this function returns IDERR_DONE and the variable is set
97 IDTAG_Secondary -- [V7] (BOOL) If set to TRUE, identify will
98 warn about secondary expansions. E.g. some graphic boards
99 create more than one entry in the expansion list. Then, one
100 entry is the primary entry, and any additional are secondary.
101 This tag does only make sense when checking all mounted
102 expansions. Defaults to FALSE. (See Bugs)
104 IDTAG_ClassID -- [V8] (ULONG *) The ULONG field will be filled
105 with a numerical class ID of the expansion (see include file:
106 IDCID_...). IMPORTANT: You MUST be prepared to get a number
107 that does not match to any IDCID value. In this case, assume
110 IDTAG_Localize -- [V8] (BOOL) FALSE to get English strings
111 only, TRUE for localized strings. This is useful for applications
112 with English as only language. Defaults to TRUE.
115 To check all expansion boards, you may use this code:
117 void PrintExpansions(void)
119 struct ConfigDev *expans = NULL;
120 char manuf[IDENTIFYBUFLEN];
121 char prod[IDENTIFYBUFLEN];
122 char pclass[IDENTIFYBUFLEN];
124 while(!IdExpansionTags(
125 IDTAG_ManufStr ,manuf,
127 IDTAG_ClassStr ,pclass,
128 IDTAG_Expansion,&expans,
131 Printf("Current ConfigDev = 0x%08lx\n",expans);
132 Printf(" Manufacturer = %s\n",manuf);
133 Printf(" Product = %s\n",prod);
134 Printf(" Expansion class = %s\n\n",class);
139 This function isn't implemented yet.
141 If the manufacturer or the product is not known, the string will be
142 filled with its number.
144 This call is guaranteed to preserve all registers except D0.
147 You must also provide IDTAG_ProdStr if you want to use IDTAG_Secondary.
156 *****************************************************************************/
160 STRPTR manufstr
= NULL
;
161 STRPTR prodstr
= NULL
;
162 STRPTR classstr
= NULL
;
163 ULONG strlength
= 50;
164 struct ConfigDev
**expansion
= NULL
;
165 BOOL secondary
= FALSE
;
166 ULONG
*classid
= NULL
;
167 BOOL localize
= TRUE
;
170 struct TagItem
*tags
;
172 for (tags
= taglist
; (tag
= NextTagItem(&tags
)); )
176 case IDTAG_ConfigDev
:
177 // doesn't return anything
181 // doesn't return anything
185 // doesn't return anything
189 manufstr
= (STRPTR
)tag
->ti_Data
;
193 prodstr
= (STRPTR
)tag
->ti_Data
;
197 classstr
= (STRPTR
)tag
->ti_Data
;
200 case IDTAG_StrLength
:
201 strlength
= tag
->ti_Data
;
204 case IDTAG_Expansion
:
205 expansion
= (struct ConfigDev
**)tag
->ti_Data
;
208 case IDTAG_Secondary
:
209 secondary
= tag
->ti_Data
? TRUE
: FALSE
;
213 classid
= (ULONG
*)tag
->ti_Data
;
217 localize
= tag
->ti_Data
? TRUE
: FALSE
;
225 return IDERR_NOLENGTH
;
229 /* FIXME: Do we need to do something here? */
233 /* FIXME: Do we need to do something here? */
236 // return something to avoid crashes when function is called
239 strlcpy(manufstr
, "Unknown", strlength
);
243 strlcpy(prodstr
, "Unknown", strlength
);
247 strlcpy(classstr
, "Unknown", strlength
);
255 *classid
= IDCID_UNKNOWN
;