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>
14 #define STR(A) _STR(A)
16 #define NAME "romboot"
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
=
34 (struct Resident
*)&rb_tag
,
39 -9, /* this MUST be run before uaegfx! */
41 (STRPTR
)version_string
,
46 static void romtaginit(struct ExpansionBase
*ExpansionBase
)
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
) {
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 */
77 ReleaseConfigBinding();
78 D(bug("romtaginit done\n"));
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
)
97 /* 35 = return if RTG enabled, safe function to call */
99 "move.l %%d0,-(%%sp)\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
)
115 struct ExpansionBase
*eb
= (struct ExpansionBase
*)TaggedOpenLibrary(TAGGEDOPEN_EXPANSION
);
118 res
= OpenResource("uae.resource");
120 uaegfxhack(res
, "uaelib_demux");
124 CloseLibrary((struct Library
*)eb
);