Correctly access platform data via function argument.
[AROS.git] / compiler / arossupport / createseglist.c
blobb3b2c59e0573ab5bfb009cc4756ad35644a07a3d
1 /*
2 Copyright © 2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a seglist for ROM code.
6 */
8 #include <aros/debug.h>
9 #include <proto/exec.h>
11 struct phony_segment
13 ULONG Size; /* Length of segment in # of bytes */
14 BPTR Next; /* Next segment (always 0 for this) */
15 struct FullJumpVec Code; /* Code to jump to the offset */
16 } __attribute__((packed));
18 /*****************************************************************************
20 NAME */
21 #include <proto/arossupport.h>
23 BPTR CreateSegList(
25 /* SYNOPSIS */
26 APTR function )
28 /* LOCATION */
30 /* FUNCTION
31 Create a SegList, which contains a call to 'function'
33 INPUTS
34 function - Function to call when the SegList is executed
36 RESULT
37 BPTR to the SegList that was allocated. This SegList can
38 be freed by DOS/UnloadSeg. If not enough memory,
39 BNULL will be returned.
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 dos.library/UnloadSeg()
51 INTERNALS
53 *****************************************************************************/
55 struct phony_segment *segtmp;
57 segtmp = AllocMem(sizeof(*segtmp), MEMF_ANY);
58 if (!segtmp)
59 return BNULL;
61 segtmp->Size = sizeof(*segtmp);
62 segtmp->Next = (BPTR)0;
63 __AROS_SET_FULLJMP(&segtmp->Code, function);
65 CacheClearE(&segtmp->Code, sizeof(struct FullJumpVec), CACRF_ClearI | CACRF_ClearD);
67 D(bug("[CreateSegList] Created jump segment 0x%p, code 0x%p, target 0x%p\n", MKBADDR(&segtmp->Next), &segtmp->Code, function));
69 return MKBADDR(&segtmp->Next);