Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
NEMU
提交
29abde90
N
NEMU
项目概览
OpenXiangShan
/
NEMU
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
29abde90
编写于
11月 18, 2020
作者:
W
wangkaifan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
device: refactor device for XiangShan
上级
7340ce16
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
66 addition
and
22 deletion
+66
-22
include/device/map.h
include/device/map.h
+58
-0
src/device/audio.c
src/device/audio.c
+0
-3
src/device/device.c
src/device/device.c
+5
-1
src/device/io/port-io.c
src/device/io/port-io.c
+3
-0
src/device/keyboard.c
src/device/keyboard.c
+0
-2
src/device/sdcard.c
src/device/sdcard.c
+0
-3
src/device/serial.c
src/device/serial.c
+0
-3
src/device/timer.c
src/device/timer.c
+0
-3
src/device/vga.c
src/device/vga.c
+0
-6
src/isa/riscv64/clint.c
src/isa/riscv64/clint.c
+0
-1
未找到文件。
include/device/map.h
浏览文件 @
29abde90
...
...
@@ -3,6 +3,64 @@
#include <monitor/difftest.h>
#define XIANGSHAN
#ifdef XIANGSHAN
// SD
#define SD_MMIO 0x40002000
// CLINT
#define CLINT_MMIO 0x38000000
// Serial
#define SERIAL_PORT 0x3F8
#define SERIAL_MMIO 0x40600000
// VGA
#define VMEM 0x50000000
#define SCREEN_PORT 0x100 // Note that this is not the standard
#define SCREEN_MMIO 0x40001000
#define SYNC_PORT 0x104 // Note that this is not the standard
#define SYNC_MMIO 0x40001004
//--- The following devices are unused in XiangShan ---
// Timer
#define RTC_PORT 0x48 // Note that this is not the standard
#define RTC_MMIO 0xa1000048
// Keyboard
#define I8042_DATA_PORT 0x60
#define I8042_DATA_MMIO 0xa1000060
// Audio
#define AUDIO_PORT 0x200 // Note that this is not the standard
#define AUDIO_MMIO 0xa1000200
#define STREAM_BUF 0xa0800000
#else
// SD
#define SD_MMIO 0xa3000000
// Timer
#define RTC_PORT 0x48 // Note that this is not the standard
#define RTC_MMIO 0xa1000048
// Serial
#define SERIAL_PORT 0x3F8
#define SERIAL_MMIO 0xa10003F8
// Keyboard
#define I8042_DATA_PORT 0x60
#define I8042_DATA_MMIO 0xa1000060
// VGA
#define VMEM 0xa0000000
#define SCREEN_PORT 0x100 // Note that this is not the standard
#define SCREEN_MMIO 0xa1000100
#define SYNC_PORT 0x104 // Note that this is not the standard
#define SYNC_MMIO 0xa1000104
// Audio
#define AUDIO_PORT 0x200 // Note that this is not the standard
#define AUDIO_MMIO 0xa1000200
#define STREAM_BUF 0xa0800000
// CLINT
#define CLINT_MMIO 0xa2000000
#endif
typedef
void
(
*
io_callback_t
)(
uint32_t
,
int
,
nemu_bool
);
uint8_t
*
new_space
(
int
size
);
...
...
src/device/audio.c
浏览文件 @
29abde90
...
...
@@ -5,9 +5,6 @@
#include <device/map.h>
#include <SDL2/SDL.h>
#define AUDIO_PORT 0x200 // Note that this is not the standard
#define AUDIO_MMIO 0xa1000200
#define STREAM_BUF 0xa0800000
#define STREAM_BUF_MAX_SIZE 65536
static
uint8_t
*
sbuf
=
NULL
;
...
...
src/device/device.c
浏览文件 @
29abde90
...
...
@@ -5,6 +5,8 @@
#include <device/alarm.h>
#include <SDL2/SDL.h>
#define XIANGSHAN
void
init_alarm
();
void
init_serial
();
void
init_timer
();
...
...
@@ -55,10 +57,12 @@ void sdl_clear_event_queue() {
void
init_device
()
{
init_serial
();
init_timer
();
init_vga
();
#ifndef XIANGSHAN
init_timer
();
init_i8042
();
init_audio
();
#endif
add_alarm_handle
((
void
*
)
set_device_update_flag
);
init_alarm
();
...
...
src/device/io/port-io.c
浏览文件 @
29abde90
...
...
@@ -8,6 +8,9 @@ static int nr_map = 0;
/* device interface */
void
add_pio_map
(
char
*
name
,
ioaddr_t
addr
,
uint8_t
*
space
,
int
len
,
io_callback_t
callback
)
{
#ifdef __ISA_riscv64__
return
;
#endif
assert
(
nr_map
<
NR_MAP
);
assert
(
addr
+
len
<=
PORT_IO_SPACE_MAX
);
maps
[
nr_map
]
=
(
IOMap
){
.
name
=
name
,
.
low
=
addr
,
.
high
=
addr
+
len
-
1
,
...
...
src/device/keyboard.c
浏览文件 @
29abde90
...
...
@@ -2,8 +2,6 @@
#include <monitor/monitor.h>
#include <SDL2/SDL.h>
#define I8042_DATA_PORT 0x60
#define I8042_DATA_MMIO 0xa1000060
#define KEYBOARD_IRQ 1
static
uint32_t
*
i8042_data_port_base
=
(
uint32_t
*
)
nullptr
;
...
...
src/device/sdcard.c
浏览文件 @
29abde90
...
...
@@ -12,9 +12,6 @@
#define MULT (1 << (C_SIZE_MULT + 2))
#define C_SIZE (NR_BLOCK / MULT - 1)
#define SD_MMIO 0xa3000000
// This is a simple hardware implementation of linux/drivers/mmc/host/bcm2835.c
// No DMA and IRQ is supported, so the driver must be modified to start PIO
// right after sending the actual read/write commands.
...
...
src/device/serial.c
浏览文件 @
29abde90
...
...
@@ -3,9 +3,6 @@
/* http://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming */
// NOTE: this is compatible to 16550
#define SERIAL_PORT 0x3F8
#define SERIAL_MMIO 0xa10003F8
#define CH_OFFSET 0
#define LSR_OFFSET 5
#define LSR_TX_READY 0x20
...
...
src/device/timer.c
浏览文件 @
29abde90
...
...
@@ -3,9 +3,6 @@
#include <monitor/monitor.h>
#include <sys/time.h>
#define RTC_PORT 0x48 // Note that this is not the standard
#define RTC_MMIO 0xa1000048
static
uint32_t
*
rtc_port_base
=
NULL
;
static
void
rtc_io_handler
(
uint32_t
offset
,
int
len
,
nemu_bool
is_write
)
{
...
...
src/device/vga.c
浏览文件 @
29abde90
...
...
@@ -7,12 +7,6 @@
#include <device/map.h>
#include <SDL2/SDL.h>
#define VMEM 0xa0000000
#define SCREEN_PORT 0x100 // Note that this is not the standard
#define SCREEN_MMIO 0xa1000100
#define SYNC_PORT 0x104 // Note that this is not the standard
#define SYNC_MMIO 0xa1000104
#define SCREEN_H 300
#define SCREEN_W 400
#define SCREEN_SIZE ((SCREEN_H * SCREEN_W) * sizeof(uint32_t))
...
...
src/isa/riscv64/clint.c
浏览文件 @
29abde90
...
...
@@ -3,7 +3,6 @@
#include <device/map.h>
#include "local-include/csr.h"
#define CLINT_MMIO 0xa2000000
#define CLINT_MTIMECMP (0x4000 / sizeof(clint_base[0]))
#define CLINT_MTIME (0xBFF8 / sizeof(clint_base[0]))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录