config: fix build with external compiler by passing the sysroot where needed
[AROS.git] / arch / m68k-all / m680x0 / init.c
blob963690064c8caf0a844c9e37856e84aab50b4685
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <aros/libcall.h>
8 #include <aros/symbolsets.h>
10 #include <proto/exec.h>
12 #include "m680x0_intern.h"
14 extern void sp060_init(void);
16 static AROS_UFH2(struct Library*, OpenLib,
17 AROS_UFHA(ULONG, version, D0),
18 AROS_UFHA(struct Library*, base, A6))
20 AROS_USERFUNC_INIT
22 base->lib_OpenCnt++;
23 return base;
25 AROS_USERFUNC_EXIT
28 static AROS_UFH1(void, CloseLib,
29 AROS_UFHA(struct Library*, base, A6))
31 AROS_USERFUNC_INIT
33 base->lib_OpenCnt--;
35 AROS_USERFUNC_EXIT
38 static AROS_UFH1(ULONG, DummyLib,
39 AROS_UFHA(struct Library*, base, A6))
41 AROS_USERFUNC_INIT
43 return 0;
45 AROS_USERFUNC_EXIT
48 /* This is totally undocumented so complain if something calls our functions */
49 #define UNUSED(x) \
50 static AROS_UFH1(ULONG, x, \
51 AROS_UFHA(struct Library*, base, A6)) { \
52 AROS_USERFUNC_INIT \
53 bug("680x0: " #x "\n"); \
54 return 0; \
55 AROS_USERFUNC_EXIT \
58 UNUSED(Unused5);
59 UNUSED(Unused6);
60 UNUSED(Unused7);
61 UNUSED(Unused8);
62 UNUSED(Unused9);
63 UNUSED(Unused10);
64 UNUSED(Unused11);
65 UNUSED(Unused12);
66 UNUSED(Unused13);
67 UNUSED(Unused14);
68 UNUSED(Unused15);
69 UNUSED(Unused16);
71 static const APTR funcLib[] = {
72 OpenLib, CloseLib, DummyLib, DummyLib,
73 Unused5,
74 Unused6,
75 Unused7,
76 Unused8,
77 Unused9,
78 Unused10,
79 Unused11,
80 Unused12,
81 Unused13,
82 Unused14,
83 Unused15,
84 Unused16,
85 (void*)-1 };
87 static const UBYTE lib68040[] = "68040.library";
88 static const UBYTE lib68060[] = "68060.library";
90 /* m68k identify.library calls these, purpose unknown */
91 AROS_LH0(ULONG, Dummy1, struct M680x0Base*, M680x0Base, 5, m680x0)
93 AROS_LIBFUNC_INIT
94 bug("680x0: dummy1\n");
95 return 0;
96 AROS_LIBFUNC_EXIT
98 AROS_LH0(ULONG, Dummy2, struct M680x0Base*, M680x0Base, 6, m680x0)
100 AROS_LIBFUNC_INIT
101 bug("680x0: dummy2\n");
102 return 0;
103 AROS_LIBFUNC_EXIT
105 AROS_LH0(ULONG, Dummy3, struct M680x0Base*, M680x0Base, 7, m680x0)
107 AROS_LIBFUNC_INIT
108 bug("680x0: dummy3\n");
109 return 0;
110 AROS_LIBFUNC_EXIT
112 AROS_LH0(ULONG, Dummy4, struct M680x0Base*, M680x0Base, 8, m680x0)
114 AROS_LIBFUNC_INIT
115 bug("680x0: dummy4\n");
116 return 0;
117 AROS_LIBFUNC_EXIT
120 static int M680x0Init(struct M680x0Base *M680x0Base)
122 struct Library *lib;
124 if (!(SysBase->AttnFlags & (AFF_68040 | AFF_68060)))
125 return FALSE; /* 68040/060 only need emulation */
126 if (SysBase->AttnFlags & AFF_68882)
127 return FALSE; /* we already have full support? */
128 if (!(SysBase->AttnFlags & AFF_FPU40))
129 return FALSE; /* no FPU, don't bother with missing instruction emulation */
131 /* initialize emulation here */
132 sp060_init();
134 /* Create fake 68040/060.library, stops C:SetPatch from attempting to load
135 * incompatible 68040/060 libraries.
137 * We also create both 68040 and 68060.library if 68060 is detected, it prevents
138 * old SetPatch versions (that do not know about 68060) from loading 68040.library.
140 * (Maybe this is getting too far..)
142 if (SysBase->AttnFlags & AFF_68060) {
143 lib = MakeLibrary(funcLib, NULL, NULL, sizeof(struct Library), BNULL);
144 if (lib) {
145 lib->lib_Node.ln_Name = (UBYTE*)lib68060;
146 lib->lib_IdString = lib->lib_Node.ln_Name;
147 lib->lib_Version = M680x0Base->pb_LibNode.lib_Version;
148 lib->lib_Revision = M680x0Base->pb_LibNode.lib_Revision;
149 lib->lib_OpenCnt = 1;
150 AddLibrary(lib);
153 lib = MakeLibrary(funcLib, NULL, NULL, sizeof(struct Library), BNULL);
154 if (lib) {
155 lib->lib_Node.ln_Name = (UBYTE*)lib68040;
156 lib->lib_IdString = lib->lib_Node.ln_Name;
157 lib->lib_Version = M680x0Base->pb_LibNode.lib_Version;
158 lib->lib_Revision = M680x0Base->pb_LibNode.lib_Revision;
159 lib->lib_OpenCnt = 1;
160 AddLibrary(lib);
163 /* emulation installed, full 68881/68882 instruction set now supported */
164 SysBase->AttnFlags |= AFF_68881 | AFF_68882;
165 /* do not expunge us */
166 M680x0Base->pb_LibNode.lib_OpenCnt++;
167 return TRUE;
170 ADD2INITLIB(M680x0Init, 0)