mirror of
https://github.com/thelsing/knx.git
synced 2025-09-05 17:50:22 +02:00
align to pagesize
This commit is contained in:
parent
7fae86e3c2
commit
d34e7767c8
@ -25,8 +25,7 @@ void Memory::readMemory()
|
||||
|
||||
printHex("RESTORED ", flashStart, _metadataSize);
|
||||
|
||||
//uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
|
||||
uint16_t metadataBlockSize = _metadataSize;
|
||||
uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
|
||||
|
||||
_freeList = new MemoryBlock(flashStart + metadataBlockSize, flashSize - metadataBlockSize);
|
||||
|
||||
@ -175,7 +174,7 @@ void Memory::addSaveRestore(TableObject* obj)
|
||||
uint8_t* Memory::allocMemory(size_t size)
|
||||
{
|
||||
// always allocate aligned to pagesize
|
||||
//size = alignToPageSize(size);
|
||||
size = alignToPageSize(size);
|
||||
|
||||
MemoryBlock* freeBlock = _freeList;
|
||||
MemoryBlock* blockToUse = nullptr;
|
||||
@ -375,12 +374,12 @@ void Memory::addToFreeList(MemoryBlock* block)
|
||||
}
|
||||
}
|
||||
|
||||
//uint16_t Memory::alignToPageSize(size_t size)
|
||||
//{
|
||||
// size_t pageSize = _platform.flashPageSize();
|
||||
// // pagesize should be a multiply of two
|
||||
// return (size + pageSize - 1) & (-1*pageSize);
|
||||
//}
|
||||
uint16_t Memory::alignToPageSize(size_t size)
|
||||
{
|
||||
size_t pageSize = _platform.flashPageSize();
|
||||
// pagesize should be a multiply of two
|
||||
return (size + pageSize - 1) & (-1*pageSize);
|
||||
}
|
||||
|
||||
MemoryBlock* Memory::findBlockInList(MemoryBlock* head, uint8_t* address)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
void addToUsedList(MemoryBlock* block);
|
||||
void removeFromUsedList(MemoryBlock* block);
|
||||
void addToFreeList(MemoryBlock* block);
|
||||
// uint16_t alignToPageSize(size_t size);
|
||||
uint16_t alignToPageSize(size_t size);
|
||||
MemoryBlock* removeFromList(MemoryBlock* head, MemoryBlock* item);
|
||||
MemoryBlock* findBlockInList(MemoryBlock* head, uint8_t* address);
|
||||
void addNewUsedBlock(uint8_t* address, size_t size);
|
||||
|
@ -55,17 +55,16 @@ class Platform
|
||||
virtual void commitNonVolatileMemory();
|
||||
// address is relative to start of nonvolatile memory
|
||||
virtual uint32_t writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buffer, size_t size);
|
||||
// size of one flash page in bytes
|
||||
virtual size_t flashPageSize();
|
||||
|
||||
|
||||
NvMemoryType NonVolatileMemoryType();
|
||||
void NonVolatileMemoryType(NvMemoryType type);
|
||||
|
||||
protected:
|
||||
// Flash memory
|
||||
|
||||
// size of one EraseBlock in pages
|
||||
virtual size_t flashEraseBlockSize();
|
||||
// size of one flash page in bytes
|
||||
virtual size_t flashPageSize();
|
||||
// start of user flash aligned to start of an erase block
|
||||
virtual uint8_t* userFlashStart();
|
||||
// size of the user flash in EraseBlocks
|
||||
|
Loading…
Reference in New Issue
Block a user