akaros/kern/arch/x86/ros/mmu.h
<<
>>
Prefs
   1/* Contains macros and constants for the kernel VM mapping, page tables,
   2 * segmentation, control registers, etc. */
   3
   4#pragma once
   5
   6#define ROS_INC_ARCH_MMU_H
   7
   8#include <ros/arch/mmu64.h>
   9
  10/* **************************************** */
  11/* Control Registers */
  12
  13// Control Register flags
  14#define CR0_PE          0x00000001      // Protection Enable
  15#define CR0_MP          0x00000002      // Monitor coProcessor
  16#define CR0_EM          0x00000004      // Emulation
  17#define CR0_TS          0x00000008      // Task Switched
  18#define CR0_ET          0x00000010      // Extension Type
  19#define CR0_NE          0x00000020      // Numeric Error
  20#define CR0_WP          0x00010000      // Write Protect
  21#define CR0_AM          0x00040000      // Alignment Mask
  22#define CR0_NW          0x20000000      // Not Writethrough - more tricky than it sounds
  23#define CR0_CD          0x40000000      // Cache Disable
  24#define CR0_PG          0x80000000      // Paging
  25
  26// These two relate to the cacheability (L1, etc) of the page directory
  27#define CR3_PWT         0x00000008      // Page directory caching write through
  28#define CR3_PCD         0x00000010      // Page directory caching disabled
  29
  30#define CR4_VME         0x00000001      // V86 Mode Extensions
  31#define CR4_PVI         0x00000002      // Protected-Mode Virtual Interrupts
  32#define CR4_TSD         0x00000004      // Time Stamp Disable
  33#define CR4_DE          0x00000008      // Debugging Extensions
  34#define CR4_PSE         0x00000010      // Page Size Extensions
  35#define CR4_PAE         0x00000020      // Physical Address Extensions
  36#define CR4_MCE         0x00000040      // Machine Check Enable
  37#define CR4_PGE         0x00000080      // Global Pages Enabled
  38#define CR4_PCE         0x00000100      // Performance counter enable
  39#define CR4_OSFXSR      0x00000200      // OS support for FXSAVE/FXRSTOR
  40#define CR4_OSXMME      0x00000400      // OS support for unmasked SIMD FP exceptions
  41#define CR4_VMXE        0x00002000      // VMX enable
  42#define CR4_SMXE        0x00004000      // SMX enable
  43#define CR4_FSGSBASE    0x00010000      // RD/WR FS/GS Base enabled
  44#define CR4_OSXSAVE     0x00040000      // XSAVE and processor extended states-enabled
  45
  46// Eflags register
  47#define FL_CF           0x00000001      // Carry Flag
  48#define FL_PF           0x00000004      // Parity Flag
  49#define FL_AF           0x00000010      // Auxiliary carry Flag
  50#define FL_ZF           0x00000040      // Zero Flag
  51#define FL_SF           0x00000080      // Sign Flag
  52#define FL_TF           0x00000100      // Trap Flag
  53#define FL_IF           0x00000200      // Interrupt Flag
  54#define FL_DF           0x00000400      // Direction Flag
  55#define FL_OF           0x00000800      // Overflow Flag
  56#define FL_IOPL_MASK    0x00003000      // I/O Privilege Level bitmask
  57#define FL_IOPL_0       0x00000000      //   IOPL == 0
  58#define FL_IOPL_1       0x00001000      //   IOPL == 1
  59#define FL_IOPL_2       0x00002000      //   IOPL == 2
  60#define FL_IOPL_3       0x00003000      //   IOPL == 3
  61#define FL_NT           0x00004000      // Nested Task
  62#define FL_RF           0x00010000      // Resume Flag
  63#define FL_VM           0x00020000      // Virtual 8086 mode
  64#define FL_AC           0x00040000      // Alignment Check
  65#define FL_VIF          0x00080000      // Virtual Interrupt Flag
  66#define FL_VIP          0x00100000      // Virtual Interrupt Pending
  67#define FL_ID           0x00200000      // ID flag
  68#define FL_RSVD_1       0x00000002      // These 1s must be 1, rflags |= this
  69#define FL_RSVD_0       0x003f7fd7      // These 0s must be 0, rflags &= this
  70
  71// Page fault error codes
  72#define FEC_PR          0x1     // Page fault caused by protection violation
  73#define FEC_WR          0x2     // Page fault caused by a write
  74#define FEC_U           0x4     // Page fault occured while in user mode
  75