1/* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23#if defined(__i386__) || defined(__x86_64__) 24 25#include <IOKit/system.h> 26 27#include <IOKit/pci/IOPCIBridge.h> 28#include <IOKit/pci/IOPCIDevice.h> 29#include <IOKit/IOLib.h> 30#include <IOKit/assert.h> 31#include <libkern/c++/OSContainers.h> 32 33#include <architecture/i386/pio.h> 34 35/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 36 37UInt32 IOPCIDevice::ioRead32( UInt16 offset, IOMemoryMap * map ) 38{ 39 UInt32 value; 40 41 if (0 == map) 42 map = ioMap; 43 44 /* 45 * getPhysicalAddress() can block on a mutex. Since I/O memory 46 * ranges behaves identity mapped, switch to getVirtualAddress(). 47 */ 48 value = inl( map->getVirtualAddress() + offset ); 49 50 return (value); 51} 52 53UInt16 IOPCIDevice::ioRead16( UInt16 offset, IOMemoryMap * map ) 54{ 55 UInt16 value; 56 57 if (0 == map) 58 map = ioMap; 59 60 value = inw( map->getVirtualAddress() + offset ); 61 62 return (value); 63} 64 65UInt8 IOPCIDevice::ioRead8( UInt16 offset, IOMemoryMap * map ) 66{ 67 UInt32 value; 68 69 if (0 == map) 70 map = ioMap; 71 72 value = inb( map->getVirtualAddress() + offset ); 73 74 return (value); 75} 76 77void IOPCIDevice::ioWrite32( UInt16 offset, UInt32 value, 78 IOMemoryMap * map ) 79{ 80 if (0 == map) 81 map = ioMap; 82 83 outl( map->getVirtualAddress() + offset, value ); 84} 85 86void IOPCIDevice::ioWrite16( UInt16 offset, UInt16 value, 87 IOMemoryMap * map ) 88{ 89 if (0 == map) 90 map = ioMap; 91 92 outw( map->getVirtualAddress() + offset, value ); 93} 94 95void IOPCIDevice::ioWrite8( UInt16 offset, UInt8 value, 96 IOMemoryMap * map ) 97{ 98 if (0 == map) 99 map = ioMap; 100 101 outb( map->getVirtualAddress() + offset, value ); 102} 103 104 105#endif // __i386__ 106