forked from PoliEcho-holding-org/kern
more kmalloc
This commit is contained in:
@@ -11,7 +11,32 @@ void* kmalloc(size_t size);
|
||||
// Returns a pointer to allocated memory or NULL.
|
||||
void* kzalloc(size_t size);
|
||||
|
||||
// This function allocates memory for count elements each of size bytes, zeroed-out memory.
|
||||
// Returns a pointer to allocated memory or NULL.
|
||||
// This function allocates memory for count elements each of size bytes,
|
||||
// zeroed-out memory. Returns a pointer to allocated memory or NULL.
|
||||
void* kcalloc(size_t count, size_t size);
|
||||
|
||||
// powers of 2
|
||||
#define KMALLOC_MAX_SIZE 17
|
||||
|
||||
union per_cpu_freelist_cache {
|
||||
void* freelists[KMALLOC_MAX_SIZE];
|
||||
struct {
|
||||
void* kmalloc_8;
|
||||
void* kmalloc_16;
|
||||
void* kmalloc_32;
|
||||
void* kmalloc_64;
|
||||
void* kmalloc_128;
|
||||
void* kmalloc_256;
|
||||
void* kmalloc_512;
|
||||
void* kmalloc_1024;
|
||||
void* kmalloc_2048;
|
||||
void* kmalloc_4096;
|
||||
void* kmalloc_8192;
|
||||
void* kmalloc_16384;
|
||||
void* kmalloc_32768;
|
||||
void* kmalloc_65536;
|
||||
void* kmalloc_131072;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
+16
-2
@@ -2,7 +2,9 @@
|
||||
#include <kmalloc.h>
|
||||
#include <string.h>
|
||||
// this file contains SLUB inspired HEAP allocator
|
||||
void* freelist = NULL;
|
||||
|
||||
// TODO this will be an allocated array later when we have APIC MADT
|
||||
union per_cpu_freelist_cache freelists_all_cpus[1];
|
||||
|
||||
void* kcalloc(size_t count, size_t size) {
|
||||
size_t size_to_alloc;
|
||||
@@ -32,4 +34,16 @@ void* kzalloc(size_t size) {
|
||||
return allocated;
|
||||
}
|
||||
|
||||
void* kmalloc(size_t size) {}
|
||||
void* kmalloc(size_t size) {
|
||||
uint32_t core_id;
|
||||
__asm__ volatile(
|
||||
"rdtscp"
|
||||
: "=c"(core_id) // Core ID from IA32_TSC_AUX is placed in ECX
|
||||
:
|
||||
: "eax", "edx");
|
||||
|
||||
// freelists_all_cpus[core_id];
|
||||
// TODO enable when we actualy know how many CPUs we have
|
||||
if () {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user