| 0 |      1 | // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
 | 
|  |      2 | // All rights reserved.
 | 
|  |      3 | // This component and the accompanying materials are made available
 | 
|  |      4 | // under the terms of the License "Eclipse Public License v1.0"
 | 
|  |      5 | // which accompanies this distribution, and is available
 | 
|  |      6 | // at the URL "http://www.eclipse.org/legal/epl-v10.html".
 | 
|  |      7 | //
 | 
|  |      8 | // Initial Contributors:
 | 
|  |      9 | // Nokia Corporation - initial contribution.
 | 
|  |     10 | //
 | 
|  |     11 | // Contributors:
 | 
|  |     12 | //
 | 
|  |     13 | // Description:
 | 
|  |     14 | // e32\klib\dbase.cpp
 | 
|  |     15 | // 
 | 
|  |     16 | //
 | 
|  |     17 | 
 | 
|  |     18 | #include <kernel/kern_priv.h>
 | 
|  |     19 | 
 | 
|  |     20 | /**	Deletes the specified DBase derived object.
 | 
|  |     21 | 
 | 
|  |     22 | @param aPtr Pointer to the DBase derived object to be deleted.
 | 
|  |     23 | 
 | 
|  |     24 | @pre Calling thread must be in a critical section.
 | 
|  |     25 | @pre Interrupts must be enabled.
 | 
|  |     26 | @pre Kernel must be unlocked.
 | 
|  |     27 | @pre No fast mutex can be held.
 | 
|  |     28 | @pre Call in a thread context.
 | 
|  |     29 | @pre Can be used in a device driver.
 | 
|  |     30 | */
 | 
|  |     31 | EXPORT_C void DBase::Delete(DBase* aPtr)
 | 
|  |     32 | 	{
 | 
|  |     33 | 	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::Delete");	
 | 
|  |     34 | 	delete aPtr;
 | 
|  |     35 | 	}
 | 
|  |     36 | 
 | 
|  |     37 | 
 | 
|  |     38 | /**	Allocates the object from the kernel heap and then initialises its contents
 | 
|  |     39 | 	to binary zeros.
 | 
|  |     40 | 
 | 
|  |     41 | @param aSize The size of the derived class. This parameter is specified
 | 
|  |     42 |              implicitly by C++ in all circumstances in which a derived class
 | 
|  |     43 |              is allocated.
 | 
|  |     44 | 
 | 
|  |     45 | @return An untyped pointer to the allocated object.
 | 
|  |     46 | 
 | 
|  |     47 | @pre Calling thread must be in a critical section.
 | 
|  |     48 | @pre Interrupts must be enabled.
 | 
|  |     49 | @pre Kernel must be unlocked.
 | 
|  |     50 | @pre No fast mutex can be held.
 | 
|  |     51 | @pre Call in a thread context.
 | 
|  |     52 | @pre Can be used in a device driver.
 | 
|  |     53 | */
 | 
|  |     54 | EXPORT_C TAny* DBase::operator new(TUint aSize) __NO_THROW
 | 
|  |     55 | 	{
 | 
|  |     56 | 	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize)");	
 | 
|  |     57 | 	return Kern::AllocZ(aSize);
 | 
|  |     58 | 	}
 | 
|  |     59 | 
 | 
|  |     60 | 
 | 
|  |     61 | /**	Allocates the object from the kernel heap with additional memory and then
 | 
|  |     62 | 	initialises its contents to binary zeros.
 | 
|  |     63 | 
 | 
|  |     64 | @param  aSize The size of the derived class. This parameter is specified
 | 
|  |     65 |               implicitly by C++ in all circumstances in which a derived class
 | 
|  |     66 |               is allocated.
 | 
|  |     67 |               
 | 
|  |     68 | @param  anExtraSize Indicates additional size beyond the end of the base class.
 | 
|  |     69 | 
 | 
|  |     70 | @return An untyped pointer to the allocated object.
 | 
|  |     71 | 
 | 
|  |     72 | @pre Calling thread must be in a critical section.
 | 
|  |     73 | @pre Interrupts must be enabled.
 | 
|  |     74 | @pre Kernel must be unlocked.
 | 
|  |     75 | @pre No fast mutex can be held.
 | 
|  |     76 | @pre Call in a thread context.
 | 
|  |     77 | @pre Can be used in a device driver.
 | 
|  |     78 | */
 | 
|  |     79 | EXPORT_C TAny* DBase::operator new(TUint aSize, TUint anExtraSize) __NO_THROW
 | 
|  |     80 | 	{
 | 
|  |     81 | 	CHECK_PRECONDITIONS(MASK_THREAD_CRITICAL,"DBase::operator new(TUint aSize, TUint anExtraSize)");	
 | 
|  |     82 | 	aSize+=anExtraSize;
 | 
|  |     83 | 	return Kern::AllocZ(aSize);
 | 
|  |     84 | 	}
 | 
