Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / aros / arosinquirea.c
blobb8e0c66923039c3bf5cc55a567405def824a5340
1 /*
2 Copyright © 1995-2014, 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 /* Amiga hardware 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 */
50 AROS_LHA(struct TagItem *, taglist, A0),
52 /* LOCATION */
53 struct ArosBase *, ArosBase, 5, Aros)
55 /* FUNCTION
56 This function is used to query system characteristics not easily
57 queried with another function. All queries understood by this call
58 will have appropriate values assigned to the location the query tag's
59 ti_Data field points to.
61 INPUTS
62 tags - a tag list with appropriate queries. Each tag's ti_Data field
63 should point to the location where the result of the query
64 is to be stored. Do not forget to clear the location before, as
65 queries not understood will be left untouched.
67 TAGS
68 AI_KickstartBase APTR
69 AI_KickstartSize ULONG
70 AI_KickstartVersion UWORD
71 AI_KickstartRevision UWORD
72 Only support these tags if we are on the native machine. On other
73 machines this call will not touch the storage space. Set the
74 storage space to 0 beforehand if you want to see if this call
75 touches it.
77 AI_ArosVersion IPTR
78 aros.library version masquerades as AROS version. This means
79 that all AROS modules must have the same major version number.
81 AI_ArosReleaseMajor IPTR
82 Update this whenever a new AROS is released.
84 AI_ArosReleaseMinor IPTR
85 Update this whenever a new AROS is released.
87 AI_ArosReleaseDate IPTR
88 Update this whenever a new AROS is released.
90 AI_ArosBuildDate IPTR
91 Given in the format: <d>.<m>.<y>
93 AI_ArosVariant IPTR
94 Distribution name.
96 AI_ArosArchitecture IPTR
97 Return the target architecture.
99 AI_ArosABIMajor IPTR
100 Update this whenever a new ABI is introduced in AROS. Special
101 value of -1 means that the ABI is under development and subject
102 to change.
104 RESULT
105 index - the index of the first tag that could not be processed, plus
106 one (e.g. 1 for taglist[0], 2 for taglist[1] etc.). Zero if all
107 tags were handled.
109 NOTES
111 EXAMPLE
113 BUGS
115 SEE ALSO
116 aros/arosbase.h
118 INTERNALS
120 ******************************************************************************/
122 AROS_LIBFUNC_INIT
124 APTR UtilityBase;
125 struct TagItem *tag;
126 ULONG ret = 0;
127 int i = 0;
128 IPTR data = 0;
130 if (!(UtilityBase = TaggedOpenLibrary(TAGGEDOPEN_UTILITY)))
131 return 1;
133 # define SetData(tag,type,value) \
134 D(bug(" Data was: %d\n", *((type *)(tag->ti_Data)))); \
135 (*((type *)(tag->ti_Data)) = value); \
136 D(bug(" Data is : %d\n", *((type *)(tag->ti_Data))))
138 D(bug("ArosInquireA(taglist=%p)\n", taglist));
140 while( (tag = NextTagItem(&taglist)))
142 D(bug(" tag[%d] = 0x%lx data = 0x%lx\n", i, tag->ti_Tag, tag->ti_Data));
143 i++;
145 switch(tag->ti_Tag)
148 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
150 Only support these tags if we are on the native machine. On other
151 machines this call will not touch the storage space. Set the
152 storage space to 0 if you want to see if this call touches it.
155 case AI_KickstartBase:
156 SetData (tag, APTR, kickbase());
157 break;
159 case AI_KickstartSize:
160 SetData (tag, ULONG, kicksize());
161 break;
163 case AI_KickstartVersion:
164 SetData (tag, UWORD, *(UWORD *)(kickbase() + LOC_MAJORV));
165 break;
167 case AI_KickstartRevision:
168 SetData (tag, UWORD, *(UWORD *)(kickbase() + LOC_MINORV));
169 break;
170 #else
171 case AI_KickstartSize:
172 SetData (tag, ULONG, 0);
173 break;
175 #endif
177 case AI_ArosVersion:
179 aros.library version masquerades as AROS version. This means
180 that all aros modules must have the same major version number.
182 SetData (tag, IPTR, VERSION_NUMBER);
183 break;
185 case AI_ArosReleaseMajor:
186 /* Update this whenever a new AROS is released */
187 SetData (tag, IPTR, AROS_VERSION_MAJOR);
188 break;
190 case AI_ArosReleaseMinor:
191 /* Update this whenever a new AROS is released */
192 SetData (tag, IPTR, AROS_VERSION_MINOR);
193 break;
195 case AI_ArosReleaseDate:
196 /* Update this whenever a new AROS is released */
197 SetData (tag, IPTR, AROS_RELEASE_DATE);
198 break;
200 case AI_ArosBuildDate:
201 SetData (tag, IPTR, (IPTR)__DATE__);
202 break;
205 * Reserved for distribution maintainers.
206 * DO NOT set this to configure-time variant name. That name is used to identify
207 * sub-architecture name, and changing it may break compatibility between
208 * different AROS modules, especially on hosted. Full complete platform name
209 * (including variant, if appropriate) is available via KATTR_Architecture
210 * kernel's attribute.
211 * Add one more configure option, or, better, provide some another way
212 * (env variable, whatever).
214 case AI_ArosVariant:
215 #ifdef VARIANT
216 SetData (tag, IPTR, (IPTR) VARIANT);
217 #else
218 SetData (tag, IPTR, (IPTR) NULL);
219 #endif
220 break;
223 case AI_ArosABIMajor:
224 SetData (tag, IPTR, AROS_ABI_VERSION_MAJOR);
225 break;
227 case AI_ArosArchitecture:
228 #ifdef KrnGetSystemAttr
229 if (ArosBase->aros_KernelBase)
231 APTR KernelBase = ArosBase->aros_KernelBase;
232 data = KrnGetSystemAttr(KATTR_Architecture);
234 #else
236 * This is a legacy hack for old PPC-native kernel.resource implementations.
237 * Please do not support this. aros.library is a part of base kickstart, and
238 * it is platform-independent. Consequently, it should not include any hardcoded
239 * references to platform name. Platform name is specified by kernel.resource.
240 * See boot/modular_kickstart.txt for more info.
242 data = (IPTR)AROS_ARCHITECTURE;
243 #endif
244 SetData(tag, IPTR, data);
245 break;
247 default:
248 if (ret == 0)
249 ret = i;
250 break;
255 CloseLibrary(UtilityBase);
257 return ret;
258 AROS_LIBFUNC_EXIT
259 } /* ArosInquireA */
261 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
262 /* Native AROS support functions */
263 IPTR kicksize(void)
265 return *(ULONG *)(ROM_END - LOC_ROMSIZE);
268 IPTR kickbase(void)
270 return (ROM_END - kicksize());
272 #endif