mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2025-07-14 08:07:33 +02:00
kmalloc: support for PRAM0 arena
PRAM0 is mostly standard memory but it can only be read from and written to with 32-bit memory accesses.
This commit is contained in:
parent
e50769c824
commit
d8005b5d49
1 changed files with 10 additions and 7 deletions
|
@ -43,17 +43,17 @@
|
||||||
link, then one block_t pointer to the next link with LSB=1
|
link, then one block_t pointer to the next link with LSB=1
|
||||||
* For a larger block, the footer has a 4-byte block size, then a pointer to
|
* For a larger block, the footer has a 4-byte block size, then a pointer to
|
||||||
the previous link, and a pointer to the next link with LSB=0. */
|
the previous link, and a pointer to the next link with LSB=0. */
|
||||||
typedef struct {
|
typedef volatile struct {
|
||||||
uint :5;
|
uint32_t :5;
|
||||||
/* Marks the last block of the sequence */
|
/* Marks the last block of the sequence */
|
||||||
uint last: 1;
|
uint32_t last: 1;
|
||||||
/* Whether the block is used; in general this can be kept implicit, but
|
/* Whether the block is used; in general this can be kept implicit, but
|
||||||
it has to be specified for the last block */
|
it has to be specified for the last block */
|
||||||
uint used: 1;
|
uint32_t used: 1;
|
||||||
/* Boundary tag, vital to implement way #2 to merge adjacent blocks */
|
/* Boundary tag, vital to implement way #2 to merge adjacent blocks */
|
||||||
uint previous_used: 1;
|
uint32_t previous_used: 1;
|
||||||
/* Block size in bytes. */
|
/* Block size in bytes. */
|
||||||
uint size: 24;
|
uint32_t size: 24;
|
||||||
} block_t;
|
} block_t;
|
||||||
|
|
||||||
typedef kmalloc_gint_stats_t stats_t;
|
typedef kmalloc_gint_stats_t stats_t;
|
||||||
|
@ -435,7 +435,10 @@ void kmalloc_init_arena(kmalloc_arena_t *a, bool enable_statistics)
|
||||||
index->stats = (void *)a->start + sizeof(index_t);
|
index->stats = (void *)a->start + sizeof(index_t);
|
||||||
entry_block = (void *)index->stats + sizeof(stats_t);
|
entry_block = (void *)index->stats + sizeof(stats_t);
|
||||||
|
|
||||||
memset(index->stats, 0, sizeof(stats_t));
|
/* Manual 4-byte memset to allow PRAM0 arena */
|
||||||
|
for(uint i = 0; i < sizeof(stats_t) / 4; i++)
|
||||||
|
((uint32_t *)index->stats)[i] = 0;
|
||||||
|
_Static_assert((sizeof(stats_t) & 3) == 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue