Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
e2fb4373
提交
e2fb4373
10月 26, 2011
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rejigger cga and some console code.
上级
69d390f1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
47 行增加
和
84 行删除
+47
-84
boot.S
boot.S
+0
-44
cga.c
cga.c
+44
-37
kernel.h
kernel.h
+1
-1
uart.c
uart.c
+2
-2
没有找到文件。
boot.S
浏览文件 @
e2fb4373
...
...
@@ -74,9 +74,6 @@ start:
# Initialize stack.
movl $PADDR(stack+STACK), %esp
# Initialize screen.
call initscreen
# Check for page size extensions.
movl $1, %eax
...
...
@@ -192,47 +189,6 @@ bootpanic:
movb %bl, (%esi)
jmp 2b
initscreen:
pushal
# Initialize screen.
# 25 lines of white on black.
cld
movl $CGATEXTMEM, %edi
movl $0x0f20, %eax
movl $(80*25), %ecx
rep stosw
# Hide cursor at beginning of first line.
movw $0, %di
call setcursor
popal
ret
.globl setcursor
setcursor:
pushl %edx
pushl %eax
pushl %ebx
movl %edi, %ebx
movw $0x3d4, %dx
movw $14, %ax
outb %al, %dx
movw $0x3d5, %dx
movb %bh, %al
outb %al, %dx
movw $0x3d4, %dx
movw $15, %ax
outb %al, %dx
movw $0x3d5, %dx
movb %bl, %al
outb %al, %dx
popl %ebx
popl %eax
popl %edx
ret
# Initial stack
.comm stack, STACK
...
...
cga.c
浏览文件 @
e2fb4373
#include "types.h"
#include "kernel.h"
#include "x86.h"
static
volatile
u16
*
screen
=
(
u16
*
)(
KBASE
+
0xb8000
);
#define BACKSPACE 0x100
#define CRTPORT 0x3d4
static
volatile
u16
*
crt
=
(
u16
*
)(
KBASE
+
0xb8000
);
// CGA memory
// Black background, (high intensity) white foreground
static
int
color
=
((
0
<<
4
)
|
15
)
<<
8
;
static
int
cursor
;
extern
void
setcursor
(
int
);
static
void
cgaputs
(
const
char
*
s
)
{
uint8
*
p
,
*
ep
;
p
=
(
uint8
*
)
s
;
ep
=
p
+
strlen
(
s
);
for
(;
p
<
ep
;
p
++
)
cgaputc
(
*
p
);
}
void
cgaputc
(
char
c
)
cgaputc
(
int
c
)
{
int
i
;
if
(
c
==
'\n'
)
{
cursor
+=
80
-
cursor
%
80
;
}
else
{
screen
[
cursor
]
=
color
|
c
;
cursor
++
;
}
if
(
cursor
==
25
*
80
)
{
memmove
((
void
*
)
screen
+
80
*
2
,
(
void
*
)
screen
+
80
*
3
,
80
*
(
25
-
3
)
*
2
);
for
(
i
=
0
;
i
<
80
;
i
++
)
screen
[(
24
*
80
+
i
)]
=
color
|
(
' '
&
0xff
);
cursor
-=
80
;
int
pos
;
// Cursor position: col + 80*row.
outb
(
CRTPORT
,
14
);
pos
=
inb
(
CRTPORT
+
1
)
<<
8
;
outb
(
CRTPORT
,
15
);
pos
|=
inb
(
CRTPORT
+
1
);
if
(
c
==
'\n'
)
pos
+=
80
-
pos
%
80
;
else
if
(
c
==
BACKSPACE
){
if
(
pos
>
0
)
--
pos
;
}
else
crt
[
pos
++
]
=
(
c
&
0xff
)
|
color
;
if
((
pos
/
80
)
>=
24
){
// Scroll up.
memmove
((
void
*
)
crt
,
(
void
*
)
crt
+
80
,
sizeof
(
crt
[
0
])
*
23
*
80
);
pos
-=
80
;
memset
((
void
*
)
crt
+
pos
,
0
,
sizeof
(
crt
[
0
])
*
(
24
*
80
-
pos
));
}
outb
(
CRTPORT
,
14
);
outb
(
CRTPORT
+
1
,
pos
>>
8
);
outb
(
CRTPORT
,
15
);
outb
(
CRTPORT
+
1
,
pos
);
crt
[
pos
]
=
' '
|
0x0700
;
}
void
initcga
(
void
)
{
// Assume boot.S set up the screen.
// We're just taking over the cursor position.
cursor
=
2
*
80
;
setcursor
(
cursor
);
cgaputs
(
"cga...
\n
"
);
setcursor
(
cursor
);
char
*
p
;
int
i
;
for
(
i
=
0
;
i
<
80
*
25
;
i
++
)
crt
[
i
]
=
0x0f20
;
outb
(
CRTPORT
,
14
);
outb
(
CRTPORT
+
1
,
0
);
outb
(
CRTPORT
,
15
);
outb
(
CRTPORT
+
1
,
0
);
// Announce that we're here.
for
(
p
=
"cga..
\n
"
;
*
p
;
p
++
)
cgaputc
(
*
p
);
}
kernel.h
浏览文件 @
e2fb4373
...
...
@@ -36,7 +36,7 @@ void brelse(struct buf*, int writer);
void
bwrite
(
struct
buf
*
);
// cga.c
void
cgaputc
(
char
c
);
void
cgaputc
(
int
c
);
// condvar.c
void
initcondvar
(
struct
condvar
*
,
char
*
);
...
...
uart.c
浏览文件 @
e2fb4373
...
...
@@ -39,7 +39,7 @@ uartintr(void)
void
inituart
(
void
)
{
char
*
p
;
char
*
p
;
// Turn off the FIFO
outb
(
COM1
+
2
,
0
);
...
...
@@ -65,6 +65,6 @@ inituart(void)
ioapicenable
(
IRQ_COM1
,
0
);
// Announce that we're here.
for
(
p
=
"uart..
.
\n
"
;
*
p
;
p
++
)
for
(
p
=
"uart..
\n
"
;
*
p
;
p
++
)
uartputc
(
*
p
);
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论