Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
29270816
提交
29270816
7月 20, 2006
创建
作者:
rtm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uint32_t -> uint &c
上级
bd228a81
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
252 行增加
和
271 行删除
+252
-271
bootmain.c
bootmain.c
+8
-8
console.c
console.c
+1
-1
defs.h
defs.h
+6
-6
elf.h
elf.h
+23
-23
ide.c
ide.c
+7
-13
lapic.c
lapic.c
+3
-3
main.c
main.c
+7
-7
mmu.h
mmu.h
+41
-41
mp.c
mp.c
+19
-19
mp.h
mp.h
+41
-41
picirq.c
picirq.c
+2
-2
proc.h
proc.h
+1
-1
spinlock.h
spinlock.h
+1
-1
string.c
string.c
+3
-3
syscall.c
syscall.c
+2
-0
types.h
types.h
+3
-9
x86.h
x86.h
+84
-93
没有找到文件。
bootmain.c
浏览文件 @
29270816
...
...
@@ -33,8 +33,8 @@
#define SECTSIZE 512
#define ELFHDR ((struct elfhdr *) 0x10000) // scratch space
void
readsect
(
void
*
,
uint
32_t
);
void
readseg
(
uint
32_t
,
uint32_t
,
uint32_
t
);
void
readsect
(
void
*
,
uint
);
void
readseg
(
uint
,
uint
,
uin
t
);
void
cmain
(
void
)
...
...
@@ -42,14 +42,14 @@ cmain(void)
struct
proghdr
*
ph
,
*
eph
;
// read 1st page off disk
readseg
((
uint
32_t
)
ELFHDR
,
SECTSIZE
*
8
,
0
);
readseg
((
uint
)
ELFHDR
,
SECTSIZE
*
8
,
0
);
// is this a valid ELF?
if
(
ELFHDR
->
magic
!=
ELF_MAGIC
)
goto
bad
;
// load each program segment (ignores ph flags)
ph
=
(
struct
proghdr
*
)
((
u
int8_t
*
)
ELFHDR
+
ELFHDR
->
phoff
);
ph
=
(
struct
proghdr
*
)
((
u
char
*
)
ELFHDR
+
ELFHDR
->
phoff
);
eph
=
ph
+
ELFHDR
->
phnum
;
for
(;
ph
<
eph
;
ph
++
)
readseg
(
ph
->
va
,
ph
->
memsz
,
ph
->
offset
);
...
...
@@ -68,9 +68,9 @@ bad:
// Read 'count' bytes at 'offset' from kernel into virtual address 'va'.
// Might copy more than asked
void
readseg
(
uint
32_t
va
,
uint32_t
count
,
uint32_
t
offset
)
readseg
(
uint
va
,
uint
count
,
uin
t
offset
)
{
uint
32_t
end_va
;
uint
end_va
;
va
&=
0xFFFFFF
;
end_va
=
va
+
count
;
...
...
@@ -85,7 +85,7 @@ readseg(uint32_t va, uint32_t count, uint32_t offset)
// We'd write more to memory than asked, but it doesn't matter --
// we load in increasing order.
while
(
va
<
end_va
)
{
readsect
((
u
int8_t
*
)
va
,
offset
);
readsect
((
u
char
*
)
va
,
offset
);
va
+=
SECTSIZE
;
offset
++
;
}
...
...
@@ -100,7 +100,7 @@ waitdisk(void)
}
void
readsect
(
void
*
dst
,
uint
32_t
offset
)
readsect
(
void
*
dst
,
uint
offset
)
{
// wait for disk to be ready
waitdisk
();
...
...
console.c
浏览文件 @
29270816
...
...
@@ -28,7 +28,7 @@ static void
cons_putc
(
int
c
)
{
int
crtport
=
0x3d4
;
// io port of CGA
u
int16_t
*
crt
=
(
uint16_
t
*
)
0xB8000
;
// base of CGA memory
u
short
*
crt
=
(
ushor
t
*
)
0xB8000
;
// base of CGA memory
int
ind
;
if
(
panicked
){
...
...
defs.h
浏览文件 @
29270816
...
...
@@ -40,8 +40,8 @@ int strncmp(const char *p, const char *q, uint n);
void
syscall
(
void
);
// picirq.c
extern
u
int16_
t
irq_mask_8259A
;
void
irq_setmask_8259A
(
u
int16_
t
mask
);
extern
u
shor
t
irq_mask_8259A
;
void
irq_setmask_8259A
(
u
shor
t
mask
);
void
pic_init
(
void
);
// mp.c
...
...
@@ -50,9 +50,9 @@ void mp_startthem(void);
int
mp_bcpu
(
void
);
// lapic
extern
uint
32_t
*
lapicaddr
;
extern
uint
*
lapicaddr
;
void
lapic_init
(
int
);
void
lapic_startap
(
u
int8_t
,
int
);
void
lapic_startap
(
u
char
,
int
);
void
lapic_timerinit
(
void
);
void
lapic_timerintr
(
void
);
void
lapic_enableintr
(
void
);
...
...
@@ -66,7 +66,7 @@ void release(struct spinlock*);
int
holding
(
struct
spinlock
*
);
// main.c
void
load_icode
(
struct
proc
*
p
,
u
int8_t
*
binary
,
uint
size
);
void
load_icode
(
struct
proc
*
p
,
u
char
*
binary
,
uint
size
);
// pipe.c
struct
pipe
;
...
...
@@ -87,6 +87,6 @@ void fd_incref(struct fd *fd);
// ide.c
void
ide_init
(
void
);
void
ide_intr
(
void
);
void
*
ide_start_read
(
uint
32_t
secno
,
void
*
dst
,
uint
nsecs
);
void
*
ide_start_read
(
uint
secno
,
void
*
dst
,
uint
nsecs
);
int
ide_finish_read
(
void
*
);
elf.h
浏览文件 @
29270816
#define ELF_MAGIC 0x464C457FU
/* "\x7FELF" in little endian */
struct
elfhdr
{
uint
32_t
magic
;
// must equal ELF_MAGIC
u
int8_t
elf
[
12
];
u
int16_
t
type
;
u
int16_
t
machine
;
uint
32_t
version
;
uint
32_t
entry
;
uint
32_t
phoff
;
uint
32_t
shoff
;
uint
32_t
flags
;
u
int16_
t
ehsize
;
u
int16_
t
phentsize
;
u
int16_
t
phnum
;
u
int16_
t
shentsize
;
u
int16_
t
shnum
;
u
int16_
t
shstrndx
;
uint
magic
;
// must equal ELF_MAGIC
u
char
elf
[
12
];
u
shor
t
type
;
u
shor
t
machine
;
uint
version
;
uint
entry
;
uint
phoff
;
uint
shoff
;
uint
flags
;
u
shor
t
ehsize
;
u
shor
t
phentsize
;
u
shor
t
phnum
;
u
shor
t
shentsize
;
u
shor
t
shnum
;
u
shor
t
shstrndx
;
};
struct
proghdr
{
uint
32_t
type
;
uint
32_t
offset
;
uint
32_t
va
;
uint
32_t
pa
;
uint
32_t
filesz
;
uint
32_t
memsz
;
uint
32_t
flags
;
uint
32_t
align
;
uint
type
;
uint
offset
;
uint
va
;
uint
pa
;
uint
filesz
;
uint
memsz
;
uint
flags
;
uint
align
;
};
// Values for Proghdr type
...
...
ide.c
浏览文件 @
29270816
...
...
@@ -18,7 +18,8 @@
#define IDE_ERR 0x01
struct
ide_request
{
uint32_t
secno
;
int
diskno
;
uint
secno
;
void
*
dst
;
uint
nsecs
;
};
...
...
@@ -26,7 +27,6 @@ struct ide_request request[NREQUEST];
int
head
,
tail
;
struct
spinlock
ide_lock
;
static
int
diskno
=
0
;
int
disk_channel
;
static
int
...
...
@@ -80,14 +80,6 @@ ide_probe_disk1(void)
}
void
ide_set_disk
(
int
d
)
{
if
(
d
!=
0
&&
d
!=
1
)
panic
(
"bad disk number"
);
diskno
=
d
;
}
void
ide_start_request
(
void
)
{
struct
ide_request
*
r
;
...
...
@@ -100,13 +92,13 @@ ide_start_request (void)
outb
(
0x1F3
,
r
->
secno
&
0xFF
);
outb
(
0x1F4
,
(
r
->
secno
>>
8
)
&
0xFF
);
outb
(
0x1F5
,
(
r
->
secno
>>
16
)
&
0xFF
);
outb
(
0x1F6
,
0xE0
|
((
diskno
&
1
)
<<
4
)
|
((
r
->
secno
>>
24
)
&
0x0F
));
outb
(
0x1F6
,
0xE0
|
((
r
->
diskno
&
1
)
<<
4
)
|
((
r
->
secno
>>
24
)
&
0x0F
));
outb
(
0x1F7
,
0x20
);
// CMD 0x20 means read sector
}
}
void
*
ide_start_read
(
uint
32_t
secno
,
void
*
dst
,
uint
nsecs
)
ide_start_read
(
uint
secno
,
void
*
dst
,
uint
nsecs
)
{
struct
ide_request
*
r
;
if
(
!
holding
(
&
ide_lock
))
...
...
@@ -122,6 +114,7 @@ ide_start_read(uint32_t secno, void *dst, uint nsecs)
r
->
secno
=
secno
;
r
->
dst
=
dst
;
r
->
nsecs
=
nsecs
;
r
->
diskno
=
0
;
ide_start_request
();
...
...
@@ -155,9 +148,10 @@ ide_finish_read(void *c)
}
int
ide_write
(
uint
32_t
secno
,
const
void
*
src
,
uint
nsecs
)
ide_write
(
uint
secno
,
const
void
*
src
,
uint
nsecs
)
{
int
r
;
int
diskno
=
0
;
if
(
nsecs
>
256
)
panic
(
"ide_write"
);
...
...
lapic.c
浏览文件 @
29270816
...
...
@@ -92,7 +92,7 @@ enum { /* LAPIC_TDCR */
LAPIC_X1
=
0x0000000B
,
/* divide by 1 */
};
uint
32_t
*
lapicaddr
;
uint
*
lapicaddr
;
static
int
lapic_read
(
int
r
)
...
...
@@ -127,7 +127,7 @@ lapic_timerintr(void)
void
lapic_init
(
int
c
)
{
uint
32_t
r
,
lvt
;
uint
r
,
lvt
;
cprintf
(
"lapic_init %d
\n
"
,
c
);
...
...
@@ -180,7 +180,7 @@ cpu(void)
}
void
lapic_startap
(
u
int8_t
apicid
,
int
v
)
lapic_startap
(
u
char
apicid
,
int
v
)
{
int
crhi
,
i
;
volatile
int
j
=
0
;
...
...
main.c
浏览文件 @
29270816
...
...
@@ -11,9 +11,9 @@
#include "spinlock.h"
extern
char
edata
[],
end
[];
extern
u
int8_t
_binary_user1_start
[],
_binary_user1_size
[];
extern
u
int8_t
_binary_usertests_start
[],
_binary_usertests_size
[];
extern
u
int8_t
_binary_userfs_start
[],
_binary_userfs_size
[];
extern
u
char
_binary_user1_start
[],
_binary_user1_size
[];
extern
u
char
_binary_usertests_start
[],
_binary_usertests_size
[];
extern
u
char
_binary_userfs_start
[],
_binary_userfs_size
[];
extern
int
use_console_lock
;
...
...
@@ -73,7 +73,7 @@ main0(void)
lapic_enableintr
();
// init disk device
//
ide_init();
ide_init
();
// Enable interrupts on this processor.
cpus
[
cpu
()].
nlock
--
;
...
...
@@ -81,8 +81,8 @@ main0(void)
p
=
copyproc
(
&
proc
[
0
]);
load_icode
(
p
,
_binary_usertests_start
,
(
uint
)
_binary_usertests_size
);
//
load_icode(p, _binary_userfs_start, (uint) _binary_userfs_size);
//
load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size);
load_icode
(
p
,
_binary_userfs_start
,
(
uint
)
_binary_userfs_size
);
p
->
state
=
RUNNABLE
;
cprintf
(
"loaded userfs
\n
"
);
...
...
@@ -107,7 +107,7 @@ mpmain(void)
}
void
load_icode
(
struct
proc
*
p
,
u
int8_t
*
binary
,
uint
size
)
load_icode
(
struct
proc
*
p
,
u
char
*
binary
,
uint
size
)
{
int
i
;
struct
elfhdr
*
elf
;
...
...
mmu.h
浏览文件 @
29270816
...
...
@@ -124,43 +124,43 @@ struct segdesc {
// Task state segment format (as described by the Pentium architecture book)
struct
taskstate
{
uint
32_t
link
;
// Old ts selector
uint
ptr_t
esp0
;
// Stack pointers and segment selectors
u
int16_
t
ss0
;
// after an increase in privilege level
u
int16_
t
padding1
;
uint
ptr_t
esp1
;
u
int16_
t
ss1
;
u
int16_
t
padding2
;
uint
ptr_t
esp2
;
u
int16_
t
ss2
;
u
int16_
t
padding3
;
physaddr_t
cr3
;
// Page directory base
uint
ptr_t
eip
;
// Saved state from last task switch
uint
32_t
eflags
;
uint
32_t
eax
;
// More saved state (registers)
uint
32_t
ecx
;
uint
32_t
edx
;
uint
32_t
ebx
;
uint
ptr_t
esp
;
uint
ptr_t
ebp
;
uint
32_t
esi
;
uint
32_t
edi
;
u
int16_
t
es
;
// Even more saved state (segment selectors)
u
int16_
t
padding4
;
u
int16_
t
cs
;
u
int16_
t
padding5
;
u
int16_
t
ss
;
u
int16_
t
padding6
;
u
int16_
t
ds
;
u
int16_
t
padding7
;
u
int16_
t
fs
;
u
int16_
t
padding8
;
u
int16_
t
gs
;
u
int16_
t
padding9
;
u
int16_
t
ldt
;
u
int16_
t
padding10
;
u
int16_
t
t
;
// Trap on task switch
u
int16_
t
iomb
;
// I/O map base address
uint
link
;
// Old ts selector
uint
*
esp0
;
// Stack pointers and segment selectors
u
shor
t
ss0
;
// after an increase in privilege level
u
shor
t
padding1
;
uint
*
esp1
;
u
shor
t
ss1
;
u
shor
t
padding2
;
uint
*
esp2
;
u
shor
t
ss2
;
u
shor
t
padding3
;
void
*
cr3
;
// Page directory base
uint
*
eip
;
// Saved state from last task switch
uint
eflags
;
uint
eax
;
// More saved state (registers)
uint
ecx
;
uint
edx
;
uint
ebx
;
uint
*
esp
;
uint
*
ebp
;
uint
esi
;
uint
edi
;
u
shor
t
es
;
// Even more saved state (segment selectors)
u
shor
t
padding4
;
u
shor
t
cs
;
u
shor
t
padding5
;
u
shor
t
ss
;
u
shor
t
padding6
;
u
shor
t
ds
;
u
shor
t
padding7
;
u
shor
t
fs
;
u
shor
t
padding8
;
u
shor
t
gs
;
u
shor
t
padding9
;
u
shor
t
ldt
;
u
shor
t
padding10
;
u
shor
t
t
;
// Trap on task switch
u
shor
t
iomb
;
// I/O map base address
};
// Gate descriptors for interrupts and traps
...
...
@@ -185,7 +185,7 @@ struct gatedesc {
// this interrupt/trap gate explicitly using an int instruction.
#define SETGATE(gate, istrap, sel, off, d) \
{ \
(gate).off_15_0 = (uint
32_t
) (off) & 0xffff; \
(gate).off_15_0 = (uint) (off) & 0xffff; \
(gate).ss = (sel); \
(gate).args = 0; \
(gate).rsv1 = 0; \
...
...
@@ -193,13 +193,13 @@ struct gatedesc {
(gate).s = 0; \
(gate).dpl = (d); \
(gate).p = 1; \
(gate).off_31_16 = (uint
32_t
) (off) >> 16; \
(gate).off_31_16 = (uint) (off) >> 16; \
}
// Set up a call gate descriptor.
#define SETCALLGATE(gate, ss, off, d) \
{ \
(gate).off_15_0 = (uint
32_t
) (off) & 0xffff; \
(gate).off_15_0 = (uint) (off) & 0xffff; \
(gate).ss = (ss); \
(gate).args = 0; \
(gate).rsv1 = 0; \
...
...
@@ -207,7 +207,7 @@ struct gatedesc {
(gate).s = 0; \
(gate).dpl = (d); \
(gate).p = 1; \
(gate).off_31_16 = (uint
32_t
) (off) >> 16; \
(gate).off_31_16 = (uint) (off) >> 16; \
}
#endif
/* !__ASSEMBLER__ */
...
...
mp.c
浏览文件 @
29270816
...
...
@@ -37,12 +37,12 @@ int ncpu;
static
struct
cpu
*
bcpu
;
static
struct
mp
*
mp_scan
(
u
int8_t
*
addr
,
int
len
)
mp_scan
(
u
char
*
addr
,
int
len
)
{
u
int8_t
*
e
,
*
p
,
sum
;
u
char
*
e
,
*
p
,
sum
;
int
i
;
cprintf
(
"scanning: 0x%x
\n
"
,
(
uint
32_t
)
addr
);
cprintf
(
"scanning: 0x%x
\n
"
,
(
uint
)
addr
);
e
=
addr
+
len
;
for
(
p
=
addr
;
p
<
e
;
p
+=
sizeof
(
struct
mp
)){
if
(
memcmp
(
p
,
"_MP_"
,
4
))
...
...
@@ -59,8 +59,8 @@ mp_scan(uint8_t *addr, int len)
static
struct
mp
*
mp_search
(
void
)
{
u
int8_t
*
bda
;
uint
32_t
p
;
u
char
*
bda
;
uint
p
;
struct
mp
*
mp
;
/*
...
...
@@ -70,25 +70,25 @@ mp_search(void)
* 2) in the last KB of system base memory;
* 3) in the BIOS ROM between 0xE0000 and 0xFFFFF.
*/
bda
=
(
u
int8_t
*
)
0x400
;
bda
=
(
u
char
*
)
0x400
;
if
((
p
=
(
bda
[
0x0F
]
<<
8
)
|
bda
[
0x0E
])){
if
((
mp
=
mp_scan
((
u
int8_t
*
)
p
,
1024
)))
if
((
mp
=
mp_scan
((
u
char
*
)
p
,
1024
)))
return
mp
;
}
else
{
p
=
((
bda
[
0x14
]
<<
8
)
|
bda
[
0x13
])
*
1024
;
if
((
mp
=
mp_scan
((
u
int8_t
*
)
p
-
1024
,
1024
)))
if
((
mp
=
mp_scan
((
u
char
*
)
p
-
1024
,
1024
)))
return
mp
;
}
return
mp_scan
((
u
int8_t
*
)
0xF0000
,
0x10000
);
return
mp_scan
((
u
char
*
)
0xF0000
,
0x10000
);
}
static
int
mp_detect
(
void
)
{
struct
mpctb
*
pcmp
;
u
int8_t
*
p
,
sum
;
uint
32_t
length
;
u
char
*
p
,
sum
;
uint
length
;
/*
* Search for an MP configuration table. For now,
...
...
@@ -106,7 +106,7 @@ mp_detect(void)
length
=
pcmp
->
length
;
sum
=
0
;
for
(
p
=
(
u
int8_t
*
)
pcmp
;
length
;
length
--
)
for
(
p
=
(
u
char
*
)
pcmp
;
length
;
length
--
)
sum
+=
*
p
++
;
if
(
sum
||
(
pcmp
->
version
!=
1
&&
pcmp
->
version
!=
4
))
...
...
@@ -120,7 +120,7 @@ void
mp_init
(
void
)
{
int
r
;
u
int8_t
*
p
,
*
e
;
u
char
*
p
,
*
e
;
struct
mpctb
*
mpctb
;
struct
mppe
*
proc
;
struct
mpbe
*
bus
;
...
...
@@ -137,10 +137,10 @@ mp_init(void)
* is guaranteed to be in order such that only one pass is necessary.
*/
mpctb
=
(
struct
mpctb
*
)
mp
->
physaddr
;
lapicaddr
=
(
uint
32_t
*
)
mpctb
->
lapicaddr
;
lapicaddr
=
(
uint
*
)
mpctb
->
lapicaddr
;
cprintf
(
"apicaddr: %x
\n
"
,
lapicaddr
);
p
=
((
u
int8_t
*
)
mpctb
)
+
sizeof
(
struct
mpctb
);
e
=
((
u
int8_t
*
)
mpctb
)
+
mpctb
->
length
;
p
=
((
u
char
*
)
mpctb
)
+
sizeof
(
struct
mpctb
);
e
=
((
u
char
*
)
mpctb
)
+
mpctb
->
length
;
while
(
p
<
e
)
{
switch
(
*
p
){
...
...
@@ -195,18 +195,18 @@ extern void mpmain(void);
void
mp_startthem
(
void
)
{
extern
u
int8_t
_binary_bootother_start
[],
_binary_bootother_size
[];
extern
u
char
_binary_bootother_start
[],
_binary_bootother_size
[];
extern
int
main
();
int
c
;
memmove
((
void
*
)
APBOOTCODE
,
_binary_bootother_start
,
(
uint
32_t
)
_binary_bootother_size
);
(
uint
)
_binary_bootother_size
);
for
(
c
=
0
;
c
<
ncpu
;
c
++
){
if
(
c
==
cpu
())
continue
;
cprintf
(
"starting processor %d
\n
"
,
c
);
*
(
uint
*
)(
APBOOTCODE
-
4
)
=
(
uint
)
(
cpus
[
c
].
mpstack
)
+
MPSTACK
;
// tell it what to use for %esp
*
(
uint
*
)(
APBOOTCODE
-
8
)
=
(
uint
)
mpmain
;
// tell it where to jump to
lapic_startap
(
cpus
[
c
].
apicid
,
(
uint
32_t
)
APBOOTCODE
);
lapic_startap
(
cpus
[
c
].
apicid
,
(
uint
)
APBOOTCODE
);
}
}
mp.h
浏览文件 @
29270816
...
...
@@ -5,63 +5,63 @@
*/
struct
mp
{
/* floating pointer */
u
int8_t
signature
[
4
];
/* "_MP_" */
physaddr_t
physaddr
;
/* physical address of MP configuration table */
u
int8_t
length
;
/* 1 */
u
int8_t
specrev
;
/* [14] */
u
int8_t
checksum
;
/* all bytes must add up to 0 */
u
int8_t
type
;
/* MP system configuration type */
u
int8_t
imcrp
;
u
int8_t
reserved
[
3
];
u
char
signature
[
4
];
/* "_MP_" */
void
*
physaddr
;
/* physical address of MP configuration table */
u
char
length
;
/* 1 */
u
char
specrev
;
/* [14] */
u
char
checksum
;
/* all bytes must add up to 0 */
u
char
type
;
/* MP system configuration type */
u
char
imcrp
;
u
char
reserved
[
3
];
};
struct
mpctb
{
/* configuration table header */
u
int8_t
signature
[
4
];
/* "PCMP" */
u
int16_
t
length
;
/* total table length */
u
int8_t
version
;
/* [14] */
u
int8_t
checksum
;
/* all bytes must add up to 0 */
u
int8_t
product
[
20
];
/* product id */
uint
ptr_t
oemtable
;
/* OEM table pointer */
u
int16_
t
oemlength
;
/* OEM table length */
u
int16_
t
entry
;
/* entry count */
uint
ptr_t
lapicaddr
;
/* address of local APIC */
u
int16_
t
xlength
;
/* extended table length */
u
int8_t
xchecksum
;
/* extended table checksum */
u
int8_t
reserved
;
u
char
signature
[
4
];
/* "PCMP" */
u
shor
t
length
;
/* total table length */
u
char
version
;
/* [14] */
u
char
checksum
;
/* all bytes must add up to 0 */
u
char
product
[
20
];
/* product id */
uint
*
oemtable
;
/* OEM table pointer */
u
shor
t
oemlength
;
/* OEM table length */
u
shor
t
entry
;
/* entry count */
uint
*
lapicaddr
;
/* address of local APIC */
u
shor
t
xlength
;
/* extended table length */
u
char
xchecksum
;
/* extended table checksum */
u
char
reserved
;
};
struct
mppe
{
/* processor table entry */
u
int8_t
type
;
/* entry type (0) */
u
int8_t
apicid
;
/* local APIC id */
u
int8_t
version
;
/* local APIC verison */
u
int8_t
flags
;
/* CPU flags */
u
int8_t
signature
[
4
];
/* CPU signature */
uint
32_t
feature
;
/* feature flags from CPUID instruction */
u
int8_t
reserved
[
8
];
u
char
type
;
/* entry type (0) */
u
char
apicid
;
/* local APIC id */
u
char
version
;
/* local APIC verison */
u
char
flags
;
/* CPU flags */
u
char
signature
[
4
];
/* CPU signature */
uint
feature
;
/* feature flags from CPUID instruction */
u
char
reserved
[
8
];
};
struct
mpbe
{
/* bus table entry */
u
int8_t
type
;
/* entry type (1) */
u
int8_t
busno
;
/* bus id */
u
char
type
;
/* entry type (1) */
u
char
busno
;
/* bus id */
char
string
[
6
];
/* bus type string */
};
struct
mpioapic
{
/* I/O APIC table entry */
u
int8_t
type
;
/* entry type (2) */
u
int8_t
apicno
;
/* I/O APIC id */
u
int8_t
version
;
/* I/O APIC version */
u
int8_t
flags
;
/* I/O APIC flags */
uint
ptr_t
addr
;
/* I/O APIC address */
u
char
type
;
/* entry type (2) */
u
char
apicno
;
/* I/O APIC id */
u
char
version
;
/* I/O APIC version */
u
char
flags
;
/* I/O APIC flags */
uint
*
addr
;
/* I/O APIC address */
};
struct
mpie
{
/* interrupt table entry */
u
int8_t
type
;
/* entry type ([34]) */
u
int8_t
intr
;
/* interrupt type */
u
int16_
t
flags
;
/* interrupt flag */
u
int8_t
busno
;
/* source bus id */
u
int8_t
irq
;
/* source bus irq */
u
int8_t
apicno
;
/* destination APIC id */
u
int8_t
intin
;
/* destination APIC [L]INTIN# */
u
char
type
;
/* entry type ([34]) */
u
char
intr
;
/* interrupt type */
u
shor
t
flags
;
/* interrupt flag */
u
char
busno
;
/* source bus id */
u
char
irq
;
/* source bus irq */
u
char
apicno
;
/* destination APIC id */
u
char
intin
;
/* destination APIC [L]INTIN# */
};
enum
{
/* table entry types */
...
...
picirq.c
浏览文件 @
29270816
...
...
@@ -12,7 +12,7 @@
// Current IRQ mask.
// Initial IRQ mask has interrupt 2 enabled (for slave 8259A).
u
int16_
t
irq_mask_8259A
=
0xFFFF
&
~
(
1
<<
IRQ_SLAVE
);
u
shor
t
irq_mask_8259A
=
0xFFFF
&
~
(
1
<<
IRQ_SLAVE
);
/* Initialize the 8259A interrupt controllers. */
void
...
...
@@ -71,7 +71,7 @@ pic_init(void)
}
void
irq_setmask_8259A
(
u
int16_
t
mask
)
irq_setmask_8259A
(
u
shor
t
mask
)
{
int
i
;
irq_mask_8259A
=
mask
;
...
...
proc.h
浏览文件 @
29270816
...
...
@@ -65,7 +65,7 @@ extern struct proc *curproc[NCPU]; // can be NULL if no proc running.
#define MPSTACK 512
struct
cpu
{
u
int8_t
apicid
;
// Local APIC ID
u
char
apicid
;
// Local APIC ID
struct
jmpbuf
jmpbuf
;
char
mpstack
[
MPSTACK
];
// per-cpu start-up stack, only used to get into main()
struct
proc
*
lastproc
;
// last proc scheduled on this cpu (never NULL)
...
...
spinlock.h
浏览文件 @
29270816
struct
spinlock
{
uint
locked
;
uint
32_t
pc
;
uint
pc
;
int
cpu
;
};
string.c
浏览文件 @
29270816
...
...
@@ -15,8 +15,8 @@ memset(void *dst, int c, uint n)
int
memcmp
(
const
void
*
v1
,
const
void
*
v2
,
uint
n
)
{
const
u
int8_t
*
s1
=
(
const
uint8_t
*
)
v1
;
const
u
int8_t
*
s2
=
(
const
uint8_t
*
)
v2
;
const
u
char
*
s1
=
(
const
uchar
*
)
v1
;
const
u
char
*
s2
=
(
const
uchar
*
)
v2
;
while
(
n
--
>
0
)
{
if
(
*
s1
!=
*
s2
)
...
...
@@ -55,7 +55,7 @@ strncmp(const char *p, const char *q, uint n)
if
(
n
==
0
)
return
0
;
else
return
(
int
)
((
u
int8_t
)
*
p
-
(
uint8_t
)
*
q
);
return
(
int
)
((
u
char
)
*
p
-
(
uchar
)
*
q
);
}
// Memcpy is deprecated and should NOT be called.
...
...
syscall.c
浏览文件 @
29270816
...
...
@@ -235,8 +235,10 @@ sys_block(void)
if
((
c
=
ide_start_read
(
i
,
buf
,
1
))
==
0
)
{
panic
(
"couldn't start read
\n
"
);
}
#if 0
cprintf("call sleep\n");
sleep (c, &ide_lock);
#endif
if
(
ide_finish_read
(
c
))
{
panic
(
"couldn't do read
\n
"
);
}
...
...
types.h
浏览文件 @
29270816
typedef
unsigned
int
uint
;
typedef
unsigned
long
long
uint64_t
;
typedef
unsigned
int
uint32_t
;
typedef
unsigned
short
uint16_t
;
typedef
unsigned
char
uint8_t
;
typedef
uint32_t
uintptr_t
;
typedef
uint32_t
physaddr_t
;
typedef
unsigned
int
uint
;
typedef
unsigned
short
ushort
;
typedef
unsigned
char
uchar
;
x86.h
浏览文件 @
29270816
差异被折叠。
点击展开。
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论