Updated debug output.
[AROS.git] / rom / aros / arosinquirea.c
blobd0cf777204c2404f1a16d3aa5447cce8e45b9a9f
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/config.h>
10 #include <exec/types.h>
11 #include <utility/tagitem.h>
12 #include <aros/kernel.h>
13 #include <aros/libcall.h>
14 #include <proto/kernel.h>
15 #include <proto/utility.h>
17 #include "aros_intern.h"
19 #define DEBUG 0
20 #include <aros/debug.h>
21 #undef kprintf
23 /* Kickstart ROM location offsets */
24 #define LOC_COOKIE 0x00
25 #define LOC_ADDRESS 0x04
26 #define LOC_MAJORV 0x0c
27 #define LOC_MINORV 0x0e
28 #define LOC_ROMSIZE 0x14 /* offset from end of ROM! */
29 #define ROM_END 0x1000000
31 #define AROS_VERSION_MAJOR 1
32 #define AROS_VERSION_MINOR 12
33 #define AROS_ABI_VERSION_MAJOR -1 /* Change only value, name is used in external script */
34 #define AROS_RELEASE_DATE 7560 /* in days since 1978-01-01 */
36 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
37 /* Native AROS support functions */
38 IPTR kicksize(void);
39 IPTR kickbase(void);
40 #endif
42 /*****************************************************************************
44 NAME */
45 #include <aros/inquire.h>
47 AROS_LH1(ULONG, ArosInquireA,
49 /* SYNOPSIS */
51 AROS_LHA(struct TagItem *, taglist, A0),
53 /* LOCATION */
55 struct ArosBase *, ArosBase, 5, Aros)
57 /* FUNCTION
58 This function is used to query system characteristics not easily
59 queried with another function.
61 INPUTS
62 tags -- taglist with appropriate queries. The tag's ti_Data field
63 should point to the location where the result of the query
64 is stored. Do not forget to clear the location before, as
65 queries not understood will be left untouched.
67 AI_KickstartBase APTR
68 AI_KickstartSize ULONG
69 AI_KickstartVersion UWORD
70 AI_KickstartRevision UWORD
71 Only support these tags if we are on the native machine. On other machines this
72 call will not touch the storage space. Set the storage space to 0 if you want to
73 see if this call touches it.
75 AI_ArosVersion IPTR
76 aros.library version masquerades as AROS version. This means
77 that all aros modules must have the same major version number.
79 AI_ArosReleaseMajor IPTR
80 Update this whenever a new AROS is released.
82 AI_ArosReleaseMinor IPTR
83 Update this whenever a new AROS is released.
85 AI_ArosReleaseDate IPTR
86 Update this whenever a new AROS is released.
88 AI_ArosBuildDate IPTR
89 Given in the format: <d>.<m>.<y>
91 AI_ArosVariant IPTR
92 Distribution name.
94 AI_ArosArchitecture IPTR
95 Return the target architecture.
97 AI_ArosABIMajor IPTR
98 Update this whenever a new ABI is introduced in AROS. Special value of
99 -1 means that the ABI is under development and subject to change.
102 RESULT
103 All queries understood by this call will have appropriate values
104 assigned to the location a tag's ti_Data pointed to.
106 This function will return 0 on success, or the index of the
107 first tag that could not be processed. (Ie 1 for Tag[0], 2 for
108 Tag[1], etc)
110 NOTES
112 EXAMPLE
114 BUGS
116 SEE ALSO
117 aros/arosbase.h
119 INTERNALS
121 ******************************************************************************/
123 AROS_LIBFUNC_INIT
125 APTR UtilityBase;
126 struct TagItem *tag;
127 ULONG ret = 0;
128 int i = 0;
129 IPTR data = 0;
131 if (!(UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY)))
132 return 1;
134 # define SetData(tag,type,value) \
135 D(bug(" Data was: %d\n", *((type *)(tag->ti_Data)))); \
136 (*((type *)(tag->ti_Data)) = value); \
137 D(bug(" Data is : %d\n", *((type *)(tag->ti_Data))))
139 D(bug("ArosInquireA(taglist=%p)\n", taglist));
141 while( (tag = NextTagItem(&taglist)))
143 D(bug(" tag[%d] = 0x%lx data = 0x%lx\n", i, tag->ti_Tag, tag->ti_Data));
144 i++;
146 switch(tag->ti_Tag)
149 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
151 Only support these tags if we are on the native machine. On other
152 machines this call will not touch the storage space. Set the
153 storage space to 0 if you want to see if this call touches it.
156 case AI_KickstartBase:
157 SetData (tag, APTR, kickbase());
158 break;
160 case AI_KickstartSize:
161 SetData (tag, ULONG, kicksize());
162 break;
164 case AI_KickstartVersion:
165 SetData (tag, UWORD, *(UWORD *)(kickbase() + LOC_MAJORV));
166 break;
168 case AI_KickstartRevision:
169 SetData (tag, UWORD, *(UWORD *)(kickbase() + LOC_MINORV));
170 break;
171 #else
172 case AI_KickstartSize:
173 SetData (tag, ULONG, 0);
174 break;
176 #endif
178 case AI_ArosVersion:
180 aros.library version masquerades as AROS version. This means
181 that all aros modules must have the same major version number.
183 SetData (tag, IPTR, VERSION_NUMBER);
184 break;
186 case AI_ArosReleaseMajor:
187 /* Update this whenever a new AROS is released */
188 SetData (tag, IPTR, AROS_VERSION_MAJOR);
189 break;
191 case AI_ArosReleaseMinor:
192 /* Update this whenever a new AROS is released */
193 SetData (tag, IPTR, AROS_VERSION_MINOR);
194 break;
196 case AI_ArosReleaseDate:
197 /* Update this whenever a new AROS is released */
198 SetData (tag, IPTR, AROS_RELEASE_DATE);
199 break;
201 case AI_ArosBuildDate:
202 SetData (tag, IPTR, (IPTR)__DATE__);
203 break;
205 #ifdef VARIANT
207 * Reserved for distribution maintainers.
208 * DO NOT set this to configure-time variant name. That name is used to identify
209 * sub-architecture name, and changing it may break compatibility between
210 * different AROS modules, especially on hosted. Full complete platform name
211 * (including variant, if appropriate) is available via KATTR_Architecture
212 * kernel's attribute.
213 * Add one more configure option, or, better, provide some another way
214 * (env variable, whatever).
216 case AI_ArosVariant:
217 SetData (tag, IPTR, (IPTR) VARIANT);
218 break;
219 #endif
221 case AI_ArosABIMajor:
222 SetData (tag, IPTR, AROS_ABI_VERSION_MAJOR);
223 break;
225 case AI_ArosArchitecture:
226 #ifdef KrnGetSystemAttr
227 if (ArosBase->aros_KernelBase)
229 APTR KernelBase = ArosBase->aros_KernelBase;
230 data = KrnGetSystemAttr(KATTR_Architecture);
232 #else
234 * This is a legacy hack for old PPC-native kernel.resource implementations.
235 * Please do not support this. aros.library is a part of base kickstart, and
236 * it is platform-independent. Consequently, it should not include any hardcoded
237 * references to platform name. Platform name is specified by kernel.resource.
238 * See boot/modular_kickstart.txt for more info.
240 data = (IPTR)AROS_ARCHITECTURE;
241 #endif
242 SetData(tag, IPTR, data);
243 break;
245 default:
246 SetData (tag, IPTR, 0);
247 if (ret == 0)
248 ret = i;
249 break;
254 CloseLibrary(UtilityBase);
256 return ret;
257 AROS_LIBFUNC_EXIT
258 } /* ArosInquireA */
260 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
261 /* Native AROS support functions */
262 IPTR kicksize(void)
264 return *(ULONG *)(ROM_END - LOC_ROMSIZE);
267 IPTR kickbase(void)
269 return (ROM_END - kicksize());
271 #endif