revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / asm.c
blob410e127dba615aea286580c92aaec1626ba29e34
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/config.h>
8 #include <exec/alerts.h>
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <exec/interrupts.h>
12 #include <exec/tasks.h>
13 #include <dos/dosextens.h>
14 #include <graphics/clip.h>
16 #include <setjmp.h>
17 #include <stddef.h>
19 #ifdef __mc68000
20 #include "exec_intern.h"
21 #undef KernelBase
22 #include "kernel_base.h"
23 #include "kernel_intern.h"
25 /* m68k relative addresses must *not* start with a '#' */
26 #define DEFINE(sym, val) \
27 asm volatile("\n.asciz \"#define " #sym " %c0 \"": : "i" (val))
28 #else
29 #define DEFINE(sym, val) \
30 asm volatile("\n.asciz \"#define " #sym " %0 \"": : "i" (val))
31 #endif
33 #define FuncOffset(x) (long)__AROS_GETJUMPVEC(0,x)
35 int main(void) {
36 asm volatile("\n.asciz \"/* Macros */\"\n" ::);
38 asm volatile("\n.asciz \"#define AROS_CSYMNAME(n) n\"\n" ::);
39 asm volatile("\n.asciz \"#define AROS_CDEFNAME(n) n\"\n" ::);
40 asm volatile("\n.asciz \"#define AROS_SLIB_ENTRY(n,s,o) s ## _ ## o ## _ ## n\"\n" ::);
42 asm volatile("\n.asciz \"#define _FUNCTION(n) .type n,@function\"" ::);
43 asm volatile("\n.asciz \"#define _ALIGNMENT .balign %0\"" :: "i" (AROS_WORSTALIGN));
45 asm volatile("\n.asciz \"/* ExecBase */\"" ::);
46 DEFINE(AttnResched , offsetof (struct ExecBase, AttnResched));
47 DEFINE(AttnFlags , offsetof (struct ExecBase, AttnFlags));
48 #if !defined(__AROSEXEC_SMP__)
49 DEFINE(IDNestCnt , offsetof (struct ExecBase, IDNestCnt));
50 DEFINE(TDNestCnt , offsetof (struct ExecBase, TDNestCnt));
51 #else
52 DEFINE(SMPPrivate4 , offsetof (struct ExecBase, SMPPrivate4));
53 DEFINE(SMPPrivate5 , offsetof (struct ExecBase, SMPPrivate5));
54 #endif
55 DEFINE(TaskReady , offsetof (struct ExecBase, TaskReady));
56 #if !defined(__AROSEXEC_SMP__)
57 DEFINE(ThisTask , offsetof (struct ExecBase, ThisTask));
58 #else
59 DEFINE(SMPPrivate1 , offsetof (struct ExecBase, SMPPrivate1));
60 #endif
61 DEFINE(SysFlags , offsetof (struct ExecBase, SysFlags));
62 DEFINE(IdleCount , offsetof (struct ExecBase, IdleCount));
63 DEFINE(DispCount , offsetof (struct ExecBase, DispCount));
64 #if !defined(__AROSEXEC_SMP__)
65 DEFINE(Quantum , offsetof (struct ExecBase, Quantum));
66 DEFINE(Elapsed , offsetof (struct ExecBase, Elapsed));
67 #else
68 DEFINE(SMPPrivate2 , offsetof (struct ExecBase, SMPPrivate2));
69 DEFINE(SMPPrivate3 , offsetof (struct ExecBase, SMPPrivate3));
70 #endif
71 DEFINE(SysStkUpper , offsetof (struct ExecBase, SysStkUpper));
73 asm volatile("\n.asciz \"/* struct Task */\"" ::);
74 DEFINE(tc_State , offsetof (struct Task, tc_State));
75 DEFINE(tc_Flags , offsetof (struct Task, tc_Flags));
76 DEFINE(tc_ExceptCode , offsetof (struct Task, tc_ExceptCode));
77 DEFINE(tc_ExceptData , offsetof (struct Task, tc_ExceptData));
78 DEFINE(tc_SigExcept , offsetof (struct Task, tc_SigExcept));
79 DEFINE(tc_SigRecvd , offsetof (struct Task, tc_SigRecvd));
80 DEFINE(tc_Launch , offsetof (struct Task, tc_Launch));
81 DEFINE(tc_Switch , offsetof (struct Task, tc_Switch));
82 DEFINE(tc_SPReg , offsetof (struct Task, tc_SPReg));
83 DEFINE(tc_SPLower , offsetof (struct Task, tc_SPLower));
84 DEFINE(tc_SPUpper , offsetof (struct Task, tc_SPUpper));
85 DEFINE(tc_IDNestCnt , offsetof (struct Task, tc_IDNestCnt));
86 DEFINE(tc_ETask , offsetof (struct Task, tc_UnionETask.tc_ETask));
88 asm volatile("\n.asciz \"/* struct ETask */\"" ::);
89 DEFINE(et_TaskStorage, offsetof (struct ETask, et_TaskStorage));
91 asm volatile("\n.asciz \"/* struct Process */\"" ::);
92 DEFINE(pr_CES , offsetof (struct Process, pr_CES));
93 DEFINE(pr_CIS , offsetof (struct Process, pr_CIS));
94 DEFINE(pr_CLI , offsetof (struct Process, pr_CLI));
95 DEFINE(pr_COS , offsetof (struct Process, pr_COS));
96 DEFINE(pr_CurrentDir , offsetof (struct Process, pr_CurrentDir));
97 DEFINE(pr_ConsoleTask, offsetof (struct Process, pr_ConsoleTask));
98 DEFINE(pr_FileSystemTask, offsetof (struct Process, pr_FileSystemTask));
99 DEFINE(pr_MsgPort , offsetof (struct Process, pr_MsgPort));
100 DEFINE(pr_Result2 , offsetof (struct Process, pr_Result2));
101 DEFINE(pr_ReturnAddr , offsetof (struct Process, pr_ReturnAddr));
102 DEFINE(pr_SegList , offsetof (struct Process, pr_SegList));
103 DEFINE(pr_WindowPtr , offsetof (struct Process, pr_WindowPtr));
105 asm volatile("\n.asciz \"/* struct DosBase */\"" ::);
106 DEFINE(dl_Root , offsetof (struct DosLibrary, dl_Root));
107 DEFINE(dl_TimeReq , offsetof (struct DosLibrary, dl_TimeReq));
108 DEFINE(dl_UtilityBase , offsetof (struct DosLibrary, dl_UtilityBase));
109 DEFINE(dl_IntuitionBase, offsetof (struct DosLibrary, dl_IntuitionBase));
111 asm volatile("\n.asciz \"/* struct DosPacket */\"" ::);
112 DEFINE(dp_Link , offsetof (struct DosPacket, dp_Link));
113 DEFINE(dp_Port , offsetof (struct DosPacket, dp_Port));
114 DEFINE(dp_Type , offsetof (struct DosPacket, dp_Type));
115 DEFINE(dp_Res1 , offsetof (struct DosPacket, dp_Res1));
116 DEFINE(dp_Res2 , offsetof (struct DosPacket, dp_Res2));
117 DEFINE(dp_Arg1 , offsetof (struct DosPacket, dp_Arg1));
118 DEFINE(dp_Arg2 , offsetof (struct DosPacket, dp_Arg2));
119 DEFINE(dp_Arg3 , offsetof (struct DosPacket, dp_Arg3));
120 DEFINE(dp_Arg4 , offsetof (struct DosPacket, dp_Arg4));
121 DEFINE(dp_Arg5 , offsetof (struct DosPacket, dp_Arg5));
122 DEFINE(dp_Arg6 , offsetof (struct DosPacket, dp_Arg6));
123 DEFINE(dp_Arg7 , offsetof (struct DosPacket, dp_Arg7));
125 asm volatile("\n.asciz \"/* struct FileHandle */\"" ::);
126 DEFINE(fh_Flags , offsetof (struct FileHandle, fh_Flags));
127 DEFINE(fh_Interactive, offsetof (struct FileHandle, fh_Interactive));
128 DEFINE(fh_Type , offsetof (struct FileHandle, fh_Type ));
129 DEFINE(fh_Buf , offsetof (struct FileHandle, fh_Buf ));
130 DEFINE(fh_Pos , offsetof (struct FileHandle, fh_Pos ));
131 DEFINE(fh_End , offsetof (struct FileHandle, fh_End ));
133 asm volatile("\n.asciz \"/* struct IORequest */\"" ::);
134 DEFINE(io_Message , offsetof (struct IORequest, io_Message));
135 DEFINE(io_Device , offsetof (struct IORequest, io_Device ));
136 DEFINE(io_Unit , offsetof (struct IORequest, io_Unit ));
137 DEFINE(io_Command , offsetof (struct IORequest, io_Command));
138 DEFINE(io_Flags , offsetof (struct IORequest, io_Flags ));
139 DEFINE(io_Error , offsetof (struct IORequest, io_Error ));
141 asm volatile("\n.asciz \"/* struct timerequest */\"" ::);
142 DEFINE(tr_time , offsetof (struct timerequest, tr_time ));
144 asm volatile("\n.asciz \"/* struct MsgPort */\"" ::);
145 DEFINE(mp_SigTask , offsetof (struct MsgPort, mp_SigTask));
147 asm volatile("\n.asciz \"/* struct StackSwapStruct */\"" ::);
148 DEFINE(stk_Lower , offsetof (struct StackSwapStruct, stk_Lower));
149 DEFINE(stk_Upper , offsetof (struct StackSwapStruct, stk_Upper));
150 DEFINE(stk_Pointer , offsetof (struct StackSwapStruct, stk_Pointer));
152 asm volatile("\n.asciz \"/* struct Layer */\"" ::);
153 DEFINE(ly_Lock , offsetof (struct Layer, Lock));
155 asm volatile("\n.asciz \"/* Task Flags */\"" ::);
156 DEFINE(TS_RUN , TS_RUN);
157 DEFINE(TS_READY , TS_READY);
158 DEFINE(TF_STACKCHK , TF_STACKCHK);
159 DEFINE(TF_EXCEPT , TF_EXCEPT);
160 DEFINE(TF_SWITCH , TF_SWITCH);
161 DEFINE(TF_LAUNCH , TF_LAUNCH);
163 asm volatile("\n.asciz \"/* Exec Flags */\"" ::);
164 DEFINE(AFF_FPU , AFF_FPU);
166 asm volatile("\n.asciz \"/* Exec functions */\"" ::);
167 DEFINE(Supervisor , FuncOffset (5));
168 DEFINE(Reschedule , FuncOffset (8));
169 DEFINE(Switch , FuncOffset (9));
170 DEFINE(Dispatch , FuncOffset (10));
171 DEFINE(Exception , FuncOffset (11));
172 DEFINE(Alert , FuncOffset (18));
173 DEFINE(Disable , FuncOffset (20));
174 DEFINE(Enable , FuncOffset (21));
175 DEFINE(Enqueue , FuncOffset (45));
176 DEFINE(FindTask , FuncOffset (49));
177 DEFINE(ObtainSemaphore, FuncOffset (94));
178 DEFINE(ReleaseSemaphore, FuncOffset (95));
179 DEFINE(AttemptSemaphore, FuncOffset (96));
180 DEFINE(StackSwap , FuncOffset (122));
182 asm volatile("\n.asciz \"/* Constants */\"" ::);
183 DEFINE(AT_DeadEnd , AT_DeadEnd);
184 DEFINE(AN_StackProbe , AN_StackProbe);
186 DEFINE(ln_Succ , offsetof (struct Node, ln_Succ));
187 DEFINE(ln_Pred , offsetof (struct Node, ln_Pred));
188 DEFINE(ln_Pri , offsetof (struct Node, ln_Pri));
189 DEFINE(ln_Name , offsetof (struct Node, ln_Name));
191 DEFINE(lh_Head , offsetof (struct List, lh_Head));
192 DEFINE(lh_TailPred , offsetof (struct List, lh_TailPred));
194 asm volatile("\n.asciz \"/* CPU context */\"" ::);
195 #ifdef __x86_64__
196 DEFINE(ECF_SEGMENTS, ECF_SEGMENTS);
198 DEFINE(Flags , offsetof(struct ExceptionContext, Flags));
199 DEFINE(reg_ds, offsetof(struct ExceptionContext, ds));
200 DEFINE(reg_es, offsetof(struct ExceptionContext, es));
201 DEFINE(reg_fs, offsetof(struct ExceptionContext, fs));
202 DEFINE(reg_gs, offsetof(struct ExceptionContext, gs));
203 #endif
204 #ifdef __i386__
205 DEFINE(ECF_SEGMENTS, ECF_SEGMENTS);
207 DEFINE(Flags , offsetof(struct ExceptionContext, Flags));
208 DEFINE(reg_ds, offsetof(struct ExceptionContext, ds));
209 DEFINE(reg_es, offsetof(struct ExceptionContext, es));
210 DEFINE(reg_fs, offsetof(struct ExceptionContext, fs));
211 DEFINE(reg_gs, offsetof(struct ExceptionContext, gs));
212 #endif
213 #ifdef __mc68000
214 DEFINE(eb_KernelBase, offsetof(struct IntExecBase, KernelBase));
215 DEFINE(kb_PlatformData, offsetof(struct KernelBase, kb_PlatformData));
216 DEFINE(MMU_Level_A, offsetof(struct PlatformData, MMU_Level_A));
217 DEFINE(zeropagedescriptor, offsetof(struct PlatformData, zeropagedescriptor));
218 DEFINE(cachemodestore, offsetof(struct PlatformData, cachemodestore));
219 #endif
221 #ifdef UseExecstubs
222 asm volatile("\n.asciz \"#define UseExecstubs 1\"" ::);
223 #endif
225 asm volatile("\n.asciz \"/* jmp_buf */\"" ::);
226 DEFINE(jmpbuf_SIZEOF, sizeof(jmp_buf));
227 DEFINE(retaddr, offsetof(struct __jmp_buf, retaddr));
229 return 0;