xref: /haiku/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h (revision ba0223da5d79c5cd27496ee0e5712921cebb7642)
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 #define PAGE_INVALIDATE_CACHE_SIZE 64
13 
14 
15 struct X86PagingStructures;
16 class TranslationMapPhysicalPageMapper;
17 
18 
19 struct X86VMTranslationMap : VMTranslationMap {
20 								X86VMTranslationMap();
21 	virtual						~X86VMTranslationMap();
22 
23 			status_t			Init(bool kernel);
24 
25 	virtual	bool				Lock() final;
26 	virtual	void				Unlock() final;
27 
28 	virtual	addr_t				MappedSize() const final;
29 
30 	virtual	void				Flush() final;
31 
32 	virtual	X86PagingStructures* PagingStructures() const = 0;
33 
34 	inline	void				InvalidatePage(addr_t address);
35 
36 protected:
37 			TranslationMapPhysicalPageMapper* fPageMapper;
38 			int					fInvalidPagesCount;
39 			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
40 			bool				fIsKernelMap;
41 };
42 
43 
44 void
45 X86VMTranslationMap::InvalidatePage(addr_t address)
46 {
47 	if (fInvalidPagesCount < PAGE_INVALIDATE_CACHE_SIZE)
48 		fInvalidPages[fInvalidPagesCount] = address;
49 
50 	fInvalidPagesCount++;
51 }
52 
53 
54 #endif	// KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
55