⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bus.hh

📁 一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,
💻 HH
字号:
#include <clock.hh>#include <device.hh>#include <pcidevice.hh>#include <inttypes.hh>#include <module.hh>#include <mips64/bus.hh>#define TIMER_CLOCKS_PER_TICK 2class MIPS64SimpleBus    : public virtual Serializable, public MIPS64Bus{private:    static SerialType<MIPS64SimpleBus> type;    // The memory array.    UInt64* ram;    UInt64  memory_size;    const char* file_name;    Device* decode[16];    Device* cs1_subdecode[4];    PCIDevice* pcidev[8];    UInt32 pciconfig_address;    Device *find_device(char *name);    ClockValue pciconfig_read(UInt32 addr, UInt32* buf, int size);    ClockValue pciconfig_write(UInt32 addr, const UInt32* buf, int size);    class Timer : public Event    {      private:	MIPS64SimpleBus *bus;	int timer_id;	bool running, is_timer;	UInt32 start_value;      public:	Timer(MIPS64SimpleBus *b, int id)		: Event(0, 0), bus(b), timer_id(id) { running = false; }	void invoke();	UInt32 read();	void write(UInt32 val);	void control(bool enable, bool timer);    };    friend class Timer;    Timer *timer[4];    UInt32 timer_control;    UInt32 intr_pending, intr_mask;    void timer_interrupt(unsigned int id);    void check_interrupts(void);public:    // Constructors, etc.    MIPS64SimpleBus(const SimArgs& args);    MIPS64SimpleBus(Checkpoint& cp);    ~MIPS64SimpleBus();    // Module interfaces.    void reset(bool warm);    // Serialization information.    void checkpoint(Checkpoint& cp, bool parent = false) const;        // Device access.    ClockValue read(UInt64 addr, UInt64* buf, int sz);    ClockValue write(UInt64 addr, const UInt64* buf, int sz);    struct {	char *file_name;	int memory;	char *cpu;	char *cs0, *cs1, *cs2, *cs3, *bootcs;	char *cs1a, *cs1b, *cs1c, *cs1d;	char *pciintctrl;	char *pci[8];    } conf;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -