root/kernel/memlayout.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 // Physical memory layout
   2 
   3 // qemu -machine virt is set up like this,
   4 // based on qemu's hw/riscv/virt.c:
   5 //
   6 // 00001000 -- boot ROM, provided by qemu
   7 // 02000000 -- CLINT
   8 // 0C000000 -- PLIC
   9 // 10000000 -- uart0
  10 // 10001000 -- virtio disk
  11 // 80000000 -- qemu's boot ROM loads the kernel here,
  12 //             then jumps here.
  13 // unused RAM after 80000000.
  14 
  15 // the kernel uses physical memory thus:
  16 // 80000000 -- entry.S, then kernel text and data
  17 // end -- start of kernel page allocation area
  18 // PHYSTOP -- end RAM used by the kernel
  19 
  20 // qemu puts UART registers here in physical memory.
  21 #define UART0     0x10000000L
  22 #define UART0_IRQ 10
  23 
  24 // virtio mmio interface
  25 #define VIRTIO0     0x10001000
  26 #define VIRTIO0_IRQ 1
  27 
  28 // core-local interrupt controller (CLINT)
  29 #define CLINT_BASE  0x02000000L
  30 #define CLINT(hart) (CLINT_BASE + (hart) * 4)
  31 
  32 // qemu puts platform-level interrupt controller (PLIC) here.
  33 #define PLIC                 0x0c000000L
  34 #define PLIC_PRIORITY        (PLIC + 0x0)
  35 #define PLIC_PENDING         (PLIC + 0x1000)
  36 #define PLIC_SENABLE(hart)   (PLIC + 0x2080 + (hart) * 0x100)
  37 #define PLIC_SPRIORITY(hart) (PLIC + 0x201000 + (hart) * 0x2000)
  38 #define PLIC_SCLAIM(hart)    (PLIC + 0x201004 + (hart) * 0x2000)
  39 
  40 // the kernel expects there to be RAM
  41 // for use by the kernel and user pages
  42 // from physical address 0x80000000 to PHYSTOP.
  43 #define KERNBASE 0x80000000L
  44 #define PHYSTOP  (KERNBASE + 128 * 1024 * 1024)
  45 
  46 // map the trampoline page to the highest address,
  47 // in both user and kernel space.
  48 #define TRAMPOLINE (MAXVA - PGSIZE)
  49 
  50 // map kernel stacks beneath the trampoline,
  51 // each surrounded by invalid guard pages.
  52 #define KSTACK(p) (TRAMPOLINE - ((p) + 1) * 2 * PGSIZE)
  53 
  54 // User memory layout.
  55 // Address zero first:
  56 //   text
  57 //   original data and bss
  58 //   fixed-size stack
  59 //   expandable heap
  60 //   ...
  61 //   TRAPFRAME (p->trapframe, used by the trampoline)
  62 //   TRAMPOLINE (the same page as in the kernel)
  63 #define TRAPFRAME (TRAMPOLINE - PGSIZE)

/* [<][>][^][v][top][bottom][index][help] */