KERNEL: Cleanup
Removing quite a few unnecessary parts.
This commit is contained in:
@ -1,44 +0,0 @@
|
||||
#include "MBI_MMap.h"
|
||||
|
||||
/*
|
||||
void mapMultibootMemoryMap( MemoryInfo* memInfo , multiboot_info_t *mbt) {
|
||||
|
||||
printf("mmap_addr = 0x%x, mmap_length = 0x%x\n", (unsigned) mbt->mmap_addr , (unsigned) mbt->mmap_length );
|
||||
|
||||
|
||||
multiboot_memory_map_t *mmap = (multiboot_memory_map_t*) mbt->mmap_addr;
|
||||
|
||||
for (; (unsigned long) mmap < mbt->mmap_addr + mbt->mmap_length; mmap = (multiboot_memory_map_t *) ((unsigned long) mmap + mmap->size + sizeof(mmap->size))){
|
||||
|
||||
if ( mmap->type == MULTIBOOT_MEMORY_AVAILABLE){
|
||||
|
||||
memInfo->TotalMemory += mmap->len;
|
||||
} else {
|
||||
memInfo->ReservedMemory += mmap->len;
|
||||
}
|
||||
|
||||
print_Multiboot_memory_Map(mmap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/**
|
||||
* @brief Debug Verbose functions
|
||||
*
|
||||
* @param mmap
|
||||
*/
|
||||
/*
|
||||
void print_Multiboot_memory_Map(multiboot_memory_map_t* mmap) {
|
||||
printf(
|
||||
"size = 0x%x, base_addr = 0x%x%08x, length = 0x%x%08x, type = 0x%x\n",
|
||||
(unsigned) mmap->size,
|
||||
(unsigned) (mmap->addr >> 32),
|
||||
(unsigned) (mmap->addr & 0xffffffff),
|
||||
(unsigned) (mmap->len >> 32),
|
||||
(unsigned) (mmap->len & 0xffffffff),
|
||||
(unsigned) mmap->type
|
||||
);
|
||||
}
|
||||
*/
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include <stddef.h>
|
||||
//#include "../../multiboot.h"
|
||||
#include "../memoryinfo.h"
|
||||
|
||||
void initialise_available_regions(uint32_t memoryMapAddr, uint32_t memoryMapLastAddr, uint32_t* memoryBitMap, int* used_blocks);
|
||||
|
||||
/*
|
||||
void mapMultibootMemoryMap( MemoryInfo* memInfo , multiboot_info_t *mbt);
|
||||
*/
|
||||
/**
|
||||
* @brief Debug Verbose Functions
|
||||
*
|
||||
* @param mmap
|
||||
*/
|
||||
/*
|
||||
void print_Multiboot_memory_Map(multiboot_memory_map_t* mmap);
|
||||
*/
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
struct MemoryArea{
|
||||
void* StartAddress;
|
||||
size_t Size;
|
||||
unsigned int type;
|
||||
MemoryArea* Next;
|
||||
|
||||
}__attribute__((packed));
|
||||
|
||||
struct MemoryInfo {
|
||||
uint32_t TotalMemory;
|
||||
uint32_t ReservedMemory;
|
||||
MemoryArea* MemoryRegionList;
|
||||
}__attribute__((packed));
|
||||
|
||||
|
||||
|
@ -1,56 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
/*
|
||||
This file contains some handy definitions for different types
|
||||
that have to do with paging in atleast 32 bit and maybe sometime in the future
|
||||
also 64 bit mode.
|
||||
*/
|
||||
|
||||
#define MAX_DIRECTORY_ENTRIES 1024
|
||||
#define MAX_PAGE_TABLE_ENTRIES 1024
|
||||
#define MAX_PAGES 1024
|
||||
|
||||
#define PHYSICAL_ADDRESS uint32_t
|
||||
#define VIRTUAL_ADDRESS uint32_t
|
||||
|
||||
#define PageDirectoryEntry uint32_t
|
||||
#define PageTableEntry uint32_t
|
||||
|
||||
|
||||
#define KERNEL_VRT_MEMORY_BEGIN 0xC0000000
|
||||
#define KERNEL_VRT_MEMORY_END 0xCFFFFFFF
|
||||
#define PAGE_SIZE 4096;
|
||||
|
||||
|
||||
// NOTE: FIXME: I am fairly certain these masks are off by one!
|
||||
|
||||
#define PD32_PRESENT_MASK (0x1 << 0)
|
||||
#define PD32_READ_WRITE_MASK (0x1 << 1)
|
||||
#define PD32_SUPERVISOR_MASK (0x1 << 2)
|
||||
#define PD32_WRITE_THROUGH_MASK (0x1 << 3)
|
||||
#define PD32_CACHE_DISABLE_MASK (0x1 << 4)
|
||||
#define PD32_ACCESSED_MASK (0x1 << 5)
|
||||
#define PD32_AVAILABLE_1_4KB_MASK (0x1 << 6)
|
||||
#define PD32_DISABLE_4MB_MASK (0x1 << 6)
|
||||
#define PD32_PAGE_SIZE_MASK (0x1 << 7)
|
||||
#define PD32_GLOBAL_4MB_MASK (0x1 << 8)
|
||||
#define PD32_AVAILABLE_2_4MB_MASK ( 14 << 9)
|
||||
#define PD32_AVAILABLE_2_4KB_MASK ( 15 << 8)
|
||||
#define PD32_ADDRESS_4KB_MASK (0x8FFFF << 12)
|
||||
#define PD32_PAGE_ATTRIBUTE_TABLE_4MB_MASK (0x1 << 12)
|
||||
#define PD32_HIGH_HALF_ADDRESS_4MB_MASK (0x7F<< 13)
|
||||
#define PD32_RESERVED_4MB_MASK (0x1 << 21)
|
||||
#define PD32_LOWER_HALF_ADDRESS_4MB_MASK (0x1FF << 22)
|
||||
|
||||
#define PT32_PRESENT_MASK (0x1 << 0)
|
||||
#define PT32_READ_WRITE_MASK (0x1 << 1)
|
||||
#define PT32_SUPERVISOR_MASK (0x1 << 2)
|
||||
#define PT32_WRITE_THROUGH_MASK (0x1 << 3)
|
||||
#define PT32_CACHE_DISABLE_MASK (0x1 << 4)
|
||||
#define PT32_ACCESSED_MASK (0x1 << 5)
|
||||
#define PT32_DIRTY_MASK (0x1 << 6)
|
||||
#define PT32_PAGE_ATTRIBUTE_TABLE_MASK (0x1 << 7)
|
||||
#define PT32_GLOBAL_MASK (0x1 << 8)
|
||||
#define PT32_AVAILABLE_MASK (0x7 << 9)
|
||||
#define PT32_CACHE_DISABLE_MASK (0x7FFFF << 12)
|
||||
|
@ -1,44 +0,0 @@
|
||||
# NOTE: I wish this wasn't AT&T Syntax its horrible
|
||||
# REMINDER: INSTRUCTION FROM_REGISTER, TO_REGISTER
|
||||
.globl enablePaging
|
||||
enablePaging:
|
||||
# Create a new call frame
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
|
||||
# Set the PG bit of CR0
|
||||
mov %cr0, %eax
|
||||
or $0x80000000, %eax
|
||||
mov %eax, %cr0
|
||||
|
||||
# Restore to the previous call frame
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
.globl loadPageDirectory
|
||||
loadPageDirectory:
|
||||
push %ebp
|
||||
mov %esp, %ebp
|
||||
|
||||
/* NOTE: We should probably check if paging is already enabled.
|
||||
Changing the CR3 register whilst paging is enabled might
|
||||
result in unwanted behaviour (in the worst case) or cause a
|
||||
fault (in the best case).
|
||||
*/
|
||||
|
||||
mov 8(%esp), %eax # Move the first argument in the eax register
|
||||
|
||||
mov %eax, %cr3 # Move the value of eax into the CR3 register
|
||||
|
||||
/*
|
||||
Moving the value of the argument passed to this function
|
||||
into the CR3 register will allow the MMU to access the paging
|
||||
structure we setup in memory once we enable paging
|
||||
*/
|
||||
|
||||
mov %ebp, %esp
|
||||
pop %ebp
|
||||
ret
|
||||
|
||||
|
Reference in New Issue
Block a user