get the cache sizes in bytes
[AROS.git] / arch / m68k-amiga / romboot / romboot.c
blob9698b9f5e89c7438167bbb7890742576197cc5e7
2 #define DEBUG 1
4 #include <aros/debug.h>
5 #include <exec/types.h>
6 #include <exec/resident.h>
7 #include <proto/expansion.h>
8 #include <aros/asmcall.h>
9 #include <libraries/expansionbase.h>
10 #include <libraries/configvars.h>
11 #include <libraries/configregs.h>
13 #define _STR(A) #A
14 #define STR(A) _STR(A)
16 #define NAME "romboot"
17 #define VERSION 41
18 #define REVISION 1
20 static AROS_UFP3 (APTR, Init,
21 AROS_UFPA(struct Library *, lh, D0),
22 AROS_UFPA(BPTR, segList, A0),
23 AROS_UFPA(struct ExecBase *, sysBase, A6));
25 static const TEXT name_string[] = NAME;
26 static const TEXT version_string[] =
27 NAME " " STR(VERSION) "." STR(REVISION) " " ADATE "\n";
29 extern void romboot_end(void);
31 const struct Resident rb_tag =
33 RTC_MATCHWORD,
34 (struct Resident *)&rb_tag,
35 (APTR)&romboot_end,
36 RTF_COLDSTART,
37 VERSION,
38 NT_UNKNOWN,
39 -9, /* this MUST be run before uaegfx! */
40 (STRPTR)name_string,
41 (STRPTR)version_string,
42 (APTR)Init
45 // ROMTAG INIT time
46 static void romtaginit(struct ExpansionBase *ExpansionBase)
48 struct Node *node;
49 // look for possible romtags in expansion ROM image and InitResident() them if found
50 D(bug("romtaginit\n"));
51 ObtainConfigBinding();
52 ForeachNode(&ExpansionBase->BoardList, node) {
53 struct ConfigDev *configDev = (struct ConfigDev*)node;
54 if ((configDev->cd_Flags & CDF_CONFIGME) && (configDev->cd_Rom.er_Type & ERTF_DIAGVALID) &&
55 configDev->cd_Rom.er_DiagArea && (configDev->cd_Rom.er_DiagArea->da_Config & DAC_BOOTTIME) == DAC_CONFIGTIME) {
56 struct Resident *res;
57 UWORD *romptr = (UWORD*)configDev->cd_Rom.er_DiagArea;
58 UWORD *romend = (UWORD*)(((UBYTE*)configDev->cd_Rom.er_DiagArea) + configDev->cd_Rom.er_DiagArea->da_Size - 26); // 26 = real sizeof(struct Resident)!
59 struct CurrentBinding cb = {
60 .cb_ConfigDev = configDev
62 SetCurrentBinding(&cb, sizeof(cb));
63 while (romptr <= romend) {
64 res = (struct Resident*)romptr;
65 if (res->rt_MatchWord == RTC_MATCHWORD && res->rt_MatchTag == res) {
66 D(bug("Diag board %p InitResident %p (V=%d P=%d F=%02x '%s' '%s')\n",
67 configDev->cd_BoardAddr, res, res->rt_Version, res->rt_Pri, res->rt_Flags,
68 res->rt_Name != NULL ? (char*)res->rt_Name : "<null>",
69 res->rt_IdString != NULL ? (char*)res->rt_IdString : "<null>"));
70 InitResident(res, BNULL);
71 break; /* must not keep looking */
73 romptr++;
77 ReleaseConfigBinding();
78 D(bug("romtaginit done\n"));
81 /* Stupid hack.
82 * romtaginit() would initialize WinUAE built-in uaegfx.card which unfortunately also
83 * disables direct RTG uaelib calls that uaegfx needs if uaelib is not called at least once.
84 * We need to do this here because it was wrong to call romtaginit() after uaegfx, there
85 * are RTG boards that are only active after rormtaginit, for example PicassoIV.
88 static void uaegfxhack(APTR uaeres, UBYTE *name)
90 asm volatile (
91 "move.l %0,%%a6\n"
92 "move.l %1,%%a0\n"
93 "jsr -6(%%a6)\n"
94 "tst.l %%d0\n"
95 "beq.s 0f\n"
96 "move.l %%d0,%%a0\n"
97 /* 35 = return if RTG enabled, safe function to call */
98 "moveq #35,%%d0\n"
99 "move.l %%d0,-(%%sp)\n"
100 "jsr (%%a0)\n"
101 "addq.l #4,%%sp\n"
102 "0:\n"
103 : : "m" (uaeres), "m" (name) : "d0", "d1", "a0", "a1", "a6"
107 static AROS_UFH3 (APTR, Init,
108 AROS_UFHA(struct Library *, lh, D0),
109 AROS_UFHA(BPTR, segList, A0),
110 AROS_UFHA(struct ExecBase *, SysBase, A6)
113 AROS_USERFUNC_INIT
115 struct ExpansionBase *eb = (struct ExpansionBase*)TaggedOpenLibrary(TAGGEDOPEN_EXPANSION);
116 APTR res;
118 res = OpenResource("uae.resource");
119 if (res)
120 uaegfxhack(res, "uaelib_demux");
122 romtaginit(eb);
124 CloseLibrary((struct Library*)eb);
126 AROS_USERFUNC_EXIT
128 return NULL;