1 /* 2 * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler, axeld@pinc-software.de 7 */ 8 #ifndef DRIVER_H 9 #define DRIVER_H 10 11 12 #include <KernelExport.h> 13 #include <PCI.h> 14 15 #include <kernel/lock.h> 16 17 #include "intel_extreme_private.h" 18 19 20 extern char* gDeviceNames[]; 21 extern intel_info* gDeviceInfo[]; 22 extern pci_module_info* gPCI; 23 extern pci_x86_module_info* gPCIx86Module; 24 extern agp_gart_module_info* gGART; 25 extern mutex gLock; 26 27 28 static inline uint32 29 get_pci_config(pci_info* info, uint8 offset, uint8 size) 30 { 31 return gPCI->read_pci_config(info->bus, info->device, info->function, 32 offset, size); 33 } 34 35 36 static inline void 37 set_pci_config(pci_info* info, uint8 offset, uint8 size, uint32 value) 38 { 39 gPCI->write_pci_config(info->bus, info->device, info->function, offset, 40 size, value); 41 } 42 43 44 static inline uint16 45 read16(intel_info &info, uint32 encodedRegister) 46 { 47 return *(volatile uint16*)(info.registers 48 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)] 49 + REGISTER_REGISTER(encodedRegister)); 50 } 51 52 53 static inline uint32 54 read32(intel_info &info, uint32 encodedRegister) 55 { 56 return *(volatile uint32*)(info.registers 57 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)] 58 + REGISTER_REGISTER(encodedRegister)); 59 } 60 61 62 static inline void 63 write16(intel_info &info, uint32 encodedRegister, uint16 value) 64 { 65 *(volatile uint16*)(info.registers 66 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)] 67 + REGISTER_REGISTER(encodedRegister)) = value; 68 } 69 70 71 static inline void 72 write32(intel_info &info, uint32 encodedRegister, uint32 value) 73 { 74 *(volatile uint32*)(info.registers 75 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)] 76 + REGISTER_REGISTER(encodedRegister)) = value; 77 } 78 79 #endif /* DRIVER_H */ 80