[add] laos using xv6-riscv thought
This commit is contained in:
@@ -1 +1,5 @@
|
||||
#include <device.hh>
|
||||
#include <device.hh>
|
||||
|
||||
Device::Device(bool cacheable): cacheable_(cacheable) {}
|
||||
|
||||
bool Device::is_cacheable() { return cacheable_; }
|
||||
@@ -3,9 +3,15 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
class Device {
|
||||
protected:
|
||||
bool cacheable_ = false;
|
||||
|
||||
public:
|
||||
Device() = default;
|
||||
Device(bool cacheable);
|
||||
|
||||
bool is_cacheable();
|
||||
|
||||
virtual const size_t &size() const = 0;
|
||||
|
||||
@@ -29,7 +35,9 @@ public:
|
||||
|
||||
template <typename T>
|
||||
class WRDevice : public Device{
|
||||
protected:
|
||||
size_t devsiz;
|
||||
|
||||
public:
|
||||
WRDevice(size_t siz);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <device.hh>
|
||||
|
||||
class SystemBus {
|
||||
std::map<uint64_t, Device *> iomap;
|
||||
std::map<uint64_t, Device *> iomap_;
|
||||
|
||||
std::pair<const uint64_t, Device *> &finddev(uint64_t addr);
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
std::pair<const uint64_t, Device *> &SystemBus::finddev(uint64_t addr) {
|
||||
Device *dev = nullptr;
|
||||
auto &&iter = iomap.upper_bound(addr);
|
||||
if (iter == iomap.begin())
|
||||
auto &&iter = iomap_.upper_bound(addr);
|
||||
if (iter == iomap_.begin())
|
||||
panic("device not found");
|
||||
iter--;
|
||||
if (iter->first <= addr && iter->first + iter->second->size() > addr)
|
||||
@@ -13,7 +13,7 @@ std::pair<const uint64_t, Device *> &SystemBus::finddev(uint64_t addr) {
|
||||
return *iter;
|
||||
}
|
||||
|
||||
void SystemBus::regdev(Device *dev, uint64_t addr) { iomap.emplace(addr, dev); }
|
||||
void SystemBus::regdev(Device *dev, uint64_t addr) { iomap_.emplace(addr, dev); }
|
||||
|
||||
void SystemBus::write(char *buf, size_t addr, size_t len) {
|
||||
auto &&dev = finddev(addr);
|
||||
|
||||
Reference in New Issue
Block a user