xref: /haiku/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h (revision b20eb413cd5afe7d879235b4553deeaab4ee5ed0)
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 
12*b20eb413SPaweł Dziepak #if __GNUC__ < 4
13*b20eb413SPaweł Dziepak #define final
14*b20eb413SPaweł Dziepak #endif
15*b20eb413SPaweł Dziepak 
16*b20eb413SPaweł Dziepak 
171b3e83adSIngo Weinhold #define PAGE_INVALIDATE_CACHE_SIZE 64
181b3e83adSIngo Weinhold 
191b3e83adSIngo Weinhold 
201b3e83adSIngo Weinhold struct X86PagingStructures;
211b3e83adSIngo Weinhold class TranslationMapPhysicalPageMapper;
221b3e83adSIngo Weinhold 
231b3e83adSIngo Weinhold 
241b3e83adSIngo Weinhold struct X86VMTranslationMap : VMTranslationMap {
251b3e83adSIngo Weinhold 								X86VMTranslationMap();
261b3e83adSIngo Weinhold 	virtual						~X86VMTranslationMap();
271b3e83adSIngo Weinhold 
281b3e83adSIngo Weinhold 			status_t			Init(bool kernel);
291b3e83adSIngo Weinhold 
30*b20eb413SPaweł Dziepak 	virtual	bool 				Lock() final;
31*b20eb413SPaweł Dziepak 	virtual	void				Unlock() final;
321b3e83adSIngo Weinhold 
33*b20eb413SPaweł Dziepak 	virtual	addr_t				MappedSize() const final;
341b3e83adSIngo Weinhold 
35*b20eb413SPaweł Dziepak 	virtual	void				Flush() final;
361b3e83adSIngo Weinhold 
371b3e83adSIngo Weinhold 	virtual	X86PagingStructures* PagingStructures() const = 0;
381b3e83adSIngo Weinhold 
391c01dd3bSIngo Weinhold 	inline	void				InvalidatePage(addr_t address);
401c01dd3bSIngo Weinhold 
411b3e83adSIngo Weinhold protected:
421b3e83adSIngo Weinhold 			TranslationMapPhysicalPageMapper* fPageMapper;
431b3e83adSIngo Weinhold 			int					fInvalidPagesCount;
441b3e83adSIngo Weinhold 			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
451b3e83adSIngo Weinhold 			bool				fIsKernelMap;
461b3e83adSIngo Weinhold };
471b3e83adSIngo Weinhold 
481b3e83adSIngo Weinhold 
491c01dd3bSIngo Weinhold void
501c01dd3bSIngo Weinhold X86VMTranslationMap::InvalidatePage(addr_t address)
511c01dd3bSIngo Weinhold {
521c01dd3bSIngo Weinhold 	if (fInvalidPagesCount < PAGE_INVALIDATE_CACHE_SIZE)
531c01dd3bSIngo Weinhold 		fInvalidPages[fInvalidPagesCount] = address;
541c01dd3bSIngo Weinhold 
551c01dd3bSIngo Weinhold 	fInvalidPagesCount++;
561c01dd3bSIngo Weinhold }
571c01dd3bSIngo Weinhold 
581c01dd3bSIngo Weinhold 
591b3e83adSIngo Weinhold #endif	// KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
60