Files
beaglefw/mmio.hh

33 lines
574 B
C++

#ifndef _MMIO_HH_
#define _MMIO_HH_
#include <cstdint>
#include "mm.hh"
#include "cortexa8.hh"
class MMIO_alloc {
public:
MMIO_alloc(uintptr_t base_p, unsigned size = 1) : base_p_{base_p}, base_v_{mm::virtalloc_io(size)}, size_{size} {
cortexa8::map_pages(base_v_, base_p_, size_);
}
~MMIO_alloc() {
cortexa8::unmap_pages(base_v_, size_);
}
uintptr_t const& get_virt() const noexcept {
return base_v_;
}
uintptr_t const& get_phys() const noexcept {
return base_p_;
}
private:
uintptr_t base_p_, base_v_;
unsigned size_;
};
#endif