xref: /haiku/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h (revision 445d4fd926c569e7b9ae28017da86280aaecbae2)
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 agp_gart_module_info* gGART;
24 extern mutex gLock;
25 
26 
27 static inline uint32
28 get_pci_config(pci_info* info, uint8 offset, uint8 size)
29 {
30 	return gPCI->read_pci_config(info->bus, info->device, info->function,
31 		offset, size);
32 }
33 
34 
35 static inline void
36 set_pci_config(pci_info* info, uint8 offset, uint8 size, uint32 value)
37 {
38 	gPCI->write_pci_config(info->bus, info->device, info->function, offset,
39 		size, value);
40 }
41 
42 
43 static inline uint16
44 read16(intel_info &info, uint32 encodedRegister)
45 {
46 	return *(volatile uint16*)(info.registers
47 		+ info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
48 		+ REGISTER_REGISTER(encodedRegister));
49 }
50 
51 
52 static inline uint32
53 read32(intel_info &info, uint32 encodedRegister)
54 {
55 	return *(volatile uint32*)(info.registers
56 		+ info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
57 		+ REGISTER_REGISTER(encodedRegister));
58 }
59 
60 
61 static inline void
62 write16(intel_info &info, uint32 encodedRegister, uint16 value)
63 {
64 	*(volatile uint16*)(info.registers
65 		+ info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
66 		+ REGISTER_REGISTER(encodedRegister)) = value;
67 }
68 
69 
70 static inline void
71 write32(intel_info &info, uint32 encodedRegister, uint32 value)
72 {
73 	*(volatile uint32*)(info.registers
74 		+ info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
75 		+ REGISTER_REGISTER(encodedRegister)) = value;
76 }
77 
78 #endif  /* DRIVER_H */
79