First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / hurd / hurd_video.c
blob8e6ae8d3635fd862e1d10fd2d6f62598127b2633
1 /*
2 * Copyright 1997, 1998 by UCHIYAMA Yasushi
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of UCHIYAMA Yasushi not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. UCHIYAMA Yasushi makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
14 * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
24 #ifdef HAVE_XORG_CONFIG_H
25 #include <xorg-config.h>
26 #endif
28 #include <mach.h>
29 #include <device/device.h>
30 #include <mach/machine/mach_i386.h>
32 #include <X11/X.h>
33 #include "input.h"
34 #include "scrnintstr.h"
36 #include "xf86.h"
37 #include "xf86Priv.h"
38 #include "xf86_OSlib.h"
39 #include "xf86OSpriv.h"
41 /**************************************************************************
42 * Video Memory Mapping section
43 ***************************************************************************/
44 pointer
45 xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size)
47 mach_port_t device,iopl_dev;
48 memory_object_t iopl_mem;
49 kern_return_t err;
50 vm_address_t addr=(vm_address_t)0;
52 err = get_privileged_ports (NULL, &device);
53 if( err )
55 errno = err;
56 FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno));
58 err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev);
59 mach_port_deallocate (mach_task_self(), device);
60 if( err )
62 errno = err;
63 FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno));
66 err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&iopl_mem,0);
67 if( err )
69 errno = err;
70 FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno));
72 err = vm_map(mach_task_self(),
73 &addr,
74 Size,
75 0, /* mask */
76 TRUE, /* anywhere */
77 iopl_mem,
78 (vm_offset_t)Base,
79 FALSE, /* copy on write */
80 VM_PROT_READ|VM_PROT_WRITE,
81 VM_PROT_READ|VM_PROT_WRITE,
82 VM_INHERIT_SHARE);
83 mach_port_deallocate(mach_task_self(),iopl_mem);
84 if( err )
86 errno = err;
87 FatalError("xf86MapVidMem() can't vm_map.(iopl_mem) (%s)\n",strerror(errno));
89 mach_port_deallocate(mach_task_self(),iopl_dev);
90 if( err )
92 errno = err;
93 FatalError("xf86MapVidMem() can't mach_port_deallocate.(iopl_dev) (%s)\n",strerror(errno));
95 return (pointer)addr;
98 void
99 xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size)
101 kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size);
102 if( err )
104 errno = err;
105 ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno));
107 return;
110 Bool
111 xf86LinearVidMem()
113 return(TRUE);
116 /**************************************************************************
117 * I/O Permissions section
118 ***************************************************************************/
121 * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
122 * this.
124 extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on);
126 Bool
127 xf86EnableIO()
129 if (ioperm(0, 0xffff, 1)) {
130 FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno));
131 return FALSE;
133 ioperm(0x40,4,0); /* trap access to the timer chip */
134 ioperm(0x60,4,0); /* trap access to the keyboard controller */
135 return TRUE;
138 void
139 xf86DisableIO()
141 ioperm(0,0xffff,0);
142 return;
145 /**************************************************************************
146 * Interrupt Handling section
147 **************************************************************************/
148 Bool
149 xf86DisableInterrupts()
151 return TRUE;
153 void
154 xf86EnableInterrupts()
156 return;
159 void
160 xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
161 unsigned long Size)
165 Bool
166 xf86CheckMTRR(int s)
168 return FALSE;