AP, kmalloc

This commit is contained in:
Taku Shimosawa
2011-11-06 19:27:09 +09:00
parent 5ddd25df98
commit 83a17650b9
10 changed files with 279 additions and 42 deletions

27
kernel/include/cls.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef __HEADER_CLS_H
#define __HEADER_CLS_H
/*
* CPU Local Storage (cls)
*/
struct malloc_header {
struct malloc_header *next;
unsigned long size;
};
struct cpu_local_var {
/* malloc */
struct malloc_header free_list;
/* Align to 64-byte */
} __attribute__((aligned(64)));
struct cpu_local_var *get_cpu_local_var(int id);
static struct cpu_local_var *get_this_cpu_local_var(void)
{
return get_cpu_local_var(aal_mc_get_processor_id());
}
#define cpu_local_var(name) get_this_cpu_local_var()->name
#endif

7
kernel/include/kmalloc.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __HEADER_KMALLOC_H
#define __HEADER_KMALLOC_H
void *kmalloc(int size, int flag);
void kfree(void *ptr);
#endif

7
kernel/include/page.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef __HEADER_PAGE_H
#define __HEADER_PAGE_H
void *allocate_pages(int npages, enum aal_mc_ap_flag flag);
void free_pages(void *va, int npages);
#endif