Changing code back to the way it was in revision 48562
[AROS.git] / compiler / arossupport / createseglist.c
blob08c4f38eaf546ec514f0c840d6e1fa0abf2b2cf7
1 /*
2 Copyright © 2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a seglist for ROM code.
6 */
8 #define AROS_LIBREQ(base,ver) /* We test for versions manually */
10 #include <aros/debug.h>
11 #include <proto/exec.h>
13 struct phony_segment
15 ULONG Size; /* Length of segment in # of bytes */
16 BPTR Next; /* Next segment (always 0 for this) */
17 struct FullJumpVec Code; /* Code to jump to the offset */
18 } __attribute__((packed));
20 /*****************************************************************************
22 NAME */
23 #include <proto/arossupport.h>
25 BPTR __CreateSegList(
27 /* SYNOPSIS */
28 APTR function, struct ExecBase *SysBase )
30 /* LOCATION */
32 /* FUNCTION
33 Create a SegList, which contains a call to 'function'
35 INPUTS
36 function - Function to call when the SegList is executed
38 RESULT
39 BPTR to the SegList that was allocated. This SegList can
40 be freed by DOS/UnloadSeg. If not enough memory,
41 BNULL will be returned.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
51 dos.library/UnloadSeg()
53 INTERNALS
55 *****************************************************************************/
57 struct phony_segment *segtmp;
59 segtmp = AllocMem(sizeof(*segtmp), MEMF_ANY);
60 if (!segtmp)
61 return BNULL;
63 segtmp->Size = sizeof(*segtmp);
64 segtmp->Next = (BPTR)0;
65 __AROS_SET_FULLJMP(&segtmp->Code, function);
67 if (SysBase->LibNode.lib_Version >= 36)
68 CacheClearE(&segtmp->Code, sizeof(struct FullJumpVec), CACRF_ClearI | CACRF_ClearD);
70 D(bug("[CreateSegList] Created jump segment 0x%p, code 0x%p, target 0x%p\n", MKBADDR(&segtmp->Next), &segtmp->Code, function));
72 return MKBADDR(&segtmp->Next);