1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2014 Joyent, Inc.  All rights reserved.
  14  */
  15 
  16 #include <sys/types.h>
  17 #include <sys/bootconf.h>
  18 #include <sys/obpdefs.h>
  19 #include <sys/promif.h>
  20 
  21 /*
  22  *      32-bit Kernel's Virtual memory layout.
  23  *              +-----------------------+
  24  *              |    exception table    |
  25  * 0xFFFF0000  -|-----------------------|- EXCEPTION_ADDRESS
  26  *              |                       |
  27  * 0xFFC00000  -|-----------------------|- ARGSBASE
  28  *              |   XXX  debugger?      |
  29  * 0xFF800000  -|-----------------------|- XXX SEGDEBUBBASE?+
  30  *              |      Kernel Data      |
  31  * 0xFEC00000  -|-----------------------|
  32  *              |      Kernel Text      |
  33  * 0xFE800000  -|-----------------------|- KERNEL_TEXT
  34  *              |                       |
  35  *              |    XXX No idea yet    |
  36  *              |                       |
  37  * 0xC8002000  -|-----------------------|- XXX segmap_start?
  38  *              |       Red Zone        |
  39  * 0xC8000000  -|-----------------------|- kernelbase / userlimit (floating)
  40  *              |      User Stack       |
  41  *              |                       |
  42  *              |                       |
  43  *
  44  *              :                       :
  45  *              |    shared objects     |
  46  *              :                       :
  47  *
  48  *              :                       :
  49  *              |       user data       |
  50  *             -|-----------------------|-
  51  *              |       user text       |
  52  * 0x00002000  -|-----------------------|-  XXX Not necessairily truetoday
  53  *              |       invalid         |
  54  * 0x00000000  -|-----------------------|-
  55  *
  56  * + Item does not exist at this time.
  57  */
  58 
  59 struct bootops          *bootops = 0;   /* passed in from boot */
  60 struct bootops          **bootopsp;
  61 struct boot_syscalls    *sysp;          /* passed in from boot */
  62 
  63 char kern_bootargs[OBP_MAXPATHLEN];
  64 char kern_bootfile[OBP_MAXPATHLEN];
  65 
  66 caddr_t s_text;         /* start of kernel text segment */
  67 caddr_t e_text;         /* end of kernel text segment */
  68 caddr_t s_data;         /* start of kernel data segment */
  69 caddr_t e_data;         /* end of kernel data segment */
  70 caddr_t modtext;        /* start of loadable module text reserved */
  71 caddr_t e_modtext;      /* end of loadable module text reserved */
  72 caddr_t moddata;        /* start of loadable module data reserved */
  73 caddr_t e_moddata;      /* end of loadable module data reserved */
  74 
  75 /*
  76  * Some CPUs have holes in the middle of the 64-bit virtual address range.
  77  */
  78 uintptr_t hole_start, hole_end;
  79 
  80 /*
  81  * PROM debugging facilities
  82  */
  83 int prom_debug = 1;
  84 
  85 /*
  86  * VM related data
  87  */
  88 long page_hashsz;               /* Size of page hash table (power of two) */
  89 unsigned int page_hashsz_shift; /* log2(page_hashsz) */
  90 struct page *pp_base;           /* Base of initial system page struct array */
  91 struct page **page_hash;        /* Page hash table */
  92 pad_mutex_t *pse_mutex;         /* Locks protecting pp->p_selock */
  93 size_t pse_table_size;          /* Number of mutexes in pse_mutex[] */
  94 int pse_shift;                  /* log2(pse_table_size) */
  95 
  96 /*
  97  * Cache size information filled in via cpuid.
  98  */
  99 int l2cache_sz;
 100 int l2cache_linesz ;
 101 int l2cache_assoc;
 102 
 103 /*
 104  * Do basic set up.
 105  */
 106 static void
 107 startup_init()
 108 {
 109         if (BOP_GETPROPLEN(bootops, "prom_debug") >= 0) {
 110                 ++prom_debug;
 111                 prom_printf("prom_debug found in boot enviroment");
 112         }
 113 }
 114 
 115 static void
 116 startup_memlist()
 117 {
 118         bop_panic("startup_memlist");
 119 }
 120 
 121 static void
 122 startup_kmem()
 123 {
 124         bop_panic("startup_kmem");
 125 }
 126 
 127 static void
 128 startup_vm()
 129 {
 130         bop_panic("startup_vm");
 131 }
 132 
 133 static void
 134 startup_modules()
 135 {
 136         bop_panic("startup_modules");
 137 }
 138 
 139 static void
 140 startup_end()
 141 {
 142         bop_panic("startup_end");
 143 }
 144 
 145 /*
 146  * Our kernel text is at 0xfe800000, data at 0xfec000000, and exception vector
 147  * at 0xffff0000. These addresses are all determined and set in stone at link
 148  * time.
 149  *
 150  * This is the ARM machine-dependent startup code. Let's startup the world!
 151  */
 152 void
 153 startup(void)
 154 {
 155         startup_init();
 156         /* TODO if we ever need a board specific startup, it goes here */
 157         startup_memlist();
 158         startup_kmem();
 159         startup_vm();
 160         startup_modules();
 161         startup_end();
 162 }