Attempt to write an iterator for the multiboot memory map list
This commit is contained in:
parent
fad5a48e5b
commit
ec74cb650c
2 changed files with 134 additions and 12 deletions
|
@ -15,19 +15,51 @@
|
|||
|
||||
namespace multiboot {
|
||||
|
||||
struct PACKED MemoryChunk
|
||||
{
|
||||
/** Base address of the chunk of memory. */
|
||||
uint64_t base;
|
||||
/** Length of the chunk of memory, in bytes. */
|
||||
uint64_t length;
|
||||
/** Type of address range. 1 indicates available; all other values indicate reserved memory. */
|
||||
uint32_t type;
|
||||
};
|
||||
|
||||
/**
|
||||
* The multiboot information struct. Defined by the multiboot spec.
|
||||
* See http://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Machine-state
|
||||
*/
|
||||
struct PACKED Information
|
||||
{
|
||||
struct MemoryMapIterator
|
||||
{
|
||||
MemoryMapIterator(uint32_t address, uint32_t count);
|
||||
MemoryMapIterator(const MemoryMapIterator& other);
|
||||
|
||||
MemoryMapIterator& operator++();
|
||||
MemoryMapIterator operator++(int);
|
||||
MemoryChunk operator*();
|
||||
|
||||
bool operator==(const MemoryMapIterator& other) const;
|
||||
bool operator!=(const MemoryMapIterator& other) const;
|
||||
|
||||
private:
|
||||
MemoryChunk *mCurrent;
|
||||
uint32_t mCount;
|
||||
};
|
||||
|
||||
static const Information *information();
|
||||
static void setInformation(Information* info);
|
||||
|
||||
uint32_t lowerMemoryKB() const;
|
||||
uint32_t upperMemoryKB() const;
|
||||
|
||||
const char* commandLine() const;
|
||||
|
||||
uint32_t memoryMapChunks() const;
|
||||
MemoryMapIterator memoryMapBegin() const;
|
||||
MemoryMapIterator memoryMapEnd() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Bit field of flags. Fields below are only defined if the appropriate
|
||||
|
@ -98,16 +130,16 @@ private:
|
|||
} symbols;
|
||||
|
||||
/**
|
||||
* @defgroup Memory Map
|
||||
* Points to a buffer containing a memory map of the machine provided by the
|
||||
* BIOS. Defined only if `memoryMapPresent == true`.
|
||||
* @{
|
||||
*/
|
||||
struct PACKED
|
||||
{
|
||||
/** Number of memory map entries present. */
|
||||
uint32_t count;
|
||||
/** Pointer to start of memory map entry array. */
|
||||
uint32_t address;
|
||||
} memoryMap;
|
||||
/** Number of memory map entries present. */
|
||||
uint32_t memoryMapCount;
|
||||
/** Pointer to start of memory map entry array. */
|
||||
uint32_t memoryMapAddress;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* Points to a buffer containing a list of drive definitions provided by the
|
||||
|
@ -152,11 +184,6 @@ struct PACKED Module
|
|||
uint32_t reserved;
|
||||
};
|
||||
|
||||
// TODO: Define the MemoryMap struct
|
||||
struct PACKED MemoryChunk
|
||||
{
|
||||
};
|
||||
|
||||
// TODO: Define the Drive struct
|
||||
struct PACKED Drive
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue