WIP: add an initial skeleton for a real scsi.device based upon the ata device impleme...
[AROS.git] / compiler / arossupport / createseglist.c
blob8c8fd685ec595d138d8f53ef469855aa490071f7
1 /*
2 Copyright © 2011-2019, 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 } __attribute__((packed));
19 /*****************************************************************************
21 NAME */
22 #include <proto/arossupport.h>
24 BPTR __CreateSegList(
26 /* SYNOPSIS */
27 APTR function, struct ExecBase *SysBase )
29 /* LOCATION */
31 /* FUNCTION
32 Create a SegList, which contains a call to 'function'
34 INPUTS
35 function - Function to call when the SegList is executed
37 RESULT
38 BPTR to the SegList that was allocated. This SegList can
39 be freed by DOS/UnloadSeg. If not enough memory,
40 BNULL will be returned.
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 dos.library/UnloadSeg()
52 INTERNALS
54 *****************************************************************************/
56 struct phony_segment *segtmp;
57 struct FullJumpVec *Code; /* Code to jump to the offset */
59 segtmp = AllocMem(sizeof(*segtmp) + sizeof(*Code), MEMF_ANY);
60 if (!segtmp)
61 return BNULL;
63 Code = (struct FullJumpVec *)((IPTR)segtmp + sizeof(*segtmp));
64 segtmp->Size = sizeof(*segtmp) + sizeof(*Code);
65 segtmp->Next = (BPTR)0;
66 __AROS_SET_FULLJMP(Code, function);
68 if (SysBase->LibNode.lib_Version >= 36)
69 CacheClearE(Code, sizeof(*Code), CACRF_ClearI | CACRF_ClearD);
71 D(bug("[CreateSegList] Created jump segment 0x%p, code 0x%p, target 0x%p\n", MKBADDR(&segtmp->Next), Code, function));
73 return MKBADDR(&segtmp->Next);