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>
29 #include <device/device.h>
30 #include <mach/machine/mach_i386.h>
34 #include "scrnintstr.h"
38 #include "xf86_OSlib.h"
39 #include "xf86OSpriv.h"
41 /**************************************************************************
42 * Video Memory Mapping section
43 ***************************************************************************/
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
;
50 vm_address_t addr
=(vm_address_t
)0;
52 err
= get_privileged_ports (NULL
, &device
);
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
);
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);
70 FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno
));
72 err
= vm_map(mach_task_self(),
79 FALSE
, /* copy on write */
80 VM_PROT_READ
|VM_PROT_WRITE
,
81 VM_PROT_READ
|VM_PROT_WRITE
,
83 mach_port_deallocate(mach_task_self(),iopl_mem
);
87 FatalError("xf86MapVidMem() can't vm_map.(iopl_mem) (%s)\n",strerror(errno
));
89 mach_port_deallocate(mach_task_self(),iopl_dev
);
93 FatalError("xf86MapVidMem() can't mach_port_deallocate.(iopl_dev) (%s)\n",strerror(errno
));
99 xf86UnMapVidMem(int ScreenNum
,pointer Base
,unsigned long Size
)
101 kern_return_t err
= vm_deallocate(mach_task_self(), (int)Base
, Size
);
105 ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno
));
116 /**************************************************************************
117 * I/O Permissions section
118 ***************************************************************************/
121 * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
124 extern int ioperm(unsigned long __from
, unsigned long __num
, int __turn_on
);
129 if (ioperm(0, 0xffff, 1)) {
130 FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno
));
133 ioperm(0x40,4,0); /* trap access to the timer chip */
134 ioperm(0x60,4,0); /* trap access to the keyboard controller */
145 /**************************************************************************
146 * Interrupt Handling section
147 **************************************************************************/
149 xf86DisableInterrupts()
154 xf86EnableInterrupts()
160 xf86MapReadSideEffects(int ScreenNum
, int Flags
, pointer Base
,