2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Exec patches for AROS for Amiga
13 #include <exec/types.h>
14 #include <exec/resident.h>
15 #include <exec/nodes.h>
16 #include <exec/execbase.h>
17 #include <proto/exec.h>
20 #include <hardware/cia.h>
23 #include "exec_extfuncs.h"
25 #include <aros/debug.h>
36 Architecture dependent function variations:
38 extern void AROS_SLIB_ENTRY(GetCC_10
,Exec
)();
39 extern void AROS_SLIB_ENTRY(CacheClearU_20
,Exec
)();
40 extern void AROS_SLIB_ENTRY(CacheClearU_40
,Exec
)();
41 extern void AROS_SLIB_ENTRY(CachePreDMA_40
,Exec
)();
42 extern void AROS_SLIB_ENTRY(CachePostDMA_30
,Exec
)();
43 extern void AROS_SLIB_ENTRY(CachePostDMA_40
,Exec
)();
48 Expand, improve and generally make the world a better place. :)
56 extern const char name
[];
57 extern const char version
[];
58 extern UBYTE dearray
[];
59 extern int start(void);
60 extern const char end
;
62 struct SpecialResident
70 #define SR_COOKIE 0x4afa4afb
72 const struct SpecialResident resident
=
76 (struct Resident
*)&resident
,
81 106, /* Just above exec.library.
82 Because exec is RTF_SINGLETASK, and this is
83 RTF_COLDSTART, we'll still be started after
89 SR_COOKIE
, /* magic cookie to recognize a patchable library */
90 dearray
, /* pointer to array of function status bytes */
91 137 /* highest vector slot in this library */
94 const char name
[] = "exec.strap";
95 const char version
[] = "$VER: exec.strap 41.10 (2.4.1997)";
98 Array of function slots to enable/disable. They are all set to 1 (enabled)
99 by default. Arosboot will find the SR_COOKIE in the resident structure to see
100 if this array is present, and will then disable certain functions if they
101 are specified as off in the config file. We could extend this for more config
102 file options, as we have 7 more bits to play with in the array.
106 /* 137 functions in exec.library V40 (plus one for offset 0) */
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0- 9 */
108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 10- 19 */
109 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 20- 29 */
110 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 30- 39 */
111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 40- 49 */
112 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 50- 59 */
113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 60- 69 */
114 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 70- 79 */
115 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 80- 89 */
116 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 90- 99 */
117 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 100-109 */
118 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 110-119 */
119 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 120-129 */
120 1, 1, 1, 1, 1, 1, 1, 1 /* 130-137 */
123 #define SetFunc(offset,name) \
125 if(dearray[offset]) \
126 SetFunction((struct Library *)SysBase, (offset * -6), (APTR)&AROS_SLIB_ENTRY(name,Exec)); \
132 UBYTE
*ciapra
= (void *)0xbfe001;
134 struct ExecBase
*SysBase
;
137 SysBase
= *(void **)4;
138 cpuflags
= SysBase
->AttnFlags
;
141 if(!(*ciapra
& CIAF_GAMEPORT0
))
143 D(bug("\nLMB pressed. Clearing reset vectors and resetting.\n\n"));
144 SysBase
->KickTagPtr
= SysBase
->KickMemPtr
= SysBase
->KickCheckSum
= 0;
146 ColdReboot(); /* Never returns. */
150 D(bug("\nexec.strap installing...\n"));
153 This test will have to be changed if we start patching the exec version
156 if (SysBase
->LibNode
.lib_Version
< 37)
158 /* Refuse to run on anything less than ROM 2.04 */
159 D(bug("Found kickstart < 37. Exec.strap not started.\n"));
165 #if 1 /* Disable in arosboot.config */
166 /* The cause of a second infinite reset loop, as reported on 39.106 ROM?
167 I have the same ROM, without this problem */
168 /* Update: gcc produced 64-bit multiply instructions, which are missing on
169 the 68060. Recoded so it won't produce these anymore. Still to test. */
170 /* First patch SetFunction itself. */
171 SetFunc( 70, SetFunction
);
175 The biggie: SetFunction() as many library vectors as possible.
176 Protection from multitasking is provided by SetFunction (Forbid/Permit).
178 Some functions are safe to call even from interrupts, so protect these
180 Alert/Cause/Disable/Enable/FindName/FindPort/FindTask/PutMsg/ReplyMsg/Signal/
181 AddHead/AddTail/Enqueue/RemHead/RemTail/Insert/Remove ... any more?
185 SetFunc( 20, Disable
);
186 SetFunc( 22, Forbid
);
188 /* "Some trouble prevented CycleToMenu to initialize itself properly"
189 Related to the microkernel. I know what it is. Cannot be fixed right now. */
190 SetFunc( 23, Permit
);
193 SetFunc( 39, Insert
);
194 SetFunc( 40, AddHead
);
195 SetFunc( 41, AddTail
);
196 SetFunc( 42, Remove
);
197 SetFunc( 43, RemHead
);
198 SetFunc( 44, RemTail
);
200 /* Serial trouble. Can't receive a good/complete connectstring. */
201 SetFunc( 45, Enqueue
);
203 SetFunc( 46, FindName
);
204 SetFunc( 49, FindTask
);
205 SetFunc( 65, FindPort
);
206 SetFunc( 61, PutMsg
);
207 SetFunc( 63, ReplyMsg
);
209 /* The "move.w ccr,d0" should really be implemented as part of the jumptable, for speed.
210 Do not patch, for now. */
211 if ((cpuflags
& AFF_68010
) == AFF_68010
)
212 SetFunc( 88, GetCC_10
);
217 BTW: What bit(s) is (are) set for the MC68060?
219 BTW2: They would really be set by the 68060.library, which will obviously
220 not have executed at this point in the reset-procedure.
221 ANS: So we have to recognize it ourselves. Write routine.
222 BTW3: If there is an agreed upon bit for the 68060, we could examine the
223 type of processor for ourselves in exec.strap, and update AttnFlags
226 BTW4: The 68060 can be recognized by its Processor Configuration Register (PCR).
227 This register also contains the bit to enable Superscalar Operation,
228 which we could set at this point in the reset-procedure to speed
229 things up considerably (if nothing breaks).
231 BTW5: For the MC68060, we could also enable the Branch Cache at this point.
235 #warning TODO: Rework
236 /* TODO: Rework this logic so a particular vector isn't patched more than
237 once. SetFunction() calls CacheClearU(), so putting the routine address
238 directly in the vector+2, and manually clearing of the cache (not with
239 the Cachexxx() functions) when done is the way to go here. Better write
240 a short assembler function to do all this.
242 SetFunc(106, CacheClearU
);
243 SetFunc(127, CachePreDMA
);
244 SetFunc(128, CachePostDMA
);
245 if ((cpuflags
& AFF_68020
) == AFF_68020
)
247 SetFunc(106, CacheClearU_20
);
249 if ((cpuflags
& AFF_68030
) == AFF_68030
)
251 SetFunc(128, CachePostDMA_30
);
253 if ((cpuflags
& AFF_68040
) == AFF_68040
)
255 SetFunc(106, CacheClearU_40
);
256 SetFunc(127, CachePreDMA_40
);
257 SetFunc(128, CachePostDMA_40
);
264 SetFunc( 12, InitCode
);
266 /* Fails, presumably on the AROS_ALIGN restrictions: */
267 SetFunc( 13, InitStruct
);
269 SetFunc( 14, MakeLibrary
);
270 SetFunc( 15, MakeFunctions
);
271 SetFunc( 16, FindResident
);
272 SetFunc( 17, InitResident
);
273 SetFunc( 27, SetIntVector
);
274 SetFunc( 28, AddIntServer
);
275 SetFunc( 29, RemIntServer
);
277 /* Computer boots ok, but then programs fail. KingCON allows you to enter
278 a command, but if you enter return, hangs. No other keypresses are
279 accepted; mclk (clock window) still runs, though: */
280 SetFunc( 33, AllocMem
);
281 SetFunc( 35, FreeMem
);
283 SetFunc( 36, AvailMem
);
284 SetFunc( 37, AllocEntry
);
285 SetFunc( 38, FreeEntry
);
286 SetFunc( 51, SetSignal
);
287 SetFunc( 55, AllocSignal
);
288 SetFunc( 56, FreeSignal
);
289 SetFunc( 59, AddPort
);
290 SetFunc( 60, RemPort
);
291 SetFunc( 62, GetMsg
);
292 SetFunc( 64, WaitPort
);
293 SetFunc( 66, AddLibrary
);
294 SetFunc( 67, RemLibrary
);
295 SetFunc( 68, OldOpenLibrary
);
296 SetFunc( 69, CloseLibrary
);
297 SetFunc( 71, SumLibrary
);
298 SetFunc( 72, AddDevice
);
299 SetFunc( 73, RemDevice
);
300 SetFunc( 74, OpenDevice
);
301 SetFunc( 75, CloseDevice
);
303 SetFunc( 77, SendIO
);
304 SetFunc( 78, CheckIO
);
305 SetFunc( 79, WaitIO
);
306 SetFunc( 80, AbortIO
);
307 SetFunc( 81, AddResource
);
308 SetFunc( 82, RemResource
);
309 SetFunc( 83, OpenResource
);
311 /* Hangs just after accessing HD for the first time. Related to BCPL/BSTR
313 SetFunc( 87, RawDoFmt
);
315 SetFunc( 89, TypeOfMem
);
316 #if 1 /* Disable in arosboot.config */
317 /* May be incompatible with OS37 OpenLibrary() */
318 SetFunc( 92, OpenLibrary
);
320 SetFunc( 93, InitSemaphore
);
322 /* Can only be patched if we have control over the microkernel: */
323 SetFunc( 94, ObtainSemaphore
);
326 SetFunc( 96, AttemptSemaphore
);
328 SetFunc( 99, FindSemaphore
);
329 SetFunc(100, AddSemaphore
);
330 SetFunc(101, RemSemaphore
);
331 SetFunc(103, AddMemList
);
332 SetFunc(109, CreateIORequest
);
333 SetFunc(110, DeleteIORequest
);
334 SetFunc(111, CreateMsgPort
);
335 SetFunc(112, DeleteMsgPort
);
337 /* Can only be patched if we have control over the microkernel: */
338 SetFunc(113, ObtainSemaphoreShared
);
340 SetFunc(114, AllocVec
);
341 SetFunc(115, FreeVec
);
342 #if 0 /* Enable as a group, as they are not internally compat with orig */
343 /* Guru 0100000f-> "DH0 Software Failure"-> 80000003 guru upon reset */
344 SetFunc(116, CreatePool
);
345 SetFunc(117, DeletePool
);
346 SetFunc(118, AllocPooled
);
347 SetFunc(119, FreePooled
);
350 SetFunc(120, AttemptSemaphoreShared
);
352 SetFunc(121, ColdReboot
);
355 This test will have to be changed if we start patching the exec version
358 if (SysBase
->LibNode
.lib_Version
>= 39)
360 D(bug("Found kickstart >= 39. Extra functions installed.\n"));
361 /* V39+ functions: */
362 SetFunc(129, AddMemHandler
);
363 SetFunc(130, RemMemHandler
);
364 SetFunc(135, TaggedOpenLibrary
);
366 /* We don't have to clear any caches, SetFunction takes care of them. */
370 D(bug("exec.strap installation done.\n"));
374 /* High-tech display tricks :-) */
375 void flash(UWORD color
)
378 UWORD
*color00
= (void *)0xdff180;
380 for (x
=0; x
<1000; x
++)
382 for (y
= 200; y
; y
--) *color00
= color
;
383 for (y
= 200; y
; y
--) *color00
= 0x000;
389 /*************************************************************************
390 * Functions not yet added to this file (whether enabled or not):
423 * ObtainSemaphoreList
424 * ReleaseSemaphoreList
436 ************************************************************************/