20 #include "DiskImage.h" 21 #include "pedigree/kernel/BootstrapInfo.h" 22 #include "pedigree/kernel/Log.h" 26 bool DiskImage::initialise()
28 if (g_pBootstrapInfo->getModuleCount() < 3)
30 NOTICE(
"not enough modules to create a DiskImage");
34 uintptr_t baseAddress = g_pBootstrapInfo->getModuleArray()[2].base;
35 uintptr_t endAddress = g_pBootstrapInfo->getModuleArray()[2].end;
37 m_pBase =
reinterpret_cast<void *
>(baseAddress);
38 m_nSize = endAddress - baseAddress;
44 if ((location > m_nSize) || !m_pBase)
46 ERROR(
"DiskImage::read() - location " << location <<
" > " << m_nSize);
47 ERROR(
" -> or " << m_pBase <<
" is null");
54 uintptr_t buffer = m_Cache.
lookup(location);
57 return buffer + offset;
62 reinterpret_cast<void *>(buffer), adjust_pointer(m_pBase, location),
67 return buffer + offset;
77 m_Cache.
pin(location);
Bootstrap structure passed to the kernel entry point.
uintptr_t insert(uintptr_t key, bool *alreadyExisted=nullptr)
void markNoLongerEditing(uintptr_t key, size_t length=0)
virtual size_t getBlockSize() const
Gets the block size of the disk.
virtual uintptr_t read(uint64_t location)
virtual void unpin(uint64_t location)
virtual void pin(uint64_t location)
Pins a cache page.
uintptr_t lookup(uintptr_t key)
void release(uintptr_t key)
virtual size_t getSize() const
Gets the size of the disk.