/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_GNUmach.c,v 1.1.2.1 1998/12/22 12:20:11 hohndel Exp $ */ /* * (c) Copyright 1993,1994 by Robert V. Baron * * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * ROBERT V. BARON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Robert V. Baron shall not be * used in advertising or otherwise to promote the sale, use or other dealings * in this Software without prior written authorization from Robert V. Baron. * */ /* $XConsortium: OS_Mach.c /main/5 1996/02/21 17:11:12 kaleb $ */ /* GNU/Hurd port by UCHIYAMA Yasushi */ #define _GNU_SOURCE #define MACH3 #include #include #include "Probe.h" #include #include #include /* These can be Mach 2.5 or 3.0 headers */ #include #include #include static device_t device_master = MACH_PORT_NULL; static int iopl_dev = MACH_PORT_NULL; static memory_object_t iopl_mem = MACH_PORT_NULL; static vm_address_t mapped_address; /* * OpenVideo -- * * Enable access to the installed video hardware. For Mach, we disable * IO protection, since this is currently the only way to access any * IO registers. */ int screen_addr; int OpenVideo() { int ret; #define C /*Bios_Base*/ 0xc0000 #define S 0x40000 if(KERN_SUCCESS != get_privileged_ports(0,&device_master)){ fprintf(stderr,"Failed get_privileged_ports\n"); return -1; } if (KERN_SUCCESS != device_open(device_master,D_READ|D_WRITE,"iopl",&iopl_dev)){ fprintf(stderr, "Failed to device_open iopl\n"); return -1; } if(KERN_SUCCESS != device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, C , S ,&iopl_mem,0)){ fprintf(stderr, "Failed to device_map\n"); return -1; } if(KERN_SUCCESS != vm_map(mach_task_self(), &mapped_address,S, 0,1,iopl_mem,C,0,VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE,VM_INHERIT_NONE)){ fprintf(stderr,"Failed to vm_map\n"); return -1; } screen_addr = (int)mapped_address; return TRUE; } /* * CloseVideo -- * * Disable access to the video hardware. For Mach, we re-enable * IO protection. */ void CloseVideo() { if (KERN_SUCCESS != vm_deallocate(mach_task_self(), screen_addr, S)) { fprintf(stderr, "Failed vmdeallocate %x\n", S); } } /* * MapVGA -- * * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for * the process for use in probing memory. */ Byte *MapVGA() { return((Byte *)0); } Byte *MapMem(address,size) unsigned long address; unsigned long size; { return((Byte *)0); } /* * UnMapVGA -- * * Unmap the VGA memory window. */ void UnMapVGA(base) Byte *base; { return; } void UnMapMem(base,size) Byte *base; unsigned long size; { return; } /* * ReadBIOS -- * * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into * buffer 'Buffer'. */ int ReadBIOS(Offset, Buffer, Len) unsigned Offset; Byte *Buffer; int Len; { Word tmp; Byte *Base; Base = (Byte *)(screen_addr + Bios_Base + Offset - C); #ifdef DEBUG {int i; fprintf(stderr, "ReadBIOS(Offset %x, Buffer %x, Len %x) .. ", Offset, Buffer, Len); for (i=0;i