From feb468177b4477d29be25732af007983d250eebe Mon Sep 17 00:00:00 2001 From: Yourtion Date: Thu, 14 Apr 2016 11:45:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AD=98=E7=AE=A1=E7=90=86=EF=BC=88?= =?UTF-8?q?=E7=BB=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 10_day/bootpack.h | 2 ++ 10_day/memory.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/10_day/bootpack.h b/10_day/bootpack.h index 0e46fc2..3e572bb 100644 --- a/10_day/bootpack.h +++ b/10_day/bootpack.h @@ -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); diff --git a/10_day/memory.c b/10_day/memory.c index c9f8cd8..654e816 100644 --- a/10_day/memory.c +++ b/10_day/memory.c @@ -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; +}