2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <exec/resident.h>
11 #include <proto/expansion.h>
12 #include <aros/asmcall.h>
13 #include <libraries/expansionbase.h>
14 #include <libraries/configvars.h>
15 #include <libraries/configregs.h>
18 #define STR(A) _STR(A)
20 #define NAME "romboot"
24 static AROS_UFP3 (APTR
, Init
,
25 AROS_UFPA(struct Library
*, lh
, D0
),
26 AROS_UFPA(BPTR
, segList
, A0
),
27 AROS_UFPA(struct ExecBase
*, sysBase
, A6
));
29 static const TEXT name_string
[] = NAME
;
30 static const TEXT version_string
[] =
31 NAME
" " STR(VERSION
) "." STR(REVISION
) " " ADATE
"\n";
33 extern void romboot_end(void);
35 const struct Resident rb_tag
=
38 (struct Resident
*)&rb_tag
,
43 -9, /* this MUST be run before uaegfx! */
45 (STRPTR
)version_string
,
50 static void romtaginit(struct ExpansionBase
*ExpansionBase
)
53 // look for possible romtags in expansion ROM image and InitResident() them if found
54 D(bug("romtaginit\n"));
55 ObtainConfigBinding();
56 ForeachNode(&ExpansionBase
->BoardList
, node
) {
57 struct ConfigDev
*configDev
= (struct ConfigDev
*)node
;
58 if ((configDev
->cd_Flags
& CDF_CONFIGME
) && (configDev
->cd_Rom
.er_Type
& ERTF_DIAGVALID
) &&
59 configDev
->cd_Rom
.er_DiagArea
&& (configDev
->cd_Rom
.er_DiagArea
->da_Config
& DAC_BOOTTIME
) == DAC_CONFIGTIME
) {
61 UWORD
*romptr
= (UWORD
*)configDev
->cd_Rom
.er_DiagArea
;
62 UWORD
*romend
= (UWORD
*)(((UBYTE
*)configDev
->cd_Rom
.er_DiagArea
) + configDev
->cd_Rom
.er_DiagArea
->da_Size
- 26); // 26 = real sizeof(struct Resident)!
63 struct CurrentBinding cb
= {
64 .cb_ConfigDev
= configDev
66 SetCurrentBinding(&cb
, sizeof(cb
));
67 while (romptr
<= romend
) {
68 res
= (struct Resident
*)romptr
;
69 if (res
->rt_MatchWord
== RTC_MATCHWORD
&& res
->rt_MatchTag
== res
) {
70 D(bug("Diag board %p InitResident %p (V=%d P=%d F=%02x '%s' '%s')\n",
71 configDev
->cd_BoardAddr
, res
, res
->rt_Version
, res
->rt_Pri
, res
->rt_Flags
,
72 res
->rt_Name
!= NULL
? (char*)res
->rt_Name
: "<null>",
73 res
->rt_IdString
!= NULL
? (char*)res
->rt_IdString
: "<null>"));
74 InitResident(res
, BNULL
);
75 break; /* must not keep looking */
81 ReleaseConfigBinding();
82 D(bug("romtaginit done\n"));
86 * romtaginit() would initialize WinUAE built-in uaegfx.card which unfortunately also
87 * disables direct RTG uaelib calls that uaegfx needs if uaelib is not called at least once.
88 * We need to do this here because it was wrong to call romtaginit() after uaegfx, there
89 * are RTG boards that are only active after rormtaginit, for example PicassoIV.
92 static void uaegfxhack(APTR uaeres
, UBYTE
*name
)
101 /* 35 = return if RTG enabled, safe function to call */
103 "move.l %%d0,-(%%sp)\n"
107 : : "m" (uaeres
), "m" (name
) : "d0", "d1", "a0", "a1", "a6"
111 static AROS_UFH3 (APTR
, Init
,
112 AROS_UFHA(struct Library
*, lh
, D0
),
113 AROS_UFHA(BPTR
, segList
, A0
),
114 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)
119 struct ExpansionBase
*eb
= (struct ExpansionBase
*)TaggedOpenLibrary(TAGGEDOPEN_EXPANSION
);
122 res
= OpenResource("uae.resource");
124 uaegfxhack(res
, "uaelib_demux");
128 CloseLibrary((struct Library
*)eb
);