mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-27 18:59:43 +02:00
physmem.c: align memory to word and page size
- physmem.c (align_sbrk): align the end of the data segment - physmem.c (calloc_phys_vec): align the line pointer vector to a machine word, just in case - physmem.c (calloc_phys_vec): crudely align the line buffers within pages, to avoid page-crossing within a line (yes, this does reduce noise)
This commit is contained in:
parent
2cee702ff4
commit
debe9cc351
@ -21,13 +21,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
static void align_brk(int alignment)
|
||||||
|
{
|
||||||
|
unsigned long addr;
|
||||||
|
|
||||||
|
addr = (unsigned long) sbrk(0);
|
||||||
|
sbrk(alignment-(addr % alignment));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void **calloc_phys_vec(size_t n, size_t size)
|
void **calloc_phys_vec(size_t n, size_t size)
|
||||||
{
|
{
|
||||||
void **vec;
|
void **vec;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
align_brk(sizeof(void *));
|
||||||
vec = sbrk(sizeof(void *)*n);
|
vec = sbrk(sizeof(void *)*n);
|
||||||
|
|
||||||
for (i = 0; i != n; i++) {
|
for (i = 0; i != n; i++) {
|
||||||
|
align_brk(512); /* crude page alignment */
|
||||||
vec[i] = sbrk(size);
|
vec[i] = sbrk(size);
|
||||||
memset(vec[i], 0, size);
|
memset(vec[i], 0, size);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user