From 7255f89646c6cd4be38750ef6412f0509406ca99 Mon Sep 17 00:00:00 2001 From: ngiddings Date: Mon, 12 Apr 2021 01:05:26 -0500 Subject: [PATCH] Removed old kernel C++ files --- src/kernel.cpp | 31 ---------- src/kernel.hpp | 156 ------------------------------------------------ src/process.hpp | 54 ----------------- 3 files changed, 241 deletions(-) delete mode 100644 src/kernel.cpp delete mode 100644 src/kernel.hpp delete mode 100644 src/process.hpp diff --git a/src/kernel.cpp b/src/kernel.cpp deleted file mode 100644 index 98795ff..0000000 --- a/src/kernel.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "kernel.hpp" - -int Kernel::allocateRegion(void* page, size_t length, int flags) -{ - char* ptr = (char*) page; - for(int i = (int) length; i > 0; i -= mmgr.getPageSize()) - { - physaddr_t frame = pageAllocator.allocate(mmgr.getPageSize()); - if(frame != 0) - mmgr.mapPage(page, reserveFrame(), flags); - else - return -1; - ptr += mmgr.getPageSize(); - } - return 0; -} - -void Kernel::freeRegion(void* page, size_t length) -{ - char* ptr = (char*) page; - for(int i = (int) length; i > 0; i -= mmgr.getPageSize()) - { - pageAllocator.free(mmgr.unmapPage((void*) ptr), mmgr.getPageSize()); - ptr += mmgr.getPageSize(); - } -} - -int Kernel::mapRegion(void* page, physaddr_t frame, size_t length, int flags) -{ - -} \ No newline at end of file diff --git a/src/kernel.hpp b/src/kernel.hpp deleted file mode 100644 index 700989a..0000000 --- a/src/kernel.hpp +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef KERNEL_H -#define KERNEL_H - -#include "pageallocator.hpp" -#include "memorymanager.hpp" -#include "memorymap.hpp" -#include "sharedblock.hpp" -#include "process.hpp" -#include "systypes.hpp" - -using namespace kernelns; - -class Kernel -{ -public: - - void* malloc(size_t size); - - void free(void* ptr); - - /** - * @brief Maps a region of pages starting at virtual address 'page' with - * length 'length'. Allocates each mapped frame and any necessary page - * tables. This method does not perform any checks before overwriting page - * tables; it is the responsibility of the caller to ensure that the - * operation is safe to perform. - * - * @param page The virtual address of the first page to map - * @param length The size in bytes of the region to map - * @param flags The flags to apply to each page - * - * @returns zero upon success, nonzero on failure - */ - int allocateRegion(void* page, size_t length, int flags); - - /** - * @brief Unmaps and frees a region of mapped pages starting at virtual - * address 'page' with length 'length'. Does not free any page tables - * that are made redundant by this operation. It is the responsibility - * of the caller to ensure that all pages in the specified region are - * mapped and should be returned to the page allocator. - * - * @param page The virtual address of the first page to free - * @param length The size in bytes of the region to free - */ - void freeRegion(void* page, size_t length); - - /** - * @brief Maps a contiguous region of pages to a contiguous region of - * frames. Allocates new page tables as needed. All pages will share - * the same flags. - * - * @param page The virtual address of the first page to map - * @param frame The physical address of the first frame to map to - * @param length The size in bytes of the region to map - * @param flags The flags to apply to each page - * - * @returns zero upon success, nonzero on failure - */ - int mapRegion(void* page, physaddr_t frame, size_t length, int flags); - - /** - * @brief Unmaps a region of pages; does not return them to the page - * allocator. - * - * @param page The virtual address of the first page to unmap - * @param length The size in bytes of the region to unmap - */ - void unmapRegion(void* page, size_t length); - - /** - * @brief Create a Shared Block object - * - * @param length - * @param flags - * @returns The ID of the - */ - unsigned int createSharedBlock(size_t length, int flags); - - /** - * @brief Get the shared memory block referred to by 'id' - * - * @param id - * @returns a reference - */ - const SharedBlock& getSharedBlock(unsigned int id); - - /** - * @brief Create a new process - * - * @param imageBlockID - * @return Process& - */ - Process& createProcess(unsigned int imageBlockID); - - /** - * @brief Get the process object corresponsing to 'pid' - * - * @param pid id of the process to fetch - * @returns a reference to the requested process - */ - Process& getProcess(unsigned int pid); - - /** - * @brief Get the current active process object. - * - * @returns a reference to the active process - */ - Process& getActiveProcess(); - - /** - * @brief Puts the current active process back on the run queue, and sets - * the active process to the next one selected by the scheduler. - * - * @returns a reference to the new active process - */ - Process& yieldActiveProcess(); - - /** - * @brief Puts the current active process to sleep, and sets the active - * process to the next one selected by the scheduler. - * - * @returns a reference to the new active process - */ - Process& sleepActiveProcess(); - - /** - * @brief Terminates the current active process, freeing all its resources, - * and activates the next process selected by the scheduler. - * - * @return Process& - */ - Process& terminateActiveProcess(); - - /** - * @brief Terminates the process with id 'pid', freeing all its resources. - * If it holds any shared blocks which are not held by any other process, - * those blocks will be freed. - * - * @param pid id of the process to terminate - */ - void terminateProcess(unsigned int pid); - -private: - - PageAllocator& pageAllocator; - - MemoryManager& mmgr; - - MemoryMap& memoryMap; - -}; - -extern Kernel kernel; - -#endif \ No newline at end of file diff --git a/src/process.hpp b/src/process.hpp deleted file mode 100644 index b25238f..0000000 --- a/src/process.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef PROCESS_H -#define PROCESS_H - -#include - -#include "message.hpp" - -namespace kernelns -{ - -class Process -{ -public: - - size_t priority; - - void* stack; - - Process(); - - unsigned int getID() const; - - bool map(void* location, size_t size); - - /** - * @brief If the specified region is mapped and does not overlap a shared - * or private block, or the kernel, removes that region from the process's - * internal memory map. If the specified region overlaps an unmapped region, - * a shared or private block, or the kernel, the object goes unmodified. - * This method does not affect the page tables in any way, only the process's - * internal bookkeeping. - * - * @param location - * @param size - * @return true if the memory map was sucessfully updated - * @return false if the memory map was not modified - */ - bool unmap(void* location, size_t size); - - bool hasSharedBlock(unsigned int blockID) const; - - bool hasPhysicalBlock(unsigned int blockID) const; - - void pushMessage(Message* message); - - Message* popMessage(); - -private: - -}; - -} - -#endif \ No newline at end of file