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