vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / drivers / graphics / intel_extreme / driver.h
blob66cebef1a9f343e76f212757c901a27d21c32461
1 /*
2 * Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
8 #ifndef DRIVER_H
9 #define DRIVER_H
12 #include <KernelExport.h>
13 #include <PCI.h>
15 #include <kernel/lock.h>
17 #include "intel_extreme_private.h"
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;
28 static inline uint32
29 get_pci_config(pci_info* info, uint8 offset, uint8 size)
31 return gPCI->read_pci_config(info->bus, info->device, info->function,
32 offset, size);
36 static inline void
37 set_pci_config(pci_info* info, uint8 offset, uint8 size, uint32 value)
39 gPCI->write_pci_config(info->bus, info->device, info->function, offset,
40 size, value);
44 static inline uint16
45 read16(intel_info &info, uint32 encodedRegister)
47 return *(volatile uint16*)(info.registers
48 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
49 + REGISTER_REGISTER(encodedRegister));
53 static inline uint32
54 read32(intel_info &info, uint32 encodedRegister)
56 return *(volatile uint32*)(info.registers
57 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
58 + REGISTER_REGISTER(encodedRegister));
62 static inline void
63 write16(intel_info &info, uint32 encodedRegister, uint16 value)
65 *(volatile uint16*)(info.registers
66 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
67 + REGISTER_REGISTER(encodedRegister)) = value;
71 static inline void
72 write32(intel_info &info, uint32 encodedRegister, uint32 value)
74 *(volatile uint32*)(info.registers
75 + info.shared_info->register_blocks[REGISTER_BLOCK(encodedRegister)]
76 + REGISTER_REGISTER(encodedRegister)) = value;
79 #endif /* DRIVER_H */