NJU-ProjectN/nemu ics2023 initialized
NJU-ProjectN/nemu eb63cf3568dbf4e0c3c6ef462e6ec685550fabbc Merge pull request #76 from rijuyuezhu/master
This commit is contained in:
parent
1efe03efb9
commit
2824efad33
141 changed files with 19573 additions and 0 deletions
24
nemu/include/device/alarm.h
Normal file
24
nemu/include/device/alarm.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/***************************************************************************************
|
||||
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
|
||||
*
|
||||
* NEMU is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
***************************************************************************************/
|
||||
|
||||
#ifndef __DEVICE_ALARM_H__
|
||||
#define __DEVICE_ALARM_H__
|
||||
|
||||
#define TIMER_HZ 60
|
||||
|
||||
typedef void (*alarm_handler_t) ();
|
||||
void add_alarm_handle(alarm_handler_t h);
|
||||
|
||||
#endif
|
56
nemu/include/device/map.h
Normal file
56
nemu/include/device/map.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/***************************************************************************************
|
||||
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
|
||||
*
|
||||
* NEMU is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
***************************************************************************************/
|
||||
|
||||
#ifndef __DEVICE_MAP_H__
|
||||
#define __DEVICE_MAP_H__
|
||||
|
||||
#include <cpu/difftest.h>
|
||||
|
||||
typedef void(*io_callback_t)(uint32_t, int, bool);
|
||||
uint8_t* new_space(int size);
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
// we treat ioaddr_t as paddr_t here
|
||||
paddr_t low;
|
||||
paddr_t high;
|
||||
void *space;
|
||||
io_callback_t callback;
|
||||
} IOMap;
|
||||
|
||||
static inline bool map_inside(IOMap *map, paddr_t addr) {
|
||||
return (addr >= map->low && addr <= map->high);
|
||||
}
|
||||
|
||||
static inline int find_mapid_by_addr(IOMap *maps, int size, paddr_t addr) {
|
||||
int i;
|
||||
for (i = 0; i < size; i ++) {
|
||||
if (map_inside(maps + i, addr)) {
|
||||
difftest_skip_ref();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void add_pio_map(const char *name, ioaddr_t addr,
|
||||
void *space, uint32_t len, io_callback_t callback);
|
||||
void add_mmio_map(const char *name, paddr_t addr,
|
||||
void *space, uint32_t len, io_callback_t callback);
|
||||
|
||||
word_t map_read(paddr_t addr, int len, IOMap *map);
|
||||
void map_write(paddr_t addr, int len, word_t data, IOMap *map);
|
||||
|
||||
#endif
|
24
nemu/include/device/mmio.h
Normal file
24
nemu/include/device/mmio.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/***************************************************************************************
|
||||
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
|
||||
*
|
||||
* NEMU is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* See the Mulan PSL v2 for more details.
|
||||
***************************************************************************************/
|
||||
|
||||
#ifndef __DEVICE_MMIO_H__
|
||||
#define __DEVICE_MMIO_H__
|
||||
|
||||
#include <common.h>
|
||||
|
||||
word_t mmio_read(paddr_t addr, int len);
|
||||
void mmio_write(paddr_t addr, int len, word_t data);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue