Enabling X2APIC
[akaros.git] / kern / arch / x86 / ros / mmu64.h
index be2058e..3ebd79e 100644 (file)
@@ -1,5 +1,4 @@
-#ifndef ROS_INC_ARCH_MMU64_H
-#define ROS_INC_ARCH_MMU64_H
+#pragma once
 
 #ifndef ROS_INC_ARCH_MMU_H
 #error "Do not include include ros/arch/mmu64.h directly"
@@ -32,14 +31,14 @@ typedef struct x86_pgdir {
  *                     |                              |                     |
  * KERN_LOAD_ADDR -->  +------------------------------+ 0xffffffffc0000000 -+
  *                     |                              |
- *                     |          Local APIC          | RW/--  APIC_SIZE (1MB)
+ *                     |            IOAPIC            | RW/--  APIC_SIZE (1MB)
  *                     |                              |
- *    LAPIC_BASE  -->  +------------------------------+ 0xffffffffbff00000
+ *   IOAPIC_BASE  -->  +------------------------------+ 0xffffffffbff00000
  *                     |                              |
- *                     |            IOAPIC            | RW/--  APIC_SIZE (1MB)
+ *                     |                              | RW/--  APIC_SIZE (1MB)
  *                     |                              |
- *  IOAPIC_BASE,  -->  +------------------------------+ 0xffffffffbfe00000
- *  KERN_DYN_TOP       |   Kernel Dynamic Mappings    |
+ *   KERN_DYN_TOP -->  +------------------------------+ 0xffffffffbfe00000
+ *                     |   Kernel Dynamic Mappings    |
  *                     |              .               |
  *                     :              .               :
  *                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RW/--
@@ -118,6 +117,17 @@ typedef struct x86_pgdir {
  *                     |     Program Data & Heap      |
  *                     |                              |
  *                     +------------------------------+ 0x0000000000400000
+ *                     .                              .
+ *                     .                              .
+ *                     |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
+ *                     |                              |
+ *                     |       ld.so (Dynamic)        |
+ *                     |                              |
+ * MMAP_LD_FIXED_VA    +------------------------------+ 0x0000000000100000
+ *                     |                              |
+ *                     |                              |
+ *                     |                              |
+ * MMAP_LOWEST_VA      +------------------------------+ 0x0000000000001000
  *                     |                              |
  *                     |       Empty Memory (*)       |
  *                     |                              |
@@ -142,8 +152,7 @@ typedef struct x86_pgdir {
 #define KERN_LOAD_ADDR  0xffffffffc0000000
 /* Static kernel mappings */
 #define APIC_SIZE              0x100000
-#define LAPIC_BASE             (KERN_LOAD_ADDR - APIC_SIZE)
-#define IOAPIC_BASE            (LAPIC_BASE - APIC_SIZE)
+#define IOAPIC_BASE            (KERN_LOAD_ADDR - APIC_SIZE)
 /* All arches must define this, which is the lower limit of their static
  * mappings, and where the dynamic mappings will start. */
 #define KERN_DYN_TOP   IOAPIC_BASE
@@ -239,27 +248,11 @@ typedef struct x86_pgdir {
 #define LA2PPN(la)             ((uintptr_t)(la) >> PGSHIFT)
 #define PTE2PPN(pte)   LA2PPN(pte)
 #define PGOFF(la)              ((uintptr_t)(la) & (PGSIZE - 1))
-
-/* construct PTE from PPN and flags */
-#define PTE(ppn, flags) ((ppn) << PGSHIFT | PGOFF(flags))
-
-/* construct linear address from indexes and offset */
-#define PGADDR(p4, p3, p2, p1, o) ((void*)(((p4) << PML4_SHIFT) |              \
-                                           ((p3) << PML3_SHIFT) |              \
-                                           ((p2) << PML2_SHIFT) |              \
-                                           ((p1) << PML1_SHIFT) |(o)))
+#define NPTENTRIES             512
 
 /* This is used in places (procinfo) meaning "size of smallest jumbo page" */
 #define PTSIZE PML2_PTE_REACH
 
-
-/* TODO: not sure if we'll need these - limited to 64bit code */
-/* this only gives us the L1 PML */
-#define PTX(la)                ((((uintptr_t) (la)) >> 12) & 0x1ff)
-#define JPGOFF(la)     (((uintptr_t) (la)) & 0x001FFFFF)
-#define NPTENTRIES             512
-#define JPGSIZE PTSIZE
-
 /* Page table/directory entry flags. */
 
 /* Some things to be careful of:  Global and PAT only apply to the last PTE in
@@ -515,5 +508,3 @@ typedef struct Pseudodesc {
 
 /* TLS 'syscall', coupled to trapentry64.S.  Needed a non-canon 'addr' */
 #define FASTCALL_SETFSBASE 0xf0f0000000000001
-
-#endif /* ROS_INC_ARCH_MMU64_H */