Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
2224e0e7
提交
2224e0e7
1月 11, 2012
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'scale-amd64' of
ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6
into scale-amd64
上级
ffcf89fe
63590a59
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
75 行增加
和
103 行删除
+75
-103
Makefile
Makefile
+1
-1
compiler.h
compiler.h
+3
-0
console.c
console.c
+52
-10
e1000.c
e1000.c
+2
-0
gc.c
gc.c
+2
-1
kernel.h
kernel.h
+4
-2
lib.h
lib.h
+4
-0
multiboot.S
multiboot.S
+0
-78
net.c
net.c
+4
-0
prof.c
prof.c
+1
-1
sampler.c
sampler.c
+0
-1
trap.c
trap.c
+2
-6
types.h
types.h
+0
-3
没有找到文件。
Makefile
浏览文件 @
2224e0e7
...
@@ -21,7 +21,7 @@ OBJCOPY = $(TOOLPREFIX)objcopy
...
@@ -21,7 +21,7 @@ OBJCOPY = $(TOOLPREFIX)objcopy
CFLAGS
=
-fno-pic
-static
-fno-builtin
-fno-strict-aliasing
-O2
-Wall
-MD
-ggdb
\
CFLAGS
=
-fno-pic
-static
-fno-builtin
-fno-strict-aliasing
-O2
-Wall
-MD
-ggdb
\
-m64
-Werror
-std
=
c99
-fms-extensions
-mno-sse
-mcmodel
=
large
-I
$(QEMUSRC)
\
-m64
-Werror
-std
=
c99
-fms-extensions
-mno-sse
-mcmodel
=
large
-I
$(QEMUSRC)
\
-fno-omit-frame-pointer
-DHW_
$(HW)
-include
param.h
-fno-omit-frame-pointer
-DHW_
$(HW)
-include
param.h
-include
compiler.h
CFLAGS
+=
$(
shell
$(CC)
-fno-stack-protector
-E
-x
c /dev/null
>
/dev/null 2>&1
&&
echo
-fno-stack-protector
)
CFLAGS
+=
$(
shell
$(CC)
-fno-stack-protector
-E
-x
c /dev/null
>
/dev/null 2>&1
&&
echo
-fno-stack-protector
)
ASFLAGS
=
-m64
-gdwarf-2
-MD
ASFLAGS
=
-m64
-gdwarf-2
-MD
LDFLAGS
+=
-m
elf_x86_64
LDFLAGS
+=
-m
elf_x86_64
...
...
compiler.h
0 → 100644
浏览文件 @
2224e0e7
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __noret__ __attribute__((noreturn))
console.c
浏览文件 @
2224e0e7
...
@@ -95,6 +95,16 @@ snprintf(char *buf, u32 n, char *fmt, ...)
...
@@ -95,6 +95,16 @@ snprintf(char *buf, u32 n, char *fmt, ...)
}
}
void
void
__cprintf
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
vprintfmt
(
writecons
,
0
,
fmt
,
ap
);
va_end
(
ap
);
}
void
cprintf
(
const
char
*
fmt
,
...)
cprintf
(
const
char
*
fmt
,
...)
{
{
va_list
ap
;
va_list
ap
;
...
@@ -131,7 +141,7 @@ stacktrace(void)
...
@@ -131,7 +141,7 @@ stacktrace(void)
do { \
do { \
uptr addr = (uptr) __builtin_return_address(i); \
uptr addr = (uptr) __builtin_return_address(i); \
if ((addr & KBASE) == KBASE) \
if ((addr & KBASE) == KBASE) \
cprintf(" %lx\n", addr);
\
__cprintf(" %lx\n", addr);
\
else \
else \
return; \
return; \
} while (0)
} while (0)
...
@@ -147,23 +157,55 @@ stacktrace(void)
...
@@ -147,23 +157,55 @@ stacktrace(void)
#undef PRINT_RET
#undef PRINT_RET
}
}
void
__
attribute__
((
noreturn
))
void
__
noret__
panic
(
const
char
*
s
)
kerneltrap
(
struct
trapframe
*
tf
)
{
{
extern
void
sys_halt
();
extern
void
sys_halt
();
const
char
*
name
=
"(no name)"
;
void
*
kstack
=
NULL
;
int
pid
=
0
;
uptr
pc
[
10
];
int
i
;
cli
();
cli
();
acquire
(
&
cons
.
lock
);
cons
.
locking
=
0
;
if
(
myproc
()
!=
NULL
)
{
if
(
myproc
()
->
name
&&
myproc
()
->
name
[
0
]
!=
0
)
name
=
myproc
()
->
name
;
pid
=
myproc
()
->
pid
;
kstack
=
myproc
()
->
kstack
;
}
__cprintf
(
"kernel trap %u cpu %u
\n
"
" tf: rip %p rsp %p cr2 %p
\n
"
" proc: name %s pid %u kstack %p
\n
"
,
tf
->
trapno
,
mycpu
()
->
id
,
tf
->
rip
,
tf
->
rsp
,
rcr2
(),
name
,
pid
,
kstack
);
getcallerpcs
((
void
*
)
tf
->
rbp
,
pc
);
for
(
i
=
0
;
i
<
NELEM
(
pc
)
&&
pc
[
i
]
!=
0
;
i
++
)
__cprintf
(
" %p
\n
"
,
pc
[
i
]);
cprintf
(
"cpu%d: panic: "
,
mycpu
()
->
id
);
cprintf
(
s
);
cprintf
(
"
\n
"
);
stacktrace
();
panicked
=
1
;
panicked
=
1
;
sys_halt
();
for
(;;)
;
}
void
__noret__
panic
(
const
char
*
s
)
{
extern
void
sys_halt
();
cli
();
acquire
(
&
cons
.
lock
);
acquire
(
&
cons
.
lock
);
// Never release cons.lock
__cprintf
(
"cpu%d: panic: "
,
mycpu
()
->
id
);
__cprintf
(
s
);
__cprintf
(
"
\n
"
);
stacktrace
();
panicked
=
1
;
sys_halt
();
sys_halt
();
for
(;;)
for
(;;)
;
;
...
...
e1000.c
浏览文件 @
2224e0e7
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#define RX_RING_SIZE 64
#define RX_RING_SIZE 64
int
e1000irq
;
int
e1000irq
;
int
e1000init
;
static
struct
{
static
struct
{
u32
membase
;
u32
membase
;
...
@@ -296,5 +297,6 @@ e1000attach(struct pci_func *pcif)
...
@@ -296,5 +297,6 @@ e1000attach(struct pci_func *pcif)
for
(
i
=
0
;
i
<
WMREG_MTA
;
i
+=
4
)
for
(
i
=
0
;
i
<
WMREG_MTA
;
i
+=
4
)
ewr
(
WMREG_CORDOVA_MTA
+
i
,
0
);
ewr
(
WMREG_CORDOVA_MTA
+
i
,
0
);
e1000init
=
1
;
return
0
;
return
0
;
}
}
gc.c
浏览文件 @
2224e0e7
...
@@ -260,7 +260,8 @@ gc_worker(void *x)
...
@@ -260,7 +260,8 @@ gc_worker(void *x)
{
{
struct
spinlock
wl
;
struct
spinlock
wl
;
cprintf
(
"gc_worker: %d
\n
"
,
mycpu
()
->
id
);
if
(
VERBOSE
)
cprintf
(
"gc_worker: %d
\n
"
,
mycpu
()
->
id
);
initlock
(
&
wl
,
"rcu_gc_worker dummy"
);
// dummy lock
initlock
(
&
wl
,
"rcu_gc_worker dummy"
);
// dummy lock
for
(;;)
{
for
(;;)
{
...
...
kernel.h
浏览文件 @
2224e0e7
...
@@ -45,7 +45,8 @@ void cv_tick(void);
...
@@ -45,7 +45,8 @@ void cv_tick(void);
// console.c
// console.c
void
cprintf
(
const
char
*
,
...);
void
cprintf
(
const
char
*
,
...);
void
panic
(
const
char
*
)
__attribute__
((
noreturn
));
void
panic
(
const
char
*
)
__noret__
;
void
kerneltrap
(
struct
trapframe
*
tf
)
__noret__
;
void
snprintf
(
char
*
buf
,
u32
n
,
char
*
fmt
,
...);
void
snprintf
(
char
*
buf
,
u32
n
,
char
*
fmt
,
...);
void
consoleintr
(
int
(
*
)(
void
));
void
consoleintr
(
int
(
*
)(
void
));
...
@@ -76,6 +77,7 @@ void crange_print(struct crange *cr, int);
...
@@ -76,6 +77,7 @@ void crange_print(struct crange *cr, int);
// e1000.c
// e1000.c
extern
int
e1000irq
;
extern
int
e1000irq
;
extern
int
e1000init
;
void
e1000intr
(
void
);
void
e1000intr
(
void
);
int
e1000tx
(
void
*
buf
,
u32
len
);
int
e1000tx
(
void
*
buf
,
u32
len
);
void
e1000hwaddr
(
u8
*
hwaddr
);
void
e1000hwaddr
(
u8
*
hwaddr
);
...
@@ -239,7 +241,7 @@ int growproc(int);
...
@@ -239,7 +241,7 @@ int growproc(int);
int
kill
(
int
);
int
kill
(
int
);
void
pinit
(
void
);
void
pinit
(
void
);
void
procdumpall
(
void
);
void
procdumpall
(
void
);
void
scheduler
(
void
)
__
attribute__
((
noreturn
))
;
void
scheduler
(
void
)
__
noret__
;
void
sched
(
void
);
void
sched
(
void
);
void
userinit
(
void
);
void
userinit
(
void
);
int
wait
(
void
);
int
wait
(
void
);
...
...
lib.h
浏览文件 @
2224e0e7
...
@@ -22,3 +22,7 @@
...
@@ -22,3 +22,7 @@
#define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val)
#define subfetch(ptr, val) __sync_sub_and_fetch(ptr, val)
#define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val)
#define fetchadd(ptr, val) __sync_fetch_and_add(ptr, val)
#define __offsetof offsetof
#define __offsetof offsetof
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
#define __noret__ __attribute__((noreturn))
multiboot.S
deleted
100644 → 0
浏览文件 @
ffcf89fe
# Multiboot header, for multiboot boot loaders like GNU Grub.
# http://www.gnu.org/software/grub/manual/multiboot/multiboot.html
#
# Using GRUB 2, you can boot xv6 from a file stored in a
# Linux file system by copying kernel or kernelmemfs to /boot
# and then adding this menu entry:
#
# menuentry "xv6" {
# insmod ext2
# set root='(hd0,msdos1)'
# set kernel='/boot/kernel'
# echo "Loading ${kernel}..."
# multiboot ${kernel} ${kernel}
# boot
# }
#include "asm.h"
#include "memlayout.h"
#define RELOC(x) ((x) - KERNBASE) // same as V2P, but without casts
#define STACK 4096
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
# Multiboot header. Data to direct multiboot loader.
.p2align 2
.text
.globl multiboot_header
multiboot_header:
#define magic 0x1badb002
#define flags (1<<16 | 1<<0)
.long magic
.long flags
.long (-magic-flags)
.long multiboot_header # beginning of image
.long multiboot_header
.long edata
.long end
.long multiboot_entry
# Multiboot entry point. Machine is mostly set up.
# Configure the GDT to match the environment that our usual
# boot loader - bootasm.S - sets up.
.globl multiboot_entry
multiboot_entry:
lgdt RELOC(gdtdesc)
ljmp $(SEG_KCODE<<3), $mbstart32
mbstart32:
# Set up the protected-mode data segment registers
movw $(SEG_KDATA<<3), %ax # Our data segment selector
movw %ax, %ds # -> DS: Data Segment
movw %ax, %es # -> ES: Extra Segment
movw %ax, %ss # -> SS: Stack Segment
movw $0, %ax # Zero segments not ready for use
movw %ax, %fs # -> FS
movw %ax, %gs # -> GS
# Set up the stack pointer and call into C.
movl $(stack + STACK), %esp
call main
spin:
jmp spin
# Bootstrap GDT
.p2align 2 # force 4 byte alignment
gdt:
SEG_NULLASM # null seg
SEG_ASM(STA_X|STA_R, -KERNBASE, 0xffffffff) # code seg
SEG_ASM(STA_W, -KERNBASE, 0xffffffff) # data seg
gdtdesc:
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.long RELOC(gdt) # address gdt
.comm stack, STACK
net.c
浏览文件 @
2224e0e7
...
@@ -37,12 +37,16 @@ netalloc(void)
...
@@ -37,12 +37,16 @@ netalloc(void)
int
int
nettx
(
void
*
va
,
u16
len
)
nettx
(
void
*
va
,
u16
len
)
{
{
if
(
e1000init
==
0
)
return
-
1
;
return
e1000tx
(
va
,
len
);
return
e1000tx
(
va
,
len
);
}
}
void
void
nethwaddr
(
u8
*
hwaddr
)
nethwaddr
(
u8
*
hwaddr
)
{
{
if
(
e1000init
==
0
)
return
;
e1000hwaddr
(
hwaddr
);
e1000hwaddr
(
hwaddr
);
}
}
...
...
prof.c
浏览文件 @
2224e0e7
#include "types.h"
#include "types.h"
#include "kernel.h"
#include "spinlock.h"
#include "spinlock.h"
#include "condvar.h"
#include "condvar.h"
#include "fs.h"
#include "fs.h"
#include "file.h"
#include "file.h"
#include "prof.h"
#include "prof.h"
#include "kernel.h"
#include "bits.h"
#include "bits.h"
#include "amd64.h"
#include "amd64.h"
...
...
sampler.c
浏览文件 @
2224e0e7
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include "condvar.h"
#include "condvar.h"
#include "fs.h"
#include "fs.h"
#include "file.h"
#include "file.h"
#include "prof.h"
#include "kernel.h"
#include "kernel.h"
#include "bits.h"
#include "bits.h"
#include "amd64.h"
#include "amd64.h"
...
...
trap.c
浏览文件 @
2224e0e7
...
@@ -115,12 +115,8 @@ trap(struct trapframe *tf)
...
@@ -115,12 +115,8 @@ trap(struct trapframe *tf)
break
;
break
;
}
}
if
(
myproc
()
==
0
||
(
tf
->
cs
&
3
)
==
0
){
if
(
myproc
()
==
0
||
(
tf
->
cs
&
3
)
==
0
)
// In kernel, it must be our mistake.
kerneltrap
(
tf
);
cprintf
(
"unexpected trap %d from cpu %d rip %lx (cr2=0x%lx)
\n
"
,
tf
->
trapno
,
mycpu
()
->
id
,
tf
->
rip
,
rcr2
());
panic
(
"trap"
);
}
if
(
tf
->
trapno
==
T_PGFLT
){
if
(
tf
->
trapno
==
T_PGFLT
){
uptr
addr
=
rcr2
();
uptr
addr
=
rcr2
();
...
...
types.h
浏览文件 @
2224e0e7
...
@@ -18,6 +18,3 @@ typedef uptr paddr;
...
@@ -18,6 +18,3 @@ typedef uptr paddr;
typedef
u64
pme_t
;
// Page Map Entry (refers to any entry in any level)
typedef
u64
pme_t
;
// Page Map Entry (refers to any entry in any level)
typedef
pme_t
pml4e_t
;
typedef
pme_t
pml4e_t
;
#define __mpalign__ __attribute__((aligned(CACHELINE)))
#define __padout__ char __padout[0] __attribute__((aligned(CACHELINE)))
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论