1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_SimpleAutoStackManagerBase.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev:$ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_OS_OS_SIMPLEAUTOSTACKMANAGERBASE_H_ 17 #define NN_OS_OS_SIMPLEAUTOSTACKMANAGERBASE_H_ 18 19 #include <nn/config.h> 20 #if NN_PLATFORM_HAS_MMU 21 22 #ifdef __cplusplus 23 24 #include <nn/os/os_Mutex.h> 25 #include <nn/os/os_AutoStackManager.h> 26 27 namespace nn { 28 namespace fnd 29 { 30 class IAllocator; 31 } 32 33 namespace os { 34 35 36 class SimpleAutoStackManagerBase : public AutoStackManager 37 { 38 private: 39 Mutex m_DestructorMutex; 40 fnd::IAllocator* m_pAllocator; 41 uptr m_DestructorStackBottom; 42 43 public: SimpleAutoStackManagerBase()44 SimpleAutoStackManagerBase() 45 : m_pAllocator(NULL) 46 { 47 } 48 49 virtual ~SimpleAutoStackManagerBase(); 50 51 void Initialize(fnd::IAllocator* pAllocator, uptr stackBottom); 52 53 uptr Finalize(); 54 55 56 protected: 57 virtual void FreeStack(void* pStackBottom) = 0; 58 IsInitialized()59 bool IsInitialized() const { return m_DestructorMutex.IsValid(); } GetAllocator()60 fnd::IAllocator* GetAllocator() { return m_pAllocator; } 61 62 void DestructImpl(void* pStackBottom, uptr returnAddress, bool isError); 63 void CallFreeStackOnOtherStack(void* pStackBottom, uptr stackBottom, uptr returnAddress); 64 }; 65 66 67 }} // namespace nn::os 68 69 #endif // __cplusplus 70 71 #endif // if NN_PLATFORM_HAS_MMU 72 #endif /* NN_OS_OS_SIMPLEAUTOSTACKMANAGERBASE_H_ */ 73