Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
a56c8d60
提交
a56c8d60
8月 08, 2011
创建
作者:
Frans Kaashoek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
One definition of several macros and constants
上级
11b7438b
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
25 行增加
和
33 行删除
+25
-33
bootasm.S
bootasm.S
+3
-5
bootother.S
bootother.S
+4
-10
memlayout.h
memlayout.h
+3
-1
mmu.h
mmu.h
+11
-0
multiboot.S
multiboot.S
+3
-7
proc.h
proc.h
+0
-7
trapasm.S
trapasm.S
+1
-3
没有找到文件。
bootasm.S
浏览文件 @
a56c8d60
#include "asm.h"
#include "asm.h"
#include "memlayout.h"
#include "mmu.h"
# Start the first CPU: switch to 32-bit protected mode, jump into C.
# Start the first CPU: switch to 32-bit protected mode, jump into C.
# The BIOS loads this code from the first sector of the hard disk into
# The BIOS loads this code from the first sector of the hard disk into
# memory at physical address 0x7c00 and starts executing in real mode
# memory at physical address 0x7c00 and starts executing in real mode
# with %cs=0 %ip=7c00.
# with %cs=0 %ip=7c00.
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
#define CR0_PE 1 // protected mode enable bit
.code16 # Assemble for 16-bit mode
.code16 # Assemble for 16-bit mode
.globl start
.globl start
start:
start:
...
@@ -88,3 +85,4 @@ gdt:
...
@@ -88,3 +85,4 @@ gdt:
gdtdesc:
gdtdesc:
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.long gdt # address gdt
.long gdt # address gdt
bootother.S
浏览文件 @
a56c8d60
#include "asm.h"
#include "asm.h"
#include "memlayout.h"
#include "memlayout.h"
#include "mmu.h"
# Each non-boot CPU ("AP") is started up in response to a STARTUP
# Each non-boot CPU ("AP") is started up in response to a STARTUP
# IPI from the boot CPU. Section B.4.2 of the Multi-Processor
# IPI from the boot CPU. Section B.4.2 of the Multi-Processor
# Specification says that the AP will start in real mode with CS:IP
# Specification says that the AP will start in real mode with CS:IP
...
@@ -20,13 +21,6 @@
...
@@ -20,13 +21,6 @@
# - it uses the address at start-4 for the %esp
# - it uses the address at start-4 for the %esp
# - it jumps to the address at start-8 instead of calling bootmain
# - it jumps to the address at start-8 instead of calling bootmain
#define SEG_KCODE 1
#define SEG_KDATA 2
#define CR0_PE 1
#define RELOC1(x) ((x) + KERNBASE) // same as V2P, but without casts
.code16
.code16
.globl start
.globl start
start:
start:
...
@@ -56,10 +50,10 @@ start32:
...
@@ -56,10 +50,10 @@ start32:
movw %ax, %gs
movw %ax, %gs
# switch to the stack allocated by bootothers()
# switch to the stack allocated by bootothers()
movl
RELOC1
(start-4), %esp
movl
P2V_WO
(start-4), %esp
# call mpmain()
# call mpmain()
call *(
RELOC1
(start)-8)
call *(
P2V_WO
(start)-8)
movw $0x8a00, %ax
movw $0x8a00, %ax
movw %ax, %dx
movw %ax, %dx
...
...
memlayout.h
浏览文件 @
a56c8d60
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#define IOSPACEE 0x100000 // end IO space
#define IOSPACEE 0x100000 // end IO space
#define PHYSTOP 0xE000000 // use phys mem up to here as free pool
#define PHYSTOP 0xE000000 // use phys mem up to here as free pool
// Key addresses for address space layout (see kmap in vm.c for the
actual
layout)
// Key addresses for address space layout (see kmap in vm.c for the layout)
#define KERNBASE 0xF0000000 // First kernel virtual address
#define KERNBASE 0xF0000000 // First kernel virtual address
#define USERTOP (KERNBASE-PGSIZE) // Highest user virtual address
#define USERTOP (KERNBASE-PGSIZE) // Highest user virtual address
#define KERNLINK 0xF0100000 // Address where kernel is linked
#define KERNLINK 0xF0100000 // Address where kernel is linked
...
@@ -24,3 +24,5 @@ static inline void *p2v(uint a) { return (void *) a + KERNBASE; }
...
@@ -24,3 +24,5 @@ static inline void *p2v(uint a) { return (void *) a + KERNBASE; }
#define V2P(a) ((uint) a - KERNBASE)
#define V2P(a) ((uint) a - KERNBASE)
#define P2V(a) ((void *) a + KERNBASE)
#define P2V(a) ((void *) a + KERNBASE)
#define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts
#define P2V_WO(x) ((x) + KERNBASE) // same as V2P, but without casts
mmu.h
浏览文件 @
a56c8d60
...
@@ -37,7 +37,15 @@
...
@@ -37,7 +37,15 @@
#define CR0_CD 0x40000000 // Cache Disable
#define CR0_CD 0x40000000 // Cache Disable
#define CR0_PG 0x80000000 // Paging
#define CR0_PG 0x80000000 // Paging
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
#define SEG_KCPU 3 // kernel per-cpu data
#define SEG_UCODE 4 // user code
#define SEG_UDATA 5 // user data+stack
#define SEG_TSS 6 // this process's task state
//PAGEBREAK!
//PAGEBREAK!
#ifndef __ASSEMBLER__
// Segment Descriptor
// Segment Descriptor
struct
segdesc
{
struct
segdesc
{
uint
lim_15_0
:
16
;
// Low bits of segment limit
uint
lim_15_0
:
16
;
// Low bits of segment limit
...
@@ -64,6 +72,7 @@ struct segdesc {
...
@@ -64,6 +72,7 @@ struct segdesc {
{ (lim) & 0xffff, (uint)(base) & 0xffff, \
{ (lim) & 0xffff, (uint)(base) & 0xffff, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
((uint)(base) >> 16) & 0xff, type, 1, dpl, 1, \
(uint)(lim) >> 16, 0, 0, 1, 0, (uint)(base) >> 24 }
(uint)(lim) >> 16, 0, 0, 1, 0, (uint)(base) >> 24 }
#endif
#define DPL_USER 0x3 // User DPL
#define DPL_USER 0x3 // User DPL
...
@@ -130,6 +139,7 @@ struct segdesc {
...
@@ -130,6 +139,7 @@ struct segdesc {
// Address in page table or page directory entry
// Address in page table or page directory entry
#define PTE_ADDR(pte) ((uint)(pte) & ~0xFFF)
#define PTE_ADDR(pte) ((uint)(pte) & ~0xFFF)
#ifndef __ASSEMBLER__
typedef
uint
pte_t
;
typedef
uint
pte_t
;
// Task state segment format
// Task state segment format
...
@@ -208,3 +218,4 @@ struct gatedesc {
...
@@ -208,3 +218,4 @@ struct gatedesc {
(gate).off_31_16 = (uint)(off) >> 16; \
(gate).off_31_16 = (uint)(off) >> 16; \
}
}
#endif
multiboot.S
浏览文件 @
a56c8d60
...
@@ -16,14 +16,10 @@
...
@@ -16,14 +16,10 @@
#include "asm.h"
#include "asm.h"
#include "memlayout.h"
#include "memlayout.h"
#include "mmu.h"
#define RELOC(x) ((x) - KERNBASE) // same as V2P, but without casts
#define STACK 4096
#define STACK 4096
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
# Multiboot header. Data to direct multiboot loader.
# Multiboot header. Data to direct multiboot loader.
.p2align 2
.p2align 2
.text
.text
...
@@ -45,7 +41,7 @@ multiboot_header:
...
@@ -45,7 +41,7 @@ multiboot_header:
# boot loader - bootasm.S - sets up.
# boot loader - bootasm.S - sets up.
.globl multiboot_entry
.globl multiboot_entry
multiboot_entry:
multiboot_entry:
lgdt
RELOC
(gdtdesc)
lgdt
V2P_WO
(gdtdesc)
ljmp $(SEG_KCODE<<3), $mbstart32
ljmp $(SEG_KCODE<<3), $mbstart32
mbstart32:
mbstart32:
...
@@ -73,6 +69,6 @@ gdt:
...
@@ -73,6 +69,6 @@ gdt:
gdtdesc:
gdtdesc:
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.word (gdtdesc - gdt - 1) # sizeof(gdt) - 1
.long
RELOC
(gdt) # address gdt
.long
V2P_WO
(gdt) # address gdt
.comm stack, STACK
.comm stack, STACK
proc.h
浏览文件 @
a56c8d60
// Segments in proc->gdt.
// Segments in proc->gdt.
// Also known to bootasm.S and trapasm.S
#define SEG_KCODE 1 // kernel code
#define SEG_KDATA 2 // kernel data+stack
#define SEG_KCPU 3 // kernel per-cpu data
#define SEG_UCODE 4 // user code
#define SEG_UDATA 5 // user data+stack
#define SEG_TSS 6 // this process's task state
#define NSEGS 7
#define NSEGS 7
// Per-CPU state
// Per-CPU state
...
...
trapasm.S
浏览文件 @
a56c8d60
#define SEG_KCODE 1 // kernel code
#include "mmu.h"
#define SEG_KDATA 2 // kernel data+stack
#define SEG_KCPU 3 // kernel per-cpu data
# vectors.S sends all traps here.
# vectors.S sends all traps here.
.globl alltraps
.globl alltraps
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论