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);
|
printHex("RESTORED ", flashStart, _metadataSize);
|
||||||
|
|
||||||
//uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
|
uint16_t metadataBlockSize = alignToPageSize(_metadataSize);
|
||||||
uint16_t metadataBlockSize = _metadataSize;
|
|
||||||
|
|
||||||
_freeList = new MemoryBlock(flashStart + metadataBlockSize, flashSize - metadataBlockSize);
|
_freeList = new MemoryBlock(flashStart + metadataBlockSize, flashSize - metadataBlockSize);
|
||||||
|
|
||||||
@ -175,7 +174,7 @@ void Memory::addSaveRestore(TableObject* obj)
|
|||||||
uint8_t* Memory::allocMemory(size_t size)
|
uint8_t* Memory::allocMemory(size_t size)
|
||||||
{
|
{
|
||||||
// always allocate aligned to pagesize
|
// always allocate aligned to pagesize
|
||||||
//size = alignToPageSize(size);
|
size = alignToPageSize(size);
|
||||||
|
|
||||||
MemoryBlock* freeBlock = _freeList;
|
MemoryBlock* freeBlock = _freeList;
|
||||||
MemoryBlock* blockToUse = nullptr;
|
MemoryBlock* blockToUse = nullptr;
|
||||||
@ -375,12 +374,12 @@ void Memory::addToFreeList(MemoryBlock* block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//uint16_t Memory::alignToPageSize(size_t size)
|
uint16_t Memory::alignToPageSize(size_t size)
|
||||||
//{
|
{
|
||||||
// size_t pageSize = _platform.flashPageSize();
|
size_t pageSize = _platform.flashPageSize();
|
||||||
// // pagesize should be a multiply of two
|
// pagesize should be a multiply of two
|
||||||
// return (size + pageSize - 1) & (-1*pageSize);
|
return (size + pageSize - 1) & (-1*pageSize);
|
||||||
//}
|
}
|
||||||
|
|
||||||
MemoryBlock* Memory::findBlockInList(MemoryBlock* head, uint8_t* address)
|
MemoryBlock* Memory::findBlockInList(MemoryBlock* head, uint8_t* address)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
void addToUsedList(MemoryBlock* block);
|
void addToUsedList(MemoryBlock* block);
|
||||||
void removeFromUsedList(MemoryBlock* block);
|
void removeFromUsedList(MemoryBlock* block);
|
||||||
void addToFreeList(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* removeFromList(MemoryBlock* head, MemoryBlock* item);
|
||||||
MemoryBlock* findBlockInList(MemoryBlock* head, uint8_t* address);
|
MemoryBlock* findBlockInList(MemoryBlock* head, uint8_t* address);
|
||||||
void addNewUsedBlock(uint8_t* address, size_t size);
|
void addNewUsedBlock(uint8_t* address, size_t size);
|
||||||
|
@ -55,17 +55,16 @@ class Platform
|
|||||||
virtual void commitNonVolatileMemory();
|
virtual void commitNonVolatileMemory();
|
||||||
// address is relative to start of nonvolatile memory
|
// address is relative to start of nonvolatile memory
|
||||||
virtual uint32_t writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buffer, size_t size);
|
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();
|
NvMemoryType NonVolatileMemoryType();
|
||||||
void NonVolatileMemoryType(NvMemoryType type);
|
void NonVolatileMemoryType(NvMemoryType type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Flash memory
|
|
||||||
|
|
||||||
// size of one EraseBlock in pages
|
// size of one EraseBlock in pages
|
||||||
virtual size_t flashEraseBlockSize();
|
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
|
// start of user flash aligned to start of an erase block
|
||||||
virtual uint8_t* userFlashStart();
|
virtual uint8_t* userFlashStart();
|
||||||
// size of the user flash in EraseBlocks
|
// size of the user flash in EraseBlocks
|
||||||
|
Loading…
Reference in New Issue
Block a user