📄 read.cc
字号:
#include <string.h>#include <assert.hh>#include <inttypes.hh>#include "rtc.hh"ClockValueMT48Tx2::read(UInt64 addr, UInt64* buf, int size){ assert(size > 0 && size <= 8); assert(!is_power_of_two(size) || (addr & (size - 1)) == 0); // Decode the address. Note that, as with real hardware, we simply ignore // irrelevant address lines (the hardware has no way of knowing where in // the address space it is currently mapped.) addr %= 2*KB; if (addr + size > CONTROL) { if ((addr + size > CONTROL + 1) && !bit(data[CONTROL], 6)) { msg("RTC read without halting."); update_read(bus->clock); } } // Fetch the data. if (size == sizeof(UInt8)) *buf = *(UInt8 *)(data + addr); else if (size == sizeof(UInt16)) *buf = *(UInt16 *)(data + addr); else if (size == sizeof(UInt32)) *buf = *(UInt32 *)(data + addr); else if (size == sizeof(UInt64)) *buf = *(UInt64 *)(data + addr); else { // Forget about performance. memcpy(buf, data + addr, size); if (big_endian_host()) *buf >>= (sizeof(*buf) - size) * 8; } // Compute the access latency. if (freq != bus->clock->freq) { read_latency = bus->clock->cycles(read_latency, freq); write_latency = bus->clock->cycles(write_latency, freq); freq = bus->clock->freq; } return read_latency * size;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -