forked from PoliEcho-holding-org/kern
Moved memory map stuff into physicalMemManager.h (should name it better)
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef PHYSICAL_MEM_MANAGER_H
|
||||||
|
#define PHYSICAL_MEM_MANAGER_H
|
||||||
|
|
||||||
|
typedef struct smapEntry_s {
|
||||||
|
uint64_t baseAddress;
|
||||||
|
uint64_t length;
|
||||||
|
uint32_t type;
|
||||||
|
uint32_t acpiAttr;
|
||||||
|
} __attribute__ ((packed)) smapEntry_t;
|
||||||
|
|
||||||
|
void printPhysicalMemmap() {
|
||||||
|
uint32_t entryCount = *(uint32_t*)0x8500;
|
||||||
|
smapEntry_t* smapEntry = (smapEntry_t*)0x8504;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < entryCount; i++) {
|
||||||
|
print("Region ");
|
||||||
|
print(itoa(i, 10));
|
||||||
|
print(" - base: 0x");
|
||||||
|
print(itoa(smapEntry->baseAddress, 16));
|
||||||
|
print(" length: 0x");
|
||||||
|
print(itoa(smapEntry->length, 16));
|
||||||
|
print(" type: ");
|
||||||
|
print(itoa(smapEntry->type, 10));
|
||||||
|
|
||||||
|
switch (smapEntry->type) {
|
||||||
|
case 1: print(" (Available)"); break;
|
||||||
|
case 2: print(" (Reserved)"); break;
|
||||||
|
case 3: print(" (ACPI Reclaim)"); break;
|
||||||
|
case 4: print(" (ACPI NVS)"); break;
|
||||||
|
default: print(" (Reserved)"); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
putc('\n');
|
||||||
|
smapEntry++;
|
||||||
|
}
|
||||||
|
|
||||||
|
smapEntry--; // We incremented it after the last entry
|
||||||
|
|
||||||
|
print("\nTotal memory: 0x");
|
||||||
|
print(itoa(smapEntry->baseAddress + smapEntry->length - 1, 16));
|
||||||
|
print(" Bytes\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
+1
-35
@@ -8,16 +8,10 @@
|
|||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "physicalMemManager.h" // TODO: Name this better
|
||||||
|
|
||||||
#define PROMPT "#> "
|
#define PROMPT "#> "
|
||||||
|
|
||||||
typedef struct smapEntry_s {
|
|
||||||
uint64_t baseAddress;
|
|
||||||
uint64_t length;
|
|
||||||
uint32_t type;
|
|
||||||
uint32_t acpiAttr;
|
|
||||||
} __attribute__ ((packed)) smapEntry_t;
|
|
||||||
|
|
||||||
char* filetable = (char*)0x7000; // Pretty sure we don't have to care about the bootloader at 0x7c00
|
char* filetable = (char*)0x7000; // Pretty sure we don't have to care about the bootloader at 0x7c00
|
||||||
|
|
||||||
// Function declarations
|
// Function declarations
|
||||||
@@ -292,31 +286,3 @@ void printFiletable(char* ft) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printPhysicalMemmap() {
|
|
||||||
uint32_t entryCount = *(uint32_t*)0x8500;
|
|
||||||
smapEntry_t* smapEntry = (smapEntry_t*)0x8504;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < entryCount; i++) {
|
|
||||||
print("Region ");
|
|
||||||
if (i) print(itoa(i, 10));
|
|
||||||
else print("0");
|
|
||||||
print(": base: 0x");
|
|
||||||
print(itoa(smapEntry->baseAddress, 16));
|
|
||||||
print(" length: 0x");
|
|
||||||
print(itoa(smapEntry->length, 16));
|
|
||||||
print(" type: 0x");
|
|
||||||
print(itoa(smapEntry->type, 16));
|
|
||||||
|
|
||||||
switch (smapEntry->type) {
|
|
||||||
case 1: print(" (Available)"); break;
|
|
||||||
case 2: print(" (Reserved)"); break;
|
|
||||||
case 3: print(" (ACPI Reclaim)"); break;
|
|
||||||
case 4: print(" (ACPI NVS)"); break;
|
|
||||||
default: print(" (Reserved)"); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
putc('\n');
|
|
||||||
smapEntry++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user