This repository has been archived on 2020-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
Legacy-Sync/headers/paging.h
Jenny Curle f6ba6aa117 Legacy OS files. Have an i686-elf-gcc & -ld in your PATH,
and the Makefile will take care of the rest.
2019-04-01 01:38:50 +01:00

48 lines
1.3 KiB
C

#pragma once
#include "common.h"
#include "isr.h"
#include <stdint.h>
typedef struct page
{
uint32_t present : 1; // page present in memory
uint32_t rw : 1; // ro if clear, rw if set
uint32_t user : 1; // supervisor level only if clear
uint32_t accessed : 1; // has been accessed since last referesh
uint32_t dirty : 1; // has been written to since last refresh
uint32_t unused : 7; // reserved and unused bits
uint32_t frame : 20; // frame address (right shift 12 bits)
} page_t;
typedef struct page_table
{
page_t pages[1024];
} page_table_t;
typedef struct
{
// array of pointers to pagetables
page_table_t *tables[1024];
// array of pointers to tables above but at the *physical* loc
// so they can be loaded into cr3
uint32_t tablesPhysical[1024];
uint32_t physicalAddr;
} page_directory_t;
// sets up paging
void initialize_paging(void);
// causes the specified page directory to be loaded
// into the cr3 register
void switch_page_directory(page_directory_t *new);
// retrieves a pointer to the page requires
// if make == 1, if the pagetable in which page
// should reside inst there create it
page_t *get_page(uint32_t address, int make, page_directory_t *dir);
// handler for page faults
void page_fault(registers_t *regs);