3 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 Desc: DOS function InternalLoadSeg()
14 #include <dos/dosextens.h>
15 #include <proto/dos.h>
16 #include <aros/debug.h>
17 #include "dos_intern.h"
18 #include "internalloadseg.h"
20 /*****************************************************************************
23 #include <proto/dos.h>
25 AROS_LH4(BPTR
, InternalLoadSeg
,
28 AROS_LHA(BPTR
, fh
, D0
),
29 AROS_LHA(BPTR
, table
, A0
),
30 AROS_LHA(LONG_FUNC
, functionarray
, A1
),
31 AROS_LHA(LONG
* , stack
, A2
),
34 struct DosLibrary
*, DOSBase
, 126, Dos
)
38 Functionarray is a pointer to an array of functions. See below.
40 This function really only tries to load the different file
41 formats aos, elf and aout.
44 fh : Filehandle to load from
46 functionarray : Array of function to be used fro read, alloc and free
47 FuncTable[0] -> bytes = ReadFunc(readhandle, buffer, length),DOSBase
49 FuncTable[1] -> Memory = AllocFunc(size,flags), ExecBase
51 FuncTable[2] -> FreeFunc(memory, size), ExecBase
53 stack : pointer to storage (ULONG) for stacksize.
57 seglist - pointer to loaded Seglist or NULL in case of failure.
64 Use of table and stack are not implemented, yet!
71 *****************************************************************************/
74 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
76 typedef struct _segfunc_t
78 BPTR (*func
)(BPTR
, BPTR
, LONG
*, LONG
*, struct DosLibrary
*);
79 D(CONST_STRPTR format
;)
82 #define SEGFUNC(format) { InternalLoadSeg_##format D(, #format)}
84 static const segfunc_t funcs
[] =
87 #if !defined(__mc68000__) && !defined(__arm__)
99 const int num_funcs
= sizeof(funcs
)/sizeof(funcs
[0]);
105 segs
= (*funcs
[i
].func
)(fh
, MKBADDR(NULL
), (LONG
*)functionarray
, NULL
, DOSBase
);
107 D(bug("[InternalLoadSeg] %s loading %p as an %s object.\n",
108 segs
? "Succeeded" : "FAILED", fh
, funcs
[i
].format
));
110 } while (!segs
&& (IoErr() == ERROR_NOT_EXECUTABLE
) && (++i
< num_funcs
));
116 } /* InternalLoadSeg */