Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
21575761
提交
21575761
3月 08, 2009
创建
作者:
rsc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
be consistent: no underscores in function names
上级
b7f653dc
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
121 行增加
和
136 行删除
+121
-136
bio.c
bio.c
+2
-2
console.c
console.c
+23
-23
defs.h
defs.h
+18
-18
ide.c
ide.c
+17
-17
ioapic.c
ioapic.c
+12
-12
kbd.c
kbd.c
+3
-3
lapic.c
lapic.c
+5
-5
main.c
main.c
+10
-10
mp.c
mp.c
+14
-14
picirq.c
picirq.c
+5
-5
proc.c
proc.c
+1
-1
spinlock.c
spinlock.c
+2
-2
timer.c
timer.c
+2
-2
trap.c
trap.c
+6
-6
x86.h
x86.h
+1
-16
没有找到文件。
bio.c
浏览文件 @
21575761
...
...
@@ -100,7 +100,7 @@ bread(uint dev, uint sector)
b
=
bget
(
dev
,
sector
);
if
(
!
(
b
->
flags
&
B_VALID
))
ide
_
rw
(
b
);
iderw
(
b
);
return
b
;
}
...
...
@@ -111,7 +111,7 @@ bwrite(struct buf *b)
if
((
b
->
flags
&
B_BUSY
)
==
0
)
panic
(
"bwrite"
);
b
->
flags
|=
B_DIRTY
;
ide
_
rw
(
b
);
iderw
(
b
);
}
// Release the buffer buf.
...
...
console.c
浏览文件 @
21575761
...
...
@@ -26,7 +26,7 @@ int use_console_lock = 0;
// .bochsrc to copy to the stdout:
// parport1: enabled=1, file="/dev/stdout"
static
void
lpt
_
putc
(
int
c
)
lptputc
(
int
c
)
{
int
i
;
...
...
@@ -40,7 +40,7 @@ lpt_putc(int c)
}
static
void
cga
_
putc
(
int
c
)
cgaputc
(
int
c
)
{
int
pos
;
...
...
@@ -72,7 +72,7 @@ cga_putc(int c)
}
void
cons
_
putc
(
int
c
)
consputc
(
int
c
)
{
if
(
panicked
){
cli
();
...
...
@@ -80,8 +80,8 @@ cons_putc(int c)
;
}
lpt
_
putc
(
c
);
cga
_
putc
(
c
);
lptputc
(
c
);
cgaputc
(
c
);
}
void
...
...
@@ -106,7 +106,7 @@ printint(int xx, int base, int sgn)
buf
[
i
++
]
=
'-'
;
while
(
--
i
>=
0
)
cons
_
putc
(
buf
[
i
]);
consputc
(
buf
[
i
]);
}
// Print to the console. only understands %d, %x, %p, %s.
...
...
@@ -130,7 +130,7 @@ cprintf(char *fmt, ...)
if
(
c
==
'%'
)
state
=
'%'
;
else
cons
_
putc
(
c
);
consputc
(
c
);
break
;
case
'%'
:
...
...
@@ -147,15 +147,15 @@ cprintf(char *fmt, ...)
if
(
s
==
0
)
s
=
"(null)"
;
for
(;
*
s
;
s
++
)
cons
_
putc
(
*
s
);
consputc
(
*
s
);
break
;
case
'%'
:
cons
_
putc
(
'%'
);
consputc
(
'%'
);
break
;
default:
// Print unknown % sequence to draw attention.
cons
_
putc
(
'%'
);
cons
_
putc
(
c
);
consputc
(
'%'
);
consputc
(
c
);
break
;
}
state
=
0
;
...
...
@@ -168,14 +168,14 @@ cprintf(char *fmt, ...)
}
int
console
_
write
(
struct
inode
*
ip
,
char
*
buf
,
int
n
)
consolewrite
(
struct
inode
*
ip
,
char
*
buf
,
int
n
)
{
int
i
;
iunlock
(
ip
);
acquire
(
&
console_lock
);
for
(
i
=
0
;
i
<
n
;
i
++
)
cons
_
putc
(
buf
[
i
]
&
0xff
);
consputc
(
buf
[
i
]
&
0xff
);
release
(
&
console_lock
);
ilock
(
ip
);
...
...
@@ -194,7 +194,7 @@ struct {
#define C(x) ((x)-'@') // Control-x
void
console
_
intr
(
int
(
*
getc
)(
void
))
consoleintr
(
int
(
*
getc
)(
void
))
{
int
c
;
...
...
@@ -208,19 +208,19 @@ console_intr(int (*getc)(void))
while
(
input
.
e
!=
input
.
w
&&
input
.
buf
[(
input
.
e
-
1
)
%
INPUT_BUF
]
!=
'\n'
){
input
.
e
--
;
cons
_
putc
(
BACKSPACE
);
consputc
(
BACKSPACE
);
}
break
;
case
C
(
'H'
):
// Backspace
if
(
input
.
e
!=
input
.
w
){
input
.
e
--
;
cons
_
putc
(
BACKSPACE
);
consputc
(
BACKSPACE
);
}
break
;
default:
if
(
c
!=
0
&&
input
.
e
-
input
.
r
<
INPUT_BUF
){
input
.
buf
[
input
.
e
++
%
INPUT_BUF
]
=
c
;
cons
_
putc
(
c
);
consputc
(
c
);
if
(
c
==
'\n'
||
c
==
C
(
'D'
)
||
input
.
e
==
input
.
r
+
INPUT_BUF
){
input
.
w
=
input
.
e
;
wakeup
(
&
input
.
r
);
...
...
@@ -233,7 +233,7 @@ console_intr(int (*getc)(void))
}
int
console
_
read
(
struct
inode
*
ip
,
char
*
dst
,
int
n
)
consoleread
(
struct
inode
*
ip
,
char
*
dst
,
int
n
)
{
uint
target
;
int
c
;
...
...
@@ -271,17 +271,17 @@ console_read(struct inode *ip, char *dst, int n)
}
void
console
_
init
(
void
)
consoleinit
(
void
)
{
initlock
(
&
console_lock
,
"console"
);
initlock
(
&
input
.
lock
,
"console input"
);
devsw
[
CONSOLE
].
write
=
console
_
write
;
devsw
[
CONSOLE
].
read
=
console
_
read
;
devsw
[
CONSOLE
].
write
=
consolewrite
;
devsw
[
CONSOLE
].
read
=
consoleread
;
use_console_lock
=
1
;
pic
_
enable
(
IRQ_KBD
);
ioapic
_
enable
(
IRQ_KBD
,
0
);
picenable
(
IRQ_KBD
);
ioapicenable
(
IRQ_KBD
,
0
);
}
void
...
...
defs.h
浏览文件 @
21575761
...
...
@@ -14,9 +14,9 @@ void brelse(struct buf*);
void
bwrite
(
struct
buf
*
);
// console.c
void
console
_
init
(
void
);
void
consoleinit
(
void
);
void
cprintf
(
char
*
,
...);
void
console
_
intr
(
int
(
*
)(
void
));
void
consoleintr
(
int
(
*
)(
void
));
void
panic
(
char
*
)
__attribute__
((
noreturn
));
// exec.c
...
...
@@ -50,14 +50,14 @@ void stati(struct inode*, struct stat*);
int
writei
(
struct
inode
*
,
char
*
,
uint
,
uint
);
// ide.c
void
ide
_
init
(
void
);
void
ide
_
intr
(
void
);
void
ide
_
rw
(
struct
buf
*
);
void
ideinit
(
void
);
void
ideintr
(
void
);
void
iderw
(
struct
buf
*
);
// ioapic.c
void
ioapic
_
enable
(
int
irq
,
int
cpu
);
extern
uchar
ioapic
_
id
;
void
ioapic
_
init
(
void
);
void
ioapicenable
(
int
irq
,
int
cpu
);
extern
uchar
ioapicid
;
void
ioapicinit
(
void
);
// kalloc.c
char
*
kalloc
(
int
);
...
...
@@ -65,24 +65,24 @@ void kfree(char*, int);
void
kinit
(
void
);
// kbd.c
void
kbd
_
intr
(
void
);
void
kbdintr
(
void
);
// lapic.c
int
cpu
(
void
);
extern
volatile
uint
*
lapic
;
void
lapic
_
eoi
(
void
);
void
lapic
_
init
(
int
);
void
lapic
_
startap
(
uchar
,
uint
);
void
lapiceoi
(
void
);
void
lapicinit
(
int
);
void
lapicstartap
(
uchar
,
uint
);
// mp.c
extern
int
ismp
;
int
mp
_
bcpu
(
void
);
void
mp
_
init
(
void
);
void
mp
_
startthem
(
void
);
int
mpbcpu
(
void
);
void
mpinit
(
void
);
void
mpstartthem
(
void
);
// picirq.c
void
pic
_
enable
(
int
);
void
pic
_
init
(
void
);
void
picenable
(
int
);
void
picinit
(
void
);
// pipe.c
int
pipealloc
(
struct
file
**
,
struct
file
**
);
...
...
@@ -136,7 +136,7 @@ int fetchstr(struct proc*, uint, char**);
void
syscall
(
void
);
// timer.c
void
timer
_
init
(
void
);
void
timerinit
(
void
);
// trap.c
void
idtinit
(
void
);
...
...
ide.c
浏览文件 @
21575761
...
...
@@ -26,11 +26,11 @@ static struct spinlock ide_lock;
static
struct
buf
*
ide_queue
;
static
int
disk_1_present
;
static
void
ide
_start_request
(
);
static
void
ide
start
(
struct
buf
*
);
// Wait for IDE disk to become ready.
static
int
ide
_wait_ready
(
int
check_error
)
ide
wait
(
int
check_error
)
{
int
r
;
...
...
@@ -42,14 +42,14 @@ ide_wait_ready(int check_error)
}
void
ide
_
init
(
void
)
ideinit
(
void
)
{
int
i
;
initlock
(
&
ide_lock
,
"ide"
);
pic
_
enable
(
IRQ_IDE
);
ioapic
_
enable
(
IRQ_IDE
,
ncpu
-
1
);
ide
_wait_ready
(
0
);
picenable
(
IRQ_IDE
);
ioapicenable
(
IRQ_IDE
,
ncpu
-
1
);
ide
wait
(
0
);
// Check if disk 1 is present
outb
(
0x1f6
,
0xe0
|
(
1
<<
4
));
...
...
@@ -66,12 +66,12 @@ ide_init(void)
// Start the request for b. Caller must hold ide_lock.
static
void
ide
_start_reques
t
(
struct
buf
*
b
)
ide
star
t
(
struct
buf
*
b
)
{
if
(
b
==
0
)
panic
(
"ide
_start_reques
t"
);
panic
(
"ide
star
t"
);
ide
_wait_ready
(
0
);
ide
wait
(
0
);
outb
(
0x3f6
,
0
);
// generate interrupt
outb
(
0x1f2
,
1
);
// number of sectors
outb
(
0x1f3
,
b
->
sector
&
0xff
);
...
...
@@ -88,7 +88,7 @@ ide_start_request(struct buf *b)
// Interrupt handler.
void
ide
_
intr
(
void
)
ideintr
(
void
)
{
struct
buf
*
b
;
...
...
@@ -99,7 +99,7 @@ ide_intr(void)
}
// Read data if needed.
if
(
!
(
b
->
flags
&
B_DIRTY
)
&&
ide
_wait_ready
(
1
)
>=
0
)
if
(
!
(
b
->
flags
&
B_DIRTY
)
&&
ide
wait
(
1
)
>=
0
)
insl
(
0x1f0
,
b
->
data
,
512
/
4
);
// Wake process waiting for this buf.
...
...
@@ -109,7 +109,7 @@ ide_intr(void)
// Start disk on next buf in queue.
if
((
ide_queue
=
b
->
qnext
)
!=
0
)
ide
_start_reques
t
(
ide_queue
);
ide
star
t
(
ide_queue
);
release
(
&
ide_lock
);
}
...
...
@@ -119,16 +119,16 @@ ide_intr(void)
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID.
void
ide
_
rw
(
struct
buf
*
b
)
iderw
(
struct
buf
*
b
)
{
struct
buf
**
pp
;
if
(
!
(
b
->
flags
&
B_BUSY
))
panic
(
"ide
_
rw: buf not busy"
);
panic
(
"iderw: buf not busy"
);
if
((
b
->
flags
&
(
B_VALID
|
B_DIRTY
))
==
B_VALID
)
panic
(
"ide
_
rw: nothing to do"
);
panic
(
"iderw: nothing to do"
);
if
(
b
->
dev
!=
0
&&
!
disk_1_present
)
panic
(
"ide disk 1 not present"
);
panic
(
"id
rw: id
e disk 1 not present"
);
acquire
(
&
ide_lock
);
...
...
@@ -140,7 +140,7 @@ ide_rw(struct buf *b)
// Start disk if necessary.
if
(
ide_queue
==
b
)
ide
_start_reques
t
(
b
);
ide
star
t
(
b
);
// Wait for request to finish.
// Assuming will not sleep too long: ignore cp->killed.
...
...
ioapic.c
浏览文件 @
21575761
...
...
@@ -32,21 +32,21 @@ struct ioapic {
};
static
uint
ioapic
_
read
(
int
reg
)
ioapicread
(
int
reg
)
{
ioapic
->
reg
=
reg
;
return
ioapic
->
data
;
}
static
void
ioapic
_
write
(
int
reg
,
uint
data
)
ioapicwrite
(
int
reg
,
uint
data
)
{
ioapic
->
reg
=
reg
;
ioapic
->
data
=
data
;
}
void
ioapic
_
init
(
void
)
ioapicinit
(
void
)
{
int
i
,
id
,
maxintr
;
...
...
@@ -54,21 +54,21 @@ ioapic_init(void)
return
;
ioapic
=
(
volatile
struct
ioapic
*
)
IOAPIC
;
maxintr
=
(
ioapic
_
read
(
REG_VER
)
>>
16
)
&
0xFF
;
id
=
ioapic
_
read
(
REG_ID
)
>>
24
;
if
(
id
!=
ioapic
_
id
)
cprintf
(
"ioapic
_init: id isn't equal to ioapic_
id; not a MP
\n
"
);
maxintr
=
(
ioapicread
(
REG_VER
)
>>
16
)
&
0xFF
;
id
=
ioapicread
(
REG_ID
)
>>
24
;
if
(
id
!=
ioapicid
)
cprintf
(
"ioapic
init: id isn't equal to ioapic
id; not a MP
\n
"
);
// Mark all interrupts edge-triggered, active high, disabled,
// and not routed to any CPUs.
for
(
i
=
0
;
i
<=
maxintr
;
i
++
){
ioapic
_
write
(
REG_TABLE
+
2
*
i
,
INT_DISABLED
|
(
IRQ_OFFSET
+
i
));
ioapic
_
write
(
REG_TABLE
+
2
*
i
+
1
,
0
);
ioapicwrite
(
REG_TABLE
+
2
*
i
,
INT_DISABLED
|
(
IRQ_OFFSET
+
i
));
ioapicwrite
(
REG_TABLE
+
2
*
i
+
1
,
0
);
}
}
void
ioapic
_
enable
(
int
irq
,
int
cpunum
)
ioapicenable
(
int
irq
,
int
cpunum
)
{
if
(
!
ismp
)
return
;
...
...
@@ -76,6 +76,6 @@ ioapic_enable(int irq, int cpunum)
// Mark interrupt edge-triggered, active high,
// enabled, and routed to the given cpunum,
// which happens to be that cpu's APIC ID.
ioapic
_
write
(
REG_TABLE
+
2
*
irq
,
IRQ_OFFSET
+
irq
);
ioapic
_
write
(
REG_TABLE
+
2
*
irq
+
1
,
cpunum
<<
24
);
ioapicwrite
(
REG_TABLE
+
2
*
irq
,
IRQ_OFFSET
+
irq
);
ioapicwrite
(
REG_TABLE
+
2
*
irq
+
1
,
cpunum
<<
24
);
}
kbd.c
浏览文件 @
21575761
...
...
@@ -4,7 +4,7 @@
#include "kbd.h"
int
kbd
_
getc
(
void
)
kbdgetc
(
void
)
{
static
uint
shift
;
static
uchar
*
charcode
[
4
]
=
{
...
...
@@ -44,7 +44,7 @@ kbd_getc(void)
}
void
kbd
_
intr
(
void
)
kbdintr
(
void
)
{
console
_intr
(
kbd_
getc
);
console
intr
(
kbd
getc
);
}
lapic.c
浏览文件 @
21575761
...
...
@@ -46,7 +46,7 @@ lapicw(int index, int value)
//PAGEBREAK!
void
lapic
_
init
(
int
c
)
lapicinit
(
int
c
)
{
if
(
!
lapic
)
return
;
...
...
@@ -99,11 +99,11 @@ cpu(void)
// Would prefer to panic but even printing is chancy here:
// almost everything, including cprintf and panic, calls cpu,
// often indirectly through acquire and release.
if
(
read
_
eflags
()
&
FL_IF
){
if
(
readeflags
()
&
FL_IF
){
static
int
n
;
if
(
n
++
==
0
)
cprintf
(
"cpu called from %x with interrupts enabled
\n
"
,
((
uint
*
)
read_ebp
())[
1
]
);
__builtin_return_address
(
0
)
);
}
if
(
lapic
)
...
...
@@ -113,7 +113,7 @@ cpu(void)
// Acknowledge interrupt.
void
lapic
_
eoi
(
void
)
lapiceoi
(
void
)
{
if
(
lapic
)
lapicw
(
EOI
,
0
);
...
...
@@ -136,7 +136,7 @@ microdelay(int us)
// Start additional processor running bootstrap code at addr.
// See Appendix B of MultiProcessor Specification.
void
lapic
_
startap
(
uchar
apicid
,
uint
addr
)
lapicstartap
(
uchar
apicid
,
uint
addr
)
{
int
i
;
ushort
*
wrv
;
...
...
main.c
浏览文件 @
21575761
...
...
@@ -12,22 +12,22 @@ static void mpmain(void) __attribute__((noreturn));
int
main
(
void
)
{
mp
_
init
();
// collect info about this machine
lapic
_init
(
mp_
bcpu
());
mpinit
();
// collect info about this machine
lapic
init
(
mp
bcpu
());
cprintf
(
"
\n
cpu%d: starting xv6
\n\n
"
,
cpu
());
pinit
();
// process table
binit
();
// buffer cache
pic
_
init
();
// interrupt controller
ioapic
_
init
();
// another interrupt controller
picinit
();
// interrupt controller
ioapicinit
();
// another interrupt controller
kinit
();
// physical memory allocator
tvinit
();
// trap vectors
fileinit
();
// file table
iinit
();
// inode cache
console
_
init
();
// I/O devices & their interrupts
ide
_
init
();
// disk
consoleinit
();
// I/O devices & their interrupts
ideinit
();
// disk
if
(
!
ismp
)
timer
_
init
();
// uniprocessor timer
timerinit
();
// uniprocessor timer
userinit
();
// first user process
bootothers
();
// start other processors
...
...
@@ -42,8 +42,8 @@ mpmain(void)
{
cprintf
(
"cpu%d: mpmain
\n
"
,
cpu
());
idtinit
();
if
(
cpu
()
!=
mp
_
bcpu
())
lapic
_
init
(
cpu
());
if
(
cpu
()
!=
mpbcpu
())
lapicinit
(
cpu
());
setupsegs
(
0
);
xchg
(
&
cpus
[
cpu
()].
booted
,
1
);
...
...
@@ -71,7 +71,7 @@ bootothers(void)
stack
=
kalloc
(
KSTACKSIZE
);
*
(
void
**
)(
code
-
4
)
=
stack
+
KSTACKSIZE
;
*
(
void
**
)(
code
-
8
)
=
mpmain
;
lapic
_
startap
(
c
->
apicid
,
(
uint
)
code
);
lapicstartap
(
c
->
apicid
,
(
uint
)
code
);
// Wait for cpu to get through bootstrap.
while
(
c
->
booted
==
0
)
...
...
mp.c
浏览文件 @
21575761
...
...
@@ -14,10 +14,10 @@ struct cpu cpus[NCPU];
static
struct
cpu
*
bcpu
;
int
ismp
;
int
ncpu
;
uchar
ioapic
_
id
;
uchar
ioapicid
;
int
mp
_
bcpu
(
void
)
mpbcpu
(
void
)
{
return
bcpu
-
cpus
;
}
...
...
@@ -35,7 +35,7 @@ sum(uchar *addr, int len)
// Look for an MP structure in the len bytes at addr.
static
struct
mp
*
mp
_
search1
(
uchar
*
addr
,
int
len
)
mpsearch1
(
uchar
*
addr
,
int
len
)
{
uchar
*
e
,
*
p
;
...
...
@@ -52,7 +52,7 @@ mp_search1(uchar *addr, int len)
// 2) in the last KB of system base memory;
// 3) in the BIOS ROM between 0xE0000 and 0xFFFFF.
static
struct
mp
*
mp
_
search
(
void
)
mpsearch
(
void
)
{
uchar
*
bda
;
uint
p
;
...
...
@@ -60,14 +60,14 @@ mp_search(void)
bda
=
(
uchar
*
)
0x400
;
if
((
p
=
((
bda
[
0x0F
]
<<
8
)
|
bda
[
0x0E
])
<<
4
)){
if
((
mp
=
mp
_
search1
((
uchar
*
)
p
,
1024
)))
if
((
mp
=
mpsearch1
((
uchar
*
)
p
,
1024
)))
return
mp
;
}
else
{
p
=
((
bda
[
0x14
]
<<
8
)
|
bda
[
0x13
])
*
1024
;
if
((
mp
=
mp
_
search1
((
uchar
*
)
p
-
1024
,
1024
)))
if
((
mp
=
mpsearch1
((
uchar
*
)
p
-
1024
,
1024
)))
return
mp
;
}
return
mp
_
search1
((
uchar
*
)
0xF0000
,
0x10000
);
return
mpsearch1
((
uchar
*
)
0xF0000
,
0x10000
);
}
// Search for an MP configuration table. For now,
...
...
@@ -76,12 +76,12 @@ mp_search(void)
// if correct, check the version.
// To do: check extended table checksum.
static
struct
mpconf
*
mp
_
config
(
struct
mp
**
pmp
)
mpconfig
(
struct
mp
**
pmp
)
{
struct
mpconf
*
conf
;
struct
mp
*
mp
;
if
((
mp
=
mp
_
search
())
==
0
||
mp
->
physaddr
==
0
)
if
((
mp
=
mpsearch
())
==
0
||
mp
->
physaddr
==
0
)
return
0
;
conf
=
(
struct
mpconf
*
)
mp
->
physaddr
;
if
(
memcmp
(
conf
,
"PCMP"
,
4
)
!=
0
)
...
...
@@ -95,7 +95,7 @@ mp_config(struct mp **pmp)
}
void
mp
_
init
(
void
)
mpinit
(
void
)
{
uchar
*
p
,
*
e
;
struct
mp
*
mp
;
...
...
@@ -104,7 +104,7 @@ mp_init(void)
struct
mpioapic
*
ioapic
;
bcpu
=
&
cpus
[
ncpu
];
if
((
conf
=
mp
_
config
(
&
mp
))
==
0
)
if
((
conf
=
mpconfig
(
&
mp
))
==
0
)
return
;
ismp
=
1
;
...
...
@@ -122,7 +122,7 @@ mp_init(void)
continue
;
case
MPIOAPIC
:
ioapic
=
(
struct
mpioapic
*
)
p
;
ioapic
_
id
=
ioapic
->
apicno
;
ioapicid
=
ioapic
->
apicno
;
p
+=
sizeof
(
struct
mpioapic
);
continue
;
case
MPBUS
:
...
...
@@ -131,8 +131,8 @@ mp_init(void)
p
+=
8
;
continue
;
default:
cprintf
(
"mp
_
init: unknown config type %x
\n
"
,
*
p
);
panic
(
"mp
_
init"
);
cprintf
(
"mpinit: unknown config type %x
\n
"
,
*
p
);
panic
(
"mpinit"
);
}
}
...
...
picirq.c
浏览文件 @
21575761
...
...
@@ -15,7 +15,7 @@
static
ushort
irqmask
=
0xFFFF
&
~
(
1
<<
IRQ_SLAVE
);
static
void
pic
_
setmask
(
ushort
mask
)
picsetmask
(
ushort
mask
)
{
irqmask
=
mask
;
outb
(
IO_PIC1
+
1
,
mask
);
...
...
@@ -23,14 +23,14 @@ pic_setmask(ushort mask)
}
void
pic
_
enable
(
int
irq
)
picenable
(
int
irq
)
{
pic
_
setmask
(
irqmask
&
~
(
1
<<
irq
));
picsetmask
(
irqmask
&
~
(
1
<<
irq
));
}
// Initialize the 8259A interrupt controllers.
void
pic
_
init
(
void
)
picinit
(
void
)
{
// mask all interrupts
outb
(
IO_PIC1
+
1
,
0xFF
);
...
...
@@ -80,5 +80,5 @@ pic_init(void)
outb
(
IO_PIC2
,
0x0a
);
// OCW3
if
(
irqmask
!=
0xFFFF
)
pic
_
setmask
(
irqmask
);
picsetmask
(
irqmask
);
}
proc.c
浏览文件 @
21575761
...
...
@@ -242,7 +242,7 @@ sched(void)
{
int
intena
;
if
(
read
_
eflags
()
&
FL_IF
)
if
(
readeflags
()
&
FL_IF
)
panic
(
"sched interruptible"
);
if
(
cp
->
state
==
RUNNING
)
panic
(
"sched running"
);
...
...
spinlock.c
浏览文件 @
21575761
...
...
@@ -100,7 +100,7 @@ pushcli(void)
{
int
eflags
;
eflags
=
read
_
eflags
();
eflags
=
readeflags
();
cli
();
if
(
cpus
[
cpu
()].
ncli
++
==
0
)
cpus
[
cpu
()].
intena
=
eflags
&
FL_IF
;
...
...
@@ -109,7 +109,7 @@ pushcli(void)
void
popcli
(
void
)
{
if
(
read
_
eflags
()
&
FL_IF
)
if
(
readeflags
()
&
FL_IF
)
panic
(
"popcli - interruptible"
);
if
(
--
cpus
[
cpu
()].
ncli
<
0
)
panic
(
"popcli"
);
...
...
timer.c
浏览文件 @
21575761
...
...
@@ -22,13 +22,13 @@
#define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first
void
timer
_
init
(
void
)
timerinit
(
void
)
{
// Interrupt 100 times/sec.
outb
(
TIMER_MODE
,
TIMER_SEL0
|
TIMER_RATEGEN
|
TIMER_16BIT
);
outb
(
IO_TIMER1
,
TIMER_DIV
(
100
)
%
256
);
outb
(
IO_TIMER1
,
TIMER_DIV
(
100
)
/
256
);
pic
_
enable
(
IRQ_TIMER
);
picenable
(
IRQ_TIMER
);
}
...
...
trap.c
浏览文件 @
21575761
...
...
@@ -52,20 +52,20 @@ trap(struct trapframe *tf)
wakeup
(
&
ticks
);
release
(
&
tickslock
);
}
lapic
_
eoi
();
lapiceoi
();
break
;
case
IRQ_OFFSET
+
IRQ_IDE
:
ide
_
intr
();
lapic
_
eoi
();
ideintr
();
lapiceoi
();
break
;
case
IRQ_OFFSET
+
IRQ_KBD
:
kbd
_
intr
();
lapic
_
eoi
();
kbdintr
();
lapiceoi
();
break
;
case
IRQ_OFFSET
+
IRQ_SPURIOUS
:
cprintf
(
"cpu%d: spurious interrupt at %x:%x
\n
"
,
cpu
(),
tf
->
cs
,
tf
->
eip
);
lapic
_
eoi
();
lapiceoi
();
break
;
default:
...
...
x86.h
浏览文件 @
21575761
...
...
@@ -48,15 +48,6 @@ stosb(void *addr, int data, int cnt)
"memory"
,
"cc"
);
}
static
inline
uint
read_ebp
(
void
)
{
uint
ebp
;
asm
volatile
(
"movl %%ebp, %0"
:
"=a"
(
ebp
));
return
ebp
;
}
struct
segdesc
;
static
inline
void
...
...
@@ -92,19 +83,13 @@ ltr(ushort sel)
}
static
inline
uint
read
_
eflags
(
void
)
readeflags
(
void
)
{
uint
eflags
;
asm
volatile
(
"pushfl; popl %0"
:
"=r"
(
eflags
));
return
eflags
;
}
static
inline
void
write_eflags
(
uint
eflags
)
{
asm
volatile
(
"pushl %0; popfl"
:
:
"r"
(
eflags
));
}
static
inline
uint
xchg
(
volatile
uint
*
addr
,
uint
newval
)
{
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论