The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/pc/mem.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Memory and machine-specific definitions.  Used in C and assembler.
    3  */
    4 
    5 /*
    6  * Sizes
    7  */
    8 #define BI2BY           8                       /* bits per byte */
    9 #define BI2WD           32                      /* bits per word */
   10 #define BY2WD           4                       /* bytes per word */
   11 #define BY2V            8                       /* bytes per double word */
   12 #define BY2PG           4096                    /* bytes per page */
   13 #define WD2PG           (BY2PG/BY2WD)           /* words per page */
   14 #define BY2XPG          (4096*1024)     /* bytes per big page */
   15 #define PGSHIFT         12                      /* log(BY2PG) */
   16 #define ROUND(s, sz)    (((s)+((sz)-1))&~((sz)-1))
   17 #define PGROUND(s)      ROUND(s, BY2PG)
   18 #define BLOCKALIGN      8
   19 
   20 #define MAXMACH         8                       /* max # cpus system can run */
   21 #define KSTACK          4096                    /* Size of kernel stack */
   22 
   23 /*
   24  * Time
   25  */
   26 #define HZ              (100)                   /* clock frequency */
   27 #define MS2HZ           (1000/HZ)               /* millisec per clock tick */
   28 #define TK2SEC(t)       ((t)/HZ)                /* ticks to seconds */
   29 
   30 /*
   31  *  Address spaces
   32  */
   33 #define KZERO           0xF0000000              /* base of kernel address space */
   34 #define KTZERO          (KZERO+0x100000)                /* first address in kernel text - 9load sits below */
   35 #define VPT                     (KZERO-VPTSIZE)
   36 #define VPTSIZE         BY2XPG
   37 #define NVPT            (VPTSIZE/BY2WD)
   38 #define KMAP            (VPT-KMAPSIZE)
   39 #define KMAPSIZE        BY2XPG
   40 #define VMAP            (KMAP-VMAPSIZE)
   41 #define VMAPSIZE        (0x10000000-VPTSIZE-KMAPSIZE)
   42 #define UZERO           0                       /* base of user address space */
   43 #define UTZERO          (UZERO+BY2PG)           /* first address in user text */
   44 #define USTKTOP         (VMAP-BY2PG)            /* byte just beyond user stack */
   45 #define USTKSIZE        (16*1024*1024)          /* size of user stack */
   46 #define TSTKTOP         (USTKTOP-USTKSIZE)      /* end of new stack in sysexec */
   47 #define TSTKSIZ         100     /* pages in new stack; limits exec args */
   48 
   49 /*
   50  * Fundamental addresses - bottom 64kB saved for return to real mode
   51  */
   52 #define CONFADDR        (KZERO+0x1200)          /* info passed from boot loader */
   53 #define TMPADDR         (KZERO+0x2000)          /* used for temporary mappings */
   54 #define APBOOTSTRAP     (KZERO+0x3000)          /* AP bootstrap code */
   55 #define RMUADDR         (KZERO+0x7C00)          /* real mode Ureg */
   56 #define RMCODE          (KZERO+0x8000)          /* copy of first page of KTEXT */
   57 #define RMBUF           (KZERO+0x9000)          /* buffer for user space - known to vga */
   58 #define IDTADDR         (KZERO+0x10800)         /* idt */
   59 #define REBOOTADDR      (0x11000)               /* reboot code - physical address */
   60 #define CPU0PDB         (KZERO+0x12000)         /* bootstrap processor PDB */
   61 #define CPU0PTE         (KZERO+0x13000)         /* bootstrap processor PTE's for 0-4MB */
   62 #define CPU0GDT         (KZERO+0x14000)         /* bootstrap processor GDT */
   63 #define MACHADDR        (KZERO+0x15000)         /* as seen by current processor */
   64 #define CPU0MACH        (KZERO+0x16000)         /* Mach for bootstrap processor */
   65 #define MACHSIZE        BY2PG
   66 #define CPU0PTE1        (KZERO+0x17000)         /* bootstrap processor PTE's for 4MB-8MB */
   67 #define CPU0END         (CPU0PTE1+BY2PG)
   68 /*
   69  * N.B.  ramscan knows that CPU0END is the end of reserved data
   70  * N.B.  _startPADDR knows that CPU0PDB is the first reserved page
   71  * and that there are 6 of them.
   72  */
   73 
   74 /*
   75  *  known x86 segments (in GDT) and their selectors
   76  */
   77 #define NULLSEG 0       /* null segment */
   78 #define KDSEG   1       /* kernel data/stack */
   79 #define KESEG   2       /* kernel executable */ 
   80 #define UDSEG   3       /* user data/stack */
   81 #define UESEG   4       /* user executable */
   82 #define TSSSEG  5       /* task segment */
   83 #define APMCSEG         6       /* APM code segment */
   84 #define APMCSEG16       7       /* APM 16-bit code segment */
   85 #define APMDSEG         8       /* APM data segment */
   86 #define KESEG16         9       /* kernel executable 16-bit */
   87 #define NGDT            10      /* number of GDT entries required */
   88 /* #define      APM40SEG        8       /* APM segment 0x40 */
   89 
   90 #define SELGDT  (0<<2)  /* selector is in gdt */
   91 #define SELLDT  (1<<2)  /* selector is in ldt */
   92 
   93 #define SELECTOR(i, t, p)       (((i)<<3) | (t) | (p))
   94 
   95 #define NULLSEL SELECTOR(NULLSEG, SELGDT, 0)
   96 #define KDSEL   SELECTOR(KDSEG, SELGDT, 0)
   97 #define KESEL   SELECTOR(KESEG, SELGDT, 0)
   98 #define UESEL   SELECTOR(UESEG, SELGDT, 3)
   99 #define UDSEL   SELECTOR(UDSEG, SELGDT, 3)
  100 #define TSSSEL  SELECTOR(TSSSEG, SELGDT, 0)
  101 #define APMCSEL         SELECTOR(APMCSEG, SELGDT, 0)
  102 #define APMCSEL16       SELECTOR(APMCSEG16, SELGDT, 0)
  103 #define APMDSEL         SELECTOR(APMDSEG, SELGDT, 0)
  104 /* #define      APM40SEL        SELECTOR(APM40SEG, SELGDT, 0) */
  105 
  106 /*
  107  *  fields in segment descriptors
  108  */
  109 #define SEGDATA (0x10<<8)       /* data/stack segment */
  110 #define SEGEXEC (0x18<<8)       /* executable segment */
  111 #define SEGTSS  (0x9<<8)        /* TSS segment */
  112 #define SEGCG   (0x0C<<8)       /* call gate */
  113 #define SEGIG   (0x0E<<8)       /* interrupt gate */
  114 #define SEGTG   (0x0F<<8)       /* trap gate */
  115 #define SEGTYPE (0x1F<<8)
  116 
  117 #define SEGP    (1<<15)         /* segment present */
  118 #define SEGPL(x) ((x)<<13)      /* priority level */
  119 #define SEGB    (1<<22)         /* granularity 1==4k (for expand-down) */
  120 #define SEGG    (1<<23)         /* granularity 1==4k (for other) */
  121 #define SEGE    (1<<10)         /* expand down */
  122 #define SEGW    (1<<9)          /* writable (for data/stack) */
  123 #define SEGR    (1<<9)          /* readable (for code) */
  124 #define SEGD    (1<<22)         /* default 1==32bit (for code) */
  125 
  126 /*
  127  *  virtual MMU
  128  */
  129 #define PTEMAPMEM       (1024*1024)     
  130 #define PTEPERTAB       (PTEMAPMEM/BY2PG)
  131 #define SEGMAPSIZE      1984
  132 #define SSEGMAPSIZE     16
  133 #define PPN(x)          ((x)&~(BY2PG-1))
  134 
  135 /*
  136  *  physical MMU
  137  */
  138 #define PTEVALID        (1<<0)
  139 #define PTEWT           (1<<3)
  140 #define PTEUNCACHED     (1<<4)
  141 #define PTEWRITE        (1<<1)
  142 #define PTERONLY        (0<<1)
  143 #define PTEKERNEL       (0<<2)
  144 #define PTEUSER         (1<<2)
  145 #define PTESIZE         (1<<7)
  146 #define PTEGLOBAL       (1<<8)
  147 
  148 /*
  149  * Macros for calculating offsets within the page directory base
  150  * and page tables. 
  151  */
  152 #define PDX(va)         ((((ulong)(va))>>22) & 0x03FF)
  153 #define PTX(va)         ((((ulong)(va))>>12) & 0x03FF)
  154 
  155 #define getpgcolor(a)   0
  156 

Cache object: b37aeded5f4ea7a653def2827c8450a5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.