Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * Copyright 1992 by Rich Murphey <Rich@Rice.edu> | |
3 | * Copyright 1993 by David Wexelblat <dwex@goblin.org> | |
4 | * | |
5 | * Permission to use, copy, modify, distribute, and sell this software and its | |
6 | * documentation for any purpose is hereby granted without fee, provided that | |
7 | * the above copyright notice appear in all copies and that both that | |
8 | * copyright notice and this permission notice appear in supporting | |
9 | * documentation, and that the names of Rich Murphey and David Wexelblat | |
10 | * not be used in advertising or publicity pertaining to distribution of | |
11 | * the software without specific, written prior permission. Rich Murphey and | |
12 | * David Wexelblat make no representations about the suitability of this | |
13 | * software for any purpose. It is provided "as is" without express or | |
14 | * implied warranty. | |
15 | * | |
16 | * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO | |
17 | * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
18 | * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR | |
19 | * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | |
20 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF | |
21 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
22 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
23 | * | |
24 | */ | |
25 | ||
26 | /* | |
27 | * The ARM32 code here carries the following copyright: | |
28 | * | |
29 | * Copyright 1997 | |
30 | * Digital Equipment Corporation. All rights reserved. | |
31 | * This software is furnished under license and may be used and copied only in | |
32 | * accordance with the following terms and conditions. Subject to these | |
33 | * conditions, you may download, copy, install, use, modify and distribute | |
34 | * this software in source and/or binary form. No title or ownership is | |
35 | * transferred hereby. | |
36 | * | |
37 | * 1) Any source code used, modified or distributed must reproduce and retain | |
38 | * this copyright notice and list of conditions as they appear in the | |
39 | * source file. | |
40 | * | |
41 | * 2) No right is granted to use any trade name, trademark, or logo of Digital | |
42 | * Equipment Corporation. Neither the "Digital Equipment Corporation" | |
43 | * name nor any trademark or logo of Digital Equipment Corporation may be | |
44 | * used to endorse or promote products derived from this software without | |
45 | * the prior written permission of Digital Equipment Corporation. | |
46 | * | |
47 | * 3) This software is provided "AS-IS" and any express or implied warranties, | |
48 | * including but not limited to, any implied warranties of merchantability, | |
49 | * fitness for a particular purpose, or non-infringement are disclaimed. | |
50 | * In no event shall DIGITAL be liable for any damages whatsoever, and in | |
51 | * particular, DIGITAL shall not be liable for special, indirect, | |
52 | * consequential, or incidental damages or damages for lost profits, loss | |
53 | * of revenue or loss of use, whether such damages arise in contract, | |
54 | * negligence, tort, under statute, in equity, at law or otherwise, even | |
55 | * if advised of the possibility of such damage. | |
56 | * | |
57 | */ | |
58 | ||
59 | #ifdef HAVE_XORG_CONFIG_H | |
60 | #include <xorg-config.h> | |
61 | #endif | |
62 | ||
63 | #include <X11/X.h> | |
64 | #include "xf86.h" | |
65 | #include "xf86Priv.h" | |
66 | #include "xf86_OSlib.h" | |
67 | #include "xf86OSpriv.h" | |
68 | ||
69 | #ifdef __arm32__ | |
70 | #include "machine/devmap.h" | |
71 | struct memAccess { | |
72 | int ioctl; | |
73 | struct map_info memInfo; | |
74 | pointer regionVirtBase; | |
75 | Bool Checked; | |
76 | Bool OK; | |
77 | }; | |
78 | ||
79 | static pointer xf86MapInfoMap(); | |
80 | static void xf86MapInfoUnmap(); | |
81 | static struct memAccess *checkMapInfo(); | |
82 | extern int vgaPhysLinearBase; | |
83 | ||
84 | /* A memAccess structure is needed for each possible region */ | |
85 | struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, | |
86 | FALSE, FALSE | |
87 | }; | |
88 | ||
89 | struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, | |
90 | FALSE, FALSE | |
91 | }; | |
92 | ||
93 | struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, | |
94 | FALSE, FALSE | |
95 | }; | |
96 | #endif /* __arm32__ */ | |
97 | ||
98 | #if defined(__NetBSD__) && !defined(MAP_FILE) | |
99 | #define MAP_FLAGS MAP_SHARED | |
100 | #else | |
101 | #define MAP_FLAGS (MAP_FILE | MAP_SHARED) | |
102 | #endif | |
103 | ||
104 | #define BUS_BASE 0L | |
105 | #define BUS_BASE_BWX 0L | |
106 | ||
107 | /***************************************************************************/ | |
108 | /* Video Memory Mapping section */ | |
109 | /***************************************************************************/ | |
110 | ||
111 | static Bool useDevMem = FALSE; | |
112 | static int devMemFd = -1; | |
113 | ||
114 | static pointer mapVidMem(int, unsigned long, unsigned long, int); | |
115 | static void unmapVidMem(int, pointer, unsigned long); | |
116 | ||
117 | /* | |
118 | * Check if /dev/mem can be mmap'd. If it can't print a warning when | |
119 | * "warn" is TRUE. | |
120 | */ | |
121 | static void | |
122 | checkDevMem(Bool warn) | |
123 | { | |
124 | static Bool devMemChecked = FALSE; | |
125 | int fd; | |
126 | pointer base; | |
127 | ||
128 | if (devMemChecked) | |
129 | return; | |
130 | devMemChecked = TRUE; | |
131 | ||
132 | if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { | |
133 | /* Try to map a page at the VGA address */ | |
134 | base = mmap((caddr_t) 0, 4096, PROT_READ | PROT_WRITE, | |
135 | MAP_FLAGS, fd, (off_t) 0xA0000 + BUS_BASE); | |
136 | ||
137 | if (base != MAP_FAILED) { | |
138 | munmap((caddr_t) base, 4096); | |
139 | devMemFd = fd; | |
140 | useDevMem = TRUE; | |
141 | return; | |
142 | } | |
143 | else { | |
144 | /* This should not happen */ | |
145 | if (warn) { | |
146 | xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", | |
147 | DEV_MEM, strerror(errno)); | |
148 | } | |
149 | useDevMem = FALSE; | |
150 | return; | |
151 | } | |
152 | } | |
153 | if (warn) { | |
154 | xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", | |
155 | DEV_MEM, strerror(errno)); | |
156 | } | |
157 | useDevMem = FALSE; | |
158 | return; | |
159 | } | |
160 | ||
161 | void | |
162 | xf86OSInitVidMem(VidMemInfoPtr pVidMem) | |
163 | { | |
164 | ||
165 | checkDevMem(TRUE); | |
166 | pVidMem->linearSupported = useDevMem; | |
167 | pVidMem->mapMem = armMapVidMem; | |
168 | pVidMem->unmapVidMem = armUnmapVidMem; | |
169 | ||
170 | pVidMem->initialised = TRUE; | |
171 | } | |
172 | ||
173 | static pointer | |
174 | mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) | |
175 | { | |
176 | pointer base; | |
177 | ||
178 | checkDevMem(FALSE); | |
179 | ||
180 | if (useDevMem) { | |
181 | if (devMemFd < 0) { | |
182 | FatalError("xf86MapVidMem: failed to open %s (%s)\n", | |
183 | DEV_MEM, strerror(errno)); | |
184 | } | |
185 | base = mmap((caddr_t) 0, Size, | |
186 | (flags & VIDMEM_READONLY) ? | |
187 | PROT_READ : (PROT_READ | PROT_WRITE), | |
188 | MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX); | |
189 | if (base == MAP_FAILED) { | |
190 | FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", | |
191 | "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno)); | |
192 | } | |
193 | return base; | |
194 | } | |
195 | ||
196 | /* else, mmap /dev/vga */ | |
197 | if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) { | |
198 | FatalError("%s: Address 0x%x outside allowable range\n", | |
199 | "xf86MapVidMem", Base); | |
200 | } | |
201 | base = mmap(0, Size, | |
202 | (flags & VIDMEM_READONLY) ? | |
203 | PROT_READ : (PROT_READ | PROT_WRITE), | |
204 | MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000); | |
205 | if (base == MAP_FAILED) { | |
206 | FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", | |
207 | strerror(errno)); | |
208 | } | |
209 | return base; | |
210 | } | |
211 | ||
212 | static void | |
213 | unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) | |
214 | { | |
215 | munmap((caddr_t) Base, Size); | |
216 | } | |
217 | ||
218 | /* | |
219 | * Read BIOS via mmap()ing DEV_MEM | |
220 | */ | |
221 | ||
222 | int | |
223 | xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, | |
224 | int Len) | |
225 | { | |
226 | unsigned char *ptr; | |
227 | int psize; | |
228 | int mlen; | |
229 | ||
230 | checkDevMem(TRUE); | |
231 | if (devMemFd == -1) { | |
232 | return -1; | |
233 | } | |
234 | ||
235 | psize = getpagesize(); | |
236 | Offset += Base & (psize - 1); | |
237 | Base &= ~(psize - 1); | |
238 | mlen = (Offset + Len + psize - 1) & ~(psize - 1); | |
239 | ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ, | |
240 | MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE); | |
241 | if ((long) ptr == -1) { | |
242 | xf86Msg(X_WARNING, | |
243 | "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", | |
244 | DEV_MEM, Len, Base, Offset, strerror(errno)); | |
245 | return -1; | |
246 | } | |
247 | #ifdef DEBUG | |
248 | ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", | |
249 | Base, ptr[0] | (ptr[1] << 8)); | |
250 | #endif | |
251 | (void) memcpy(Buf, (void *) (ptr + Offset), Len); | |
252 | (void) munmap((caddr_t) ptr, mlen); | |
253 | #ifdef DEBUG | |
254 | xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" | |
255 | "-> %02x %02x %02x %02x...\n", | |
256 | Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); | |
257 | #endif | |
258 | return Len; | |
259 | } | |
260 | ||
261 | /* XXX This needs to be updated for the ND */ | |
262 | ||
263 | /* | |
264 | ** Find out whether the console driver provides memory mapping information | |
265 | ** for the specified region and return the map_info pointer. Print a warning if required. | |
266 | */ | |
267 | static struct memAccess * | |
268 | checkMapInfo(Bool warn, int Region) | |
269 | { | |
270 | struct memAccess *memAccP; | |
271 | ||
272 | switch (Region) { | |
273 | case VGA_REGION: | |
274 | memAccP = &vgaMemInfo; | |
275 | break; | |
276 | ||
277 | case LINEAR_REGION: | |
278 | memAccP = &linearMemInfo; | |
279 | break; | |
280 | ||
281 | case MMIO_REGION: | |
282 | memAccP = &ioMemInfo; | |
283 | break; | |
284 | ||
285 | default: | |
286 | return NULL; | |
287 | break; | |
288 | } | |
289 | ||
290 | if (!memAccP->Checked) { | |
291 | if (ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) == | |
292 | -1) { | |
293 | if (warn) { | |
294 | xf86Msg(X_WARNING, | |
295 | "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", | |
296 | Region, strerror(errno)); | |
297 | } | |
298 | } | |
299 | else { | |
300 | if (memAccP->memInfo.u.map_info_mmap.map_offset != MAP_INFO_UNKNOWN) | |
301 | memAccP->OK = TRUE; | |
302 | } | |
303 | memAccP->Checked = TRUE; | |
304 | } | |
305 | if (memAccP->OK) { | |
306 | return memAccP; | |
307 | } | |
308 | else { | |
309 | return NULL; | |
310 | } | |
311 | } | |
312 | ||
313 | static pointer | |
314 | xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) | |
315 | { | |
316 | struct map_info *mapInfoP = &(memInfoP->memInfo); | |
317 | ||
318 | if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) { | |
319 | Size = (unsigned long) Base + Size; | |
320 | } | |
321 | else { | |
322 | Size = mapInfoP->u.map_info_mmap.map_size; | |
323 | } | |
324 | ||
325 | switch (mapInfoP->method) { | |
326 | case MAP_MMAP: | |
327 | /* Need to remap if size is unknown because we may not have | |
328 | mapped the whole region initially */ | |
329 | if (memInfoP->regionVirtBase == NULL || | |
330 | mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) { | |
331 | if ((memInfoP->regionVirtBase = | |
332 | mmap((caddr_t) 0, | |
333 | Size, | |
334 | PROT_READ | PROT_WRITE, | |
335 | MAP_SHARED, | |
336 | xf86Info.consoleFd, | |
337 | (unsigned long) mapInfoP->u.map_info_mmap.map_offset)) | |
338 | == (pointer) -1) { | |
339 | FatalError | |
340 | ("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", | |
341 | mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); | |
342 | } | |
343 | if (mapInfoP->u.map_info_mmap.internal_offset > 0) | |
344 | memInfoP->regionVirtBase += | |
345 | mapInfoP->u.map_info_mmap.internal_offset; | |
346 | } | |
347 | break; | |
348 | ||
349 | default: | |
350 | FatalError("xf86MapInfoMap: Unsuported mapping method\n"); | |
351 | break; | |
352 | } | |
353 | ||
354 | return (pointer) ((int) memInfoP->regionVirtBase + (int) Base); | |
355 | } | |
356 | ||
357 | static void | |
358 | xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) | |
359 | { | |
360 | struct map_info *mapInfoP = &(memInfoP->memInfo); | |
361 | ||
362 | switch (mapInfoP->method) { | |
363 | case MAP_MMAP: | |
364 | if (memInfoP->regionVirtBase != NULL) { | |
365 | if (mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) | |
366 | Size = mapInfoP->u.map_info_mmap.map_size; | |
367 | munmap((caddr_t) memInfoP->regionVirtBase, Size); | |
368 | memInfoP->regionVirtBase = NULL; | |
369 | } | |
370 | break; | |
371 | default: | |
372 | FatalError("xf86MapInfoMap: Unsuported mapping method\n"); | |
373 | break; | |
374 | } | |
375 | } | |
376 | ||
377 | static pointer | |
378 | armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) | |
379 | { | |
380 | struct memAccess *memInfoP; | |
381 | ||
382 | if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) { | |
383 | /* | |
384 | ** xf86 passes in a physical address offset from the start | |
385 | ** of physical memory, but xf86MapInfoMap expects an | |
386 | ** offset from the start of the specified region - it gets | |
387 | ** the physical address of the region from the display driver. | |
388 | */ | |
389 | switch (Region) { | |
390 | case LINEAR_REGION: | |
391 | if (vgaPhysLinearBase) { | |
392 | Base -= vgaPhysLinearBase; | |
393 | } | |
394 | break; | |
395 | case VGA_REGION: | |
396 | Base -= 0xA0000; | |
397 | break; | |
398 | } | |
399 | ||
400 | base = xf86MapInfoMap(memInfoP, Base, Size); | |
401 | return base; | |
402 | } | |
403 | return mapVidMem(ScreenNum, Base, Size, flags); | |
404 | } | |
405 | ||
406 | static void | |
407 | armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) | |
408 | { | |
409 | struct memAccess *memInfoP; | |
410 | ||
411 | if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) { | |
412 | xf86MapInfoUnmap(memInfoP, Base, Size); | |
413 | } | |
414 | unmapVidMem(ScreenNum, Base, Size); | |
415 | } | |
416 | ||
417 | #ifdef USE_DEV_IO | |
418 | static int IoFd = -1; | |
419 | ||
420 | Bool | |
421 | xf86EnableIO() | |
422 | { | |
423 | if (IoFd >= 0) | |
424 | return TRUE; | |
425 | ||
426 | if ((IoFd = open("/dev/io", O_RDWR)) == -1) { | |
427 | xf86Msg(X_WARNING, "xf86EnableIO: " | |
428 | "Failed to open /dev/io for extended I/O\n"); | |
429 | return FALSE; | |
430 | } | |
431 | return TRUE; | |
432 | } | |
433 | ||
434 | void | |
435 | xf86DisableIO() | |
436 | { | |
437 | if (IoFd < 0) | |
438 | return; | |
439 | ||
440 | close(IoFd); | |
441 | IoFd = -1; | |
442 | return; | |
443 | } | |
444 | ||
445 | #endif | |
446 | ||
447 | #if defined(USE_ARC_MMAP) || defined(__arm32__) | |
448 | ||
449 | Bool | |
450 | xf86EnableIO() | |
451 | { | |
452 | int fd; | |
453 | pointer base; | |
454 | ||
455 | if (ExtendedEnabled) | |
456 | return TRUE; | |
457 | ||
458 | if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { | |
459 | /* Try to map a page at the pccons I/O space */ | |
460 | base = (pointer) mmap((caddr_t) 0, 65536, PROT_READ | PROT_WRITE, | |
461 | MAP_FLAGS, fd, (off_t) 0x0000); | |
462 | ||
463 | if (base != (pointer) -1) { | |
464 | IOPortBase = base; | |
465 | } | |
466 | else { | |
467 | xf86Msg(X_WARNING, "EnableIO: failed to mmap %s (%s)\n", | |
468 | "/dev/ttyC0", strerror(errno)); | |
469 | return FALSE; | |
470 | } | |
471 | } | |
472 | else { | |
473 | xf86Msg("EnableIO: failed to open %s (%s)\n", | |
474 | "/dev/ttyC0", strerror(errno)); | |
475 | return FALSE; | |
476 | } | |
477 | ||
478 | ExtendedEnabled = TRUE; | |
479 | ||
480 | return TRUE; | |
481 | } | |
482 | ||
483 | void | |
484 | xf86DisableIO() | |
485 | { | |
486 | return; | |
487 | } | |
488 | ||
489 | #endif /* USE_ARC_MMAP */ | |
490 | ||
491 | #if 0 | |
492 | /* | |
493 | * XXX This is here for reference. It needs to be handled differently for the | |
494 | * ND. | |
495 | */ | |
496 | #if defined(USE_ARC_MMAP) || defined(__arm32__) | |
497 | ||
498 | #ifdef USE_ARM32_MMAP | |
499 | #define DEV_MEM_IOBASE 0x43000000 | |
500 | #endif | |
501 | ||
502 | static Bool ScreenEnabled[MAXSCREENS]; | |
503 | static Bool ExtendedEnabled = FALSE; | |
504 | static Bool InitDone = FALSE; | |
505 | ||
506 | Bool | |
507 | xf86EnableIOPorts(ScreenNum) | |
508 | int ScreenNum; | |
509 | { | |
510 | int i; | |
511 | int fd; | |
512 | pointer base; | |
513 | ||
514 | #ifdef __arm32__ | |
515 | struct memAccess *memInfoP; | |
516 | int *Size; | |
517 | #endif | |
518 | ||
519 | ScreenEnabled[ScreenNum] = TRUE; | |
520 | ||
521 | if (ExtendedEnabled) | |
522 | return TRUE; | |
523 | ||
524 | #ifdef USE_ARC_MMAP | |
525 | if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { | |
526 | /* Try to map a page at the pccons I/O space */ | |
527 | base = (pointer) mmap((caddr_t) 0, 65536, PROT_READ | PROT_WRITE, | |
528 | MAP_FLAGS, fd, (off_t) 0x0000); | |
529 | ||
530 | if (base != (pointer) -1) { | |
531 | IOPortBase = base; | |
532 | } | |
533 | else { | |
534 | xf86Msg(X_ERROR, | |
535 | "EnableIOPorts: failed to mmap %s (%s)\n", | |
536 | "/dev/ttyC0", strerror(errno)); | |
537 | } | |
538 | } | |
539 | else { | |
540 | xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", | |
541 | "/dev/ttyC0", strerror(errno)); | |
542 | } | |
543 | #endif | |
544 | ||
545 | #ifdef __arm32__ | |
546 | IOPortBase = (unsigned int) -1; | |
547 | ||
548 | if ((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) { | |
549 | /* | |
550 | * xf86MapInfoMap maps an offset from the start of video IO | |
551 | * space (e.g. 0x3B0), but IOPortBase is expected to map to | |
552 | * physical address 0x000, so subtract the start of video I/O | |
553 | * space from the result. This is safe for now becase we | |
554 | * actually mmap the start of the page, then the start of video | |
555 | * I/O space is added as an internal offset. | |
556 | */ | |
557 | IOPortBase = (unsigned int) xf86MapInfoMap(memInfoP, (caddr_t) 0x0, 0L) | |
558 | - memInfoP->memInfo.u.map_info_mmap.internal_offset; | |
559 | ExtendedEnabled = TRUE; | |
560 | return TRUE; | |
561 | } | |
562 | #ifdef USE_ARM32_MMAP | |
563 | checkDevMem(TRUE); | |
564 | ||
565 | if (devMemFd >= 0 && useDevMem) { | |
566 | base = (pointer) mmap((caddr_t) 0, 0x400, PROT_READ | PROT_WRITE, | |
567 | MAP_FLAGS, devMemFd, (off_t) DEV_MEM_IOBASE); | |
568 | ||
569 | if (base != (pointer) -1) | |
570 | IOPortBase = (unsigned int) base; | |
571 | } | |
572 | ||
573 | if (IOPortBase == (unsigned int) -1) { | |
574 | xf86Msg(X_WARNING, | |
575 | "xf86EnableIOPorts: failed to open mem device or map IO base. \n\ | |
576 | Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); | |
577 | return FALSE; | |
578 | } | |
579 | #else | |
580 | /* We don't have the IOBASE, so we can't map the address */ | |
581 | xf86Msg(X_WARNING, | |
582 | "xf86EnableIOPorts: failed to open mem device or map IO base. \n\ | |
583 | Try building the server with USE_ARM32_MMAP defined\n"); | |
584 | return FALSE; | |
585 | #endif | |
586 | #endif | |
587 | ||
588 | ExtendedEnabled = TRUE; | |
589 | ||
590 | return TRUE; | |
591 | } | |
592 | ||
593 | void | |
594 | xf86DisableIOPorts(ScreenNum) | |
595 | int ScreenNum; | |
596 | { | |
597 | int i; | |
598 | ||
599 | #ifdef __arm32__ | |
600 | struct memAccess *memInfoP; | |
601 | #endif | |
602 | ||
603 | ScreenEnabled[ScreenNum] = FALSE; | |
604 | ||
605 | #ifdef __arm32__ | |
606 | if ((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) { | |
607 | xf86MapInfoUnmap(memInfoP, 0); | |
608 | } | |
609 | #endif | |
610 | ||
611 | #ifdef USE_ARM32_MMAP | |
612 | if (!ExtendedEnabled) | |
613 | return; | |
614 | ||
615 | for (i = 0; i < MAXSCREENS; i++) | |
616 | if (ScreenEnabled[i]) | |
617 | return; | |
618 | ||
619 | munmap((caddr_t) IOPortBase, 0x400); | |
620 | IOPortBase = (unsigned int) -1; | |
621 | ExtendedEnabled = FALSE; | |
622 | #endif | |
623 | ||
624 | return; | |
625 | } | |
626 | ||
627 | #endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ | |
628 | #endif |