Remove the need for getting SysBaseV0 via "extern"

Now each partial library has its pointer for SysBaseV0
This commit is contained in:
deadwood 2024-03-23 20:20:21 +01:00
parent fa9b5875f8
commit 51f4427bf1
5 changed files with 49 additions and 44 deletions

View File

@ -10,7 +10,6 @@
#include "abiv0/include/aros/cpu.h"
struct LibraryV0 *abiv0TimerBase;
extern struct ExecBaseV0 *abiv0SysBase;
struct LibraryV0 *shallow_InitResident32(struct ResidentV0 *resident, BPTR segList, struct ExecBaseV0 *SysBaseV0)
{
@ -66,35 +65,35 @@ MAKE_PROXY_ARG_2(GetSysTime)
BPTR LoadSeg32 (CONST_STRPTR name, struct DosLibrary *DOSBase);
struct ResidentV0 * findResident(BPTR seg, CONST_STRPTR name);
void init_graphics();
void init_intuition();
void init_dos();
void init_exec();
void init_graphics(struct ExecBaseV0 *);
void init_intuition(struct ExecBaseV0 *);
void init_dos(struct ExecBaseV0 *);
struct ExecBaseV0 *init_exec();
LONG_FUNC run_emulation()
{
/* Init ROM */
init_exec();
struct ExecBaseV0 *SysBaseV0 = init_exec();
APTR tmp = AllocMem(1024, MEMF_31BIT | MEMF_CLEAR);
abiv0TimerBase = (tmp + 512);
__AROS_SETVECADDRV0(abiv0TimerBase, 11, (APTR32)(IPTR)proxy_GetSysTime);
init_dos();
init_dos(SysBaseV0);
BPTR cgfxseg = LoadSeg32("SYS:Libs32/partial/cybergraphics.library", DOSBase);
struct ResidentV0 *cgfxres = findResident(cgfxseg, NULL);
struct LibraryV0 *abiv0CyberGfxBase = shallow_InitResident32(cgfxres, cgfxseg, abiv0SysBase);
struct LibraryV0 *abiv0CyberGfxBase = shallow_InitResident32(cgfxres, cgfxseg, SysBaseV0);
/* Remove all vectors for now (leave LibOpen) */
for (int i = 5; i <= 38; i++) __AROS_SETVECADDRV0(abiv0CyberGfxBase, i, 0);
init_intuition();
init_intuition(SysBaseV0);
init_graphics();
init_graphics(SysBaseV0);
BPTR layersseg = LoadSeg32("SYS:Libs32/partial/layers.library", DOSBase);
struct ResidentV0 *layersres = findResident(layersseg, NULL);
struct LibraryV0 *abiv0LayersBase = shallow_InitResident32(layersres, layersseg, abiv0SysBase);
struct LibraryV0 *abiv0LayersBase = shallow_InitResident32(layersres, layersseg, SysBaseV0);
/* Remove all vectors for now */
for (int i = 1; i <= 45; i++) __AROS_SETVECADDRV0(abiv0LayersBase, i, 0);
__AROS_SETVECADDRV0(abiv0LayersBase, 1, (APTR32)(IPTR)proxy_Layers_OpenLib);
@ -138,7 +137,7 @@ LONG_FUNC run_emulation()
" lret\n"
" .code64\n"
"finished:"
:: "m"(start), "m" (abiv0SysBase) :);
:: "m"(start), "m" (SysBaseV0) :);
}
struct timerequest tr;

View File

