1bcc2c157SIngo Weinhold/*
2bcc2c157SIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3bcc2c157SIngo Weinhold * Distributed under the terms of the MIT License.
4bcc2c157SIngo Weinhold */
5bcc2c157SIngo Weinhold#ifndef KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
6bcc2c157SIngo Weinhold#define KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
7bcc2c157SIngo Weinhold
8bcc2c157SIngo Weinhold
9bcc2c157SIngo Weinhold#include <vm/VMTranslationMap.h>
10bcc2c157SIngo Weinhold
11bcc2c157SIngo Weinhold
12b20eb413SPaweł Dziepak#if __GNUC__ < 4
13b20eb413SPaweł Dziepak#define final
14b20eb413SPaweł Dziepak#endif
15b20eb413SPaweł Dziepak
16b20eb413SPaweł Dziepak
17521aff92SIngo Weinhold#define PAGE_INVALIDATE_CACHE_SIZE 64
18521aff92SIngo Weinhold
19521aff92SIngo Weinhold
205aa0503cSIngo Weinholdstruct X86PagingStructures;
215aa0503cSIngo Weinholdclass TranslationMapPhysicalPageMapper;
225aa0503cSIngo Weinhold
235aa0503cSIngo Weinhold
24bcc2c157SIngo Weinholdstruct X86VMTranslationMap : VMTranslationMap {
25bcc2c157SIngo Weinhold								X86VMTranslationMap();
26bcc2c157SIngo Weinhold	virtual						~X86VMTranslationMap();
27bcc2c157SIngo Weinhold
28bcc2c157SIngo Weinhold			status_t			Init(bool kernel);
29bcc2c157SIngo Weinhold
30b20eb413SPaweł Dziepak	virtual	bool 				Lock() final;
31b20eb413SPaweł Dziepak	virtual	void				Unlock() final;
32bcc2c157SIngo Weinhold
33b20eb413SPaweł Dziepak	virtual	addr_t				MappedSize() const final;
3440bb9481SIngo Weinhold
35b20eb413SPaweł Dziepak	virtual	void				Flush() final;
36bcc2c157SIngo Weinhold
375aa0503cSIngo Weinhold	virtual	X86PagingStructures* PagingStructures() const = 0;
385aa0503cSIngo Weinhold
391c01dd3bSIngo Weinhold	inline	void				InvalidatePage(addr_t address);
401c01dd3bSIngo Weinhold
41bcc2c157SIngo Weinholdprotected:
42521aff92SIngo Weinhold			TranslationMapPhysicalPageMapper* fPageMapper;
43521aff92SIngo Weinhold			int					fInvalidPagesCount;
44521aff92SIngo Weinhold			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
455aa0503cSIngo Weinhold			bool				fIsKernelMap;
46bcc2c157SIngo Weinhold};
47bcc2c157SIngo Weinhold
48bcc2c157SIngo Weinhold
491c01dd3bSIngo Weinholdvoid
501c01dd3bSIngo WeinholdX86VMTranslationMap::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
59bcc2c157SIngo Weinhold#endif	// KERNEL_ARCH_X86_X86_VM_TRANSLATION_MAP_H
60