[add] laos using xv6-riscv thought

This commit is contained in:
bLueriVerLHR
2023-05-18 00:05:52 +08:00
parent 399c978c09
commit 5d31bf294c
21 changed files with 462 additions and 22 deletions

View File

@@ -1 +1,5 @@
#include <device.hh>
#include <device.hh>
Device::Device(bool cacheable): cacheable_(cacheable) {}
bool Device::is_cacheable() { return cacheable_; }

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);