Refactor: move dos code to separate file

This commit is contained in:
deadwood 2024-03-23 19:43:51 +01:00
parent 11041d89eb
commit 8bc73d53b0
6 changed files with 441 additions and 295 deletions

View File

@ -22,7 +22,7 @@
BPTR LoadSeg32 (CONST_STRPTR name, struct DosLibrary *DOSBase);
struct DosLibraryV0 *abiv0DOSBase;
extern struct DosLibraryV0 *abiv0DOSBase;
struct LibraryV0 *abiv0TimerBase;
struct ExecBaseV0 *abiv0SysBase;
@ -235,12 +235,6 @@ void dummy_OpenLibrary()
LEAVE_PROXY
}
void abiv0_PutStr(CONST_STRPTR text)
{
PutStr(text);
}
MAKE_PROXY_ARG_2(PutStr)
void abiv0_CloseLibrary()
{
}
@ -326,17 +320,7 @@ struct LibraryV0 *abiv0_Layers_OpenLib(ULONG version, struct LibraryV0 *LayersBa
}
MAKE_PROXY_ARG_2(Layers_OpenLib)
struct FileHandleProxy
{
BPTR native;
};
static struct FileHandleProxy *makeFileHandleProxy(BPTR native)
{
struct FileHandleProxy *proxy = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
proxy->native = native;
return proxy;
}
APTR makeFileHandleProxy(BPTR);
struct TaskV0 *abiv0_FindTask(CONST_STRPTR name, struct ExecBaseV0 *SysBaseV0)
{
@ -349,242 +333,25 @@ struct TaskV0 *abiv0_FindTask(CONST_STRPTR name, struct ExecBaseV0 *SysBaseV0)
dummy->pr_CIS = (BPTR32)(IPTR)makeFileHandleProxy(Input());
dummy->pr_CES = 0x2; //fake
dummy->pr_COS = (BPTR32)(IPTR)makeFileHandleProxy(Output());
struct FileHandleProxy *v0homedir = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, SysBaseV0);
v0homedir->native = GetProgramDir();
dummy->pr_HomeDir = (BPTR32)(IPTR)v0homedir;
dummy->pr_HomeDir = (BPTR32)(IPTR)makeFileHandleProxy(GetProgramDir());
return (struct TaskV0 *)dummy;
}
MAKE_PROXY_ARG_2(FindTask)
LONG abiv0_SetVBuf()
{
return 0;
}
MAKE_PROXY_ARG_5(SetVBuf)
struct ProcessV0 *abiv0_CreateNewProc()
{
return (APTR)0x1;
}
MAKE_PROXY_ARG_2(CreateNewProc)
void abiv0_GetSysTime(struct timeval *dest, struct LibraryV0 *TimerBaseV0)
{
return GetSysTime(dest);
}
MAKE_PROXY_ARG_2(GetSysTime)
LONG abiv0_FPutC(BPTR file, LONG character, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *proxy = (struct FileHandleProxy *)file;
return FPutC(proxy->native, character);
}
MAKE_PROXY_ARG_3(FPutC)
LONG abiv0_FGetC(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return FGetC(fhp->native);
}
MAKE_PROXY_ARG_2(FGetC)
BPTR abiv0_Open(CONST_STRPTR name, LONG accessMode, struct DosLibraryV0 *DOSBaseV0)
{
BPTR tmp = Open(name, accessMode);
if (tmp == BNULL)
return BNULL;
struct FileHandleProxy *fhp = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
fhp->native = tmp;
return (BPTR)fhp;
}
MAKE_PROXY_ARG_3(Open)
LONG abiv0_IsInteractive(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return IsInteractive(fhp->native);
}
MAKE_PROXY_ARG_2(IsInteractive)
LONG abiv0_Read(BPTR file, APTR buffer, LONG length, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Read(fhp->native, buffer, length);
}
MAKE_PROXY_ARG_4(Read)
LONG abiv0_Seek(BPTR file, LONG position, LONG mode, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Seek(fhp->native, position, mode);
}
MAKE_PROXY_ARG_4(Seek)
BOOL abiv0_Close(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Close(fhp->native);
}
MAKE_PROXY_ARG_2(Close)
struct FileLockProxy
{
BPTR native;
};
static struct FileLockProxy *makeFileLockProxy(BPTR native)
{
struct FileLockProxy *proxy = abiv0_AllocMem(sizeof(struct FileLockProxy), MEMF_ANY, abiv0SysBase);
proxy->native = native;
return proxy;
}
BPTR abiv0_Lock(CONST_STRPTR name, LONG accessMode, struct DosLibraryV0 *DOSBaseV0)
{
BPTR tmp = Lock(name, accessMode);
if (tmp == BNULL)
return BNULL;
return (BPTR)makeFileLockProxy(tmp);
}
MAKE_PROXY_ARG_3(Lock)
struct DevProcProxy
{
struct DevProcV0 base;
struct DevProc *native;
};
struct DevProcV0 *abiv0_GetDeviceProc(CONST_STRPTR name, struct DevProcV0 *dp, struct DosLibraryV0 *DOSBaseV0)
{
struct DevProc *nativedp = NULL;
if (dp) nativedp = ((struct DevProcProxy *)dp)->native;
struct DevProc *nativeret = GetDeviceProc(name, nativedp);
if (nativeret == NULL)
return NULL;
struct DevProcProxy *proxy = abiv0_AllocMem(sizeof(struct DevProcProxy), MEMF_CLEAR, abiv0SysBase);
proxy->base.dvp_Lock = (BPTR32)(IPTR)makeFileLockProxy(nativeret->dvp_Lock);
proxy->native = nativeret;
return (struct DevProcV0 *)proxy;
}
MAKE_PROXY_ARG_3(GetDeviceProc)
void abiv0_FreeDeviceProc(struct DevProcV0 *dp, struct DosLibraryV0 *DOSBaseV0)
{
if (dp)
{
struct DevProcProxy *proxy = (struct DevProcProxy *)dp;
FreeDeviceProc(proxy->native);
abiv0_FreeMem(proxy, sizeof(struct DevProcProxy), abiv0SysBase);
}
}
MAKE_PROXY_ARG_2(FreeDeviceProc)
BPTR abiv0_DupLock(BPTR lock, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *proxy = (struct FileLockProxy *)lock;
BPTR dup = DupLock(proxy->native);
return (BPTR)makeFileLockProxy(dup);
/* ABI_V0 compatibility MISSING*/
/* Up to 2010-12-03 DupLockFromFH was an alias/define to DupLock */
}
MAKE_PROXY_ARG_2(DupLock)
struct FileInfoBlockProxy
{
struct FileInfoBlockV0 base;
struct FileInfoBlock *native;
};
struct ExAllControlProxy
{
struct ExAllControlV0 base;
struct ExAllControl *native;
};
APTR abiv0_AllocDosObject(ULONG type, const struct TagItemV0 * tags, struct DosLibraryV0 *DOSBaseV0)
{
if (type == DOS_FIB && tags == NULL)
{
struct FileInfoBlock *fib = AllocDosObject(type, NULL);
struct FileInfoBlockProxy *proxy = abiv0_AllocMem(sizeof(struct FileInfoBlockProxy), MEMF_CLEAR, abiv0SysBase);
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);
proxy->native = eac;
return proxy;
}
asm("int3");
}
MAKE_PROXY_ARG_3(AllocDosObject)
void abiv0_FreeDosObject(ULONG type, APTR ptr, struct DosLibraryV0 *DOSBaseV0)
{
if (type == DOS_FIB)
{
struct FileInfoBlockProxy *proxy = (struct FileInfoBlockProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct FileInfoBlockProxy), abiv0SysBase);
return;
} else if (type == DOS_EXALLCONTROL)
{
struct ExAllControlProxy *proxy = (struct ExAllControlProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct ExAllControlProxy), abiv0SysBase);
return;
}
asm("int3");
}
MAKE_PROXY_ARG_3(FreeDosObject)
LONG abiv0_Examine(BPTR lock, struct FileInfoBlockV0 *fib, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *flproxy = (struct FileLockProxy *)lock;
struct FileInfoBlockProxy *fibproxy = (struct FileInfoBlockProxy *)fib;
LONG res = Examine(flproxy->native, fibproxy->native);
if (res)
{
fibproxy->base.fib_Date = fibproxy->native->fib_Date;
bug("abiv0_Examine: STUB\n");
}
return res;
}
MAKE_PROXY_ARG_3(Examine)
BPTR abiv0_CurrentDir(BPTR lock, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *flproxy = (struct FileLockProxy *)lock;
BPTR old = CurrentDir(flproxy->native);
return (BPTR)makeFileLockProxy(old);
}
MAKE_PROXY_ARG_2(CurrentDir)
BOOL abiv0_ExAll(BPTR lock, struct ExAllDataV0 *buffer, LONG size, LONG type, struct ExAllControlV0 *control, struct DosLibraryV0 *DOSBaseV0)
{
bug("abiv0_ExAll: STUB\n");
return FALSE;
}
MAKE_PROXY_ARG_6(ExAll)
SIPTR abiv0_IoErr(struct DosLibraryV0 *DOSBaseV0)
{
bug("abiv0_IoErr: STUB\n");
return ERROR_NO_MORE_ENTRIES;
}
MAKE_PROXY_ARG_1(IoErr)
ULONG *execfunctable;
ULONG *dosfunctable;
@ -596,6 +363,7 @@ extern ULONG* segclassesinitlist;
void init_graphics();
void init_intuition();
void init_dos();
LONG_FUNC run_emulation()
{
@ -665,61 +433,7 @@ LONG_FUNC run_emulation()
__AROS_SETVECADDRV0(abiv0TimerBase, 11, (APTR32)(IPTR)proxy_GetSysTime);
/* Keep it! This fills global variable */
LoadSeg32("SYS:Libs32/partial/dos.library", DOSBase);
tmp = AllocMem(2048, MEMF_31BIT | MEMF_CLEAR);
abiv0DOSBase = (tmp + 1024);
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;
/* Call SysBase_autoinit */
__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"(abiv0SysBase), "m"(seginitlist[1]) : "%rax", "%rcx");
abiv0DOSBase->dl_UtilityBase = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, abiv0SysBase);
__AROS_SETVECADDRV0(abiv0DOSBase, 158, (APTR32)(IPTR)proxy_PutStr);
__AROS_SETVECADDRV0(abiv0DOSBase, 9, dosfunctable[8]); // Input
__AROS_SETVECADDRV0(abiv0DOSBase, 10, dosfunctable[9]); // Output
__AROS_SETVECADDRV0(abiv0DOSBase, 61, (APTR32)(IPTR)proxy_SetVBuf);
__AROS_SETVECADDRV0(abiv0DOSBase, 32, dosfunctable[31]); // DateStamp
__AROS_SETVECADDRV0(abiv0DOSBase, 82, dosfunctable[81]); // Cli
__AROS_SETVECADDRV0(abiv0DOSBase, 159, dosfunctable[158]); // VPrintf
__AROS_SETVECADDRV0(abiv0DOSBase, 52, (APTR32)(IPTR)proxy_FPutC);
__AROS_SETVECADDRV0(abiv0DOSBase, 83, (APTR32)(IPTR)proxy_CreateNewProc);
__AROS_SETVECADDRV0(abiv0DOSBase, 77, dosfunctable[76]); // SetIoErr
__AROS_SETVECADDRV0(abiv0DOSBase, 5, (APTR32)(IPTR)proxy_Open);
__AROS_SETVECADDRV0(abiv0DOSBase, 133, dosfunctable[132]); // ReadArgs
__AROS_SETVECADDRV0(abiv0DOSBase, 36, (APTR32)(IPTR)proxy_IsInteractive);
__AROS_SETVECADDRV0(abiv0DOSBase, 56, dosfunctable[55]); // FGets
__AROS_SETVECADDRV0(abiv0DOSBase, 51, (APTR32)(IPTR)proxy_FGetC);
__AROS_SETVECADDRV0(abiv0DOSBase, 135, dosfunctable[134]); // ReadItem
__AROS_SETVECADDRV0(abiv0DOSBase, 143, dosfunctable[142]); // FreeArgs
__AROS_SETVECADDRV0(abiv0DOSBase, 7, (APTR32)(IPTR)proxy_Read);
__AROS_SETVECADDRV0(abiv0DOSBase, 11, (APTR32)(IPTR)proxy_Seek);
__AROS_SETVECADDRV0(abiv0DOSBase, 6, (APTR32)(IPTR)proxy_Close);
__AROS_SETVECADDRV0(abiv0DOSBase, 145, dosfunctable[144]); // FilePart
__AROS_SETVECADDRV0(abiv0DOSBase, 100, dosfunctable[ 99]); // GetProgramDir
__AROS_SETVECADDRV0(abiv0DOSBase, 14, (APTR32)(IPTR)proxy_Lock);
__AROS_SETVECADDRV0(abiv0DOSBase, 107, (APTR32)(IPTR)proxy_GetDeviceProc);
__AROS_SETVECADDRV0(abiv0DOSBase, 16, (APTR32)(IPTR)proxy_DupLock);
__AROS_SETVECADDRV0(abiv0DOSBase, 38, (APTR32)(IPTR)proxy_AllocDosObject);
__AROS_SETVECADDRV0(abiv0DOSBase, 17, (APTR32)(IPTR)proxy_Examine);
__AROS_SETVECADDRV0(abiv0DOSBase, 21, (APTR32)(IPTR)proxy_CurrentDir);
__AROS_SETVECADDRV0(abiv0DOSBase, 72, (APTR32)(IPTR)proxy_ExAll);
__AROS_SETVECADDRV0(abiv0DOSBase, 22, (APTR32)(IPTR)proxy_IoErr);
__AROS_SETVECADDRV0(abiv0DOSBase, 39, (APTR32)(IPTR)proxy_FreeDosObject);
__AROS_SETVECADDRV0(abiv0DOSBase, 108, (APTR32)(IPTR)proxy_FreeDeviceProc);
init_dos();
BPTR cgfxseg = LoadSeg32("SYS:Libs32/partial/cybergraphics.library", DOSBase);
struct ResidentV0 *cgfxres = findResident(cgfxseg, NULL);