@ -12,7 +12,7 @@
#include "../include/utility/structures.h"
#include "../include/timer/structures.h"
extern struct ExecBaseV0 *abiv0SysBase;
struct ExecBaseV0 *DOS_SysBaseV0;
extern struct LibraryV0 *abiv0TimerBase;
struct DosLibraryV0 *abiv0DOSBase;
@ -29,7 +29,7 @@ struct FileHandleProxy
struct FileHandleProxy *makeFileHandleProxy(BPTR native)
{
struct FileHandleProxy *proxy = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
struct FileHandleProxy *proxy = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, DOS_SysBaseV0);
proxy->native = native;
return proxy;
}
@ -73,7 +73,7 @@ BPTR abiv0_Open(CONST_STRPTR name, LONG accessMode, struct DosLibraryV0 *DOSBase
if (tmp == BNULL)
return BNULL;
struct FileHandleProxy *fhp = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
struct FileHandleProxy *fhp = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, DOS_SysBaseV0);
fhp->native = tmp;
return (BPTR)fhp;
}
@ -109,7 +109,7 @@ MAKE_PROXY_ARG_2(Close)
static struct FileLockProxy *makeFileLockProxy(BPTR native)
{
struct FileLockProxy *proxy = abiv0_AllocMem(sizeof(struct FileLockProxy), MEMF_ANY, abiv0SysBase);
struct FileLockProxy *proxy = abiv0_AllocMem(sizeof(struct FileLockProxy), MEMF_ANY, DOS_SysBaseV0);
proxy->native = native;
return proxy;
}
@ -137,7 +137,7 @@ struct DevProcV0 *abiv0_GetDeviceProc(CONST_STRPTR name, struct DevProcV0 *dp, s
if (nativeret == NULL)
return NULL;
struct DevProcProxy *proxy = abiv0_AllocMem(sizeof(struct DevProcProxy), MEMF_CLEAR, abiv0SysBase);
struct DevProcProxy *proxy = abiv0_AllocMem(sizeof(struct DevProcProxy), MEMF_CLEAR, DOS_SysBaseV0);
proxy->base.dvp_Lock = (BPTR32)(IPTR)makeFileLockProxy(nativeret->dvp_Lock);
proxy->native = nativeret;
return (struct DevProcV0 *)proxy;
@ -150,7 +150,7 @@ void abiv0_FreeDeviceProc(struct DevProcV0 *dp, struct DosLibraryV0 *DOSBaseV0)
{
struct DevProcProxy *proxy = (struct DevProcProxy *)dp;
FreeDeviceProc(proxy->native);
abiv0_FreeMem(proxy, sizeof(struct DevProcProxy), abiv0SysBase);
abiv0_FreeMem(proxy, sizeof(struct DevProcProxy), DOS_SysBaseV0);
}
}
MAKE_PROXY_ARG_2(FreeDeviceProc)
@ -182,14 +182,14 @@ APTR abiv0_AllocDosObject(ULONG type, const struct TagItemV0 * tags, struct DosL
if (type == DOS_FIB && tags == NULL)
{
struct FileInfoBlock *fib = AllocDosObject(type, NULL);
struct FileInfoBlockProxy *proxy = abiv0_AllocMem(sizeof(struct FileInfoBlockProxy), MEMF_CLEAR, abiv0SysBase);
struct FileInfoBlockProxy *proxy = abiv0_AllocMem(sizeof(struct FileInfoBlockProxy), MEMF_CLEAR, DOS_SysBaseV0);
proxy->native = fib;
return proxy;
}
else if (type == DOS_EXALLCONTROL && tags == NULL)
{
struct ExAllControl *eac = AllocDosObject(type, NULL);
struct ExAllControlProxy *proxy = abiv0_AllocMem(sizeof(struct ExAllControlProxy), MEMF_CLEAR, abiv0SysBase);
struct ExAllControlProxy *proxy = abiv0_AllocMem(sizeof(struct ExAllControlProxy), MEMF_CLEAR, DOS_SysBaseV0);
proxy->native = eac;
return proxy;
}
@ -203,13 +203,13 @@ void abiv0_FreeDosObject(ULONG type, APTR ptr, struct DosLibraryV0 *DOSBaseV0)
{
struct FileInfoBlockProxy *proxy = (struct FileInfoBlockProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct FileInfoBlockProxy), abiv0SysBase);
abiv0_FreeMem(proxy, sizeof(struct FileInfoBlockProxy), DOS_SysBaseV0);
return;
} else if (type == DOS_EXALLCONTROL)
{
struct ExAllControlProxy *proxy = (struct ExAllControlProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct ExAllControlProxy), abiv0SysBase);
abiv0_FreeMem(proxy, sizeof(struct ExAllControlProxy), DOS_SysBaseV0);
return;
}
asm("int3");
@ -258,7 +258,7 @@ APTR abiv0_DOS_OpenLibrary(CONST_STRPTR name, ULONG version, struct ExecBaseV0 *
extern ULONG *dosfunctable;
extern ULONG *seginitlist;
void init_dos()
void init_dos(struct ExecBaseV0 *SysBaseV0)
{
/* Keep it! This fills global variable */
LoadSeg32("SYS:Libs32/partial/dos.library", DOSBase);
@ -268,6 +268,7 @@ void init_dos()
abiv0DOSBase->dl_lib.lib_Version = DOSBase->dl_lib.lib_Version;
abiv0DOSBase->dl_TimeReq = (APTR32)(IPTR)AllocMem(sizeof(struct timerequestV0), MEMF_31BIT | MEMF_CLEAR);
((struct timerequestV0 *)(IPTR)abiv0DOSBase->dl_TimeReq)->tr_node.io_Device = (APTR32)(IPTR)abiv0TimerBase;
DOS_SysBaseV0 = SysBaseV0;
/* Call SysBase_autoinit */
__asm__ volatile (
@ -279,9 +280,9 @@ void init_dos()
"call *%%eax\n"
ENTER64
"addq $4, %%rsp\n"
::"m"(abiv0SysBase), "m"(seginitlist[1]) : "%rax", "%rcx");
::"m"(SysBaseV0), "m"(seginitlist[1]) : "%rax", "%rcx");
abiv0DOSBase->dl_UtilityBase = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, abiv0SysBase);
abiv0DOSBase->dl_UtilityBase = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, SysBaseV0);
__AROS_SETVECADDRV0(abiv0DOSBase, 158, (APTR32)(IPTR)proxy_PutStr);
__AROS_SETVECADDRV0(abiv0DOSBase, 9, dosfunctable[8]); // Input

