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_PAGING_X86_PHYSICAL_PAGE_MAPPER_LARGE_MEMORY_H
6#define KERNEL_ARCH_X86_PAGING_X86_PHYSICAL_PAGE_MAPPER_LARGE_MEMORY_H
7
8
9#include <OS.h>
10
11#include <util/DoublyLinkedList.h>
12
13
14#define USER_SLOTS_PER_CPU				16
15#define KERNEL_SLOTS_PER_CPU			16
16#define TOTAL_SLOTS_PER_CPU				(USER_SLOTS_PER_CPU \
17											+ KERNEL_SLOTS_PER_CPU + 1)
18	// one slot is for use in interrupts
19
20#define EXTRA_SLOTS						2
21
22
23class TranslationMapPhysicalPageMapper;
24class X86PhysicalPageMapper;
25struct kernel_args;
26
27
28namespace X86LargePhysicalPageMapper {
29
30
31struct PhysicalPageSlotPool;
32
33
34struct PhysicalPageSlot {
35	PhysicalPageSlot*			next;
36	PhysicalPageSlotPool*		pool;
37	addr_t						address;
38
39	inline	void				Map(phys_addr_t physicalAddress);
40};
41
42
43struct PhysicalPageSlotPool : DoublyLinkedListLinkImpl<PhysicalPageSlotPool> {
44
45	virtual						~PhysicalPageSlotPool();
46
47	inline	bool				IsEmpty() const;
48
49	inline	PhysicalPageSlot*	GetSlot();
50	inline	void				PutSlot(PhysicalPageSlot* slot);
51
52	virtual	status_t			AllocatePool(PhysicalPageSlotPool*& _pool) = 0;
53	virtual	void				Map(phys_addr_t physicalAddress,
54									addr_t virtualAddress) = 0;
55
56protected:
57			PhysicalPageSlot*	fSlots;
58};
59
60
61}
62
63
64status_t large_memory_physical_page_ops_init(kernel_args* args,
65	X86LargePhysicalPageMapper::PhysicalPageSlotPool* initialPools,
66	int32 initialPoolCount, size_t poolSize,
67	X86PhysicalPageMapper*& _pageMapper,
68	TranslationMapPhysicalPageMapper*& _kernelPageMapper);
69
70
71#endif	// KERNEL_ARCH_X86_PAGING_X86_PHYSICAL_PAGE_MAPPER_LARGE_MEMORY_H
72