|  |     85 | 
 | 
|  |     86 | _LIT(KLitKernLib,"KernLib");
 | 
|  |     87 | void KL::Panic(KL::TKernLibPanic aPanic)
 | 
|  |     88 | 	{
 | 
|  |     89 | 	Kern::PanicCurrentThread(KLitKernLib,aPanic);
 | 
|  |     90 | 	}
 | 
|  |     91 | 
 | 
|  |     92 | 
 | 
|  |     93 | /** Default constructor for version type
 | 
|  |     94 | 	Sets version to 0.0.0
 | 
|  |     95 |  */
 | 
|  |     96 | EXPORT_C TVersion::TVersion()
 | 
|  |     97 | 	: iMajor(0),iMinor(0),iBuild(0)
 | 
|  |     98 | 	{}
 | 
|  |     99 | 
 | 
|  |    100 | 
 | 
|  |    101 | /**
 | 
|  |    102 | Compares two versions and returns true if the test version is less than the
 | 
|  |    103 | current version.
 | 
|  |    104 | 
 | 
|  |    105 | Version information is encapsulated by a TVersion type object and consists of
 | 
|  |    106 | a major version number, a minor version number and a build number.
 | 
|  |    107 | 
 | 
|  |    108 | The function returns true if one of the following conditions is true:
 | 
|  |    109 | 
 | 
|  |    110 | 1. the test major version is strictly less than the current major version
 | 
|  |    111 | 
 | 
|  |    112 | 2. the test major version is equal to the current major version and the test
 | 
|  |    113 |    minor version is less than or equal to the current minor version.
 | 
|  |    114 | 
 | 
|  |    115 | If neither condition is true, the function returns false.
 | 
|  |    116 | 
 | 
|  |    117 | @param aCurrent   A reference to the current version against which aRequested
 | 
|  |    118 |                   is compared.
 | 
|  |    119 | @param aRequested A reference to the test version to be compared
 | 
|  |    120 |                   against aCurrent.
 | 
|  |    121 | 
 | 
|  |    122 | @return True, if one or both conditions are true. False otherwise.
 | 
|  |    123 | */
 | 
|  |    124 | EXPORT_C TBool Kern::QueryVersionSupported(const TVersion &aCurrent,const TVersion &aRequested)
 | 
|  |    125 | 	{
 | 
|  |    126 | 
 | 
|  |    127 | 	if (aRequested.iMajor<aCurrent.iMajor || (aRequested.iMajor==aCurrent.iMajor && aRequested.iMinor<=aCurrent.iMinor))
 | 
|  |    128 | 		return(ETrue);
 | 
|  |    129 | 	return(EFalse);
 | 
|  |    130 | 	}
 | 
|  |    131 | 
 | 
|  |    132 | 
 | 
|  |    133 | /** Constructor for version type.
 | 
|  |    134 | 
 | 
|  |    135 | 	@param	aMajor	The major version number (0-127).
 | 
|  |    136 | 	@param	aMajor	The minor version number (0-127).
 | 
|  |    137 | 	@param	aMajor	The build number (0-32767).
 | 
|  |    138 |  */
 | 
|  |    139 | EXPORT_C TVersion::TVersion(TInt aMajor,TInt aMinor,TInt aBuild)
 | 
|  |    140 | 	: iMajor((TInt8)aMajor), iMinor((TInt8)aMinor), iBuild((TInt16)aBuild)
 | 
|  |    141 | 	{}
 | 
|  |    142 | 
 | 
|  |    143 | 
 | 
|  |    144 | /** Converts a version type to a text string.
 | 
|  |    145 | 
 | 
|  |    146 | 	The string is of the form X.YY(Z)
 | 
|  |    147 | 	where X is major version number, Y is minor and Z is build number.
 | 
|  |    148 | 
 | 
|  |    149 | 	@return The string in a TBuf class.
 | 
|  |    150 |  */
 | 
|  |    151 | EXPORT_C TVersionName TVersion::Name() const
 | 
|  |    152 | 	{
 | 
|  |    153 | 
 | 
|  |    154 | 	TVersionName v;
 | 
|  |    155 | 	v.AppendNum(iMajor);
 | 
|  |    156 | 	v.Append(TChar('.'));
 | 
|  |    157 | 	v.AppendNumFixedWidth(iMinor,EDecimal,2);
 | 
|  |    158 | 	v.Append(TChar('('));
 | 
|  |    159 | 	v.AppendNum(iBuild);
 | 
|  |    160 | 	v.Append(TChar(')'));
 | 
|  |    161 | 	return v;
 | 
|  |    162 | 	}
 | 
|  |    163 | 
 |