View File

@ -13,7 +13,6 @@
#include "../include/dos/structures.h"
extern struct DosLibraryV0 *abiv0DOSBase;
struct ExecBaseV0 *abiv0SysBase;
extern struct LibraryV0 *abiv0TimerBase;
APTR abiv0_AllocMem(ULONG byteSize, ULONG requirements, struct ExecBaseV0 *SysBaseV0)
@ -288,8 +287,9 @@ MAKE_PROXY_ARG_2(FindTask)
extern ULONG *execfunctable;
APTR32 global_SysBaseV0Ptr;
struct ExecBaseV0 *abiv0SysBase;
void init_exec()
struct ExecBaseV0 *init_exec()
{
APTR tmp;
@ -344,4 +344,6 @@ void init_exec()
__AROS_SETVECADDRV0(abiv0SysBase,149, (APTR32)(IPTR)proxy_AllocVecPooled);
__AROS_SETVECADDRV0(abiv0SysBase, 76, (APTR32)(IPTR)proxy_DoIO);
__AROS_SETVECADDRV0(abiv0SysBase,119, (APTR32)(IPTR)proxy_FreePooled);
}
return abiv0SysBase;
}

View File

@ -12,7 +12,7 @@
#include "../include/graphics/proxy_structures.h"
#include "../include/utility/structures.h"
extern struct ExecBaseV0 *abiv0SysBase;
struct ExecBaseV0 *Gfx_SysBaseV0;
struct LibraryV0 *abiv0_Gfx_OpenLib(ULONG version, struct LibraryV0 *GfxBaseV0)
{
@ -80,18 +80,19 @@ BPTR LoadSeg32 (CONST_STRPTR name, struct DosLibrary *DOSBase);
struct ResidentV0 * findResident(BPTR seg, CONST_STRPTR name);
APTR abiv0_DOS_OpenLibrary(CONST_STRPTR name, ULONG version, struct ExecBaseV0 *SysBaseV0);
void init_graphics()
void init_graphics(struct ExecBaseV0 *SysBaseV0)
{
BPTR graphicsseg = LoadSeg32("SYS:Libs32/partial/graphics.library", DOSBase);
struct ResidentV0 *graphicsres = findResident(graphicsseg, NULL);
struct GfxBaseV0 *abiv0GfxBase = (struct GfxBaseV0 *)shallow_InitResident32(graphicsres, graphicsseg, abiv0SysBase);
struct GfxBaseV0 *abiv0GfxBase = (struct GfxBaseV0 *)shallow_InitResident32(graphicsres, graphicsseg, SysBaseV0);
Gfx_SysBaseV0 = SysBaseV0;
/* Remove all vectors for now */
const ULONG graphicsjmpsize = 202 * sizeof(APTR32);
APTR32 *graphicsjmp = AllocMem(graphicsjmpsize, MEMF_CLEAR);
CopyMem((APTR)abiv0GfxBase - graphicsjmpsize, graphicsjmp, graphicsjmpsize);
for (int i = 1; i <= 201; i++) __AROS_SETVECADDRV0(abiv0GfxBase, i, 0);
abiv0GfxBase->ExecBase = (APTR32)(IPTR)abiv0SysBase;
*(ULONG *)((IPTR)abiv0GfxBase + 0x4b0) = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, abiv0SysBase);
abiv0GfxBase->ExecBase = (APTR32)(IPTR)SysBaseV0;
*(ULONG *)((IPTR)abiv0GfxBase + 0x4b0) = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, SysBaseV0);
__AROS_SETVECADDRV0(abiv0GfxBase, 1, (APTR32)(IPTR)proxy_Gfx_OpenLib);
__AROS_SETVECADDRV0(abiv0GfxBase, 12, (APTR32)(IPTR)proxy_OpenFont);

