提交 c7b284b3 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

kalloc.h -> kalloc.hh

上级 d678eac0
#include "types.h"
#include "mmu.h"
#include "spinlock.h"
#include "kalloc.h"
#include "syscall.h"
#include "kern_c.h"
......@@ -27,24 +26,6 @@ struct segdesc __attribute__((aligned(16))) bootgdt[NSEGS] = {
[7]=SEGDESC(0, 0, SEG_R|SEG_CODE|SEG_S|SEG_DPL(3)|SEG_P|SEG_L|SEG_G),
};
struct kmem slabmem[slab_type_max][NCPU] = {
[slab_stack][0 ... NCPU-1] = {
.name = " kstack",
.size = KSTACKSIZE,
.ninit = CPUKSTACKS,
},
[slab_perf][0 ... NCPU-1] = {
.name = " kperf",
.size = PERFSIZE,
.ninit = 1,
},
[slab_kshared][0 ... NCPU-1] = {
.name = " kshared",
.size = KSHAREDSIZE,
.ninit = CPUKSTACKS,
},
};
#define SYSCALL(name) [SYS_##name] = (void*)sys_##name
long (*syscalls[])(u64, u64, u64, u64, u64, u64) = {
......
......@@ -5,7 +5,7 @@
#include "kernel.hh"
#include "bits.hh"
#include "spinlock.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "queue.h"
#include "condvar.h"
#include "proc.hh"
......
......@@ -7,7 +7,7 @@
#include "mmu.h"
#include "kernel.hh"
#include "spinlock.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "mtrace.h"
#include "cpu.hh"
#include "multiboot.hh"
......@@ -16,6 +16,7 @@ static struct Mbmem mem[128];
static u64 nmem;
static u64 membytes;
struct kmem kmems[NCPU];
struct kmem slabmem[slab_type_max][NCPU];
extern char end[]; // first address after kernel loaded from ELF file
char *newend;
......@@ -247,7 +248,19 @@ initkalloc(u64 mbaddr)
k = (((uptr)p) - KBASE);
for (int c = 0; c < NCPU; c++) {
// Fill slab allocators
for (int i = 0; i < NELEM(slabmem); i++)
strncpy(slabmem[slab_stack][c].name, " kstack", MAXNAME);
slabmem[slab_stack][c].size = KSTACKSIZE;
slabmem[slab_stack][c].ninit = CPUKSTACKS;
strncpy(slabmem[slab_perf][c].name, " kperf", MAXNAME);
slabmem[slab_perf][c].size = PERFSIZE;
slabmem[slab_perf][c].ninit = 1;
strncpy(slabmem[slab_kshared][c].name, " kshared", MAXNAME);
slabmem[slab_kshared][c].size = KSHAREDSIZE;
slabmem[slab_kshared][c].ninit = CPUKSTACKS;
for (int i = 0; i < slab_type_max; i++)
slabinit(&slabmem[i][c], &p, &k);
// The rest goes to the page allocator
......
......@@ -6,7 +6,7 @@
#include "mmu.h"
#include "kernel.hh"
#include "spinlock.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "mtrace.h"
#include "cpu.hh"
......
......@@ -2,7 +2,7 @@
#include "multiboot.hh"
#include "kernel.hh"
#include "spinlock.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "cpu.hh"
#include "amd64.h"
#include "hwvm.hh"
......
......@@ -10,7 +10,7 @@
#include "bits.hh"
#include "kmtrace.hh"
#include "sched.hh"
#include "kalloc.h"
#include "kalloc.hh"
#include "vm.hh"
#include "ns.hh"
......
......@@ -4,7 +4,7 @@
#include "condvar.h"
#include "fs.h"
#include "stat.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "file.hh"
#include "bits.hh"
#include "amd64.h"
......
......@@ -5,7 +5,7 @@
#include "kernel.hh"
#include "bits.hh"
#include "spinlock.h"
#include "kalloc.h"
#include "kalloc.hh"
#include "queue.h"
#include "condvar.h"
#include "proc.hh"
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论