1/*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef KERNEL_ARCH_ARM_ARM_VM_TRANSLATION_MAP_H
6#define KERNEL_ARCH_ARM_ARM_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 ARMPagingStructures;
21class TranslationMapPhysicalPageMapper;
22
23
24struct ARMVMTranslationMap : VMTranslationMap {
25								ARMVMTranslationMap();
26	virtual						~ARMVMTranslationMap();
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	ARMPagingStructures* PagingStructures() const = 0;
38
39	inline	void				InvalidatePage(addr_t address);
40
41	virtual	status_t			SetFlags(addr_t virtualAddress, uint32 flags) = 0;
42
43protected:
44			TranslationMapPhysicalPageMapper* fPageMapper;
45			int					fInvalidPagesCount;
46			addr_t				fInvalidPages[PAGE_INVALIDATE_CACHE_SIZE];
47			bool				fIsKernelMap;
48};
49
50
51void
52ARMVMTranslationMap::InvalidatePage(addr_t address)
53{
54	if (fInvalidPagesCount < PAGE_INVALIDATE_CACHE_SIZE)
55		fInvalidPages[fInvalidPagesCount] = address;
56
57	fInvalidPagesCount++;
58}
59
60
61#endif	// KERNEL_ARCH_ARM_ARM_VM_TRANSLATION_MAP_H
62