Skip to content
This repository was archived by the owner on Jun 5, 2019. It is now read-only.

Commit fc1209d

Browse files
committed
Remove custom heap
- remove all references and code related with custom heap - rework scatter files, AppEntry, FirstEntry and TinyHAL - reworked startup files to perform memory initializations - clean-up unused code
1 parent 513f5ae commit fc1209d

File tree

135 files changed

+1495
-2776
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+1495
-2776
lines changed

Application/EraseDeployment/EraseDeployment.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
#include "tinyhal.h"
1111

12-
HAL_DECLARE_NULL_HEAP();
13-
1412
void ApplicationEntryPoint()
1513
{
1614
int nSects = 0;

Application/MicroBooter/MicroBooter.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// <No description>
44
//
55
// Microsoft dotNetMF Project
6-
// Copyright ©2004 Microsoft Corporation
6+
// Copyright 2004 Microsoft Corporation
77
// One Microsoft Way, Redmond, Washington 98052-6399 U.S.A.
88
// All rights reserved.
99
// MICROSOFT CONFIDENTIAL
@@ -22,8 +22,6 @@ BOOL MemStreamSeekBlockAddress( BlockStorageStream &stream, UINT32 address );
2222
static SREC_Handler g_SREC;
2323
#endif
2424

25-
HAL_DECLARE_CUSTOM_HEAP( SimpleHeap_Allocate, SimpleHeap_Release, SimpleHeap_ReAllocate );
26-
2725
#pragma arm section zidata = "s_SystemStates"
2826
static INT32 s_SystemStates[SYSTEM_STATE_TOTAL_STATES];
2927
#pragma arm section zidata
@@ -265,7 +263,7 @@ static BOOL Memory_Read( UINT32 address, UINT32 length, BYTE* data )
265263

266264
if(s_ReadBuffer == NULL)
267265
{
268-
s_ReadBuffer = (UINT8*)private_malloc(readBufferSize);
266+
s_ReadBuffer = (UINT8*)malloc(readBufferSize);
269267

270268
ASSERT(s_ReadBuffer != NULL);
271269
if(s_ReadBuffer == NULL) return FALSE;
@@ -433,14 +431,6 @@ void BootEntryLoader()
433431

434432
Events_Initialize();
435433

436-
UINT8* BaseAddress;
437-
UINT32 SizeInBytes;
438-
439-
HeapLocation( BaseAddress, SizeInBytes );
440-
441-
// Initialize custom heap with heap block returned from CustomHeapLocation
442-
SimpleHeap_Initialize( BaseAddress, SizeInBytes );
443-
444434
// this is the place where interrupts are enabled after boot for the first time after boot
445435
ENABLE_INTERRUPTS();
446436

Application/MicroBooter/SrecProcessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ BOOL SREC_Handler::Process( char c )
5555

5656
if(!m_Stream.IsXIP())
5757
{
58-
dstExec = (UINT32)private_malloc(m_ImageLength);
58+
dstExec = (UINT32)malloc(m_ImageLength);
5959

6060
MemStreamSeekBlockAddress( m_Stream, m_ImageStart );
6161

Application/TinyBooter/Commands.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct BitFieldManager
8080
{
8181
const BlockDeviceInfo* deviceInfo = m_blockDevice->GetDeviceInfo();
8282

83-
data = (BYTE*)private_malloc( m_region->BytesPerBlock );
83+
data = (BYTE*)malloc( m_region->BytesPerBlock );
8484

8585
if(data != NULL)
8686
{
@@ -99,7 +99,7 @@ struct BitFieldManager
9999
ConfigurationSector *pCfg = (ConfigurationSector*)data;
100100
memset( (void*)&pCfg->SignatureCheck[ 0 ], 0xFF, sizeof(pCfg->SignatureCheck) );
101101
m_blockDevice->Write( m_cfgPhysicalAddress, m_region->BytesPerBlock,data, FALSE );
102-
private_free(data);
102+
free(data);
103103
}
104104
else
105105
{
@@ -150,7 +150,7 @@ struct BitFieldManager
150150
else
151151
{
152152
UINT32 length = m_region->BytesPerBlock;
153-
BYTE* dataptr = (BYTE*)private_malloc(length);
153+
BYTE* dataptr = (BYTE*)malloc(length);
154154

155155
if(dataptr != NULL)
156156
{
@@ -174,7 +174,7 @@ struct BitFieldManager
174174

175175
// write back to sector, as we only change one bit from 0 to 1, no need to erase sector
176176
m_blockDevice->Write( m_cfgPhysicalAddress, length, dataptr, FALSE );
177-
private_free(dataptr);
177+
free(dataptr);
178178
}
179179

180180
}
@@ -227,7 +227,7 @@ struct BitFieldManager
227227
UINT32 length = sizeof(ConfigurationSector);
228228

229229
memset( &m_skipCfgSectorCheck, 0xff, sizeof(m_skipCfgSectorCheck) );
230-
data = (BYTE*)private_malloc(length);
230+
data = (BYTE*)malloc(length);
231231
stream.Device->Read( m_cfgPhysicalAddress, length, (BYTE *)data );
232232
configSector = (ConfigurationSector*)data;
233233
m_signatureCheck = NULL;
@@ -253,7 +253,7 @@ struct BitFieldManager
253253
m_signatureCheck = &m_skipCfgSectorCheck;
254254
}
255255

256-
private_free(data);
256+
free(data);
257257

258258
}
259259
else // XIP device
@@ -476,7 +476,7 @@ static bool AccessMemory( UINT32 location, UINT32 lengthInBytes, BYTE* buf, int
476476
{
477477
if (mode == AccessMemory_Check)
478478
{
479-
bufPtr = (BYTE*) private_malloc(NumOfBytes);
479+
bufPtr = (BYTE*) malloc(NumOfBytes);
480480
if(!bufPtr) return false;
481481
}
482482

@@ -486,7 +486,7 @@ static bool AccessMemory( UINT32 location, UINT32 lengthInBytes, BYTE* buf, int
486486
{
487487
if (mode == AccessMemory_Check)
488488
{
489-
private_free(bufPtr);
489+
free(bufPtr);
490490
}
491491

492492
break;
@@ -495,7 +495,7 @@ static bool AccessMemory( UINT32 location, UINT32 lengthInBytes, BYTE* buf, int
495495
if (mode == AccessMemory_Check)
496496
{
497497
*(UINT32*)buf = SUPPORT_ComputeCRC( bufPtr, NumOfBytes, *(UINT32*)buf );
498-
private_free(bufPtr);
498+
free(bufPtr);
499499
}
500500
}
501501
break;
@@ -525,18 +525,18 @@ static bool AccessMemory( UINT32 location, UINT32 lengthInBytes, BYTE* buf, int
525525
{
526526
if(g_ConfigBuffer != NULL)
527527
{
528-
private_free(g_ConfigBuffer);
528+
free(g_ConfigBuffer);
529529
}
530530
g_ConfigBufferLength = 0;
531531

532-
// g_ConfigBuffer = (UINT8*)private_malloc(pRegion->BytesPerBlock);
532+
// g_ConfigBuffer = (UINT8*)malloc(pRegion->BytesPerBlock);
533533
// Just allocate the configuration Sector size, configuration block can be large and not necessary to have that buffer.
534-
g_ConfigBuffer = (UINT8*)private_malloc(g_ConfigBufferTotalSize);
534+
g_ConfigBuffer = (UINT8*)malloc(g_ConfigBufferTotalSize);
535535

536536
}
537537
else if(g_ConfigBufferTotalSize < ( g_ConfigBufferLength + lengthInBytes))
538538
{
539-
UINT8* tmp = (UINT8*)private_malloc(g_ConfigBufferLength + lengthInBytes);
539+
UINT8* tmp = (UINT8*)malloc(g_ConfigBufferLength + lengthInBytes);
540540

541541
if(tmp == NULL)
542542
{
@@ -545,7 +545,7 @@ static bool AccessMemory( UINT32 location, UINT32 lengthInBytes, BYTE* buf, int
545545

546546
memcpy( tmp, g_ConfigBuffer, g_ConfigBufferLength );
547547

548-
private_free(g_ConfigBuffer);
548+
free(g_ConfigBuffer);
549549

550550
g_ConfigBuffer = tmp;
551551
}
@@ -754,7 +754,7 @@ bool Loader_Engine::SignedDataState::VerifySignature( UINT8* signature, UINT32 l
754754
const BlockDeviceInfo* deviceInfo = m_pDevice->GetDeviceInfo();
755755
if(!deviceInfo->Attribute.SupportsXIP)
756756
{
757-
signCheckedAddr = (BYTE*)private_malloc(m_dataLength);
757+
signCheckedAddr = (BYTE*)malloc(m_dataLength);
758758
if (signCheckedAddr == NULL)
759759
{
760760
EraseMemoryAndReset();
@@ -764,7 +764,7 @@ bool Loader_Engine::SignedDataState::VerifySignature( UINT8* signature, UINT32 l
764764
if(!m_pDevice->Read( m_dataAddress, m_dataLength, signCheckedAddr ))
765765
{
766766
EraseMemoryAndReset();
767-
private_free(signCheckedAddr);
767+
free(signCheckedAddr);
768768

769769
return false;
770770
}
@@ -791,7 +791,7 @@ bool Loader_Engine::SignedDataState::VerifySignature( UINT8* signature, UINT32 l
791791

792792
if(!deviceInfo->Attribute.SupportsXIP)
793793
{
794-
private_free(signCheckedAddr);
794+
free(signCheckedAddr);
795795
}
796796

797797
return fret;
@@ -979,7 +979,7 @@ bool Loader_Engine::ProcessPayload( WP_Message* msg )
979979
LOADER_ENGINE_SETFLAG( this, c_LoaderEngineFlag_ValidConnection );
980980

981981
//--//
982-
#if defined(BIG_ENDIAN)
982+
#if defined(NETMF_TARGET_BIG_ENDIAN)
983983
SwapEndian( msg, msg->m_payload, msg->m_header.m_size, false );
984984
#endif
985985
size_t num;
@@ -1120,7 +1120,7 @@ bool Loader_Engine::TransmitMessage( const WP_Message* msg, bool fQueue )
11201120
UINT32 payloadSize;
11211121
UINT32 flags;
11221122

1123-
#if !defined(BIG_ENDIAN)
1123+
#if !defined(NETMF_TARGET_BIG_ENDIAN)
11241124
payloadSize = msg->m_header.m_size;
11251125
flags = msg->m_header.m_flags;
11261126
#else
@@ -1178,7 +1178,7 @@ void Loader_Engine::ReplyToCommand( WP_Message* msg, bool fSuccess, bool fCritic
11781178

11791179
msgReply.Initialize( &m_controller );
11801180

1181-
#if defined(BIG_ENDIAN)
1181+
#if defined(NETMF_TARGET_BIG_ENDIAN)
11821182
SwapEndian( msg, ptr, size, true );
11831183
#endif
11841184
msgReply.PrepareReply( msg->m_header, flags, size, (UINT8*)ptr );
@@ -1203,7 +1203,7 @@ bool Loader_Engine::Monitor_Ping( WP_Message* msg )
12031203
CLR_DBG_Commands::Monitor_Ping::Reply cmdReply;
12041204
cmdReply.m_source = CLR_DBG_Commands::Monitor_Ping::c_Ping_Source_TinyBooter;
12051205

1206-
#if defined(BIG_ENDIAN)
1206+
#if defined(NETMF_TARGET_BIG_ENDIAN)
12071207
cmdReply.m_dbg_flags = CLR_DBG_Commands::Monitor_Ping::c_Ping_DbgFlag_BigEndian;
12081208
#endif
12091209

@@ -1542,7 +1542,7 @@ bool Loader_Engine::Monitor_FlashSectorMap( WP_Message* msg )
15421542

15431543
if(cnt == 1)
15441544
{
1545-
pData = (struct Flash_Sector*)private_malloc(rangeCount * sizeof(struct Flash_Sector));
1545+
pData = (struct Flash_Sector*)malloc(rangeCount * sizeof(struct Flash_Sector));
15461546

15471547
if(pData == NULL)
15481548
{
@@ -1582,12 +1582,12 @@ bool Loader_Engine::Monitor_FlashSectorMap( WP_Message* msg )
15821582

15831583
ReplyToCommand(msg, true, false, (void*)pData, rangeCount * sizeof (struct Flash_Sector) );
15841584

1585-
private_free(pData);
1585+
free(pData);
15861586

15871587
return true;
15881588
}
15891589

1590-
#if defined(BIG_ENDIAN)
1590+
#if defined(NETMF_TARGET_BIG_ENDIAN)
15911591

15921592
UINT32 Loader_Engine::SwapEndianPattern( UINT8* &buffer, UINT32 size, UINT32 count )
15931593
{

Application/TinyBooter/Commands.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct Loader_Engine
147147
bool Monitor_SignatureKeyUpdate( WP_Message* msg );
148148
bool EnumerateAndLaunch ( );
149149

150-
#if defined(BIG_ENDIAN)
150+
#if defined(NETMF_TARGET_BIG_ENDIAN)
151151
public:
152152
void SwapDebuggingValue ( UINT8* &msg, UINT32 size );
153153
void SwapEndian ( WP_Message* msg, void* ptr, int size, bool fReply );

Application/TinyBooter/ConfigurationManager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void ConfigurationSectorManager::WriteConfiguration( UINT32 writeOffset, BYTE *d
130130
// Copy the whole block to a buffer, for NonXIP or need to erase block
131131
if ((eraseWrite) || (!m_fSupportsXIP))
132132
{
133-
configurationInBytes =(BYTE*)private_malloc(writeLengthInBytes);
133+
configurationInBytes =(BYTE*)malloc(writeLengthInBytes);
134134

135135
// load data to the local buffer.
136136
if (configurationInBytes)
@@ -154,7 +154,7 @@ void ConfigurationSectorManager::WriteConfiguration( UINT32 writeOffset, BYTE *d
154154
// rewrite from the start of block
155155
m_device->Write( m_cfgPhysicalAddress, writeLengthInBytes, configurationInBytes, FALSE );
156156

157-
private_free(configurationInBytes);
157+
free(configurationInBytes);
158158

159159

160160
}

Application/TinyBooter/CryptoInterface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ bool CryptoState::VerifySignature( UINT32 keyIndex )
111111
}
112112

113113
// free RAM buffer
114-
private_free(g_ConfigBuffer);
114+
free(g_ConfigBuffer);
115115
g_ConfigBuffer = NULL;
116116

117117
return fRet;

Application/TinyBooter/TinyBooter.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,11 @@ Loader_Engine g_eng;
1818

1919
//--//
2020

21-
HAL_DECLARE_CUSTOM_HEAP( SimpleHeap_Allocate, SimpleHeap_Release, SimpleHeap_ReAllocate );
22-
23-
//--//
24-
2521
void ApplicationEntryPoint()
2622
{
2723
INT32 timeout = 20000; // 20 second timeout
2824
bool enterBootMode = false;
2925

30-
// crypto API needs to allocate memory. Initialize simple heap for it.
31-
UINT8* BaseAddress;
32-
UINT32 SizeInBytes;
33-
34-
HeapLocation ( BaseAddress, SizeInBytes );
35-
SimpleHeap_Initialize( BaseAddress, SizeInBytes );
36-
3726
g_eng.Initialize( HalSystemConfig.DebuggerPorts[ 0 ] );
3827

3928
// internal reset and stop check

Application/TinyBooter/TinyBooterDecompressor.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ typedef unsigned char UINT8;
1212

1313
int LZ77_Decompress( UINT8* inBuf, int inSize, UINT8* outBuf, int outSize );
1414

15-
HAL_DECLARE_NULL_HEAP();
16-
1715
typedef void (*APP_ENTRY_POINT)();
1816

1917
extern "C"

CLR/Core/CLR_RT_HeapBlock.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ HRESULT CLR_RT_HeapBlock::LoadFromReference( CLR_RT_HeapBlock& ref )
389389
else if(size == 1) { first = ((CLR_UINT8 *)src)[ 0 ]; }
390390
else { first = ((CLR_UINT16*)src)[ 0 ]; }
391391

392-
#if !defined(BIG_ENDIAN)
392+
#if !defined(NETMF_TARGET_BIG_ENDIAN)
393393
((CLR_UINT32*)&NumericByRef())[ 0 ] = first;
394394
((CLR_UINT32*)&NumericByRef())[ 1 ] = second;
395395
#else
@@ -403,7 +403,7 @@ HRESULT CLR_RT_HeapBlock::LoadFromReference( CLR_RT_HeapBlock& ref )
403403
((CLR_UINT32*)&NumericByRef())[ 0 ] = second;
404404
((CLR_UINT32*)&NumericByRef())[ 1 ] = first;
405405
}
406-
#endif //BIG_ENDIAN
406+
#endif //NETMF_TARGET_BIG_ENDIAN
407407

408408
TINYCLR_SET_AND_LEAVE(S_OK);
409409
}
@@ -531,7 +531,7 @@ HRESULT CLR_RT_HeapBlock::StoreToReference( CLR_RT_HeapBlock& ref, int size )
531531
}
532532
}
533533

534-
#if !defined(BIG_ENDIAN)
534+
#if !defined(NETMF_TARGET_BIG_ENDIAN)
535535
CLR_UINT32 first = ((CLR_UINT32*)&obj->NumericByRef())[ 0 ];
536536
CLR_UINT32 second = ((CLR_UINT32*)&obj->NumericByRef())[ 1 ];
537537
#else
@@ -548,7 +548,7 @@ HRESULT CLR_RT_HeapBlock::StoreToReference( CLR_RT_HeapBlock& ref, int size )
548548
first = ((CLR_UINT32*)&obj->NumericByRef())[ 1 ];
549549
second = ((CLR_UINT32*)&obj->NumericByRef())[ 0 ];
550550
}
551-
#endif //BIG_ENDIAN
551+
#endif //NETMF_TARGET_BIG_ENDIAN
552552

553553
if (sizeArray == 4) { ((CLR_UINT32*)dst)[ 0 ] = (CLR_UINT32)first; }
554554
else if(sizeArray == 8) { ((CLR_UINT32*)dst)[ 0 ] = (CLR_UINT32)first; ((CLR_UINT32*)dst)[ 1 ] = (CLR_UINT32)second; }

CLR/Core/CLR_RT_HeapBlock_Array.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ HRESULT CLR_RT_HeapBlock_Array::IndexOf( CLR_RT_HeapBlock_Array* array, CLR_RT_H
206206

207207
while(true)
208208
{
209-
#if !defined(BIG_ENDIAN)
209+
#if !defined(NETMF_TARGET_BIG_ENDIAN)
210210
if(memcmp( data, &matchPtr->NumericByRef(), sizeElem ) == 0)
211211
{
212212
index = pos;

CLR/Core/CLR_RT_Memory.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ static int s_PreHeapInitIndex = 0;
1616

1717
////////////////////////////////////////////////////////////
1818

19-
HAL_DECLARE_CUSTOM_HEAP( CLR_RT_Memory::Allocate, CLR_RT_Memory::Release, CLR_RT_Memory::ReAllocate );
20-
2119
//--//
2220

2321
void CLR_RT_Memory::Reset()

CLR/Core/Execution.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3067,7 +3067,7 @@ void CLR_RT_ExecutionEngine::StopOnBreakpoint( CLR_DBG_Commands::Debugging_Execu
30673067

30683068
if(m_breakpointsActiveNum == 1)
30693069
{
3070-
#if defined(BIG_ENDIAN)
3070+
#if defined(NETMF_TARGET_BIG_ENDIAN)
30713071
static CLR_DBG_Commands::Debugging_Execution_BreakpointDef s_breakpoint;
30723072
CLR_UINT8* data;
30733073

CLR/Core/Serialization/BinaryFormatter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ HRESULT CLR_RT_BinaryFormatter::State::AdvanceToTheNextElement()
16351635
{
16361636
TINYCLR_CHECK_HRESULT(m_parent->ReadBits( val, bits ));
16371637

1638-
#if !defined(BIG_ENDIAN)
1638+
#if !defined(NETMF_TARGET_BIG_ENDIAN)
16391639
memcpy( ptr, &val, size );
16401640
#else
16411641
memcpy( ptr, ((unsigned char*)&val)+(sizeof(val)-size), size );

0 commit comments

Comments
 (0)