1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:17:35 +00:00

Add /proc/mm and a /bin/mm utility that just dumps it.

This shows some info about the MM. Right now it's just the zone count
and the number of free physical pages. Lots more can be added.

Also added "exit" to sh so we can nest shells and exit from them.

I also noticed that we were leaking all the physical pages, so fixed that.
This commit is contained in:
Andreas Kling 2018-10-28 10:26:07 +01:00
parent 0a6a2521e8
commit c76dc9a047
10 changed files with 115 additions and 21 deletions

View file

@ -5,7 +5,7 @@
#include <AK/Retainable.h>
#include <AK/RetainPtr.h>
#include <AK/Vector.h>
#include <AK/HashMap.h>
#include <AK/HashTable.h>
#include "Task.h"
class Task;
@ -17,7 +17,7 @@ enum class PageFaultResponse {
struct Zone : public Retainable<Zone> {
public:
~Zone() { }
~Zone();
size_t size() const { return m_pages.size() * PAGE_SIZE; }
const Vector<PhysicalAddress>& pages() const { return m_pages; }
@ -25,10 +25,7 @@ public:
private:
friend class MemoryManager;
friend bool copyToZone(Zone&, const void* data, size_t);
explicit Zone(Vector<PhysicalAddress>&& pages)
: m_pages(move(pages))
{
}
explicit Zone(Vector<PhysicalAddress>&&);
Vector<PhysicalAddress> m_pages;
};
@ -38,6 +35,7 @@ bool copyToZone(Zone&, const void* data, size_t);
#define MM MemoryManager::the()
class MemoryManager {
friend ByteBuffer procfs$mm();
public:
static MemoryManager& the() PURE;
@ -62,6 +60,9 @@ public:
bool mapRegionsForTask(Task&);
bool unmapRegionsForTask(Task&);
void registerZone(Zone&);
void unregisterZone(Zone&);
private:
MemoryManager();
~MemoryManager();
@ -161,7 +162,7 @@ private:
dword* m_pageTableZero;
dword* m_pageTableOne;
HashMap<int, RetainPtr<Zone>> m_zones;
HashTable<Zone*> m_zones;
Vector<PhysicalAddress> m_freePages;
};