Skip to content

Commit

Permalink
内存管理(续)
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed Apr 14, 2016
1 parent 6e72b24 commit feb4681
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 10_day/bootpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
16 changes: 16 additions & 0 deletions 10_day/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit feb4681

Please sign in to comment.