内存管理(续)

This commit is contained in:
Yourtion
2016-04-14 11:45:22 +08:00
parent 6e72b241d9
commit feb468177b
2 changed files with 18 additions and 0 deletions

View File

@@ -133,4 +133,6 @@ unsigned int memtest(unsigned int start, unsigned int end);
void memman_init(struct MEMMAN *man);
unsigned int memman_total(struct MEMMAN *man);
unsigned int memman_alloc(struct MEMMAN *man, unsigned int size);
unsigned int memman_alloc_4k(struct MEMMAN *man, unsigned int size);
int memman_free(struct MEMMAN *man, unsigned int addr, unsigned int size);
int memman_free_4k(struct MEMMAN *man, unsigned int addr, unsigned int size);

View File

@@ -143,3 +143,19 @@ int memman_free(struct MEMMAN *man, unsigned int addr, unsigned int size)
man->lostsize += size;
return -1; /* 失败 */
}
unsigned int memman_alloc_4k(struct MEMMAN *man, unsigned int size)
{
unsigned int a;
size = (size + 0xfff) & 0xfffff000;
a = memman_alloc(man, size);
return a;
}
int memman_free_4k(struct MEMMAN *man, unsigned int addr, unsigned int size)
{
int i;
size = (size + 0xfff) & 0xfffff000;
i = memman_free(man, addr, size);
return i;
}