equal
deleted
inserted
replaced
202 } |
202 } |
203 |
203 |
204 |
204 |
205 void DReferenceCountedObject::Open() |
205 void DReferenceCountedObject::Open() |
206 { |
206 { |
207 __ASSERT_CRITICAL |
207 CHECK_PRECONDITIONS(MASK_NO_KILL_OR_SUSPEND, "DReferenceCountedObject::Open"); |
208 TBool ok = __e32_atomic_tas_ord32(&iReferenceCount, 1, 1, 0); |
208 TInt orig = __e32_atomic_tas_ord32(&iReferenceCount, 1, 1, 0); |
209 __NK_ASSERT_ALWAYS(ok); |
209 if (orig <= 0) |
|
210 __crash(); |
210 } |
211 } |
211 |
212 |
212 |
213 |
213 TBool DReferenceCountedObject::TryOpen() |
214 TBool DReferenceCountedObject::TryOpen() |
214 { |
215 { |
215 __ASSERT_CRITICAL |
216 CHECK_PRECONDITIONS(MASK_NO_KILL_OR_SUSPEND, "DReferenceCountedObject::Open"); |
216 TBool ok = __e32_atomic_tas_ord32(&iReferenceCount, 1, 1, 0); |
217 TInt orig = __e32_atomic_tas_ord32(&iReferenceCount, 1, 1, 0); |
217 return ok; |
218 return (orig>0); |
218 } |
219 } |
219 |
220 |
220 |
221 |
221 TBool DReferenceCountedObject::CheckCloseIsSafe() |
222 TBool DReferenceCountedObject::CheckCloseIsSafe() |
222 { |
223 { |
241 #endif |
242 #endif |
242 return true; |
243 return true; |
243 } |
244 } |
244 |
245 |
245 |
246 |
246 TBool DReferenceCountedObject::CheckAsyncCloseIsSafe() |
|
247 { |
|
248 __ASSERT_CRITICAL |
|
249 #ifdef _DEBUG |
|
250 NFastMutex* fm = NKern::HeldFastMutex(); |
|
251 if(fm) |
|
252 { |
|
253 Kern::Printf("DReferenceCountedObject[0x%08x]::AsyncClose() fast mutex violation %M",this,fm); |
|
254 return false; |
|
255 } |
|
256 #endif |
|
257 return true; |
|
258 } |
|
259 |
|
260 |
|
261 void DReferenceCountedObject::Close() |
247 void DReferenceCountedObject::Close() |
262 { |
248 { |
263 __ASSERT_CRITICAL |
|
264 __NK_ASSERT_DEBUG(CheckCloseIsSafe()); |
249 __NK_ASSERT_DEBUG(CheckCloseIsSafe()); |
265 __NK_ASSERT_DEBUG(iReferenceCount>0); |
250 TInt orig = __e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0); |
266 if (__e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0) == 1) |
251 if (orig == 1) |
267 delete this; |
252 delete this; |
|
253 else if (orig <= 0) |
|
254 __crash(); |
268 } |
255 } |
269 |
256 |
270 |
257 |
271 void DReferenceCountedObject::AsyncClose() |
258 void DReferenceCountedObject::AsyncClose() |
272 { |
259 { |
273 __ASSERT_CRITICAL |
260 CHECK_PRECONDITIONS(MASK_NO_KILL_OR_SUSPEND, "DReferenceCountedObject::AsyncClose"); |
274 __NK_ASSERT_DEBUG(CheckAsyncCloseIsSafe()); |
261 TInt orig = __e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0); |
275 __NK_ASSERT_DEBUG(iReferenceCount>0); |
262 if (orig == 1) |
276 if (__e32_atomic_tas_ord32(&iReferenceCount, 1, -1, 0) == 1) |
|
277 AsyncDelete(); |
263 AsyncDelete(); |
|
264 else if (orig <= 0) |
|
265 __crash(); |
278 } |
266 } |
279 |
267 |
280 |
268 |
281 // |
269 // |
282 // Memory object functions |
270 // Memory object functions |
903 PageDirectories.Init2(); |
891 PageDirectories.Init2(); |
904 |
892 |
905 // initialise address spaces... |
893 // initialise address spaces... |
906 DAddressSpace::Init2(); |
894 DAddressSpace::Init2(); |
907 |
895 |
908 // init pager... |
|
909 ThePager.Init2(); |
|
910 |
|
911 TheMmu.Init2Final(); |
896 TheMmu.Init2Final(); |
912 } |
897 } |
913 |
898 |
914 |
899 |
915 /** HAL Function wrapper for the RAM allocator. |
900 /** HAL Function wrapper for the RAM allocator. |