1/*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
6#define KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
7
8
9#include <vm/VMTranslationMap.h>
10
11
12#if __GNUC__ < 4
13#define final
14#endif
15
16
17#define PAGE_INVALIDATE_CACHE_SIZE 64
18
19
20struct X86PagingStructures;
21class TranslationMapPhysicalPageMapper;
22
23
24struct X86VMTranslationMap : VMTranslationMap {
25								X86VMTranslationMap();
26	virtual						~X86VMTranslationMap();
27
28			status_t			Init(bool kernel);
29
30	virtual	bool				Lock() final;
31	virtual	void				Unlock() final;
32
33	virtual	addr_t				MappedSize() const final;
34
35	virtual	void				Flush() final;
36
37	virtual	X86PagingStructures* PagingStructures() const = 0;
38
39	inline	void				InvalidatePage(addr_t address);
40
41protected:
42			TranslationMapPhysicalPageMapper* fPageMapper;
43			int					fInvalidPagesCount;
44			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
45			bool				fIsKernelMap;
46};
47
48
49void
50X86VMTranslationMap::InvalidatePage(addr_t address)
51{
52	if (fInvalidPagesCount < PAGE_INVALIDATE_CACHE_SIZE)
53		fInvalidPages[fInvalidPagesCount] = address;
54
55	fInvalidPagesCount++;
56}
57
58
59#endif	// KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
60