提交 29abde90 编写于 作者: W wangkaifan

device: refactor device for XiangShan

上级 7340ce16
......@@ -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);
......
......@@ -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;
......
......@@ -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();
......
......@@ -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,
......
......@@ -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;
......
......@@ -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.
......
......@@ -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
......
......@@ -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) {
......
......@@ -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))
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册