11b3e83adSIngo Weinhold /* 21b3e83adSIngo Weinhold * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 31b3e83adSIngo Weinhold * Copyright 2005-2009, Axel Dörfler, axeld@pinc-software.de. 41b3e83adSIngo Weinhold * Distributed under the terms of the MIT License. 51b3e83adSIngo Weinhold * 61b3e83adSIngo Weinhold * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 71b3e83adSIngo Weinhold * Distributed under the terms of the NewOS License. 81b3e83adSIngo Weinhold */ 91b3e83adSIngo Weinhold #ifndef KERNEL_ARCH_X86_PAGING_X86_PAGING_STRUCTURES_H 101b3e83adSIngo Weinhold #define KERNEL_ARCH_X86_PAGING_X86_PAGING_STRUCTURES_H 111b3e83adSIngo Weinhold 121b3e83adSIngo Weinhold 131b3e83adSIngo Weinhold #include <SupportDefs.h> 141b3e83adSIngo Weinhold 151b3e83adSIngo Weinhold #include <heap.h> 161b3e83adSIngo Weinhold 17*7629d527SPawel Dziepak #include <smp.h> 18*7629d527SPawel Dziepak 191b3e83adSIngo Weinhold 201b3e83adSIngo Weinhold struct X86PagingStructures : DeferredDeletable { 21e276cc04SAlex Smith phys_addr_t pgdir_phys; 2273ad2473SPawel Dziepak int32 ref_count; 23*7629d527SPawel Dziepak CPUSet active_on_cpus; 241b3e83adSIngo Weinhold // mask indicating on which CPUs the map is currently used 251b3e83adSIngo Weinhold 261b3e83adSIngo Weinhold X86PagingStructures(); 271b3e83adSIngo Weinhold virtual ~X86PagingStructures(); 281b3e83adSIngo Weinhold 291b3e83adSIngo Weinhold inline void AddReference(); 301b3e83adSIngo Weinhold inline void RemoveReference(); 311b3e83adSIngo Weinhold 321b3e83adSIngo Weinhold virtual void Delete() = 0; 331b3e83adSIngo Weinhold }; 341b3e83adSIngo Weinhold 351b3e83adSIngo Weinhold 361b3e83adSIngo Weinhold inline void AddReference()371b3e83adSIngo WeinholdX86PagingStructures::AddReference() 381b3e83adSIngo Weinhold { 391b3e83adSIngo Weinhold atomic_add(&ref_count, 1); 401b3e83adSIngo Weinhold } 411b3e83adSIngo Weinhold 421b3e83adSIngo Weinhold 431b3e83adSIngo Weinhold inline void RemoveReference()441b3e83adSIngo WeinholdX86PagingStructures::RemoveReference() 451b3e83adSIngo Weinhold { 461b3e83adSIngo Weinhold if (atomic_add(&ref_count, -1) == 1) 471b3e83adSIngo Weinhold Delete(); 481b3e83adSIngo Weinhold } 491b3e83adSIngo Weinhold 501b3e83adSIngo Weinhold 511b3e83adSIngo Weinhold #endif // KERNEL_ARCH_X86_PAGING_X86_PAGING_STRUCTURES_H 52