提交 fd9c281b 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

vm.h

上级 e096f2f8
......@@ -12,6 +12,7 @@
#include "file.h"
#include "elf.h"
#include "cpu.h"
#include "vm.h"
#define USTACKPAGES 2
......
......@@ -10,6 +10,7 @@
#include "queue.h"
#include "condvar.h"
#include "proc.h"
#include "vm.h"
#include <stddef.h>
extern pml4e_t kpml4[];
......@@ -189,3 +190,19 @@ freevm(pml4e_t *pml4)
kfree(pml4);
}
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
inittls(void)
{
struct cpu *c;
// Initialize cpu-local storage.
c = &cpus[cpunum()];
writegs(KDSEG);
writemsr(MSR_GS_BASE, (u64)&c->cpu);
c->cpu = c;
c->proc = NULL;
c->kmem = &kmems[cpunum()];
}
......@@ -10,6 +10,7 @@
#include "cpu.h"
#include "bits.h"
#include "xv6-mtrace.h"
#include "vm.h"
extern void trapret(void);
......
#include "spinlock.h"
// A mapping of a chunk of an address space to
// a specific memory object.
enum vmatype { PRIVATE, COW};
struct vma {
uptr va_start; // start of mapping
uptr va_end; // one past the last byte
enum vmatype va_type;
struct vmnode *n;
struct spinlock lock; // serialize fault/unmap
char lockname[16];
};
// A memory object (physical pages or inode).
enum vmntype { EAGER, ONDEMAND};
struct vmnode {
u64 npages;
char *page[128];
u64 ref;
enum vmntype type;
struct inode *ip;
u64 offset;
u64 sz;
};
// An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address.
struct vmap {
#ifdef TREE
struct node* root;
#else
struct vma* e[16];
#endif
struct spinlock lock; // serialize map/lookup/unmap
u64 ref;
u64 alloc;
pml4e_t *pml4; // Page table
char lockname[16];
};
// Saved registers for kernel context switches.
// (also implicitly defined in swtch.S)
struct context {
......
......@@ -8,6 +8,7 @@
#include "queue.h"
#include "proc.h"
#include "cpu.h"
#include "vm.h"
int
sys_fork(void)
......
......@@ -10,23 +10,7 @@
#include "queue.h"
#include "condvar.h"
#include "proc.h"
#include <stddef.h>
// Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU.
void
inittls(void)
{
struct cpu *c;
// Initialize cpu-local storage.
c = &cpus[cpunum()];
writegs(KDSEG);
writemsr(MSR_GS_BASE, (u64)&c->cpu);
c->cpu = c;
c->proc = NULL;
c->kmem = &kmems[cpunum()];
}
#include "vm.h"
static struct vma *
vma_alloc(void)
......
// A mapping of a chunk of an address space to
// a specific memory object.
enum vmatype { PRIVATE, COW};
struct vma {
uptr va_start; // start of mapping
uptr va_end; // one past the last byte
enum vmatype va_type;
struct vmnode *n;
struct spinlock lock; // serialize fault/unmap
char lockname[16];
};
// A memory object (physical pages or inode).
enum vmntype { EAGER, ONDEMAND};
struct vmnode {
u64 npages;
char *page[128];
u64 ref;
enum vmntype type;
struct inode *ip;
u64 offset;
u64 sz;
};
// An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address.
struct vmap {
#ifdef TREE
struct node* root;
#else
struct vma* e[16];
#endif
struct spinlock lock; // serialize map/lookup/unmap
u64 ref;
u64 alloc;
pml4e_t *pml4; // Page table
char lockname[16];
};
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论