summaryrefslogtreecommitdiff
path: root/hw/xfree86/os-support/linux/lnxResource.c
blob: bd038351f4e3d171ce1f36dbb761cfd59430898c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.19 2004/02/04 16:30:50 tsi Exp $ */

/* Resource information code */

#include "X.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Privstr.h"
#include "xf86Pci.h"
#include "xf86Resources.h"
#define NEED_OS_RAC_PROTOS
#include "xf86_OSlib.h"
#include "lnx.h"

/* Avoid Imakefile changes */
#include "bus/Pci.h"

resRange PciAvoid[] =
{
#if !defined(__sparc__) || !defined(INCLUDE_XF86_NO_DOMAIN)
    _PCI_AVOID_PC_STYLE,
#endif
    _END
};

#ifdef INCLUDE_XF86_NO_DOMAIN

#ifdef __alpha__

resPtr
xf86BusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;

    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

resPtr
xf86PciBusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;
    /*
     * On the Alpha the first 16MB of every 128 Mb segment in
     * sparse address space are an image of the ISA bus range
     */
    if (_bus_base_sparse()) {
	RANGE(range, 0x00000000, 0x07ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x09000000, 0x0fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x11000000, 0x17ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x19000000, 0x1fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x21000000, 0x27ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x29000000, 0x2fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x31000000, 0x37ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x39000000, 0x3fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x41000000, 0x47ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x49000000, 0x4fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x51000000, 0x57ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x59000000, 0x5fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x61000000, 0x67ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x69000000, 0x6fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x71000000, 0x77ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x79000000, 0x7fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x81000000, 0x87ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x89000000, 0x8fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x91000000, 0x97ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0x99000000, 0x9fffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xa1000000, 0xa7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xa9000000, 0xafffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xb1000000, 0xb7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xb9000000, 0xbfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xc1000000, 0xc7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xc9000000, 0xcfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xd1000000, 0xd7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xd9000000, 0xdfffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xe1000000, 0xe7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xe9000000, 0xefffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xf1000000, 0xf7ffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
	RANGE(range, 0xf9000000, 0xffffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
    } else {
	RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
	ret = xf86AddResToList(ret, &range, -1);
    }
    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

#ifdef INCLUDE_UNUSED

resPtr
xf86IsaBusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;

    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

#endif /* INCLUDE_UNUSED */

resPtr
xf86AccResFromOS(resPtr ret)
{
    resRange range;

    /*
     * Fallback is to claim the following areas:
     *
     * 0x000c0000 - 0x000effff  location of VGA and other extensions ROMS
     */

    RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

    /*
     * Fallback would be to claim well known ports in the 0x0 - 0x3ff range
     * along with their sparse I/O aliases, but that's too imprecise.  Instead
     * claim a bare minimum here.
     */
    RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */
    ret = xf86AddResToList(ret, &range, -1);

    /*
     * At minimum, the top and bottom resources must be claimed, so that
     * resources that are (or appear to be) unallocated can be relocated.
     */
    RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);
    RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);
/*  RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1); */
    RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);

    /* XXX add others */
    return ret;
}

#elif defined(__powerpc__) || \
      defined(__sparc__) || \
      defined(__mips__) || \
      defined(__sh__) || \
      defined(__mc68000__) || \
      defined(__arm__) || \
      defined(__s390__) || \
      defined(__hppa__)

 /*
  * XXX this isn't exactly correct but it will get the server working 
  * for now until we get something better.
  */
  
resPtr
xf86BusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;

    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

#if defined(__sparc__) || defined(__powerpc__)
    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
#else
    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
#endif
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

resPtr
xf86PciBusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;

    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

#if defined(__sparc__) || defined(__powerpc__)
    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
#else
    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
#endif
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

#ifdef INCLUDE_UNUSED

resPtr
xf86IsaBusAccWindowsFromOS(void)
{
    resPtr ret = NULL;
    resRange range;

    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);

#if defined(__sparc__) || defined(__powerpc__)
    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
#else
    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
#endif
    ret = xf86AddResToList(ret, &range, -1);
    return ret;
}

#endif /* INCLUDE_UNUSED */

resPtr
xf86AccResFromOS(resPtr ret)
{
    resRange range;

    /*
     * At minimum, the top and bottom resources must be claimed, so that
     * resources that are (or appear to be) unallocated can be relocated.
     */
    RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);
    RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock);
    ret = xf86AddResToList(ret, &range, -1);
    RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock);
    ret = xf86AddResToList(ret, &range, -1);
#if defined(__sparc__) || defined(__powerpc__)
    RANGE(range, 0x00ffffff, 0x00ffffff, ResExcIoBlock);
#else
    RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock);
#endif
    ret = xf86AddResToList(ret, &range, -1);

    return ret;
}

#else

#error : Put your platform dependent code here!!

#endif

#endif /* INCLUDE_XF86_NO_DOMAIN */