xref: /haiku/src/system/kernel/arch/ppc/paging/PPCPagingStructures.h (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2  * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de.
4  * Distributed under the terms of the MIT License.
5  *
6  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
7  * Distributed under the terms of the NewOS License.
8  */
9 #ifndef KERNEL_ARCH_PPC_PAGING_PPC_PAGING_STRUCTURES_H
10 #define KERNEL_ARCH_PPC_PAGING_PPC_PAGING_STRUCTURES_H
11 
12 
13 #include <SupportDefs.h>
14 
15 #include <heap.h>
16 
17 #include <smp.h>
18 
19 
20 struct PPCPagingStructures : DeferredDeletable {
21 	// X86 stuff, probably useless
22 	phys_addr_t					pgdir_phys;
23 	int32						ref_count;
24 	CPUSet						active_on_cpus;
25 		// mask indicating on which CPUs the map is currently used
26 
27 								PPCPagingStructures();
28 	virtual						~PPCPagingStructures();
29 
30 	inline	void				AddReference();
31 	inline	void				RemoveReference();
32 
33 	virtual	void				Delete() = 0;
34 };
35 
36 
37 inline void
38 PPCPagingStructures::AddReference()
39 {
40 	atomic_add(&ref_count, 1);
41 }
42 
43 
44 inline void
45 PPCPagingStructures::RemoveReference()
46 {
47 	if (atomic_add(&ref_count, -1) == 1)
48 		Delete();
49 }
50 
51 
52 #endif	// KERNEL_ARCH_PPC_PAGING_PPC_PAGING_STRUCTURES_H
53