1/*
2 * Copyright 2006-2008, 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 INTEL_EXTREME_PRIVATE_H
9#define INTEL_EXTREME_PRIVATE_H
10
11
12#include <AGP.h>
13#include <KernelExport.h>
14#include <PCI.h>
15
16#include "intel_extreme.h"
17#include "lock.h"
18
19
20struct intel_info {
21	int32			open_count;
22	status_t		init_status;
23	int32			id;
24	pci_info*		pci;
25	addr_t			aperture_base;
26	aperture_id		aperture;
27
28	uint8*			registers;
29
30	area_id			registers_area;
31	struct intel_shared_info* shared_info;
32	area_id			shared_area;
33
34	struct overlay_registers* overlay_registers;
35
36	bool			fake_interrupts;
37
38	const char*		device_identifier;
39	DeviceType		device_type;
40};
41
42
43static inline uint32
44find_reg(const intel_info& info, uint32 target)
45{
46	if (REGISTER_BLOCK(target) != REGS_FLAT) {
47		panic("find_reg is only supposed to be used for unrouped registers\n");
48		return target;
49	}
50
51	if (!info.device_type.HasPlatformControlHub())
52		return target;
53
54	#define RETURN_REG(x)	case INTEL_##x: return PCH_##x;
55
56	switch (target) {
57		RETURN_REG(INTERRUPT_ENABLED)
58		RETURN_REG(INTERRUPT_IDENTITY)
59		RETURN_REG(INTERRUPT_MASK)
60		RETURN_REG(INTERRUPT_STATUS)
61	}
62
63	#undef RETURN_REG
64
65	panic("find_reg didn't have any matching register\n");
66	return target;
67}
68
69
70extern status_t intel_free_memory(intel_info& info, addr_t offset);
71extern status_t intel_allocate_memory(intel_info& info, size_t size,
72	size_t alignment, uint32 flags, addr_t* _offset,
73	phys_addr_t* _physicalBase = NULL);
74extern status_t intel_extreme_init(intel_info& info);
75extern void intel_extreme_uninit(intel_info& info);
76
77#endif  /* INTEL_EXTREME_PRIVATE_H */
78