- Give PCI controllers lower unit numbers than legacy controllers.
[cake.git] / compiler / arossupport / rt.h
blobee499989d7e0eada89fabd4c23e9a2ef8916b528
1 #ifndef _RT_H
2 #define _RT_H
4 /*
5 Copyright © 1995-96, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Common header file for RT
9 Lang: english
11 #define ENABLE_RT 0 /* no RT inside this file */
12 #define RT_INTERNAL 1
13 #include <aros/rt.h>
15 #include <exec/lists.h>
16 #include <stdarg.h>
18 #include <aros/system.h>
19 #include <exec/tasks.h>
20 #include <exec/ports.h>
21 #include <exec/memory.h>
22 #include <exec/execbase.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <proto/exec.h>
26 #include <proto/dos.h>
27 #include <proto/intuition.h>
28 #include <proto/arossupport.h>
29 #include <proto/alib.h>
31 #include "etask.h"
33 #define RT_VERSION 1 /* Current version of RT */
35 #define HASH_BITS 4 /* Size of hash in bits and entries */
36 #define HASH_SIZE (1L << HASH_BITS)
38 typedef struct
40 const char * Function;
41 const char * File;
42 ULONG Line;
44 RTStack;
46 #define STACKDEPTH 256
49 /* This is what is behind etask->iet_RT */
50 typedef struct
52 ULONG rtd_Version; /* RT_VERSION */
53 struct MinList rtd_ResHash[RTT_MAX][HASH_SIZE];
54 ULONG rtd_StackPtr;
55 RTStack rtd_CallStack[STACKDEPTH];
56 } RTData;
58 extern RTData * intRT; /* Global variable in case no ETask is available */
60 typedef struct
62 struct MinNode Node;
63 const char * File;
64 ULONG Line;
65 ULONG Flags;
67 RTNode;
69 /* Private flags of resource nodes */
70 #define RTNF_DONT_FREE 0x80000000 /* Resource must not be freed */
72 typedef struct
74 RTNode Node;
75 APTR Resource; /* This should be common to every resource */
77 Resource;
79 typedef struct __RTDesc RTDesc;
81 typedef IPTR (* RT_AllocFunc) (RTData * rtd, RTNode *, va_list, BOOL * success);
82 typedef IPTR (* RT_FreeFunc) (RTData * rtd, RTNode *);
83 typedef IPTR (* RT_SearchFunc) (RTData * rtd, int, RTNode **, va_list);
84 typedef IPTR (* RT_ShowError) (RTData * rtd, int, RTNode *, IPTR, int, const char * file, ULONG line, va_list);
85 typedef IPTR (* RT_CheckFunc) (RTData * rtd, int, const char * file, ULONG line, ULONG op, va_list);
87 #define HASH_BASE(rtn) (((Resource *)rtn)->Resource)
89 #if HASH_BITS==4
90 #define CALCHASH(res) \
91 ((((ULONG)res) + (((ULONG)res)>>4) +(((ULONG)res)>>8) + (((ULONG)res)>>12) + \
92 (((ULONG)res)>>16) + (((ULONG)res)>>20) +(((ULONG)res)>>24) + (((ULONG)res)>>28)) \
93 & 0x0000000FL)
94 #endif
96 struct __RTDesc
98 const ULONG Size;
99 RT_AllocFunc AllocFunc;
100 RT_FreeFunc FreeFunc;
101 RT_SearchFunc SearchFunc;
102 RT_ShowError ShowError;
103 RT_CheckFunc CheckFunc;
106 #define GetRTData() \
107 ({ \
108 struct IntETask * et; \
110 et = (struct IntETask *)GetETask (FindTask(NULL)); \
112 et \
113 && et->iet_RT \
114 && ((RTData *)et->iet_RT)->rtd_Version == RT_VERSION \
115 ? et->iet_RT \
116 : intRTD; \
118 #define SetRTData(rtd) \
120 struct IntETask * et; \
122 et = (struct IntETask *)GetETask (FindTask(NULL)); \
124 if (et) \
125 et->iet_RT = rtd; \
126 else \
127 intRTD = rtd; \
130 /* Return values of SearchFunc */
131 #define RT_SEARCH_FOUND 0
132 #define RT_SEARCH_NOT_FOUND 1
133 #define RT_SEARCH_SIZE_MISMATCH 2
135 #define RT_FREE 0
136 #define RT_CHECK 1
137 #define RT_EXIT 2
139 extern RTDesc const * RT_Resources[RTT_MAX];
141 #define GetRTDesc(no) RT_Resources[no]
142 #define GetRTField(no,f) (GetRTDesc(no) ? GetRTDesc(no)->f : NULL)
143 #define GetRTSize(no) (GetRTDesc(no) ? GetRTDesc(no)->Size : 0)
144 #define GetRTAllocFunc(no) (GetRTField(no,AllocFunc))
145 #define GetRTFreeFunc(no) (GetRTField(no,FreeFunc))
146 #define GetRTSearchFunc(no) (GetRTField(no,SearchFunc))
147 #define GetRTShowError(no) (GetRTField(no,ShowError))
148 #define GetRTCheckFunc(no) (GetRTField(no,CheckFunc))
150 extern void RT_FreeResource (RTData * rtd, int rtt, RTNode * rtnode);
152 #define ALIGNED_PTR 0x00000001 /* Must be aligned */
153 #define NULL_PTR 0x00000002 /* May be NULL */
154 extern BOOL CheckPtr (APTR ptr, ULONG flags);
155 extern BOOL CheckArea (APTR ptr, ULONG size, ULONG flags);
157 extern IPTR RT_Search (RTData * rtd, int rtt, RTNode ** rtptr, va_list args);
159 #endif /* _RT_H */