2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
9 #include <exec/execbase.h>
10 #include <exec/memory.h>
11 #include <dos/dosasl.h>
12 #include <dos/doshunks.h>
13 #include <dos/dosextens.h>
14 #include <proto/exec.h>
15 #include <proto/dos.h>
16 #include <proto/arossupport.h>
17 #include <aros/asmcall.h>
18 #include <aros/debug.h>
19 #include <aros/macros.h>
21 #include <loadseg/loadseg.h>
23 #include "dos_intern.h"
25 #if (AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT) && defined(__mc68000)
26 static AROS_UFH4(LONG
, ReadFunc
,
27 AROS_UFHA(BPTR
, file
, D1
),
28 AROS_UFHA(APTR
, buffer
, D2
),
29 AROS_UFHA(LONG
, length
, D3
),
30 AROS_UFHA(struct DosLibrary
*, DOSBase
, A6
)
35 return FRead(file
, buffer
, 1, length
);
40 static AROS_UFH3(APTR
, AllocFunc
,
41 AROS_UFHA(ULONG
, length
, D0
),
42 AROS_UFHA(ULONG
, flags
, D1
),
43 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)
48 return AllocMem(length
, flags
);
53 static AROS_UFH3(void, FreeFunc
,
54 AROS_UFHA(APTR
, buffer
, A1
),
55 AROS_UFHA(ULONG
, length
, D0
),
56 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)
61 FreeMem(buffer
, length
);
66 AROS_UFH4(BPTR
, LoadSeg_Overlay
,
67 AROS_UFHA(UBYTE
*, name
, D1
),
68 AROS_UFHA(BPTR
, hunktable
, D2
),
69 AROS_UFHA(BPTR
, fh
, D3
),
70 AROS_UFHA(struct DosLibrary
*, DOSBase
, A6
))
74 void (*FunctionArray
[3])();
77 SIPTR error
= RETURN_OK
;
79 FunctionArray
[0] = (APTR
)ReadFunc
;
80 FunctionArray
[1] = (APTR
)AllocFunc
;
81 FunctionArray
[2] = (APTR
)FreeFunc
;
83 D(bug("LoadSeg_Overlay. table=%x fh=%x\n", hunktable
, fh
));
84 if (AROS_UFC4(LONG
, ReadFunc
,
85 AROS_UFCA(BPTR
, fh
, D1
),
86 AROS_UFCA(void *, &hunktype
, D2
),
87 AROS_UFCA(LONG
, sizeof(hunktype
), D3
),
88 AROS_UFCA(struct Library
*, DOSBase
,A6
)) != sizeof(hunktype
))
90 hunktype
= AROS_BE2LONG(hunktype
);
91 if (hunktype
!= HUNK_HEADER
)
93 seg
= LoadSegment(fh
, hunktable
, (SIPTR
*)FunctionArray
, NULL
, &error
, (struct Library
*)DOSBase
);