View File

@ -0,0 +1,320 @@
#include <proto/exec.h>
#include <proto/dos.h>
#include <aros/debug.h>
#include "../include/exec/structures.h"
#include "../include/exec/functions.h"
#include "../include/aros/cpu.h"
#include "../include/aros/proxy.h"
#include "../include/dos/structures.h"
#include "../include/utility/structures.h"
#include "../include/timer/structures.h"
extern struct ExecBaseV0 *abiv0SysBase;
extern struct LibraryV0 *abiv0TimerBase;
struct DosLibraryV0 *abiv0DOSBase;
struct FileLockProxy
{
BPTR native;
};
struct FileHandleProxy
{
BPTR native;
};
struct FileHandleProxy *makeFileHandleProxy(BPTR native)
{
struct FileHandleProxy *proxy = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
proxy->native = native;
return proxy;
}
void abiv0_PutStr(CONST_STRPTR text)
{
PutStr(text);
}
MAKE_PROXY_ARG_2(PutStr)
LONG abiv0_SetVBuf()
{
return 0;
}
MAKE_PROXY_ARG_5(SetVBuf)
struct ProcessV0 *abiv0_CreateNewProc()
{
return (APTR)0x1;
}
MAKE_PROXY_ARG_2(CreateNewProc)
LONG abiv0_FPutC(BPTR file, LONG character, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *proxy = (struct FileHandleProxy *)file;
return FPutC(proxy->native, character);
}
MAKE_PROXY_ARG_3(FPutC)
LONG abiv0_FGetC(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return FGetC(fhp->native);
}
MAKE_PROXY_ARG_2(FGetC)
BPTR abiv0_Open(CONST_STRPTR name, LONG accessMode, struct DosLibraryV0 *DOSBaseV0)
{
BPTR tmp = Open(name, accessMode);
if (tmp == BNULL)
return BNULL;
struct FileHandleProxy *fhp = abiv0_AllocMem(sizeof(struct FileHandleProxy), MEMF_ANY, abiv0SysBase);
fhp->native = tmp;
return (BPTR)fhp;
}
MAKE_PROXY_ARG_3(Open)
LONG abiv0_IsInteractive(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return IsInteractive(fhp->native);
}
MAKE_PROXY_ARG_2(IsInteractive)
LONG abiv0_Read(BPTR file, APTR buffer, LONG length, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Read(fhp->native, buffer, length);
}
MAKE_PROXY_ARG_4(Read)
LONG abiv0_Seek(BPTR file, LONG position, LONG mode, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Seek(fhp->native, position, mode);
}
MAKE_PROXY_ARG_4(Seek)
BOOL abiv0_Close(BPTR file, struct DosLibraryV0 *DOSBaseV0)
{
struct FileHandleProxy *fhp = (struct FileHandleProxy *)file;
return Close(fhp->native);
}
MAKE_PROXY_ARG_2(Close)
static struct FileLockProxy *makeFileLockProxy(BPTR native)
{
struct FileLockProxy *proxy = abiv0_AllocMem(sizeof(struct FileLockProxy), MEMF_ANY, abiv0SysBase);
proxy->native = native;
return proxy;
}
BPTR abiv0_Lock(CONST_STRPTR name, LONG accessMode, struct DosLibraryV0 *DOSBaseV0)
{
BPTR tmp = Lock(name, accessMode);
if (tmp == BNULL)
return BNULL;
return (BPTR)makeFileLockProxy(tmp);
}
MAKE_PROXY_ARG_3(Lock)
struct DevProcProxy
{
struct DevProcV0 base;
struct DevProc *native;
};
struct DevProcV0 *abiv0_GetDeviceProc(CONST_STRPTR name, struct DevProcV0 *dp, struct DosLibraryV0 *DOSBaseV0)
{
struct DevProc *nativedp = NULL;
if (dp) nativedp = ((struct DevProcProxy *)dp)->native;
struct DevProc *nativeret = GetDeviceProc(name, nativedp);
if (nativeret == NULL)
return NULL;
struct DevProcProxy *proxy = abiv0_AllocMem(sizeof(struct DevProcProxy), MEMF_CLEAR, abiv0SysBase);
proxy->base.dvp_Lock = (BPTR32)(IPTR)makeFileLockProxy(nativeret->dvp_Lock);
proxy->native = nativeret;
return (struct DevProcV0 *)proxy;
}
MAKE_PROXY_ARG_3(GetDeviceProc)
void abiv0_FreeDeviceProc(struct DevProcV0 *dp, struct DosLibraryV0 *DOSBaseV0)
{
if (dp)
{
struct DevProcProxy *proxy = (struct DevProcProxy *)dp;
FreeDeviceProc(proxy->native);
abiv0_FreeMem(proxy, sizeof(struct DevProcProxy), abiv0SysBase);
}
}
MAKE_PROXY_ARG_2(FreeDeviceProc)
BPTR abiv0_DupLock(BPTR lock, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *proxy = (struct FileLockProxy *)lock;
BPTR dup = DupLock(proxy->native);
return (BPTR)makeFileLockProxy(dup);
/* ABI_V0 compatibility MISSING*/
/* Up to 2010-12-03 DupLockFromFH was an alias/define to DupLock */
}
MAKE_PROXY_ARG_2(DupLock)
struct FileInfoBlockProxy
{
struct FileInfoBlockV0 base;
struct FileInfoBlock *native;
};
struct ExAllControlProxy
{
struct ExAllControlV0 base;
struct ExAllControl *native;
};
APTR abiv0_AllocDosObject(ULONG type, const struct TagItemV0 * tags, struct DosLibraryV0 *DOSBaseV0)
{
if (type == DOS_FIB && tags == NULL)
{
struct FileInfoBlock *fib = AllocDosObject(type, NULL);
struct FileInfoBlockProxy *proxy = abiv0_AllocMem(sizeof(struct FileInfoBlockProxy), MEMF_CLEAR, abiv0SysBase);
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);
proxy->native = eac;
return proxy;
}
asm("int3");
}
MAKE_PROXY_ARG_3(AllocDosObject)
void abiv0_FreeDosObject(ULONG type, APTR ptr, struct DosLibraryV0 *DOSBaseV0)
{
if (type == DOS_FIB)
{
struct FileInfoBlockProxy *proxy = (struct FileInfoBlockProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct FileInfoBlockProxy), abiv0SysBase);
return;
} else if (type == DOS_EXALLCONTROL)
{
struct ExAllControlProxy *proxy = (struct ExAllControlProxy *)ptr;
FreeDosObject(type, proxy->native);
abiv0_FreeMem(proxy, sizeof(struct ExAllControlProxy), abiv0SysBase);
return;
}
asm("int3");
}
MAKE_PROXY_ARG_3(FreeDosObject)
LONG abiv0_Examine(BPTR lock, struct FileInfoBlockV0 *fib, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *flproxy = (struct FileLockProxy *)lock;
struct FileInfoBlockProxy *fibproxy = (struct FileInfoBlockProxy *)fib;
LONG res = Examine(flproxy->native, fibproxy->native);
if (res)
{
fibproxy->base.fib_Date = fibproxy->native->fib_Date;
bug("abiv0_Examine: STUB\n");
}
return res;
}
MAKE_PROXY_ARG_3(Examine)
BPTR abiv0_CurrentDir(BPTR lock, struct DosLibraryV0 *DOSBaseV0)
{
struct FileLockProxy *flproxy = (struct FileLockProxy *)lock;
BPTR old = CurrentDir(flproxy->native);
return (BPTR)makeFileLockProxy(old);
}
MAKE_PROXY_ARG_2(CurrentDir)
BOOL abiv0_ExAll(BPTR lock, struct ExAllDataV0 *buffer, LONG size, LONG type, struct ExAllControlV0 *control, struct DosLibraryV0 *DOSBaseV0)
{
bug("abiv0_ExAll: STUB\n");
return FALSE;
}
MAKE_PROXY_ARG_6(ExAll)
SIPTR abiv0_IoErr(struct DosLibraryV0 *DOSBaseV0)
{
bug("abiv0_IoErr: STUB\n");
return ERROR_NO_MORE_ENTRIES;
}
MAKE_PROXY_ARG_1(IoErr)
// struct LibraryV0 *shallow_InitResident32(struct ResidentV0 *resident, BPTR segList, struct ExecBaseV0 *SysBaseV0);
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);
extern ULONG *dosfunctable;
extern ULONG *seginitlist;
void init_dos()
{
/* Keep it! This fills global variable */
LoadSeg32("SYS:Libs32/partial/dos.library", DOSBase);
APTR tmp = AllocMem(2048, MEMF_31BIT | MEMF_CLEAR);
abiv0DOSBase = (tmp + 1024);
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;
/* Call SysBase_autoinit */
__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"(abiv0SysBase), "m"(seginitlist[1]) : "%rax", "%rcx");
abiv0DOSBase->dl_UtilityBase = (APTR32)(IPTR)abiv0_DOS_OpenLibrary("utility.library", 0L, abiv0SysBase);
__AROS_SETVECADDRV0(abiv0DOSBase, 158, (APTR32)(IPTR)proxy_PutStr);
__AROS_SETVECADDRV0(abiv0DOSBase, 9, dosfunctable[8]); // Input
__AROS_SETVECADDRV0(abiv0DOSBase, 10, dosfunctable[9]); // Output
__AROS_SETVECADDRV0(abiv0DOSBase, 61, (APTR32)(IPTR)proxy_SetVBuf);
__AROS_SETVECADDRV0(abiv0DOSBase, 32, dosfunctable[31]); // DateStamp
__AROS_SETVECADDRV0(abiv0DOSBase, 82, dosfunctable[81]); // Cli
__AROS_SETVECADDRV0(abiv0DOSBase, 159, dosfunctable[158]); // VPrintf
__AROS_SETVECADDRV0(abiv0DOSBase, 52, (APTR32)(IPTR)proxy_FPutC);
__AROS_SETVECADDRV0(abiv0DOSBase, 83, (APTR32)(IPTR)proxy_CreateNewProc);
__AROS_SETVECADDRV0(abiv0DOSBase, 77, dosfunctable[76]); // SetIoErr
__AROS_SETVECADDRV0(abiv0DOSBase, 5, (APTR32)(IPTR)proxy_Open);
__AROS_SETVECADDRV0(abiv0DOSBase, 133, dosfunctable[132]); // ReadArgs
__AROS_SETVECADDRV0(abiv0DOSBase, 36, (APTR32)(IPTR)proxy_IsInteractive);
__AROS_SETVECADDRV0(abiv0DOSBase, 56, dosfunctable[55]); // FGets
__AROS_SETVECADDRV0(abiv0DOSBase, 51, (APTR32)(IPTR)proxy_FGetC);
__AROS_SETVECADDRV0(abiv0DOSBase, 135, dosfunctable[134]); // ReadItem
__AROS_SETVECADDRV0(abiv0DOSBase, 143, dosfunctable[142]); // FreeArgs
__AROS_SETVECADDRV0(abiv0DOSBase, 7, (APTR32)(IPTR)proxy_Read);
__AROS_SETVECADDRV0(abiv0DOSBase, 11, (APTR32)(IPTR)proxy_Seek);
__AROS_SETVECADDRV0(abiv0DOSBase, 6, (APTR32)(IPTR)proxy_Close);
__AROS_SETVECADDRV0(abiv0DOSBase, 145, dosfunctable[144]); // FilePart
__AROS_SETVECADDRV0(abiv0DOSBase, 100, dosfunctable[ 99]); // GetProgramDir
__AROS_SETVECADDRV0(abiv0DOSBase, 14, (APTR32)(IPTR)proxy_Lock);
__AROS_SETVECADDRV0(abiv0DOSBase, 107, (APTR32)(IPTR)proxy_GetDeviceProc);
__AROS_SETVECADDRV0(abiv0DOSBase, 16, (APTR32)(IPTR)proxy_DupLock);
__AROS_SETVECADDRV0(abiv0DOSBase, 38, (APTR32)(IPTR)proxy_AllocDosObject);
__AROS_SETVECADDRV0(abiv0DOSBase, 17, (APTR32)(IPTR)proxy_Examine);
__AROS_SETVECADDRV0(abiv0DOSBase, 21, (APTR32)(IPTR)proxy_CurrentDir);
__AROS_SETVECADDRV0(abiv0DOSBase, 72, (APTR32)(IPTR)proxy_ExAll);
__AROS_SETVECADDRV0(abiv0DOSBase, 22, (APTR32)(IPTR)proxy_IoErr);
__AROS_SETVECADDRV0(abiv0DOSBase, 39, (APTR32)(IPTR)proxy_FreeDosObject);
__AROS_SETVECADDRV0(abiv0DOSBase, 108, (APTR32)(IPTR)proxy_FreeDeviceProc);
}

