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 30#include <IOKit/IOLib.h> 31#include <IOKit/assert.h> 32 33#include <libkern/OSByteOrder.h> 34#include <libkern/c++/OSContainers.h> 35 36/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 37 38UInt32 IOPCIDevice::ioRead32( UInt16 offset, IOMemoryMap * map ) 39{ 40 UInt32 value; 41 42 if (0 == map) 43 { 44 map = ioMap; 45 if (0 == map) 46 return (0); 47 } 48 49 value = OSReadLittleInt32( (volatile void *)map->getVirtualAddress(), offset); 50 OSSynchronizeIO(); 51 52 return (value); 53} 54 55UInt16 IOPCIDevice::ioRead16( UInt16 offset, IOMemoryMap * map ) 56{ 57 UInt16 value; 58 59 if (0 == map) 60 { 61 map = ioMap; 62 if (0 == map) 63 return (0); 64 } 65 66 value = OSReadLittleInt16( (volatile void *)map->getVirtualAddress(), offset); 67 OSSynchronizeIO(); 68 69 return (value); 70} 71 72UInt8 IOPCIDevice::ioRead8( UInt16 offset, IOMemoryMap * map ) 73{ 74 UInt32 value; 75 76 if (0 == map) 77 { 78 map = ioMap; 79 if (0 == map) 80 return (0); 81 } 82 83 value = ((volatile UInt8 *) map->getVirtualAddress())[ offset ]; 84 OSSynchronizeIO(); 85 86 return (value); 87} 88 89void IOPCIDevice::ioWrite32( UInt16 offset, UInt32 value, 90 IOMemoryMap * map ) 91{ 92 if (0 == map) 93 { 94 map = ioMap; 95 if (0 == map) 96 return ; 97 } 98 99 OSWriteLittleInt32( (volatile void *)map->getVirtualAddress(), offset, value); 100 OSSynchronizeIO(); 101} 102 103void IOPCIDevice::ioWrite16( UInt16 offset, UInt16 value, 104 IOMemoryMap * map ) 105{ 106 if (0 == map) 107 { 108 map = ioMap; 109 if (0 == map) 110 return ; 111 } 112 113 OSWriteLittleInt16( (volatile void *)map->getVirtualAddress(), offset, value); 114 OSSynchronizeIO(); 115} 116 117void IOPCIDevice::ioWrite8( UInt16 offset, UInt8 value, 118 IOMemoryMap * map ) 119{ 120 if (0 == map) 121 { 122 map = ioMap; 123 if (0 == map) 124 return ; 125 } 126 127 ((volatile UInt8 *) map->getVirtualAddress())[ offset ] = value; 128 OSSynchronizeIO(); 129} 130 131#endif // !defined(__i386__) && !defined(__x86_64__) 132 133 134