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

trap.c -> trap.cc

上级 b932ffeb
......@@ -42,6 +42,7 @@ LDFLAGS = -m elf_x86_64
OBJS = \
bio.o \
bootdata.o \
cga.o \
cilk.o \
condvar.o \
......
#include "types.h"
#include "mmu.h"
struct segdesc __attribute__((aligned(16))) bootgdt[NSEGS] = {
// null
[0]=SEGDESC(0, 0, 0),
// 32-bit kernel code
[1]=SEGDESC(0, 0xfffff, SEG_R|SEG_CODE|SEG_S|SEG_DPL(0)|SEG_P|SEG_D|SEG_G),
// 64-bit kernel code
[2]=SEGDESC(0, 0, SEG_R|SEG_CODE|SEG_S|SEG_DPL(0)|SEG_P|SEG_L|SEG_G),
// kernel data
[3]=SEGDESC(0, 0xfffff, SEG_W|SEG_S|SEG_DPL(0)|SEG_P|SEG_D|SEG_G),
// The order of the user data and user code segments is
// important for syscall instructions. See initseg.
// 64-bit user data
[6]=SEGDESC(0, 0xfffff, SEG_W|SEG_S|SEG_DPL(3)|SEG_P|SEG_D|SEG_G),
// 64-bit user code
[7]=SEGDESC(0, 0, SEG_R|SEG_CODE|SEG_S|SEG_DPL(3)|SEG_P|SEG_L|SEG_G),
};
......@@ -345,4 +345,5 @@ void mpboot(void);
void trapret(void);
void threadstub(void);
void threadhelper(void (*fn)(void *), void *arg);
void trap(struct trapframe *tf);
......@@ -123,6 +123,6 @@ struct taskstate
// that records the given code segment, instruction pointer,
// and type bits.
#define INTDESC(cs, rip, bits) (struct intdesc){ \
(rip)&0xffff, (cs), 0, bits, ((rip)>>16)&0xffff, \
(u64)(rip)>>32, 0, \
(u16) ((rip)&0xffff), (cs), 0, bits, (u16) (((rip)>>16)&0xffff), \
(u32) ((u64)(rip)>>32), 0, \
}
extern "C" {
#include "types.h"
#include "mmu.h"
#include "kernel.h"
......@@ -10,23 +11,7 @@
#include "proc.h"
#include "kmtrace.h"
#include "bits.h"
struct segdesc __attribute__((aligned(16))) bootgdt[NSEGS] = {
// null
[0]=SEGDESC(0, 0, 0),
// 32-bit kernel code
[1]=SEGDESC(0, 0xfffff, SEG_R|SEG_CODE|SEG_S|SEG_DPL(0)|SEG_P|SEG_D|SEG_G),
// 64-bit kernel code
[2]=SEGDESC(0, 0, SEG_R|SEG_CODE|SEG_S|SEG_DPL(0)|SEG_P|SEG_L|SEG_G),
// kernel data
[3]=SEGDESC(0, 0xfffff, SEG_W|SEG_S|SEG_DPL(0)|SEG_P|SEG_D|SEG_G),
// The order of the user data and user code segments is
// important for syscall instructions. See initseg.
// 64-bit user data
[6]=SEGDESC(0, 0xfffff, SEG_W|SEG_S|SEG_DPL(3)|SEG_P|SEG_D|SEG_G),
// 64-bit user code
[7]=SEGDESC(0, 0, SEG_R|SEG_CODE|SEG_S|SEG_DPL(3)|SEG_P|SEG_L|SEG_G),
};
}
struct intdesc idt[256] __attribute__((aligned(16)));
......@@ -179,7 +164,7 @@ void
inittrap(void)
{
u64 entry;
u32 bits;
u8 bits;
int i;
bits = INT_P | SEG_INTR64; // present, interrupt gate
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论