xref: /haiku/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h (revision 3ea2ee1a401ada153db3076affc0dea996e2f1f5)
11b3e83adSIngo Weinhold /*
21b3e83adSIngo Weinhold  * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
31b3e83adSIngo Weinhold  * Distributed under the terms of the MIT License.
41b3e83adSIngo Weinhold  */
51b3e83adSIngo Weinhold #ifndef KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
61b3e83adSIngo Weinhold #define KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
71b3e83adSIngo Weinhold 
81b3e83adSIngo Weinhold 
91b3e83adSIngo Weinhold #include <vm/VMTranslationMap.h>
101b3e83adSIngo Weinhold 
111b3e83adSIngo Weinhold 
121b3e83adSIngo Weinhold #define PAGE_INVALIDATE_CACHE_SIZE 64
131b3e83adSIngo Weinhold 
141b3e83adSIngo Weinhold 
151b3e83adSIngo Weinhold struct X86PagingStructures;
161b3e83adSIngo Weinhold class TranslationMapPhysicalPageMapper;
171b3e83adSIngo Weinhold 
181b3e83adSIngo Weinhold 
191b3e83adSIngo Weinhold struct X86VMTranslationMap : VMTranslationMap {
201b3e83adSIngo Weinhold 								X86VMTranslationMap();
211b3e83adSIngo Weinhold 	virtual						~X86VMTranslationMap();
221b3e83adSIngo Weinhold 
231b3e83adSIngo Weinhold 			status_t			Init(bool kernel);
241b3e83adSIngo Weinhold 
25*b20eb413SPaweł Dziepak 	virtual	bool				Lock() final;
26*b20eb413SPaweł Dziepak 	virtual	void				Unlock() final;
271b3e83adSIngo Weinhold 
28*b20eb413SPaweł Dziepak 	virtual	addr_t				MappedSize() const final;
291b3e83adSIngo Weinhold 
30*b20eb413SPaweł Dziepak 	virtual	void				Flush() final;
311b3e83adSIngo Weinhold 
321b3e83adSIngo Weinhold 	virtual	X86PagingStructures* PagingStructures() const = 0;
331b3e83adSIngo Weinhold 
341c01dd3bSIngo Weinhold 	inline	void				InvalidatePage(addr_t address);
351c01dd3bSIngo Weinhold 
361b3e83adSIngo Weinhold protected:
371b3e83adSIngo Weinhold 			TranslationMapPhysicalPageMapper* fPageMapper;
381b3e83adSIngo Weinhold 			int					fInvalidPagesCount;
391b3e83adSIngo Weinhold 			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
401b3e83adSIngo Weinhold 			bool				fIsKernelMap;
411b3e83adSIngo Weinhold };
421b3e83adSIngo Weinhold 
431b3e83adSIngo Weinhold 
441c01dd3bSIngo Weinhold void
InvalidatePage(addr_t address)451c01dd3bSIngo Weinhold X86VMTranslationMap::InvalidatePage(addr_t address)
461c01dd3bSIngo Weinhold {
471c01dd3bSIngo Weinhold 	if (fInvalidPagesCount < PAGE_INVALIDATE_CACHE_SIZE)
481c01dd3bSIngo Weinhold 		fInvalidPages[fInvalidPagesCount] = address;
491c01dd3bSIngo Weinhold 
501c01dd3bSIngo Weinhold 	fInvalidPagesCount++;
511c01dd3bSIngo Weinhold }
521c01dd3bSIngo Weinhold 
531c01dd3bSIngo Weinhold 
541b3e83adSIngo Weinhold #endif	// KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
55