Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
NEMU
提交
eccb333d
N
NEMU
项目概览
OpenXiangShan
/
NEMU
大约 1 年 前同步成功
通知
7
Star
171
Fork
67
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NEMU
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eccb333d
编写于
11月 18, 2020
作者:
W
wangkaifan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
device: support uartlite
* note that serial input is not supported currently
上级
3f072846
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
97 addition
and
2 deletion
+97
-2
src/device/device.c
src/device/device.c
+6
-2
src/device/uartlite.c
src/device/uartlite.c
+91
-0
未找到文件。
src/device/device.c
浏览文件 @
eccb333d
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
void
init_alarm
();
void
init_alarm
();
void
init_serial
();
void
init_serial
();
void
init_uartlite
();
void
init_timer
();
void
init_timer
();
void
init_vga
();
void
init_vga
();
void
init_i8042
();
void
init_i8042
();
...
@@ -56,9 +57,12 @@ void sdl_clear_event_queue() {
...
@@ -56,9 +57,12 @@ void sdl_clear_event_queue() {
}
}
void
init_device
()
{
void
init_device
()
{
init_serial
();
#ifdef XIANGSHAN
init_vga
();
init_uartlite
();
#else
init_vga
();
init_vga
();
#ifndef XIANGSHAN
init_serial
();
init_timer
();
init_timer
();
init_i8042
();
init_i8042
();
init_audio
();
init_audio
();
...
...
src/device/uartlite.c
0 → 100644
浏览文件 @
eccb333d
#include <device/map.h>
#define CH_OFFSET 0
#define UARTLITE_RX_FIFO 0x0
#define UARTLITE_TX_FIFO 0x4
#define UARTLITE_STAT_REG 0x8
#define UARTLITE_CTRL_REG 0xc
#define UARTLITE_RST_FIFO 0x03
#define UARTLITE_TX_FULL 0x08
#define UARTLITE_RX_VALID 0x01
// #define QUEUE_SIZE 1024
// static char queue[QUEUE_SIZE] = {};
// static int f = 0, r = 0;
static
uint8_t
*
serial_base
=
NULL
;
// static void serial_enqueue(char ch) {
// int next = (r + 1) % QUEUE_SIZE;
// if (next != f) {
// // not full
// queue[r] = ch;
// r = next;
// }
// }
// static char serial_dequeue() {
// char ch = 0xff;
// extern uint32_t uptime();
// static uint32_t last = 0;
// uint32_t now = uptime();
// if (now > last) {
// Log("now = %d", now);
// last = now;
// }
// // 90s after starting
// if (now > 90) {
// if (f != r) {
// ch = queue[f];
// f = (f + 1) % QUEUE_SIZE;
// }
// }
// return ch;
// }
static
void
serial_io_handler
(
uint32_t
offset
,
int
len
,
nemu_bool
is_write
)
{
assert
(
len
==
1
);
switch
(
offset
)
{
/* We bind the serial port with the host stdout in NEMU. */
case
UARTLITE_TX_FIFO
:
if
(
is_write
)
putc
(
serial_base
[
UARTLITE_TX_FIFO
],
stderr
);
else
panic
(
"Cannot read UARTLITE_TX_FIFO"
);
break
;
case
UARTLITE_STAT_REG
:
if
(
!
is_write
)
serial_base
[
UARTLITE_STAT_REG
]
=
0x0
;
break
;
}
}
// #define rt_thread_cmd "memtrace\n"
// #define busybox_cmd "ls\n" \
// "cd /root\n" \
// "echo hello2\n" \
// "cd /root/benchmark\n" \
// "./stream\n" \
// "echo hello3\n" \
// "cd /root/redis\n" \
// "ls\n" \
// "ifconfig -a\n" \
// "ls\n" \
// "./redis-server\n" \
// #define debian_cmd "root\n" \
// static void preset_input() {
// char buf[] = debian_cmd;
// int i;
// for (i = 0; i < strlen(buf); i ++) {
// serial_enqueue(buf[i]);
// }
// }
void
init_uartlite
()
{
serial_base
=
new_space
(
0xd
);
add_pio_map
(
"uartlite"
,
SERIAL_PORT
,
serial_base
,
0xd
,
serial_io_handler
);
add_mmio_map
(
"uartlite"
,
SERIAL_MMIO
,
serial_base
,
0xd
,
serial_io_handler
);
preset_input
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录