View File

@ -12,7 +12,7 @@
#include "../include/intuition/structures.h"
#include "../include/graphics/proxy_structures.h"
extern struct ExecBaseV0 *abiv0SysBase;
struct ExecBaseV0 *Intuition_SysBaseV0;
struct ScreenProxy
{
@ -32,20 +32,20 @@ struct ScreenV0 *abiv0_LockPubScreen(CONST_STRPTR name, struct LibraryV0 *Intuit
if (scr == NULL)
return NULL;
struct ScreenProxy *ret = abiv0_AllocMem(sizeof(struct ScreenProxy), MEMF_CLEAR, abiv0SysBase);
struct ScreenProxy *ret = abiv0_AllocMem(sizeof(struct ScreenProxy), MEMF_CLEAR, Intuition_SysBaseV0);
ret->base.Width = scr->Width;
ret->base.Height = scr->Height;
ret->native = scr;
struct ColorMapProxy *cmproxy = abiv0_AllocMem(sizeof(struct ColorMapProxy), MEMF_CLEAR, abiv0SysBase);
struct ColorMapProxy *cmproxy = abiv0_AllocMem(sizeof(struct ColorMapProxy), MEMF_CLEAR, Intuition_SysBaseV0);
cmproxy->native = scr->ViewPort.ColorMap;
ret->base.ViewPort.ColorMap = (APTR32)(IPTR)cmproxy;
struct TextAttrV0 * v0font = abiv0_AllocMem(sizeof(struct TextAttrV0), MEMF_CLEAR, abiv0SysBase);
struct TextAttrV0 * v0font = abiv0_AllocMem(sizeof(struct TextAttrV0), MEMF_CLEAR, Intuition_SysBaseV0);
v0font->ta_YSize = scr->Font->ta_YSize;
v0font->ta_Flags = scr->Font->ta_Flags;
v0font->ta_Style = scr->Font->ta_Style;
STRPTR v0font_name = abiv0_AllocMem(strlen(scr->Font->ta_Name) + 1, MEMF_CLEAR, abiv0SysBase);
STRPTR v0font_name = abiv0_AllocMem(strlen(scr->Font->ta_Name) + 1, MEMF_CLEAR, Intuition_SysBaseV0);
CopyMem(scr->Font->ta_Name, v0font_name, strlen(scr->Font->ta_Name) + 1);
v0font->ta_Name = (APTR32)(IPTR)v0font_name;
ret->base.Font = (APTR32)(IPTR)v0font;
@ -68,8 +68,8 @@ struct DrawInfoV0 *abiv0_GetScreenDrawInfo(struct ScreenV0 *screen, struct Libra
if (dri == NULL)
return NULL;
struct DrawInfoV0 *ret = abiv0_AllocMem(sizeof(struct DrawInfoV0), MEMF_CLEAR, abiv0SysBase);
ret->dri_Pens = (APTR32)(IPTR)abiv0_AllocMem(NUMDRIPENS * sizeof(UWORD), MEMF_CLEAR, abiv0SysBase);
struct DrawInfoV0 *ret = abiv0_AllocMem(sizeof(struct DrawInfoV0), MEMF_CLEAR, Intuition_SysBaseV0);
ret->dri_Pens = (APTR32)(IPTR)abiv0_AllocMem(NUMDRIPENS * sizeof(UWORD), MEMF_CLEAR, Intuition_SysBaseV0);
CopyMem(dri->dri_Pens, (APTR)(IPTR)ret->dri_Pens, NUMDRIPENS * sizeof(UWORD));
bug("abiv0_GetScreenDrawInfo: STUB\n");
@ -85,11 +85,13 @@ APTR abiv0_DOS_OpenLibrary(CONST_STRPTR name, ULONG version, struct ExecBaseV0 *
extern ULONG* segclassesinitlist;
extern ULONG *seginitlist;
void init_intuition()
void init_intuition(struct ExecBaseV0 *SysBaseV0)
{
BPTR intuitionseg = LoadSeg32("SYS:Libs32/partial/intuition.library", DOSBase);
struct ResidentV0 *intuitionres = findResident(intuitionseg, NULL);
struct LibraryV0 *abiv0IntuitionBase = shallow_InitResident32(intuitionres, intuitionseg, abiv0SysBase);
struct LibraryV0 *abiv0IntuitionBase = shallow_InitResident32(intuitionres, intuitionseg, SysBaseV0);
Intuition_SysBaseV0 = SysBaseV0;
/* Remove all vectors for now */
const ULONG intuitionjmpsize = 165 * sizeof(APTR32);
APTR32 *intuitionjmp = AllocMem(intuitionjmpsize, MEMF_CLEAR);
@ -106,7 +108,7 @@ void init_intuition()
"call *%%eax\n"
ENTER64
"addq $4, %%rsp\n"
::"m"(abiv0SysBase), "m"(seginitlist[1]) : "%rax", "%rcx");
::"m"(Intuition_SysBaseV0), "m"(seginitlist[1]) : "%rax", "%rcx");
__AROS_SETVECADDRV0(abiv0IntuitionBase, 1, (APTR32)(IPTR)proxy_Intuition_OpenLib);
__AROS_SETVECADDRV0(abiv0IntuitionBase, 113, intuitionjmp[165 - 113]); // MakeClass
@ -142,5 +144,5 @@ void init_intuition()
}
/* Set internal Intuition pointer of utility */
*(ULONG *)((IPTR)abiv0IntuitionBase + 0x60) = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, abiv0SysBase);
*(ULONG *)((IPTR)abiv0IntuitionBase + 0x60) = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, SysBaseV0);
}