Load dos.library binary from disk and run SysBase_autoinit

InitResident cannot be run, because DOS's rt_Init vector is quite
special and part of boot procedure.
This commit is contained in:
deadwood 2024-03-11 18:01:14 +01:00
parent 4e46269f63
commit 1549ec8c73
2 changed files with 27 additions and 0 deletions

View File

@ -202,6 +202,8 @@ struct TaskV0 *abiv0_FindTask(CONST_STRPTR name, struct ExecBaseV0 *SysBaseV0)
MAKE_PROXY_ARG_2(FindTask)
ULONG *execfunctable;
ULONG *dosfunctable;
ULONG *dosinitlist;
LONG_FUNC run_emulation()
{
@ -236,11 +238,24 @@ LONG_FUNC run_emulation()
__AROS_SETVECADDRV0(sysbase, 74, (APTR32)(IPTR)proxy_OpenDevice);
__AROS_SETVECADDRV0(sysbase,118, (APTR32)(IPTR)proxy_AllocPooled);
__AROS_SETVECADDRV0(sysbase,114, (APTR32)(IPTR)proxy_AllocVec);
/* Keep it! This fills global variable */
LoadSeg32("SYS:Libs32/dos.library", DOSBase);
tmp = AllocMem(2048, MEMF_31BIT | MEMF_CLEAR);
abiv0DOSBase = (tmp + 1024);
abiv0DOSBase->dl_lib.lib_Version = DOSBase->dl_lib.lib_Version;
__asm__ volatile (
"subq $4, %%rsp\n"
"movl %0, %%eax\n"
"movl %%eax, (%%rsp)\n"
"movl %1, %%eax\n"
ENTER32
"call *%%eax\n"
ENTER64
"addq $4, %%rsp\n"
::"m"(sysbase), "m"(dosinitlist[1]) : "%rax", "%rcx");
__AROS_SETVECADDRV0(abiv0DOSBase, 158, (APTR32)(IPTR)proxy_PutStr);
/* Switch to CS = 0x23 during FAR call. This switches 32-bit emulation mode.

View File

@ -393,6 +393,18 @@ static int relocate
execfunctable = (APTR)(IPTR)s;
}
if ((name[0] == 'D') && (strcmp(name, "Dos_FuncTable") == 0))
{
extern ULONG *dosfunctable;
dosfunctable = (APTR)(IPTR)s;
}
if ((name[0] == '_') && (strcmp(name, "__INIT_LIST__") == 0))
{
extern ULONG* dosinitlist;
dosinitlist = (APTR)(IPTR)s;
}
}
switch (ELF_R_TYPE(rel->info))