View File

@ -7,6 +7,7 @@
APTR abiv0_InitResident(struct ResidentV0 *resident, BPTR segList, struct ExecBaseV0 *SysBaseV0);
APTR abiv0_AllocMem(ULONG byteSize, ULONG requirements, struct ExecBaseV0 *SysBaseV0);
void abiv0_FreeMem(APTR memoryBlock, ULONG byteSize, struct ExecBaseV0 *SysBaseV0);
struct LibraryV0 * abiv0_MakeLibrary(APTR32 funcInit, APTR32 structInit, APTR32 libInit, ULONG dataSize,
BPTR segList, struct ExecBaseV0 * SysBaseV0);
ULONG abiv0_MakeFunctions(APTR target, APTR32 functionArray, APTR32 funcDispBase, struct ExecBaseV0 *SysBaseV0);

View File

@ -302,6 +302,7 @@ static int __attribute__ ((noinline)) load_hunk
ULONG *segclassesinitlist;
ULONG *seginitlist;
ULONG *dosfunctable;
static int relocate
(
@ -404,7 +405,6 @@ static int relocate
if ((name[0] == 'D') && (strcmp(name, "Dos_FuncTable") == 0))
{
extern ULONG *dosfunctable;
dosfunctable = (APTR)(IPTR)s;
}

View File

@ -0,0 +1,111 @@
/*
Copyright (C) 1995-2019, The AROS Development Team. All rights reserved.
*/
#include <aros/config.h>
#include <libraries/debug.h>
#include <proto/debug.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include "dos_intern.h"
#include "internalloadseg.h"
static char *getname(BPTR file, char **bufferp, struct DosLibrary *DOSBase)
{
/* Some applications pass a non-filehandle to
* Dos/InternalLoadSeg, so don't try to register
* the hunks if this is not a real FileHandle
*
* A real-life example of this is C:AddDataTypes
* from AmigaOS 3.9
*/
if (DOSBase && ISFILEHANDLE(file)) {
char *buffer = AllocMem(512, MEMF_ANY);
if (buffer) {
*bufferp = buffer;
if (NameFromFH(file, buffer, 512)) {
char *nameptr = buffer;
/* gdb support needs full paths */
#if !AROS_MODULES_DEBUG
/* First, go through the name, till end of the string */
while(*nameptr++);
/* Now, go back until either ":" or "/" is found */
while(nameptr > buffer && nameptr[-1] != ':' && nameptr[-1] != '/')
nameptr--;
#endif
return nameptr;
}
}
}
return "unknown";
}
void register_elf(BPTR file, BPTR hunks, struct elfheader *eh, struct sheader *sh, struct DosLibrary *DOSBase)
{
if (DOSBase)
{
struct Node *segnode = AllocVec(sizeof(struct Node), MEMF_CLEAR);
if (segnode)
{
segnode->ln_Name = (char *)hunks;
segnode->ln_Type = SEGTYPE_ELF;
ObtainSemaphore(&IDosBase(DOSBase)->segsem);
AddTail(&IDosBase(DOSBase)->segdata, segnode);
ReleaseSemaphore(&IDosBase(DOSBase)->segsem);
if (DebugBase)
{
char *buffer = NULL;
char *nameptr = getname(file, &buffer, DOSBase);
struct ELF_DebugInfo dbg = {eh, sh};
RegisterModule(nameptr, hunks, DEBUG_ELF, &dbg);
FreeMem(buffer, 512);
}
}
}
}
#undef DebugBase
/* DOSBase is NULL if called by m68k RDB filesystem loader.
* No DosBase = Open debug.library manually, this enables
* us to have RDB segments in debug.library list.
*/
void register_hunk(BPTR file, BPTR hunks, APTR header, struct DosLibrary *DOSBase)
{
struct Library *DebugBase;
if (DOSBase)
{
struct Node *segnode = AllocVec(sizeof(struct Node), MEMF_CLEAR);
if (segnode)
{
segnode->ln_Name = (char *)hunks;
segnode->ln_Type = SEGTYPE_HUNK;
ObtainSemaphore(&IDosBase(DOSBase)->segsem);
AddTail(&IDosBase(DOSBase)->segdata, segnode);
ReleaseSemaphore(&IDosBase(DOSBase)->segsem);
}
DebugBase = IDosBase(DOSBase)->debugBase;
}
else
DebugBase = OpenLibrary("debug.library", 0);
if (DebugBase)
{
char *buffer = NULL;
char *nameptr = getname(file, &buffer, DOSBase);
struct HUNK_DebugInfo dbg = { header };
RegisterModule(nameptr, hunks, DEBUG_HUNK, &dbg);
FreeMem(buffer, 512);
}
if (!DOSBase)
CloseLibrary(DebugBase);
}
#if defined(DOCACHECLEAR)
void ils_ClearCache(APTR address, IPTR length, ULONG caches)
{
CacheClearE(address, length, caches);
}
#endif

View File

@ -2,8 +2,7 @@
include $(SRCDIR)/config/aros.cfg
FILES := AoA loadseg32 internalloadseg32 internalloadseg_elf32 \
$(SRCDIR)/rom/dos/internalloadseg_support \
FILES := AoA loadseg32 internalloadseg32 internalloadseg_elf32 internalloadseg_support32 \
abiv0/exec/initresident \
abiv0/exec/makelibrary \
abiv0/exec/makefunctions \
@ -14,6 +13,7 @@ FILES := AoA loadseg32 internalloadseg32 internalloadseg_elf32 \
abiv0/exec/addresource \
abiv0/graphics/graphics_init \
abiv0/intuition/intuition_init \
abiv0/dos/dos_init \
EXEDIR := $(AROS_C)
USER_INCLUDES := -I$(SRCDIR)/rom/dos