usr/src/uts/i86pc/os/startup.c
author Vikram Hegde <Vikram.Hegde@Sun.COM>
Mon, 22 Jun 2009 15:41:16 -0700
changeset 9940 82fa1538a908
parent 9732 256da057a700
child 10175 dd9708d1f561
permissions -rw-r--r--
6819642 Intel IOMMU has multiple issues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     1
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     2
 * CDDL HEADER START
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     3
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1455
b43f098fa50c 6378953 allocation of interrupt threads could be more common
andrei
parents: 1417
diff changeset
     5
 * Common Development and Distribution License (the "License").
b43f098fa50c 6378953 allocation of interrupt threads could be more common
andrei
parents: 1417
diff changeset
     6
 * You may not use this file except in compliance with the License.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     7
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    11
 * and limitations under the License.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    12
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    18
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    19
 * CDDL HEADER END
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    20
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    21
/*
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
    22
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    23
 * Use is subject to license terms.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    24
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    25
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    26
#include <sys/types.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    27
#include <sys/t_lock.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    28
#include <sys/param.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    29
#include <sys/sysmacros.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    30
#include <sys/signal.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    31
#include <sys/systm.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    32
#include <sys/user.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    33
#include <sys/mman.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    34
#include <sys/vm.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    35
#include <sys/conf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    36
#include <sys/avintr.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    37
#include <sys/autoconf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    38
#include <sys/disp.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    39
#include <sys/class.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    40
#include <sys/bitmap.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    41
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    42
#include <sys/privregs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    43
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    44
#include <sys/proc.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    45
#include <sys/buf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    46
#include <sys/kmem.h>
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
    47
#include <sys/mem.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    48
#include <sys/kstat.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    49
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    50
#include <sys/reboot.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    51
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    52
#include <sys/cred.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    53
#include <sys/vnode.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    54
#include <sys/file.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    55
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    56
#include <sys/procfs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    57
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    58
#include <sys/vfs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    59
#include <sys/cmn_err.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    60
#include <sys/utsname.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    61
#include <sys/debug.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    62
#include <sys/kdi.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    63
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    64
#include <sys/dumphdr.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    65
#include <sys/bootconf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    66
#include <sys/varargs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    67
#include <sys/promif.h>
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
    68
#include <sys/modctl.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    69
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    70
#include <sys/sunddi.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    71
#include <sys/sunndi.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    72
#include <sys/ndi_impldefs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    73
#include <sys/ddidmareq.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    74
#include <sys/psw.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    75
#include <sys/regset.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    76
#include <sys/clock.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    77
#include <sys/pte.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    78
#include <sys/tss.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    79
#include <sys/stack.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    80
#include <sys/trap.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    81
#include <sys/fp.h>
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
    82
#include <vm/kboot_mmu.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    83
#include <vm/anon.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    84
#include <vm/as.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    85
#include <vm/page.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    86
#include <vm/seg.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    87
#include <vm/seg_dev.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    88
#include <vm/seg_kmem.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    89
#include <vm/seg_kpm.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    90
#include <vm/seg_map.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    91
#include <vm/seg_vn.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    92
#include <vm/seg_kp.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    93
#include <sys/memnode.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    94
#include <vm/vm_dep.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    95
#include <sys/thread.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    96
#include <sys/sysconf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    97
#include <sys/vm_machparam.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    98
#include <sys/archsystm.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
    99
#include <sys/machsystm.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   100
#include <vm/hat.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   101
#include <vm/hat_i86.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   102
#include <sys/pmem.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   103
#include <sys/smp_impldefs.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   104
#include <sys/x86_archext.h>
6336
4eaf084434c9 6470538 domUs are unfriendly when too little memory is available to boot
bholler
parents: 5741
diff changeset
   105
#include <sys/cpuvar.h>
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   106
#include <sys/segments.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   107
#include <sys/clconf.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   108
#include <sys/kobj.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   109
#include <sys/kobj_lex.h>
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   110
#include <sys/cpc_impl.h>
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
   111
#include <sys/cpu_module.h>
437
76c202dd62bf PSARC 2005/483 SMBIOS Support for Solaris
mws
parents: 423
diff changeset
   112
#include <sys/smbios.h>
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   113
#include <sys/debug_info.h>
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   114
#include <sys/bootinfo.h>
5107
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
   115
#include <sys/ddi_timer.h>
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
   116
#include <sys/systeminfo.h>
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   117
#include <sys/multiboot.h>
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   118
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   119
#ifdef __xpv
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   120
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   121
#include <sys/hypervisor.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   122
#include <sys/xen_mmu.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   123
#include <sys/evtchn_impl.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   124
#include <sys/gnttab.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   125
#include <sys/xpv_panic.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   126
#include <xen/sys/xenbus_comms.h>
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   127
#include <xen/public/physdev.h>
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   128
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   129
extern void xen_late_startup(void);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   130
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   131
struct xen_evt_data cpu0_evt_data;
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   132
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
   133
#endif /* __xpv */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   134
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   135
extern void progressbar_init(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   136
extern void progressbar_start(void);
2712
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
   137
extern void brand_init(void);
6880
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
   138
extern void pcf_init(void);
8906
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
   139
extern void pg_init(void);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   140
4878
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   141
extern int size_pse_array(pgcnt_t, int);
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   142
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   143
#if defined(_SOFT_HOSTID)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   144
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   145
#include <sys/rtc.h>
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   146
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   147
static int32_t set_soft_hostid(void);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   148
static char hostid_file[] = "/etc/hostid";
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   149
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   150
#endif
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   151
8215
dc6a5d93e70c 6774448 Toonie needs non-unity map
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7942
diff changeset
   152
void *gfx_devinfo_list;
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
   153
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   154
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   155
 * XXX make declaration below "static" when drivers no longer use this
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   156
 * interface.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   157
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   158
extern caddr_t p0_va;	/* Virtual address for accessing physical page 0 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   159
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   160
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   161
 * segkp
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   162
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   163
extern int segkp_fromheap;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   164
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   165
static void kvm_init(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   166
static void startup_init(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   167
static void startup_memlist(void);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   168
static void startup_kmem(void);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   169
static void startup_modules(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   170
static void startup_vm(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   171
static void startup_end(void);
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   172
static void layout_kernel_va(void);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   173
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   174
#if !defined(__xpv)
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   175
void (*rootnex_iommu_init)(void) = NULL;
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   176
#endif
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   177
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   178
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   179
 * Declare these as initialized data so we can patch them.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   180
 */
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   181
#ifdef __i386
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   182
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   183
/*
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   184
 * Due to virtual address space limitations running in 32 bit mode, restrict
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   185
 * the amount of physical memory configured to a max of PHYSMEM pages (16g).
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   186
 *
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   187
 * If the physical max memory size of 64g were allowed to be configured, the
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   188
 * size of user virtual address space will be less than 1g. A limited user
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   189
 * address space greatly reduces the range of applications that can run.
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   190
 *
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   191
 * If more physical memory than PHYSMEM is required, users should preferably
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   192
 * run in 64 bit mode which has far looser virtual address space limitations.
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   193
 *
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   194
 * If 64 bit mode is not available (as in IA32) and/or more physical memory
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   195
 * than PHYSMEM is required in 32 bit mode, physmem can be set to the desired
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   196
 * value or to 0 (to configure all available memory) via eeprom(1M). kernelbase
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   197
 * should also be carefully tuned to balance out the need of the user
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   198
 * application while minimizing the risk of kernel heap exhaustion due to
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   199
 * kernelbase being set too high.
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   200
 */
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   201
#define	PHYSMEM	0x400000
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   202
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   203
#else /* __amd64 */
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
   204
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   205
/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   206
 * For now we can handle memory with physical addresses up to about
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   207
 * 64 Terabytes. This keeps the kernel above the VA hole, leaving roughly
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   208
 * half the VA space for seg_kpm. When systems get bigger than 64TB this
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   209
 * code will need revisiting. There is an implicit assumption that there
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   210
 * are no *huge* holes in the physical address space too.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   211
 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   212
#define	TERABYTE		(1ul << 40)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   213
#define	PHYSMEM_MAX64		mmu_btop(64 * TERABYTE)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   214
#define	PHYSMEM			PHYSMEM_MAX64
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   215
#define	AMD64_VA_HOLE_END	0xFFFF800000000000ul
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   216
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   217
#endif /* __amd64 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   218
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   219
pgcnt_t physmem = PHYSMEM;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   220
pgcnt_t obp_pages;	/* Memory used by PROM for its text and data */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   221
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   222
char *kobj_file_buf;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   223
int kobj_file_bufsize;	/* set in /etc/system */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   224
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   225
/* Global variables for MP support. Used in mp_startup */
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   226
caddr_t	rm_platter_va = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   227
uint32_t rm_platter_pa;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   228
841
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
   229
int	auto_lpg_disable = 1;
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
   230
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   231
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   232
 * Some CPUs have holes in the middle of the 64-bit virtual address range.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   233
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   234
uintptr_t hole_start, hole_end;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   235
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   236
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   237
 * kpm mapping window
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   238
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   239
caddr_t kpm_vbase;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   240
size_t  kpm_size;
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   241
static int kpm_desired;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   242
#ifdef __amd64
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   243
static uintptr_t segkpm_base = (uintptr_t)SEGKPM_BASE;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   244
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   245
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   246
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   247
 * Configuration parameters set at boot time.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   248
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   249
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   250
caddr_t econtig;		/* end of first block of contiguous kernel */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   251
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   252
struct bootops		*bootops = 0;	/* passed in from boot */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   253
struct bootops		**bootopsp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   254
struct boot_syscalls	*sysp;		/* passed in from boot */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   255
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   256
char bootblock_fstype[16];
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   257
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   258
char kern_bootargs[OBP_MAXPATHLEN];
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   259
char kern_bootfile[OBP_MAXPATHLEN];
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   260
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   261
/*
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   262
 * ZFS zio segment.  This allows us to exclude large portions of ZFS data that
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   263
 * gets cached in kmem caches on the heap.  If this is set to zero, we allocate
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   264
 * zio buffers from their own segment, otherwise they are allocated from the
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   265
 * heap.  The optimization of allocating zio buffers from their own segment is
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   266
 * only valid on 64-bit kernels.
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   267
 */
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   268
#if defined(__amd64)
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   269
int segzio_fromheap = 0;
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   270
#else
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   271
int segzio_fromheap = 1;
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   272
#endif
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   273
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   274
/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   275
 * new memory fragmentations are possible in startup() due to BOP_ALLOCs. this
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   276
 * depends on number of BOP_ALLOC calls made and requested size, memory size
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   277
 * combination and whether boot.bin memory needs to be freed.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   278
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   279
#define	POSS_NEW_FRAGMENTS	12
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   280
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   281
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   282
 * VM data structures
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   283
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   284
long page_hashsz;		/* Size of page hash table (power of two) */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   285
struct page *pp_base;		/* Base of initial system page struct array */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   286
struct page **page_hash;	/* Page hash table */
4878
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   287
pad_mutex_t *pse_mutex;		/* Locks protecting pp->p_selock */
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   288
size_t pse_table_size;		/* Number of mutexes in pse_mutex[] */
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   289
int pse_shift;			/* log2(pse_table_size) */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   290
struct seg ktextseg;		/* Segment used for kernel executable image */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   291
struct seg kvalloc;		/* Segment used for "valloc" mapping */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   292
struct seg kpseg;		/* Segment used for pageable kernel virt mem */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   293
struct seg kmapseg;		/* Segment used for generic kernel mappings */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   294
struct seg kdebugseg;		/* Segment used for the kernel debugger */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   295
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   296
struct seg *segkmap = &kmapseg;	/* Kernel generic mapping segment */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   297
static struct seg *segmap = &kmapseg;	/* easier to use name for in here */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   298
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   299
struct seg *segkp = &kpseg;	/* Pageable kernel virtual memory segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   300
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   301
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   302
struct seg kvseg_core;		/* Segment used for the core heap */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   303
struct seg kpmseg;		/* Segment used for physical mapping */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   304
struct seg *segkpm = &kpmseg;	/* 64bit kernel physical mapping segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   305
#else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   306
struct seg *segkpm = NULL;	/* Unused on IA32 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   307
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   308
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   309
caddr_t segkp_base;		/* Base address of segkp */
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   310
caddr_t segzio_base;		/* Base address of segzio */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   311
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   312
pgcnt_t segkpsize = btop(SEGKPDEFSIZE);	/* size of segkp segment in pages */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   313
#else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   314
pgcnt_t segkpsize = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   315
#endif
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   316
pgcnt_t segziosize = 0;		/* size of zio segment in pages */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   317
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   318
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   319
 * VA range available to the debugger
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   320
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   321
const caddr_t kdi_segdebugbase = (const caddr_t)SEGDEBUGBASE;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   322
const size_t kdi_segdebugsize = SEGDEBUGSIZE;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   323
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   324
struct memseg *memseg_base;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   325
struct vnode unused_pages_vp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   326
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   327
#define	FOURGB	0x100000000LL
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   328
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   329
struct memlist *memlist;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   330
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   331
caddr_t s_text;		/* start of kernel text segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   332
caddr_t e_text;		/* end of kernel text segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   333
caddr_t s_data;		/* start of kernel data segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   334
caddr_t e_data;		/* end of kernel data segment */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   335
caddr_t modtext;	/* start of loadable module text reserved */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   336
caddr_t e_modtext;	/* end of loadable module text reserved */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   337
caddr_t moddata;	/* start of loadable module data reserved */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   338
caddr_t e_moddata;	/* end of loadable module data reserved */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   339
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   340
struct memlist *phys_install;	/* Total installed physical memory */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   341
struct memlist *phys_avail;	/* Total available physical memory */
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   342
struct memlist *bios_rsvd;	/* Bios reserved memory */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   343
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   344
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   345
 * kphysm_init returns the number of pages that were processed
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   346
 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   347
static pgcnt_t kphysm_init(page_t *, pgcnt_t);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   348
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   349
#define	IO_PROP_SIZE	64	/* device property size */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   350
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   351
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   352
 * a couple useful roundup macros
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   353
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   354
#define	ROUND_UP_PAGE(x)	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   355
	((uintptr_t)P2ROUNDUP((uintptr_t)(x), (uintptr_t)MMU_PAGESIZE))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   356
#define	ROUND_UP_LPAGE(x)	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   357
	((uintptr_t)P2ROUNDUP((uintptr_t)(x), mmu.level_size[1]))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   358
#define	ROUND_UP_4MEG(x)	\
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   359
	((uintptr_t)P2ROUNDUP((uintptr_t)(x), (uintptr_t)FOUR_MEG))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   360
#define	ROUND_UP_TOPLEVEL(x)	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   361
	((uintptr_t)P2ROUNDUP((uintptr_t)(x), mmu.level_size[mmu.max_level]))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   362
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   363
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   364
 *	32-bit Kernel's Virtual memory layout.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   365
 *		+-----------------------+
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   366
 *		|			|
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   367
 * 0xFFC00000  -|-----------------------|- ARGSBASE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   368
 *		|	debugger	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   369
 * 0xFF800000  -|-----------------------|- SEGDEBUGBASE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   370
 *		|      Kernel Data	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   371
 * 0xFEC00000  -|-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   372
 *              |      Kernel Text	|
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   373
 * 0xFE800000  -|-----------------------|- KERNEL_TEXT (0xFB400000 on Xen)
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   374
 *		|---       GDT       ---|- GDT page (GDT_VA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   375
 *		|---    debug info   ---|- debug info (DEBUG_INFO_VA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   376
 *		|			|
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   377
 * 		|   page_t structures	|
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   378
 * 		|   memsegs, memlists, 	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   379
 * 		|   page hash, etc.	|
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   380
 * ---	       -|-----------------------|- ekernelheap, valloc_base (floating)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   381
 *		|			|  (segkp is just an arena in the heap)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   382
 *		|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   383
 *		|	kvseg		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   384
 *		|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   385
 *		|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   386
 * ---         -|-----------------------|- kernelheap (floating)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   387
 * 		|        Segkmap	|
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   388
 * 0xC3002000  -|-----------------------|- segmap_start (floating)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   389
 *		|	Red Zone	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   390
 * 0xC3000000  -|-----------------------|- kernelbase / userlimit (floating)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   391
 *		|			|			||
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   392
 *		|     Shared objects	|			\/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   393
 *		|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   394
 *		:			:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   395
 *		|	user data	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   396
 *		|-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   397
 *		|	user text	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   398
 * 0x08048000  -|-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   399
 *		|	user stack	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   400
 *		:			:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   401
 *		|	invalid		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   402
 * 0x00000000	+-----------------------+
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   403
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   404
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   405
 *		64-bit Kernel's Virtual memory layout. (assuming 64 bit app)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   406
 *			+-----------------------+
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   407
 *			|			|
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   408
 * 0xFFFFFFFF.FFC00000  |-----------------------|- ARGSBASE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   409
 *			|	debugger (?)	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   410
 * 0xFFFFFFFF.FF800000  |-----------------------|- SEGDEBUGBASE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   411
 *			|      unused    	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   412
 *			+-----------------------+
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   413
 *			|      Kernel Data	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   414
 * 0xFFFFFFFF.FBC00000  |-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   415
 *			|      Kernel Text	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   416
 * 0xFFFFFFFF.FB800000  |-----------------------|- KERNEL_TEXT
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   417
 *			|---       GDT       ---|- GDT page (GDT_VA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   418
 *			|---    debug info   ---|- debug info (DEBUG_INFO_VA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   419
 *			|			|
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   420
 * 			|      Core heap	| (used for loadable modules)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   421
 * 0xFFFFFFFF.C0000000  |-----------------------|- core_base / ekernelheap
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   422
 *			|	 Kernel		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   423
 *			|	  heap		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   424
 * 0xFFFFFXXX.XXX00000  |-----------------------|- kernelheap (floating)
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   425
 *			|	 segmap		|
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   426
 * 0xFFFFFXXX.XXX00000  |-----------------------|- segmap_start (floating)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   427
 *			|    device mappings	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   428
 * 0xFFFFFXXX.XXX00000  |-----------------------|- toxic_addr (floating)
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   429
 *			|	  segzio	|
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
   430
 * 0xFFFFFXXX.XXX00000  |-----------------------|- segzio_base (floating)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   431
 *			|	  segkp		|
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   432
 * ---                  |-----------------------|- segkp_base (floating)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   433
 * 			|   page_t structures	|  valloc_base + valloc_sz
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   434
 * 			|   memsegs, memlists, 	|
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   435
 * 			|   page hash, etc.	|
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   436
 * 0xFFFFFF00.00000000  |-----------------------|- valloc_base (lower if > 1TB)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   437
 *			|	 segkpm		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   438
 * 0xFFFFFE00.00000000  |-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   439
 *			|	Red Zone	|
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   440
 * 0xFFFFFD80.00000000  |-----------------------|- KERNELBASE (lower if > 1TB)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   441
 *			|     User stack	|- User space memory
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   442
 * 			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   443
 * 			| shared objects, etc	|	(grows downwards)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   444
 *			:			:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   445
 * 			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   446
 * 0xFFFF8000.00000000  |-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   447
 * 			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   448
 * 			| VA Hole / unused	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   449
 * 			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   450
 * 0x00008000.00000000  |-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   451
 *			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   452
 *			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   453
 *			:			:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   454
 *			|	user heap	|	(grows upwards)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   455
 *			|			|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   456
 *			|	user data	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   457
 *			|-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   458
 *			|	user text	|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   459
 * 0x00000000.04000000  |-----------------------|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   460
 *			|	invalid		|
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   461
 * 0x00000000.00000000	+-----------------------+
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   462
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   463
 * A 32 bit app on the 64 bit kernel sees the same layout as on the 32 bit
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   464
 * kernel, except that userlimit is raised to 0xfe000000
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   465
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   466
 * Floating values:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   467
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   468
 * valloc_base: start of the kernel's memory management/tracking data
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   469
 * structures.  This region contains page_t structures for
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   470
 * physical memory, memsegs, memlists, and the page hash.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   471
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   472
 * core_base: start of the kernel's "core" heap area on 64-bit systems.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   473
 * This area is intended to be used for global data as well as for module
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   474
 * text/data that does not fit into the nucleus pages.  The core heap is
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   475
 * restricted to a 2GB range, allowing every address within it to be
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   476
 * accessed using rip-relative addressing
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   477
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   478
 * ekernelheap: end of kernelheap and start of segmap.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   479
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   480
 * kernelheap: start of kernel heap.  On 32-bit systems, this starts right
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   481
 * above a red zone that separates the user's address space from the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   482
 * kernel's.  On 64-bit systems, it sits above segkp and segkpm.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   483
 *
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   484
 * segmap_start: start of segmap. The length of segmap can be modified
7692
5f48c0bb1a31 6700742 incorrect comment for tuning segmap on x64
Amrita Sadhukhan <Amrita.Sadhukhan@Sun.COM>
parents: 7656
diff changeset
   485
 * through eeprom. The default length is 16MB on 32-bit systems and 64MB
5f48c0bb1a31 6700742 incorrect comment for tuning segmap on x64
Amrita Sadhukhan <Amrita.Sadhukhan@Sun.COM>
parents: 7656
diff changeset
   486
 * on 64-bit systems.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   487
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   488
 * kernelbase: On a 32-bit kernel the default value of 0xd4000000 will be
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   489
 * decreased by 2X the size required for page_t.  This allows the kernel
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   490
 * heap to grow in size with physical memory.  With sizeof(page_t) == 80
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   491
 * bytes, the following shows the values of kernelbase and kernel heap
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   492
 * sizes for different memory configurations (assuming default segmap and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   493
 * segkp sizes).
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   494
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   495
 *	mem	size for	kernelbase	kernel heap
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   496
 *	size	page_t's			size
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   497
 *	----	---------	----------	-----------
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   498
 *	1gb	0x01400000	0xd1800000	684MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   499
 *	2gb	0x02800000	0xcf000000	704MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   500
 *	4gb	0x05000000	0xca000000	744MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   501
 *	6gb	0x07800000	0xc5000000	784MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   502
 *	8gb	0x0a000000	0xc0000000	824MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   503
 *	16gb	0x14000000	0xac000000	984MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   504
 *	32gb	0x28000000	0x84000000	1304MB
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   505
 *	64gb	0x50000000	0x34000000	1944MB (*)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   506
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   507
 * kernelbase is less than the abi minimum of 0xc0000000 for memory
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   508
 * configurations above 8gb.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   509
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   510
 * (*) support for memory configurations above 32gb will require manual tuning
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   511
 * of kernelbase to balance out the need of user applications.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   512
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   513
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   514
/* real-time-clock initialization parameters */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   515
extern time_t process_rtc_config_file(void);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   516
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   517
uintptr_t	kernelbase;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   518
uintptr_t	postbootkernelbase;	/* not set till boot loader is gone */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   519
uintptr_t	eprom_kernelbase;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   520
size_t		segmapsize;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   521
uintptr_t	segmap_start;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   522
int		segmapfreelists;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   523
pgcnt_t		npages;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   524
pgcnt_t		orig_npages;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   525
size_t		core_size;		/* size of "core" heap */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   526
uintptr_t	core_base;		/* base address of "core" heap */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   527
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   528
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   529
 * List of bootstrap pages. We mark these as allocated in startup.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   530
 * release_bootstrap() will free them when we're completely done with
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   531
 * the bootstrap.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   532
 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   533
static page_t *bootpages;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   534
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   535
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   536
 * boot time pages that have a vnode from the ramdisk will keep that forever.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   537
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   538
static page_t *rd_pages;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   539
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   540
/*
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   541
 * Lower 64K
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   542
 */
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   543
static page_t *lower_pages = NULL;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   544
static int lower_pages_count = 0;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   545
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   546
struct system_hardware system_hardware;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   547
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   548
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   549
 * Enable some debugging messages concerning memory usage...
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   550
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   551
static void
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   552
print_memlist(char *title, struct memlist *mp)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   553
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   554
	prom_printf("MEMLIST: %s:\n", title);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   555
	while (mp != NULL)  {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   556
		prom_printf("\tAddress 0x%" PRIx64 ", size 0x%" PRIx64 "\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   557
		    mp->address, mp->size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   558
		mp = mp->next;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   559
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   560
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   561
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   562
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   563
 * XX64 need a comment here.. are these just default values, surely
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   564
 * we read the "cpuid" type information to figure this out.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   565
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   566
int	l2cache_sz = 0x80000;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   567
int	l2cache_linesz = 0x40;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   568
int	l2cache_assoc = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   569
4426
1b5c93035912 6544121 Implement text replication
aguzovsk
parents: 4004
diff changeset
   570
static size_t	textrepl_min_gb = 10;
1b5c93035912 6544121 Implement text replication
aguzovsk
parents: 4004
diff changeset
   571
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   572
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   573
 * on 64 bit we use a predifined VA range for mapping devices in the kernel
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   574
 * on 32 bit the mappings are intermixed in the heap, so we use a bit map
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   575
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   576
#ifdef __amd64
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   577
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   578
vmem_t		*device_arena;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   579
uintptr_t	toxic_addr = (uintptr_t)NULL;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   580
size_t		toxic_size = 1024 * 1024 * 1024; /* Sparc uses 1 gig too */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   581
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   582
#else	/* __i386 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   583
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   584
ulong_t		*toxic_bit_map;	/* one bit for each 4k of VA in heap_arena */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   585
size_t		toxic_bit_map_len = 0;	/* in bits */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   586
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   587
#endif	/* __i386 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   588
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   589
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   590
 * Simple boot time debug facilities
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   591
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   592
static char *prm_dbg_str[] = {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   593
	"%s:%d: '%s' is 0x%x\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   594
	"%s:%d: '%s' is 0x%llx\n"
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   595
};
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   596
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   597
int prom_debug;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   598
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   599
#define	PRM_DEBUG(q)	if (prom_debug) 	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   600
	prom_printf(prm_dbg_str[sizeof (q) >> 3], "startup.c", __LINE__, #q, q);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   601
#define	PRM_POINT(q)	if (prom_debug) 	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   602
	prom_printf("%s:%d: %s\n", "startup.c", __LINE__, q);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   603
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   604
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   605
 * This structure is used to keep track of the intial allocations
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   606
 * done in startup_memlist(). The value of NUM_ALLOCATIONS needs to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   607
 * be >= the number of ADD_TO_ALLOCATIONS() executed in the code.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   608
 */
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   609
#define	NUM_ALLOCATIONS 8
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   610
int num_allocations = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   611
struct {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   612
	void **al_ptr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   613
	size_t al_size;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   614
} allocations[NUM_ALLOCATIONS];
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   615
size_t valloc_sz = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   616
uintptr_t valloc_base;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   617
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   618
#define	ADD_TO_ALLOCATIONS(ptr, size) {					\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   619
		size = ROUND_UP_PAGE(size);		 		\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   620
		if (num_allocations == NUM_ALLOCATIONS)			\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   621
			panic("too many ADD_TO_ALLOCATIONS()");		\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   622
		allocations[num_allocations].al_ptr = (void**)&ptr;	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   623
		allocations[num_allocations].al_size = size;		\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   624
		valloc_sz += size;					\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   625
		++num_allocations;				 	\
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   626
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   627
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   628
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   629
 * Allocate all the initial memory needed by the page allocator.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   630
 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   631
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   632
perform_allocations(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   633
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   634
	caddr_t mem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   635
	int i;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   636
	int valloc_align;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   637
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   638
	PRM_DEBUG(valloc_base);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   639
	PRM_DEBUG(valloc_sz);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   640
	valloc_align = mmu.level_size[mmu.max_page_level > 0];
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   641
	mem = BOP_ALLOC(bootops, (caddr_t)valloc_base, valloc_sz, valloc_align);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   642
	if (mem != (caddr_t)valloc_base)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   643
		panic("BOP_ALLOC() failed");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   644
	bzero(mem, valloc_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   645
	for (i = 0; i < num_allocations; ++i) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   646
		*allocations[i].al_ptr = (void *)mem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   647
		mem += allocations[i].al_size;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   648
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   649
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   650
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   651
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   652
 * Our world looks like this at startup time.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   653
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   654
 * In a 32-bit OS, boot loads the kernel text at 0xfe800000 and kernel data
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   655
 * at 0xfec00000.  On a 64-bit OS, kernel text and data are loaded at
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   656
 * 0xffffffff.fe800000 and 0xffffffff.fec00000 respectively.  Those
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   657
 * addresses are fixed in the binary at link time.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   658
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   659
 * On the text page:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   660
 * unix/genunix/krtld/module text loads.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   661
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   662
 * On the data page:
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   663
 * unix/genunix/krtld/module data loads.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   664
 *
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   665
 * Machine-dependent startup code
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   666
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   667
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   668
startup(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   669
{
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   670
#if !defined(__xpv)
1494
2327b3ecb7ad 6385042 x86 slot-names gone missing (again)
jg
parents: 1479
diff changeset
   671
	extern void startup_bios_disk(void);
2327b3ecb7ad 6385042 x86 slot-names gone missing (again)
jg
parents: 1479
diff changeset
   672
	extern void startup_pci_bios(void);
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   673
	extern int post_fastreboot;
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   674
#endif
6336
4eaf084434c9 6470538 domUs are unfriendly when too little memory is available to boot
bholler
parents: 5741
diff changeset
   675
	extern cpuset_t cpu_ready_set;
4eaf084434c9 6470538 domUs are unfriendly when too little memory is available to boot
bholler
parents: 5741
diff changeset
   676
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   677
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   678
	 * Make sure that nobody tries to use sekpm until we have
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   679
	 * initialized it properly.
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   680
	 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   681
#if defined(__amd64)
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   682
	kpm_desired = 1;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   683
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   684
	kpm_enable = 0;
6336
4eaf084434c9 6470538 domUs are unfriendly when too little memory is available to boot
bholler
parents: 5741
diff changeset
   685
	CPUSET_ONLY(cpu_ready_set, 0);	/* cpu 0 is boot cpu */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   686
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   687
#if defined(__xpv)	/* XXPV fix me! */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   688
	{
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   689
		extern int segvn_use_regions;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   690
		segvn_use_regions = 0;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   691
	}
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   692
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   693
	progressbar_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   694
	startup_init();
5316
35a13307d903 6612324 ::threadlist could identify taskq threads
johnlev
parents: 5254
diff changeset
   695
#if defined(__xpv)
35a13307d903 6612324 ::threadlist could identify taskq threads
johnlev
parents: 5254
diff changeset
   696
	startup_xen_version();
35a13307d903 6612324 ::threadlist could identify taskq threads
johnlev
parents: 5254
diff changeset
   697
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   698
	startup_memlist();
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   699
	startup_kmem();
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
   700
	startup_vm();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   701
#if !defined(__xpv)
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   702
	if (!post_fastreboot)
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   703
		startup_pci_bios();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   704
#endif
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
   705
#if defined(__xpv)
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
   706
	startup_xen_mca();
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
   707
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   708
	startup_modules();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   709
#if !defined(__xpv)
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   710
	if (!post_fastreboot)
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
   711
		startup_bios_disk();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   712
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   713
	startup_end();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   714
	progressbar_start();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   715
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   716
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   717
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   718
startup_init()
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   719
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   720
	PRM_POINT("startup_init() starting...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   721
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   722
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   723
	 * Complete the extraction of cpuid data
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   724
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   725
	cpuid_pass2(CPU);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   726
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   727
	(void) check_boot_version(BOP_GETVERSION(bootops));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   728
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   729
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   730
	 * Check for prom_debug in boot environment
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   731
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   732
	if (BOP_GETPROPLEN(bootops, "prom_debug") >= 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   733
		++prom_debug;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   734
		PRM_POINT("prom_debug found in boot enviroment");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   735
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   736
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   737
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   738
	 * Collect node, cpu and memory configuration information.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   739
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   740
	get_system_configuration();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   741
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   742
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   743
	 * Halt if this is an unsupported processor.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   744
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   745
	if (x86_type == X86_TYPE_486 || x86_type == X86_TYPE_CYRIX_486) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   746
		printf("\n486 processor (\"%s\") detected.\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   747
		    CPU->cpu_brandstr);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   748
		halt("This processor is not supported by this release "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   749
		    "of Solaris.");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   750
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   751
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   752
	PRM_POINT("startup_init() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   753
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   754
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   755
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   756
 * Callback for copy_memlist_filter() to filter nucleus, kadb/kmdb, (ie.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   757
 * everything mapped above KERNEL_TEXT) pages from phys_avail. Note it
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   758
 * also filters out physical page zero.  There is some reliance on the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   759
 * boot loader allocating only a few contiguous physical memory chunks.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   760
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   761
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   762
avail_filter(uint64_t *addr, uint64_t *size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   763
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   764
	uintptr_t va;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   765
	uintptr_t next_va;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   766
	pfn_t pfn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   767
	uint64_t pfn_addr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   768
	uint64_t pfn_eaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   769
	uint_t prot;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   770
	size_t len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   771
	uint_t change;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   772
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   773
	if (prom_debug)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   774
		prom_printf("\tFilter: in: a=%" PRIx64 ", s=%" PRIx64 "\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   775
		    *addr, *size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   776
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   777
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   778
	 * page zero is required for BIOS.. never make it available
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   779
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   780
	if (*addr == 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   781
		*addr += MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   782
		*size -= MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   783
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   784
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   785
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   786
	 * First we trim from the front of the range. Since kbm_probe()
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   787
	 * walks ranges in virtual order, but addr/size are physical, we need
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   788
	 * to the list until no changes are seen.  This deals with the case
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   789
	 * where page "p" is mapped at v, page "p + PAGESIZE" is mapped at w
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   790
	 * but w < v.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   791
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   792
	do {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   793
		change = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   794
		for (va = KERNEL_TEXT;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   795
		    *size > 0 && kbm_probe(&va, &len, &pfn, &prot) != 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   796
		    va = next_va) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   797
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   798
			next_va = va + len;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   799
			pfn_addr = pfn_to_pa(pfn);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   800
			pfn_eaddr = pfn_addr + len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   801
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   802
			if (pfn_addr <= *addr && pfn_eaddr > *addr) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   803
				change = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   804
				while (*size > 0 && len > 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   805
					*addr += MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   806
					*size -= MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   807
					len -= MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   808
				}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   809
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   810
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   811
		if (change && prom_debug)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   812
			prom_printf("\t\ttrim: a=%" PRIx64 ", s=%" PRIx64 "\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   813
			    *addr, *size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   814
	} while (change);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   815
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   816
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   817
	 * Trim pages from the end of the range.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   818
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   819
	for (va = KERNEL_TEXT;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   820
	    *size > 0 && kbm_probe(&va, &len, &pfn, &prot) != 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   821
	    va = next_va) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   822
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   823
		next_va = va + len;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   824
		pfn_addr = pfn_to_pa(pfn);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   825
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   826
		if (pfn_addr >= *addr && pfn_addr < *addr + *size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   827
			*size = pfn_addr - *addr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   828
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   829
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   830
	if (prom_debug)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   831
		prom_printf("\tFilter out: a=%" PRIx64 ", s=%" PRIx64 "\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   832
		    *addr, *size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   833
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   834
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   835
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   836
kpm_init()
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   837
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   838
	struct segkpm_crargs b;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   839
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   840
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   841
	 * These variables were all designed for sfmmu in which segkpm is
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   842
	 * mapped using a single pagesize - either 8KB or 4MB.  On x86, we
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   843
	 * might use 2+ page sizes on a single machine, so none of these
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   844
	 * variables have a single correct value.  They are set up as if we
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   845
	 * always use a 4KB pagesize, which should do no harm.  In the long
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   846
	 * run, we should get rid of KPM's assumption that only a single
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   847
	 * pagesize is used.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   848
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   849
	kpm_pgshft = MMU_PAGESHIFT;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   850
	kpm_pgsz =  MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   851
	kpm_pgoff = MMU_PAGEOFFSET;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   852
	kpmp2pshft = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   853
	kpmpnpgs = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   854
	ASSERT(((uintptr_t)kpm_vbase & (kpm_pgsz - 1)) == 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   855
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   856
	PRM_POINT("about to create segkpm");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   857
	rw_enter(&kas.a_lock, RW_WRITER);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   858
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   859
	if (seg_attach(&kas, kpm_vbase, kpm_size, segkpm) < 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   860
		panic("cannot attach segkpm");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   861
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   862
	b.prot = PROT_READ | PROT_WRITE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   863
	b.nvcolors = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   864
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   865
	if (segkpm_create(segkpm, (caddr_t)&b) != 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   866
		panic("segkpm_create segkpm");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   867
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   868
	rw_exit(&kas.a_lock);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   869
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   870
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   871
/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   872
 * The debug info page provides enough information to allow external
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   873
 * inspectors (e.g. when running under a hypervisor) to bootstrap
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   874
 * themselves into allowing full-blown kernel debugging.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   875
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   876
static void
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   877
init_debug_info(void)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   878
{
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   879
	caddr_t mem;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   880
	debug_info_t *di;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   881
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   882
#ifndef __lint
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   883
	ASSERT(sizeof (debug_info_t) < MMU_PAGESIZE);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   884
#endif
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   885
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   886
	mem = BOP_ALLOC(bootops, (caddr_t)DEBUG_INFO_VA, MMU_PAGESIZE,
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   887
	    MMU_PAGESIZE);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   888
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   889
	if (mem != (caddr_t)DEBUG_INFO_VA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   890
		panic("BOP_ALLOC() failed");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   891
	bzero(mem, MMU_PAGESIZE);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   892
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   893
	di = (debug_info_t *)mem;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   894
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   895
	di->di_magic = DEBUG_INFO_MAGIC;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   896
	di->di_version = DEBUG_INFO_VERSION;
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   897
	di->di_modules = (uintptr_t)&modules;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   898
	di->di_s_text = (uintptr_t)s_text;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   899
	di->di_e_text = (uintptr_t)e_text;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   900
	di->di_s_data = (uintptr_t)s_data;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   901
	di->di_e_data = (uintptr_t)e_data;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   902
	di->di_hat_htable_off = offsetof(hat_t, hat_htable);
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
   903
	di->di_ht_pfn_off = offsetof(htable_t, ht_pfn);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   904
}
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   905
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   906
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   907
 * Build the memlists and other kernel essential memory system data structures.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   908
 * This is everything at valloc_base.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   909
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   910
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   911
startup_memlist(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   912
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   913
	size_t memlist_sz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   914
	size_t memseg_sz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   915
	size_t pagehash_sz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   916
	size_t pp_sz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   917
	uintptr_t va;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   918
	size_t len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   919
	uint_t prot;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   920
	pfn_t pfn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   921
	int memblocks;
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   922
	pfn_t rsvd_high_pfn;
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   923
	pgcnt_t rsvd_pgcnt;
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   924
	size_t rsvdmemlist_sz;
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   925
	int rsvdmemblocks;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   926
	caddr_t pagecolor_mem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   927
	size_t pagecolor_memsz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   928
	caddr_t page_ctrs_mem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   929
	size_t page_ctrs_size;
4878
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
   930
	size_t pse_table_alloc_size;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   931
	struct memlist *current;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   932
	extern void startup_build_mem_nodes(struct memlist *);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   933
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   934
	/* XX64 fix these - they should be in include files */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   935
	extern size_t page_coloring_init(uint_t, int, int);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   936
	extern void page_coloring_setup(caddr_t);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   937
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   938
	PRM_POINT("startup_memlist() starting...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   939
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   940
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   941
	 * Use leftover large page nucleus text/data space for loadable modules.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   942
	 * Use at most MODTEXT/MODDATA.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   943
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   944
	len = kbm_nucleus_size;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   945
	ASSERT(len > MMU_PAGESIZE);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   946
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   947
	moddata = (caddr_t)ROUND_UP_PAGE(e_data);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   948
	e_moddata = (caddr_t)P2ROUNDUP((uintptr_t)e_data, (uintptr_t)len);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   949
	if (e_moddata - moddata > MODDATA)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   950
		e_moddata = moddata + MODDATA;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   951
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   952
	modtext = (caddr_t)ROUND_UP_PAGE(e_text);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   953
	e_modtext = (caddr_t)P2ROUNDUP((uintptr_t)e_text, (uintptr_t)len);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   954
	if (e_modtext - modtext > MODTEXT)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   955
		e_modtext = modtext + MODTEXT;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   956
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   957
	econtig = e_moddata;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   958
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   959
	PRM_DEBUG(modtext);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   960
	PRM_DEBUG(e_modtext);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   961
	PRM_DEBUG(moddata);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   962
	PRM_DEBUG(e_moddata);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   963
	PRM_DEBUG(econtig);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   964
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   965
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   966
	 * Examine the boot loader physical memory map to find out:
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   967
	 * - total memory in system - physinstalled
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   968
	 * - the max physical address - physmax
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   969
	 * - the number of discontiguous segments of memory.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   970
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   971
	if (prom_debug)
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
   972
		print_memlist("boot physinstalled",
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   973
		    bootops->boot_mem->physinstalled);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   974
	installed_top_size(bootops->boot_mem->physinstalled, &physmax,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   975
	    &physinstalled, &memblocks);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   976
	PRM_DEBUG(physmax);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   977
	PRM_DEBUG(physinstalled);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   978
	PRM_DEBUG(memblocks);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   979
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   980
	/*
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   981
	 * Examine the bios reserved memory to find out:
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   982
	 * - the number of discontiguous segments of memory.
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   983
	 */
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   984
	if (prom_debug)
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   985
		print_memlist("boot reserved mem",
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   986
		    bootops->boot_mem->rsvdmem);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   987
	installed_top_size(bootops->boot_mem->rsvdmem, &rsvd_high_pfn,
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   988
	    &rsvd_pgcnt, &rsvdmemblocks);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   989
	PRM_DEBUG(rsvd_high_pfn);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   990
	PRM_DEBUG(rsvd_pgcnt);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   991
	PRM_DEBUG(rsvdmemblocks);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   992
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
   993
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   994
	 * Initialize hat's mmu parameters.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   995
	 * Check for enforce-prot-exec in boot environment. It's used to
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   996
	 * enable/disable support for the page table entry NX bit.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   997
	 * The default is to enforce PROT_EXEC on processors that support NX.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   998
	 * Boot seems to round up the "len", but 8 seems to be big enough.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
   999
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1000
	mmu_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1001
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1002
#ifdef	__i386
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1003
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1004
	 * physmax is lowered if there is more memory than can be
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1005
	 * physically addressed in 32 bit (PAE/non-PAE) modes.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1006
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1007
	if (mmu.pae_hat) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1008
		if (PFN_ABOVE64G(physmax)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1009
			physinstalled -= (physmax - (PFN_64G - 1));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1010
			physmax = PFN_64G - 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1011
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1012
	} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1013
		if (PFN_ABOVE4G(physmax)) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1014
			physinstalled -= (physmax - (PFN_4G - 1));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1015
			physmax = PFN_4G - 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1016
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1017
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1018
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1019
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1020
	startup_build_mem_nodes(bootops->boot_mem->physinstalled);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1021
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1022
	if (BOP_GETPROPLEN(bootops, "enforce-prot-exec") >= 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1023
		int len = BOP_GETPROPLEN(bootops, "enforce-prot-exec");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1024
		char value[8];
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1025
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1026
		if (len < 8)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1027
			(void) BOP_GETPROP(bootops, "enforce-prot-exec", value);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1028
		else
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1029
			(void) strcpy(value, "");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1030
		if (strcmp(value, "off") == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1031
			mmu.pt_nx = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1032
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1033
	PRM_DEBUG(mmu.pt_nx);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1034
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1035
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1036
	 * We will need page_t's for every page in the system, except for
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1037
	 * memory mapped at or above above the start of the kernel text segment.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1038
	 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1039
	 * pages above e_modtext are attributed to kernel debugger (obp_pages)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1040
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1041
	npages = physinstalled - 1; /* avail_filter() skips page 0, so "- 1" */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1042
	obp_pages = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1043
	va = KERNEL_TEXT;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1044
	while (kbm_probe(&va, &len, &pfn, &prot) != 0) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1045
		npages -= len >> MMU_PAGESHIFT;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1046
		if (va >= (uintptr_t)e_moddata)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1047
			obp_pages += len >> MMU_PAGESHIFT;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1048
		va += len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1049
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1050
	PRM_DEBUG(npages);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1051
	PRM_DEBUG(obp_pages);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1052
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1053
	/*
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1054
	 * If physmem is patched to be non-zero, use it instead of the computed
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1055
	 * value unless it is larger than the actual amount of memory on hand.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1056
	 */
1417
fa316336e215 6377034 setting physmem in /etc/system does not have desired effect on x86
kchow
parents: 1414
diff changeset
  1057
	if (physmem == 0 || physmem > npages) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1058
		physmem = npages;
1417
fa316336e215 6377034 setting physmem in /etc/system does not have desired effect on x86
kchow
parents: 1414
diff changeset
  1059
	} else if (physmem < npages) {
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1060
		orig_npages = npages;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1061
		npages = physmem;
1417
fa316336e215 6377034 setting physmem in /etc/system does not have desired effect on x86
kchow
parents: 1414
diff changeset
  1062
	}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1063
	PRM_DEBUG(physmem);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1064
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1065
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1066
	 * We now compute the sizes of all the  initial allocations for
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1067
	 * structures the kernel needs in order do kmem_alloc(). These
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1068
	 * include:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1069
	 *	memsegs
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1070
	 *	memlists
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1071
	 *	page hash table
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1072
	 *	page_t's
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1073
	 *	page coloring data structs
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1074
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1075
	memseg_sz = sizeof (struct memseg) * (memblocks + POSS_NEW_FRAGMENTS);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1076
	ADD_TO_ALLOCATIONS(memseg_base, memseg_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1077
	PRM_DEBUG(memseg_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1078
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1079
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1080
	 * Reserve space for memlists. There's no real good way to know exactly
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1081
	 * how much room we'll need, but this should be a good upper bound.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1082
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1083
	memlist_sz = ROUND_UP_PAGE(2 * sizeof (struct memlist) *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1084
	    (memblocks + POSS_NEW_FRAGMENTS));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1085
	ADD_TO_ALLOCATIONS(memlist, memlist_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1086
	PRM_DEBUG(memlist_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1087
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1088
	/*
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1089
	 * Reserve space for bios reserved memlists.
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1090
	 */
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1091
	rsvdmemlist_sz = ROUND_UP_PAGE(2 * sizeof (struct memlist) *
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1092
	    (rsvdmemblocks + POSS_NEW_FRAGMENTS));
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1093
	ADD_TO_ALLOCATIONS(bios_rsvd, rsvdmemlist_sz);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1094
	PRM_DEBUG(rsvdmemlist_sz);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1095
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1096
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1097
	 * The page structure hash table size is a power of 2
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1098
	 * such that the average hash chain length is PAGE_HASHAVELEN.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1099
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1100
	page_hashsz = npages / PAGE_HASHAVELEN;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1101
	page_hashsz = 1 << highbit(page_hashsz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1102
	pagehash_sz = sizeof (struct page *) * page_hashsz;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1103
	ADD_TO_ALLOCATIONS(page_hash, pagehash_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1104
	PRM_DEBUG(pagehash_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1105
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1106
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1107
	 * Set aside room for the page structures themselves.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1108
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1109
	PRM_DEBUG(npages);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1110
	pp_sz = sizeof (struct page) * npages;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1111
	ADD_TO_ALLOCATIONS(pp_base, pp_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1112
	PRM_DEBUG(pp_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1113
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1114
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1115
	 * determine l2 cache info and memory size for page coloring
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1116
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1117
	(void) getl2cacheinfo(CPU,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1118
	    &l2cache_sz, &l2cache_linesz, &l2cache_assoc);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1119
	pagecolor_memsz =
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1120
	    page_coloring_init(l2cache_sz, l2cache_linesz, l2cache_assoc);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1121
	ADD_TO_ALLOCATIONS(pagecolor_mem, pagecolor_memsz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1122
	PRM_DEBUG(pagecolor_memsz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1123
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1124
	page_ctrs_size = page_ctrs_sz();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1125
	ADD_TO_ALLOCATIONS(page_ctrs_mem, page_ctrs_size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1126
	PRM_DEBUG(page_ctrs_size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1127
4878
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1128
	/*
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1129
	 * Allocate the array that protects pp->p_selock.
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1130
	 */
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1131
	pse_shift = size_pse_array(physmem, max_ncpus);
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1132
	pse_table_size = 1 << pse_shift;
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1133
	pse_table_alloc_size = pse_table_size * sizeof (pad_mutex_t);
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1134
	ADD_TO_ALLOCATIONS(pse_mutex, pse_table_alloc_size);
d39bbc62dfd1 4875742 PAGE_SE_MUTEX() macro needs maintenance
blakej
parents: 4875
diff changeset
  1135
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1136
#if defined(__amd64)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1137
	valloc_sz = ROUND_UP_LPAGE(valloc_sz);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1138
	valloc_base = VALLOC_BASE;
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1139
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1140
	/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1141
	 * The default values of VALLOC_BASE and SEGKPM_BASE should work
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1142
	 * for values of physmax up to 1 Terabyte. They need adjusting when
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1143
	 * memory is at addresses above 1 TB.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1144
	 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1145
	if (physmax + 1 > mmu_btop(TERABYTE)) {
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1146
		uint64_t kpm_resv_amount = mmu_ptob(physmax + 1);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1147
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1148
		/* Round to largest possible pagesize for now */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1149
		kpm_resv_amount = P2ROUNDUP(kpm_resv_amount, ONE_GIG);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1150
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1151
		segkpm_base = -(2 * kpm_resv_amount); /* down from top VA */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1152
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1153
		/* make sure we leave some space for user apps above hole */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1154
		segkpm_base = MAX(segkpm_base, AMD64_VA_HOLE_END + TERABYTE);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1155
		if (segkpm_base > SEGKPM_BASE)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1156
			segkpm_base = SEGKPM_BASE;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1157
		PRM_DEBUG(segkpm_base);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1158
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1159
		valloc_base = segkpm_base + kpm_resv_amount;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1160
		PRM_DEBUG(valloc_base);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1161
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1162
#else	/* __i386 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1163
	valloc_base = (uintptr_t)(MISC_VA_BASE - valloc_sz);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1164
	valloc_base = P2ALIGN(valloc_base, mmu.level_size[1]);
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1165
	PRM_DEBUG(valloc_base);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1166
#endif	/* __i386 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1167
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1168
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1169
	 * do all the initial allocations
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1170
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1171
	perform_allocations();
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1172
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1173
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1174
	 * Build phys_install and phys_avail in kernel memspace.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1175
	 * - phys_install should be all memory in the system.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1176
	 * - phys_avail is phys_install minus any memory mapped before this
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1177
	 *    point above KERNEL_TEXT.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1178
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1179
	current = phys_install = memlist;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1180
	copy_memlist_filter(bootops->boot_mem->physinstalled, &current, NULL);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1181
	if ((caddr_t)current > (caddr_t)memlist + memlist_sz)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1182
		panic("physinstalled was too big!");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1183
	if (prom_debug)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1184
		print_memlist("phys_install", phys_install);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1185
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1186
	phys_avail = current;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1187
	PRM_POINT("Building phys_avail:\n");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1188
	copy_memlist_filter(bootops->boot_mem->physinstalled, &current,
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1189
	    avail_filter);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1190
	if ((caddr_t)current > (caddr_t)memlist + memlist_sz)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1191
		panic("physavail was too big!");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1192
	if (prom_debug)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1193
		print_memlist("phys_avail", phys_avail);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1194
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1195
	/*
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1196
	 * Build bios reserved memspace
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1197
	 */
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1198
	current = bios_rsvd;
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1199
	copy_memlist_filter(bootops->boot_mem->rsvdmem, &current, NULL);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1200
	if ((caddr_t)current > (caddr_t)bios_rsvd + rsvdmemlist_sz)
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1201
		panic("bios_rsvd was too big!");
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1202
	if (prom_debug)
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1203
		print_memlist("bios_rsvd", bios_rsvd);
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1204
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  1205
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1206
	 * setup page coloring
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1207
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1208
	page_coloring_setup(pagecolor_mem);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1209
	page_lock_init();	/* currently a no-op */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1210
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1211
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1212
	 * free page list counters
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1213
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1214
	(void) page_ctrs_alloc(page_ctrs_mem);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1215
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1216
	/*
6880
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1217
	 * Size the pcf array based on the number of cpus in the box at
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1218
	 * boot time.
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1219
	 */
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1220
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1221
	pcf_init();
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1222
0a9c7c25ebae 6658818 The macro PCF_INDEX is incorrect
dv142724
parents: 6336
diff changeset
  1223
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1224
	 * Initialize the page structures from the memory lists.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1225
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1226
	availrmem_initial = availrmem = freemem = 0;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1227
	PRM_POINT("Calling kphysm_init()...");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1228
	npages = kphysm_init(pp_base, npages);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1229
	PRM_POINT("kphysm_init() done");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1230
	PRM_DEBUG(npages);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1231
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1232
	init_debug_info();
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1233
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1234
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1235
	 * Now that page_t's have been initialized, remove all the
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1236
	 * initial allocation pages from the kernel free page lists.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1237
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1238
	boot_mapin((caddr_t)valloc_base, valloc_sz);
5460
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1239
	boot_mapin((caddr_t)MISC_VA_BASE, MISC_VA_SIZE);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1240
	PRM_POINT("startup_memlist() done");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1241
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1242
	PRM_DEBUG(valloc_sz);
4426
1b5c93035912 6544121 Implement text replication
aguzovsk
parents: 4004
diff changeset
  1243
4748
3bb903eb8ac9 6582037 don't enable text replication on 32bit kernels
aguzovsk
parents: 4426
diff changeset
  1244
#if defined(__amd64)
3bb903eb8ac9 6582037 don't enable text replication on 32bit kernels
aguzovsk
parents: 4426
diff changeset
  1245
	if ((availrmem >> (30 - MMU_PAGESHIFT)) >=
3bb903eb8ac9 6582037 don't enable text replication on 32bit kernels
aguzovsk
parents: 4426
diff changeset
  1246
	    textrepl_min_gb && l2cache_sz <= 2 << 20) {
3bb903eb8ac9 6582037 don't enable text replication on 32bit kernels
aguzovsk
parents: 4426
diff changeset
  1247
		extern size_t textrepl_size_thresh;
4426
1b5c93035912 6544121 Implement text replication
aguzovsk
parents: 4004
diff changeset
  1248
		textrepl_size_thresh = (16 << 20) - 1;
1b5c93035912 6544121 Implement text replication
aguzovsk
parents: 4004
diff changeset
  1249
	}
4748
3bb903eb8ac9 6582037 don't enable text replication on 32bit kernels
aguzovsk
parents: 4426
diff changeset
  1250
#endif
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1251
}
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1252
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1253
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1254
 * Layout the kernel's part of address space and initialize kmem allocator.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1255
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1256
static void
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1257
startup_kmem(void)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1258
{
3717
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1259
	extern void page_set_colorequiv_arr(void);
9370
5f964d9a7826 6750666 getisax(2) needs to detect Intel AES instruction set extension and PCLMULQDQ instruction
Kuriakose Kuruvilla <Kuriakose.Kuruvilla@Sun.COM>
parents: 9281
diff changeset
  1260
	const char *fmt = "?features: %b\n";
3717
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1261
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1262
	PRM_POINT("startup_kmem() starting...");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1263
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1264
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1265
	if (eprom_kernelbase && eprom_kernelbase != KERNELBASE)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1266
		cmn_err(CE_NOTE, "!kernelbase cannot be changed on 64-bit "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1267
		    "systems.");
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1268
	kernelbase = segkpm_base - KERNEL_REDZONE_SIZE;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1269
	core_base = (uintptr_t)COREHEAP_BASE;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1270
	core_size = (size_t)MISC_VA_BASE - COREHEAP_BASE;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1271
#else	/* __i386 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1272
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1273
	 * We configure kernelbase based on:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1274
	 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1275
	 * 1. user specified kernelbase via eeprom command. Value cannot exceed
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1276
	 *    KERNELBASE_MAX. we large page align eprom_kernelbase
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1277
	 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1278
	 * 2. Default to KERNELBASE and adjust to 2X less the size for page_t.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1279
	 *    On large memory systems we must lower kernelbase to allow
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1280
	 *    enough room for page_t's for all of memory.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1281
	 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1282
	 * The value set here, might be changed a little later.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1283
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1284
	if (eprom_kernelbase) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1285
		kernelbase = eprom_kernelbase & mmu.level_mask[1];
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1286
		if (kernelbase > KERNELBASE_MAX)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1287
			kernelbase = KERNELBASE_MAX;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1288
	} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1289
		kernelbase = (uintptr_t)KERNELBASE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1290
		kernelbase -= ROUND_UP_4MEG(2 * valloc_sz);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1291
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1292
	ASSERT((kernelbase & mmu.level_offset[1]) == 0);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1293
	core_base = valloc_base;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1294
	core_size = 0;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1295
#endif	/* __i386 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1296
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1297
	PRM_DEBUG(core_base);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1298
	PRM_DEBUG(core_size);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1299
	PRM_DEBUG(kernelbase);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1300
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1301
#if defined(__i386)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1302
	segkp_fromheap = 1;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1303
#endif	/* __i386 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1304
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1305
	ekernelheap = (char *)core_base;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1306
	PRM_DEBUG(ekernelheap);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1307
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1308
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1309
	 * Now that we know the real value of kernelbase,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1310
	 * update variables that were initialized with a value of
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1311
	 * KERNELBASE (in common/conf/param.c).
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1312
	 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1313
	 * XXX	The problem with this sort of hackery is that the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1314
	 *	compiler just may feel like putting the const declarations
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1315
	 *	(in param.c) into the .text section.  Perhaps they should
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1316
	 *	just be declared as variables there?
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1317
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1318
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1319
	*(uintptr_t *)&_kernelbase = kernelbase;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1320
	*(uintptr_t *)&_userlimit = kernelbase;
4875
4ae54dfe2667 6593326 dtrace test suite failures
josephb
parents: 4828
diff changeset
  1321
#if defined(__amd64)
4ae54dfe2667 6593326 dtrace test suite failures
josephb
parents: 4828
diff changeset
  1322
	*(uintptr_t *)&_userlimit -= KERNELBASE - USERLIMIT;
4ae54dfe2667 6593326 dtrace test suite failures
josephb
parents: 4828
diff changeset
  1323
#else
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1324
	*(uintptr_t *)&_userlimit32 = _userlimit;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1325
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1326
	PRM_DEBUG(_kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1327
	PRM_DEBUG(_userlimit);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1328
	PRM_DEBUG(_userlimit32);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1329
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1330
	layout_kernel_va();
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1331
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1332
#if defined(__i386)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1333
	/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1334
	 * If segmap is too large we can push the bottom of the kernel heap
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1335
	 * higher than the base.  Or worse, it could exceed the top of the
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1336
	 * VA space entirely, causing it to wrap around.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1337
	 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1338
	if (kernelheap >= ekernelheap || (uintptr_t)kernelheap < kernelbase)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1339
		panic("too little address space available for kernelheap,"
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1340
		    " use eeprom for lower kernelbase or smaller segmapsize");
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1341
#endif	/* __i386 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1342
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1343
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1344
	 * Initialize the kernel heap. Note 3rd argument must be > 1st.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1345
	 */
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1346
	kernelheap_init(kernelheap, ekernelheap,
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1347
	    kernelheap + MMU_PAGESIZE,
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1348
	    (void *)core_base, (void *)(core_base + core_size));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1349
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1350
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1351
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1352
	 * Link pending events struct into cpu struct
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1353
	 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1354
	CPU->cpu_m.mcpu_evt_pend = &cpu0_evt_data;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1355
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1356
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1357
	 * Initialize kernel memory allocator.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1358
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1359
	kmem_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1360
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1361
	/*
3717
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1362
	 * Factor in colorequiv to check additional 'equivalent' bins
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1363
	 */
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1364
	page_set_colorequiv_arr();
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1365
8471164f3e47 6527696 /etc/system colorequiv setting has no impact
dp78419
parents: 3552
diff changeset
  1366
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1367
	 * print this out early so that we know what's going on
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1368
	 */
9370
5f964d9a7826 6750666 getisax(2) needs to detect Intel AES instruction set extension and PCLMULQDQ instruction
Kuriakose Kuruvilla <Kuriakose.Kuruvilla@Sun.COM>
parents: 9281
diff changeset
  1369
	cmn_err(CE_CONT, fmt, x86_feature, FMT_X86_FEATURE);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1370
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1371
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1372
	 * Initialize bp_mapin().
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1373
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1374
	bp_init(MMU_PAGESIZE, HAT_STORECACHING_OK);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1375
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1376
	/*
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1377
	 * orig_npages is non-zero if physmem has been configured for less
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1378
	 * than the available memory.
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1379
	 */
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1380
	if (orig_npages) {
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1381
		cmn_err(CE_WARN, "!%slimiting physmem to 0x%lx of 0x%lx pages",
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1382
		    (npages == PHYSMEM ? "Due to virtual address space " : ""),
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1383
		    npages, orig_npages);
1479
33ca002df1d5 6373609 Solaris install fails on 16-way 64GB system with s10u1_19a.
kchow
parents: 1455
diff changeset
  1384
	}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1385
#if defined(__i386)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1386
	if (eprom_kernelbase && (eprom_kernelbase != kernelbase))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1387
		cmn_err(CE_WARN, "kernelbase value, User specified 0x%lx, "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1388
		    "System using 0x%lx",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1389
		    (uintptr_t)eprom_kernelbase, (uintptr_t)kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1390
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1391
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1392
#ifdef	KERNELBASE_ABI_MIN
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1393
	if (kernelbase < (uintptr_t)KERNELBASE_ABI_MIN) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1394
		cmn_err(CE_NOTE, "!kernelbase set to 0x%lx, system is not "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1395
		    "i386 ABI compliant.", (uintptr_t)kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1396
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1397
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1398
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1399
#ifdef __xpv
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1400
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1401
	 * Some of the xen start information has to be relocated up
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1402
	 * into the kernel's permanent address space.
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1403
	 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1404
	PRM_POINT("calling xen_relocate_start_info()");
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1405
	xen_relocate_start_info();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1406
	PRM_POINT("xen_relocate_start_info() done");
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1407
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1408
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1409
	 * (Update the vcpu pointer in our cpu structure to point into
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1410
	 * the relocated shared info.)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1411
	 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1412
	CPU->cpu_m.mcpu_vcpu_info =
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1413
	    &HYPERVISOR_shared_info->vcpu_info[CPU->cpu_id];
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1414
#endif
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1415
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1416
	PRM_POINT("startup_kmem() done");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1417
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1418
5741
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1419
#ifndef __xpv
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1420
/*
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1421
 * If we have detected that we are running in an HVM environment, we need
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1422
 * to prepend the PV driver directory to the module search path.
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1423
 */
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1424
#define	HVM_MOD_DIR "/platform/i86hvm/kernel"
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1425
static void
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1426
update_default_path()
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1427
{
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1428
	char *current, *newpath;
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1429
	int newlen;
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1430
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1431
	/*
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1432
	 * We are about to resync with krtld.  krtld will reset its
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1433
	 * internal module search path iff Solaris has set default_path.
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1434
	 * We want to be sure we're prepending this new directory to the
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1435
	 * right search path.
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1436
	 */
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1437
	current = (default_path == NULL) ? kobj_module_path : default_path;
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1438
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1439
	newlen = strlen(HVM_MOD_DIR) + strlen(current) + 1;
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1440
	newpath = kmem_alloc(newlen, KM_SLEEP);
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1441
	(void) strcpy(newpath, HVM_MOD_DIR);
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1442
	(void) strcat(newpath, " ");
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1443
	(void) strcat(newpath, current);
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1444
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1445
	default_path = newpath;
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1446
}
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1447
#endif
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1448
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1449
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1450
startup_modules(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1451
{
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1452
	int cnt;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1453
	extern void prom_setup(void);
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1454
	int32_t v, h;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1455
	char d[11];
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1456
	char *cp;
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1457
	cmi_hdl_t hdl;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1458
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1459
	PRM_POINT("startup_modules() starting...");
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1460
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1461
#ifndef __xpv
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1462
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1463
	 * Initialize ten-micro second timer so that drivers will
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1464
	 * not get short changed in their init phase. This was
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1465
	 * not getting called until clkinit which, on fast cpu's
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1466
	 * caused the drv_usecwait to be way too short.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1467
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1468
	microfind();
5741
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1469
9000
7a9c5c9ed60d 6775011 bad trap page fault while starting dom0
Stuart Maybee <Stuart.Maybee@Sun.COM>
parents: 8930
diff changeset
  1470
	if (get_hwenv() == HW_XEN_HVM)
5741
58423876d513 PSARC 2007/664 Paravirtualized Drivers for Fully Virtualized xVM Domains
mrj
parents: 5460
diff changeset
  1471
		update_default_path();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1472
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1473
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1474
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1475
	 * Read the GMT lag from /etc/rtc_config.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1476
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1477
	sgmtl(process_rtc_config_file());
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1478
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1479
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1480
	 * Calculate default settings of system parameters based upon
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1481
	 * maxusers, yet allow to be overridden via the /etc/system file.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1482
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1483
	param_calc(0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1484
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1485
	mod_setup();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1486
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1487
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1488
	 * Initialize system parameters.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1489
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1490
	param_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1491
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1492
	/*
2712
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
  1493
	 * Initialize the default brands
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
  1494
	 */
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
  1495
	brand_init();
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
  1496
f74a135872bc PSARC/2005/471 BrandZ: Support for non-native zones
nn35248
parents: 2621
diff changeset
  1497
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1498
	 * maxmem is the amount of physical memory we're playing with.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1499
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1500
	maxmem = physmem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1501
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1502
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1503
	 * Initialize segment management stuff.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1504
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1505
	seg_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1506
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1507
	if (modload("fs", "specfs") == -1)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1508
		halt("Can't load specfs");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1509
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1510
	if (modload("fs", "devfs") == -1)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1511
		halt("Can't load devfs");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1512
2621
4ea88858d952 PSARC/2003/246 Filesystem Driven Device Naming
llai1
parents: 1841
diff changeset
  1513
	if (modload("fs", "dev") == -1)
4ea88858d952 PSARC/2003/246 Filesystem Driven Device Naming
llai1
parents: 1841
diff changeset
  1514
		halt("Can't load dev");
4ea88858d952 PSARC/2003/246 Filesystem Driven Device Naming
llai1
parents: 1841
diff changeset
  1515
1676
37f4a3e2bd99 PSARC/2002/762 Layered Trusted Solaris
jpk
parents: 1582
diff changeset
  1516
	(void) modloadonly("sys", "lbl_edition");
37f4a3e2bd99 PSARC/2002/762 Layered Trusted Solaris
jpk
parents: 1582
diff changeset
  1517
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1518
	dispinit();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1519
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1520
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1521
	 * This is needed here to initialize hw_serial[] for cluster booting.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1522
	 */
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  1523
	if ((h = set_soft_hostid()) == HW_INVALID_HOSTID) {
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1524
		cmn_err(CE_WARN, "Unable to set hostid");
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  1525
	} else {
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1526
		for (v = h, cnt = 0; cnt < 10; cnt++) {
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  1527
			d[cnt] = (char)(v % 10);
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1528
			v /= 10;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1529
			if (v == 0)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1530
				break;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1531
		}
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1532
		for (cp = hw_serial; cnt >= 0; cnt--)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1533
			*cp++ = d[cnt] + '0';
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1534
		*cp = 0;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1535
	}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1536
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1537
	/* Read cluster configuration data. */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1538
	clconf_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1539
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1540
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1541
	ec_init();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1542
	gnttab_init();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1543
	(void) xs_early_init();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1544
#endif /* __xpv */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1545
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1546
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1547
	 * Create a kernel device tree. First, create rootnex and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1548
	 * then invoke bus specific code to probe devices.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1549
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1550
	setup_ddi();
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  1551
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1552
	/*
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1553
	 * Set up the CPU module subsystem for the boot cpu in the native
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1554
	 * case, and all physical cpu resource in the xpv dom0 case.
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1555
	 * Modifies the device tree, so this must be done after
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1556
	 * setup_ddi().
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1557
	 */
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1558
#ifdef __xpv
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1559
	/*
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1560
	 * If paravirtualized and on dom0 then we initialize all physical
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1561
	 * cpu handles now;  if paravirtualized on a domU then do not
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1562
	 * initialize.
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1563
	 */
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1564
	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1565
		xen_mc_lcpu_cookie_t cpi;
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1566
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1567
		for (cpi = xen_physcpu_next(NULL); cpi != NULL;
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1568
		    cpi = xen_physcpu_next(cpi)) {
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1569
			if ((hdl = cmi_init(CMI_HDL_SOLARIS_xVM_MCA,
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1570
			    xen_physcpu_chipid(cpi), xen_physcpu_coreid(cpi),
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1571
			    xen_physcpu_strandid(cpi))) != NULL &&
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1572
			    (x86_feature & X86_MCA))
5254
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5159
diff changeset
  1573
				cmi_mca_init(hdl);
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5159
diff changeset
  1574
		}
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5159
diff changeset
  1575
	}
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1576
#else
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1577
	/*
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1578
	 * Initialize a handle for the boot cpu - others will initialize
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1579
	 * as they startup.  Do not do this if we know we are in an HVM domU.
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1580
	 */
9000
7a9c5c9ed60d 6775011 bad trap page fault while starting dom0
Stuart Maybee <Stuart.Maybee@Sun.COM>
parents: 8930
diff changeset
  1581
	if ((get_hwenv() != HW_XEN_HVM) &&
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1582
	    (hdl = cmi_init(CMI_HDL_NATIVE, cmi_ntv_hwchipid(CPU),
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1583
	    cmi_ntv_hwcoreid(CPU), cmi_ntv_hwstrandid(CPU))) != NULL &&
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1584
	    (x86_feature & X86_MCA))
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  1585
			cmi_mca_init(hdl);
5254
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5159
diff changeset
  1586
#endif	/* __xpv */
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  1587
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1588
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1589
	 * Fake a prom tree such that /dev/openprom continues to work
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1590
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1591
	PRM_POINT("startup_modules: calling prom_setup...");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1592
	prom_setup();
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1593
	PRM_POINT("startup_modules: done");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1594
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1595
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1596
	 * Load all platform specific modules
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1597
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1598
	PRM_POINT("startup_modules: calling psm_modload...");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1599
	psm_modload();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1600
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1601
	PRM_POINT("startup_modules() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1602
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1603
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1604
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1605
 * claim a "setaside" boot page for use in the kernel
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1606
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1607
page_t *
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1608
boot_claim_page(pfn_t pfn)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1609
{
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1610
	page_t *pp;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1611
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1612
	pp = page_numtopp_nolock(pfn);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1613
	ASSERT(pp != NULL);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1614
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1615
	if (PP_ISBOOTPAGES(pp)) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1616
		if (pp->p_next != NULL)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1617
			pp->p_next->p_prev = pp->p_prev;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1618
		if (pp->p_prev == NULL)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1619
			bootpages = pp->p_next;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1620
		else
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1621
			pp->p_prev->p_next = pp->p_next;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1622
	} else {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1623
		/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1624
		 * htable_attach() expects a base pagesize page
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1625
		 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1626
		if (pp->p_szc != 0)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1627
			page_boot_demote(pp);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1628
		pp = page_numtopp(pfn, SE_EXCL);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1629
	}
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1630
	return (pp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1631
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1632
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1633
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1634
 * Walk through the pagetables looking for pages mapped in by boot.  If the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1635
 * setaside flag is set the pages are expected to be returned to the
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1636
 * kernel later in boot, so we add them to the bootpages list.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1637
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1638
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1639
protect_boot_range(uintptr_t low, uintptr_t high, int setaside)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1640
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1641
	uintptr_t va = low;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1642
	size_t len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1643
	uint_t prot;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1644
	pfn_t pfn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1645
	page_t *pp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1646
	pgcnt_t boot_protect_cnt = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1647
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1648
	while (kbm_probe(&va, &len, &pfn, &prot) != 0 && va < high) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1649
		if (va + len >= high)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1650
			panic("0x%lx byte mapping at 0x%p exceeds boot's "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1651
			    "legal range.", len, (void *)va);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1652
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1653
		while (len > 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1654
			pp = page_numtopp_alloc(pfn);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1655
			if (pp != NULL) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1656
				if (setaside == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1657
					panic("Unexpected mapping by boot.  "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1658
					    "addr=%p pfn=%lx\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1659
					    (void *)va, pfn);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1660
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1661
				pp->p_next = bootpages;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1662
				pp->p_prev = NULL;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1663
				PP_SETBOOTPAGES(pp);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1664
				if (bootpages != NULL) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1665
					bootpages->p_prev = pp;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1666
				}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1667
				bootpages = pp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1668
				++boot_protect_cnt;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1669
			}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1670
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1671
			++pfn;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1672
			len -= MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1673
			va += MMU_PAGESIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1674
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1675
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1676
	PRM_DEBUG(boot_protect_cnt);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1677
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1678
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1679
/*
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1680
 *
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1681
 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1682
static void
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1683
layout_kernel_va(void)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1684
{
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1685
	PRM_POINT("layout_kernel_va() starting...");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1686
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1687
	 * Establish the final size of the kernel's heap, size of segmap,
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1688
	 * segkp, etc.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1689
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1690
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1691
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1692
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1693
	kpm_vbase = (caddr_t)segkpm_base;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1694
	kpm_size = ROUND_UP_LPAGE(mmu_ptob(physmax + 1));
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1695
	if ((uintptr_t)kpm_vbase + kpm_size > (uintptr_t)valloc_base)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1696
		panic("not enough room for kpm!");
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1697
	PRM_DEBUG(kpm_size);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1698
	PRM_DEBUG(kpm_vbase);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1699
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1700
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1701
	 * By default we create a seg_kp in 64 bit kernels, it's a little
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1702
	 * faster to access than embedding it in the heap.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1703
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1704
	segkp_base = (caddr_t)valloc_base + valloc_sz;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1705
	if (!segkp_fromheap) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1706
		size_t sz = mmu_ptob(segkpsize);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1707
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1708
		/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1709
		 * determine size of segkp
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1710
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1711
		if (sz < SEGKPMINSIZE || sz > SEGKPMAXSIZE) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1712
			sz = SEGKPDEFSIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1713
			cmn_err(CE_WARN, "!Illegal value for segkpsize. "
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1714
			    "segkpsize has been reset to %ld pages",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1715
			    mmu_btop(sz));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1716
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1717
		sz = MIN(sz, MAX(SEGKPMINSIZE, mmu_ptob(physmem)));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1718
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1719
		segkpsize = mmu_btop(ROUND_UP_LPAGE(sz));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1720
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1721
	PRM_DEBUG(segkp_base);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1722
	PRM_DEBUG(segkpsize);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1723
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1724
	/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1725
	 * segzio is used for ZFS cached data. It uses a distinct VA
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1726
	 * segment (from kernel heap) so that we can easily tell not to
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1727
	 * include it in kernel crash dumps on 64 bit kernels. The trick is
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1728
	 * to give it lots of VA, but not constrain the kernel heap.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1729
	 * We scale the size of segzio linearly with physmem up to
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1730
	 * SEGZIOMAXSIZE. Above that amount it scales at 50% of physmem.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1731
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1732
	segzio_base = segkp_base + mmu_ptob(segkpsize);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1733
	if (segzio_fromheap) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1734
		segziosize = 0;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1735
	} else {
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1736
		size_t physmem_size = mmu_ptob(physmem);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1737
		size_t size = (segziosize == 0) ?
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1738
		    physmem_size : mmu_ptob(segziosize);
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1739
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1740
		if (size < SEGZIOMINSIZE)
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1741
			size = SEGZIOMINSIZE;
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1742
		if (size > SEGZIOMAXSIZE) {
3552
ea34919c6784 6520051 segzio's sizing policy needs further optimization
johansen
parents: 3446
diff changeset
  1743
			size = SEGZIOMAXSIZE;
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1744
			if (physmem_size > size)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1745
				size += (physmem_size - size) / 2;
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1746
		}
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1747
		segziosize = mmu_btop(ROUND_UP_LPAGE(size));
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1748
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1749
	PRM_DEBUG(segziosize);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1750
	PRM_DEBUG(segzio_base);
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  1751
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1752
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1753
	 * Put the range of VA for device mappings next, kmdb knows to not
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1754
	 * grep in this range of addresses.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1755
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1756
	toxic_addr =
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1757
	    ROUND_UP_LPAGE((uintptr_t)segzio_base + mmu_ptob(segziosize));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1758
	PRM_DEBUG(toxic_addr);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1759
	segmap_start = ROUND_UP_LPAGE(toxic_addr + toxic_size);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1760
#else /* __i386 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1761
	segmap_start = ROUND_UP_LPAGE(kernelbase);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1762
#endif /* __i386 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1763
	PRM_DEBUG(segmap_start);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1764
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1765
	/*
7692
5f48c0bb1a31 6700742 incorrect comment for tuning segmap on x64
Amrita Sadhukhan <Amrita.Sadhukhan@Sun.COM>
parents: 7656
diff changeset
  1766
	 * Users can change segmapsize through eeprom. If the variable
5f48c0bb1a31 6700742 incorrect comment for tuning segmap on x64
Amrita Sadhukhan <Amrita.Sadhukhan@Sun.COM>
parents: 7656
diff changeset
  1767
	 * is tuned through eeprom, there is no upper bound on the
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  1768
	 * size of segmap.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1769
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1770
	segmapsize = MAX(ROUND_UP_LPAGE(segmapsize), SEGMAPDEFAULT);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1771
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1772
#if defined(__i386)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1773
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1774
	 * 32-bit systems don't have segkpm or segkp, so segmap appears at
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1775
	 * the bottom of the kernel's address range.  Set aside space for a
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1776
	 * small red zone just below the start of segmap.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1777
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1778
	segmap_start += KERNEL_REDZONE_SIZE;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1779
	segmapsize -= KERNEL_REDZONE_SIZE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1780
#endif
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1781
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1782
	PRM_DEBUG(segmap_start);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1783
	PRM_DEBUG(segmapsize);
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1784
	kernelheap = (caddr_t)ROUND_UP_LPAGE(segmap_start + segmapsize);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1785
	PRM_DEBUG(kernelheap);
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1786
	PRM_POINT("layout_kernel_va() done...");
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1787
}
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1788
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1789
/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1790
 * Finish initializing the VM system, now that we are no longer
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1791
 * relying on the boot time memory allocators.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1792
 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1793
static void
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1794
startup_vm(void)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1795
{
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1796
	struct segmap_crargs a;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1797
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1798
	extern int use_brk_lpg, use_stk_lpg;
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1799
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1800
	PRM_POINT("startup_vm() starting...");
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1801
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1802
	/*
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1803
	 * Initialize the hat layer.
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1804
	 */
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  1805
	hat_init();
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1806
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1807
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1808
	 * Do final allocations of HAT data structures that need to
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1809
	 * be allocated before quiescing the boot loader.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1810
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1811
	PRM_POINT("Calling hat_kern_alloc()...");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1812
	hat_kern_alloc((caddr_t)segmap_start, segmapsize, ekernelheap);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1813
	PRM_POINT("hat_kern_alloc() done");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1814
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1815
#ifndef __xpv
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1816
	/*
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  1817
	 * Setup Page Attribute Table
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1818
	 */
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  1819
	pat_sync();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1820
#endif
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1821
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1822
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1823
	 * The next two loops are done in distinct steps in order
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1824
	 * to be sure that any page that is doubly mapped (both above
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1825
	 * KERNEL_TEXT and below kernelbase) is dealt with correctly.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1826
	 * Note this may never happen, but it might someday.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1827
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1828
	bootpages = NULL;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1829
	PRM_POINT("Protecting boot pages");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1830
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1831
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1832
	 * Protect any pages mapped above KERNEL_TEXT that somehow have
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1833
	 * page_t's. This can only happen if something weird allocated
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1834
	 * in this range (like kadb/kmdb).
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1835
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1836
	protect_boot_range(KERNEL_TEXT, (uintptr_t)-1, 0);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1837
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1838
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1839
	 * Before we can take over memory allocation/mapping from the boot
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1840
	 * loader we must remove from our free page lists any boot allocated
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1841
	 * pages that stay mapped until release_bootstrap().
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1842
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1843
	protect_boot_range(0, kernelbase, 1);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1844
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1845
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1846
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1847
	 * Switch to running on regular HAT (not boot_mmu)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1848
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1849
	PRM_POINT("Calling hat_kern_setup()...");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1850
	hat_kern_setup();
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1851
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1852
	/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1853
	 * It is no longer safe to call BOP_ALLOC(), so make sure we don't.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1854
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1855
	bop_no_more_mem();
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1856
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1857
	PRM_POINT("hat_kern_setup() done");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1858
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1859
	hat_cpu_online(CPU);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1860
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1861
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1862
	 * Initialize VM system
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1863
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1864
	PRM_POINT("Calling kvm_init()...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1865
	kvm_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1866
	PRM_POINT("kvm_init() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1867
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1868
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1869
	 * Tell kmdb that the VM system is now working
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1870
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1871
	if (boothowto & RB_DEBUG)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1872
		kdi_dvec_vmready();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1873
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1874
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1875
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1876
	 * Populate the I/O pool on domain 0
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1877
	 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1878
	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1879
		extern long populate_io_pool(void);
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1880
		long init_io_pool_cnt;
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1881
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1882
		PRM_POINT("Populating reserve I/O page pool");
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1883
		init_io_pool_cnt = populate_io_pool();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1884
		PRM_DEBUG(init_io_pool_cnt);
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1885
	}
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1886
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1887
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1888
	 * Mangle the brand string etc.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1889
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1890
	cpuid_pass3(CPU);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1891
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1892
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1893
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1894
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1895
	 * Create the device arena for toxic (to dtrace/kmdb) mappings.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1896
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1897
	device_arena = vmem_create("device", (void *)toxic_addr,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1898
	    toxic_size, MMU_PAGESIZE, NULL, NULL, NULL, 0, VM_SLEEP);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1899
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1900
#else	/* __i386 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1901
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1902
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1903
	 * allocate the bit map that tracks toxic pages
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1904
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1905
	toxic_bit_map_len = btop((ulong_t)(valloc_base - kernelbase));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1906
	PRM_DEBUG(toxic_bit_map_len);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1907
	toxic_bit_map =
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1908
	    kmem_zalloc(BT_SIZEOFMAP(toxic_bit_map_len), KM_NOSLEEP);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1909
	ASSERT(toxic_bit_map != NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1910
	PRM_DEBUG(toxic_bit_map);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1911
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1912
#endif	/* __i386 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1913
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1914
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1915
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1916
	 * Now that we've got more VA, as well as the ability to allocate from
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1917
	 * it, tell the debugger.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1918
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1919
	if (boothowto & RB_DEBUG)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1920
		kdi_dvec_memavail();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1921
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1922
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1923
	 * The following code installs a special page fault handler (#pf)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1924
	 * to work around a pentium bug.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1925
	 */
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1926
#if !defined(__amd64) && !defined(__xpv)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1927
	if (x86_type == X86_TYPE_P5) {
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1928
		desctbr_t idtr;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1929
		gate_desc_t *newidt;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1930
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1931
		if ((newidt = kmem_zalloc(MMU_PAGESIZE, KM_NOSLEEP)) == NULL)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1932
			panic("failed to install pentium_pftrap");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1933
5460
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1934
		bcopy(idt0, newidt, NIDT * sizeof (*idt0));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1935
		set_gatesegd(&newidt[T_PGFLT], &pentium_pftrap,
8679
9a9ef0969b61 6625634 double fault handler no longer switches stacks on 64-bit kernel
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 8662
diff changeset
  1936
		    KCS_SEL, SDT_SYSIGT, TRP_KPL, 0);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1937
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1938
		(void) as_setprot(&kas, (caddr_t)newidt, MMU_PAGESIZE,
5460
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1939
		    PROT_READ | PROT_EXEC);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1940
5460
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1941
		CPU->cpu_idt = newidt;
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1942
		idtr.dtr_base = (uintptr_t)CPU->cpu_idt;
265cc42b6f62 6624280 GDT, LDT, IDT and TSS should not share pages with other things
josephb
parents: 5349
diff changeset
  1943
		idtr.dtr_limit = (NIDT * sizeof (*idt0)) - 1;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1944
		wr_idtr(&idtr);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1945
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1946
#endif	/* !__amd64 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1947
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1948
#if !defined(__xpv)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1949
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1950
	 * Map page pfn=0 for drivers, such as kd, that need to pick up
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1951
	 * parameters left there by controllers/BIOS.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1952
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1953
	PRM_POINT("setup up p0_va");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1954
	p0_va = i86devmap(0, 1, PROT_READ);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1955
	PRM_DEBUG(p0_va);
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  1956
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1957
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1958
	cmn_err(CE_CONT, "?mem = %luK (0x%lx)\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1959
	    physinstalled << (MMU_PAGESHIFT - 10), ptob(physinstalled));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1960
841
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
  1961
	/*
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
  1962
	 * disable automatic large pages for small memory systems or
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
  1963
	 * when the disable flag is set.
5349
01422ec04372 6453272 ctfmerge uses the largest pagesize from getpagesizes() which can be bad on systems with giant pages
kchow
parents: 5316
diff changeset
  1964
	 *
01422ec04372 6453272 ctfmerge uses the largest pagesize from getpagesizes() which can be bad on systems with giant pages
kchow
parents: 5316
diff changeset
  1965
	 * Do not yet consider page sizes larger than 2m/4m.
841
814b4a127357 6344639 system spends all its time trying and failing to make big pages
kchow
parents: 810
diff changeset
  1966
	 */
2991
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1967
	if (!auto_lpg_disable && mmu.max_page_level > 0) {
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1968
		max_uheap_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1969
		max_ustack_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1970
		max_privmap_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1971
		max_uidata_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1972
		max_utext_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1973
		max_shm_lpsize = LEVEL_SIZE(1);
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1974
	}
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1975
	if (physmem < privm_lpg_min_physmem || mmu.max_page_level == 0 ||
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1976
	    auto_lpg_disable) {
423
6cbc492798ce 6294795 The behavior of malloc is different between solaris 10 and nevada
davemq
parents: 0
diff changeset
  1977
		use_brk_lpg = 0;
6cbc492798ce 6294795 The behavior of malloc is different between solaris 10 and nevada
davemq
parents: 0
diff changeset
  1978
		use_stk_lpg = 0;
2991
4b13d6c49c6b 6254029 memcntl() MC_HAT_ADVISE with page size 0 may cause segment page sizes to be demoted
susans
parents: 2712
diff changeset
  1979
	}
5349
01422ec04372 6453272 ctfmerge uses the largest pagesize from getpagesizes() which can be bad on systems with giant pages
kchow
parents: 5316
diff changeset
  1980
	mcntl0_lpsize = LEVEL_SIZE(mmu.umax_page_level);
423
6cbc492798ce 6294795 The behavior of malloc is different between solaris 10 and nevada
davemq
parents: 0
diff changeset
  1981
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1982
	PRM_POINT("Calling hat_init_finish()...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1983
	hat_init_finish();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1984
	PRM_POINT("hat_init_finish() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1985
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1986
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1987
	 * Initialize the segkp segment type.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1988
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1989
	rw_enter(&kas.a_lock, RW_WRITER);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1990
	PRM_POINT("Attaching segkp");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1991
	if (segkp_fromheap) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1992
		segkp->s_as = &kas;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1993
	} else if (seg_attach(&kas, (caddr_t)segkp_base, mmu_ptob(segkpsize),
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1994
	    segkp) < 0) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1995
		panic("startup: cannot attach segkp");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1996
		/*NOTREACHED*/
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1997
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  1998
	PRM_POINT("Doing segkp_create()");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  1999
	if (segkp_create(segkp) != 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2000
		panic("startup: segkp_create failed");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2001
		/*NOTREACHED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2002
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2003
	PRM_DEBUG(segkp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2004
	rw_exit(&kas.a_lock);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2005
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2006
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2007
	 * kpm segment
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2008
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2009
	segmap_kpm = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2010
	if (kpm_desired) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2011
		kpm_init();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2012
		kpm_enable = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2013
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2014
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2015
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2016
	 * Now create segmap segment.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2017
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2018
	rw_enter(&kas.a_lock, RW_WRITER);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2019
	if (seg_attach(&kas, (caddr_t)segmap_start, segmapsize, segmap) < 0) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2020
		panic("cannot attach segmap");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2021
		/*NOTREACHED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2022
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2023
	PRM_DEBUG(segmap);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2024
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2025
	a.prot = PROT_READ | PROT_WRITE;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2026
	a.shmsize = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2027
	a.nfreelist = segmapfreelists;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2028
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2029
	if (segmap_create(segmap, (caddr_t)&a) != 0)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2030
		panic("segmap_create segmap");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2031
	rw_exit(&kas.a_lock);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2032
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2033
	setup_vaddr_for_ppcopy(CPU);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2034
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2035
	segdev_init();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2036
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2037
	if (DOMAIN_IS_INITDOMAIN(xen_info))
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2038
#endif
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2039
		pmem_init();
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2040
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2041
	PRM_POINT("startup_vm() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2042
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2043
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2044
/*
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2045
 * Load a tod module for the non-standard tod part found on this system.
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2046
 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2047
static void
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2048
load_tod_module(char *todmod)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2049
{
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2050
	if (modload("tod", todmod) == -1)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2051
		halt("Can't load TOD module");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2052
}
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2053
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2054
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2055
startup_end(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2056
{
5107
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2057
	int i;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2058
	extern void setx86isalist(void);
9637
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2059
	extern void cpu_event_init(void);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2060
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2061
	PRM_POINT("startup_end() starting...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2062
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2063
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2064
	 * Perform tasks that get done after most of the VM
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2065
	 * initialization has been done but before the clock
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2066
	 * and other devices get started.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2067
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2068
	kern_setup1();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2069
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2070
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2071
	 * Perform CPC initialization for this CPU.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2072
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2073
	kcpc_hw_init(CPU);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2074
9637
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2075
	/*
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2076
	 * Initialize cpu event framework.
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2077
	 */
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2078
	cpu_event_init();
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2079
1582
eb879d43ab47 6323525 Mutual exclusion primitives don't work as expected on Opteron systems
kchow
parents: 1494
diff changeset
  2080
#if defined(OPTERON_WORKAROUND_6323525)
eb879d43ab47 6323525 Mutual exclusion primitives don't work as expected on Opteron systems
kchow
parents: 1494
diff changeset
  2081
	if (opteron_workaround_6323525)
eb879d43ab47 6323525 Mutual exclusion primitives don't work as expected on Opteron systems
kchow
parents: 1494
diff changeset
  2082
		patch_workaround_6323525();
eb879d43ab47 6323525 Mutual exclusion primitives don't work as expected on Opteron systems
kchow
parents: 1494
diff changeset
  2083
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2084
	/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2085
	 * If needed, load TOD module now so that ddi_get_time(9F) etc. work
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2086
	 * (For now, "needed" is defined as set tod_module_name in /etc/system)
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2087
	 */
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2088
	if (tod_module_name != NULL) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2089
		PRM_POINT("load_tod_module()");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2090
		load_tod_module(tod_module_name);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2091
	}
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2092
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2093
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2094
	/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2095
	 * Forceload interposing TOD module for the hypervisor.
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2096
	 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2097
	PRM_POINT("load_tod_module()");
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2098
	load_tod_module("xpvtod");
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2099
#endif
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2100
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2101
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2102
	 * Configure the system.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2103
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2104
	PRM_POINT("Calling configure()...");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2105
	configure();		/* set up devices */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2106
	PRM_POINT("configure() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2107
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2108
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2109
	 * Set the isa_list string to the defined instruction sets we
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2110
	 * support.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2111
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2112
	setx86isalist();
1455
b43f098fa50c 6378953 allocation of interrupt threads could be more common
andrei
parents: 1417
diff changeset
  2113
	cpu_intr_alloc(CPU, NINTR_THREADS);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2114
	psm_install();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2115
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2116
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2117
	 * We're done with bootops.  We don't unmap the bootstrap yet because
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2118
	 * we're still using bootsvcs.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2119
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2120
	PRM_POINT("NULLing out bootops");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2121
	*bootopsp = (struct bootops *)NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2122
	bootops = (struct bootops *)NULL;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2123
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2124
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2125
	ec_init_debug_irq();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2126
	xs_domu_init();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2127
#endif
9940
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2128
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2129
#if !defined(__xpv)
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2130
	if (rootnex_iommu_init != NULL) {
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2131
		rootnex_iommu_init();
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2132
	}
82fa1538a908 6819642 Intel IOMMU has multiple issues
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 9732
diff changeset
  2133
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2134
	PRM_POINT("Enabling interrupts");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2135
	(*picinitf)();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2136
	sti();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2137
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2138
	ASSERT(CPU->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask == 0);
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2139
	xen_late_startup();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2140
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2141
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2142
	(void) add_avsoftintr((void *)&softlevel1_hdl, 1, softlevel1,
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2143
	    "softlevel1", NULL, NULL); /* XXX to be moved later */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2144
5107
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2145
	/*
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2146
	 * Register these software interrupts for ddi timer.
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2147
	 * Software interrupts up to the level 10 are supported.
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2148
	 */
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2149
	for (i = DDI_IPL_1; i <= DDI_IPL_10; i++) {
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2150
		char name[sizeof ("timer_softintr") + 2];
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2151
		(void) sprintf(name, "timer_softintr%02d", i);
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2152
		(void) add_avsoftintr((void *)&softlevel_hdl[i-1], i,
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2153
		    (avfunc)timer_softintr, name, (caddr_t)(uintptr_t)i, NULL);
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2154
	}
bb9efa2ee1e8 PSARC 2007/402 Driver Periodic Timeouts
eota
parents: 5084
diff changeset
  2155
7730
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2156
#if !defined(__xpv)
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2157
	if (modload("drv", "amd_iommu") < 0) {
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2158
		PRM_POINT("No AMD IOMMU present\n");
8215
dc6a5d93e70c 6774448 Toonie needs non-unity map
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7942
diff changeset
  2159
	} else if (ddi_hold_installed_driver(ddi_name_to_major(
dc6a5d93e70c 6774448 Toonie needs non-unity map
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7942
diff changeset
  2160
	    "amd_iommu")) == NULL) {
7730
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2161
		prom_printf("ERROR: failed to attach AMD IOMMU\n");
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2162
	}
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2163
#endif
8930
02055889c73a 6786943 AMD-based systems with C1E state enabled hang at boot
Bill Holler <Bill.Holler@Sun.COM>
parents: 8906
diff changeset
  2164
	post_startup_cpu_fixups();
7730
a27323470b01 PSARC 2008/561 AMD IOMMU
Vikram Hegde <Vikram.Hegde@Sun.COM>
parents: 7720
diff changeset
  2165
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2166
	PRM_POINT("startup_end() done");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2167
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2168
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2169
/*
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2170
 * Don't remove the following 2 variables.  They are necessary
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2171
 * for reading the hostid from the legacy file (/kernel/misc/sysinit).
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2172
 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2173
char *_hs1107 = hw_serial;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2174
ulong_t  _bdhs34;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2175
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2176
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2177
post_startup(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2178
{
8906
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
  2179
	extern void cpupm_init(cpu_t *);
9637
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2180
	extern void cpu_event_init_cpu(cpu_t *);
8906
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
  2181
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2182
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2183
	 * Set the system wide, processor-specific flags to be passed
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2184
	 * to userland via the aux vector for performance hints and
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2185
	 * instruction set extensions.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2186
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2187
	bind_hwcap();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2188
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2189
#ifdef __xpv
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2190
	if (DOMAIN_IS_INITDOMAIN(xen_info))
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2191
#endif
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2192
	{
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2193
		/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2194
		 * Load the System Management BIOS into the global ksmbios
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2195
		 * handle, if an SMBIOS is present on this system.
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2196
		 */
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2197
		ksmbios = smbios_open(NULL, SMB_VERSION, ksmbios_flags, NULL);
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2198
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2199
#if defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2200
		xpv_panic_init();
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2201
#else
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2202
		/*
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2203
		 * Startup the memory scrubber.
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2204
		 * XXPV	This should be running somewhere ..
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2205
		 */
9000
7a9c5c9ed60d 6775011 bad trap page fault while starting dom0
Stuart Maybee <Stuart.Maybee@Sun.COM>
parents: 8930
diff changeset
  2206
		if (get_hwenv() != HW_XEN_HVM)
7532
bb6372f778bb PSARC 2008/569 FMA Topology & Retire Agent Refinements
Cheng Sean Ye <Sean.Ye@Sun.COM>
parents: 7515
diff changeset
  2207
			memscrub_init();
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2208
#endif
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2209
	}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2210
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2211
	/*
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  2212
	 * Complete CPU module initialization
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  2213
	 */
5254
38162db71c7d PSARC 2007/591 Generic x86 Machine Check Architecture
gavinm
parents: 5159
diff changeset
  2214
	cmi_post_startup();
1414
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  2215
b4126407ac5b PSARC 2006/020 FMA for Athlon 64 and Opteron Processors
cindi
parents: 851
diff changeset
  2216
	/*
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2217
	 * Perform forceloading tasks for /etc/system.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2218
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2219
	(void) mod_sysctl(SYS_FORCELOAD, NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2220
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2221
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2222
	 * ON4.0: Force /proc module in until clock interrupt handle fixed
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2223
	 * ON4.0: This must be fixed or restated in /etc/systems.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2224
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2225
	(void) modload("fs", "procfs");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2226
5129
5dc46a0fd425 PSARC 2007/019 KIOCMKTONE (keyboard make tone) ioctl
marx
parents: 5107
diff changeset
  2227
	(void) i_ddi_attach_hw_nodes("pit_beep");
5dc46a0fd425 PSARC 2007/019 KIOCMKTONE (keyboard make tone) ioctl
marx
parents: 5107
diff changeset
  2228
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2229
#if defined(__i386)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2230
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2231
	 * Check for required functional Floating Point hardware,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2232
	 * unless FP hardware explicitly disabled.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2233
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2234
	if (fpu_exists && (fpu_pentium_fdivbug || fp_kind == FP_NO))
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2235
		halt("No working FP hardware found");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2236
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2237
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2238
	maxmem = freemem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2239
9637
60f2a2d63713 6836576 Integrate CPU Idle Notification into ON
Randy Fishel <Randy.Fishel@Sun.COM>
parents: 9370
diff changeset
  2240
	cpu_event_init_cpu(CPU);
8906
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
  2241
	cpupm_init(CPU);
9652
6b40e106879c 6815568 ACPICA enhancements for support of ACPI-based device enumeration earlier in boot
Michael Corcoran <Michael.Corcoran@Sun.COM>
parents: 9637
diff changeset
  2242
	(void) mach_cpu_create_device_node(CPU, NULL);
8906
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
  2243
e559381f1e2b PSARC 2008/777 cpupm keyword mode extensions
Eric Saxe <Eric.Saxe@Sun.COM>
parents: 8679
diff changeset
  2244
	pg_init();
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2245
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2246
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2247
static int
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2248
pp_in_range(page_t *pp, uint64_t low_addr, uint64_t high_addr)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2249
{
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2250
	return ((pp->p_pagenum >= btop(low_addr)) &&
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2251
	    (pp->p_pagenum < btopr(high_addr)));
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2252
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2253
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2254
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2255
release_bootstrap(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2256
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2257
	int root_is_ramdisk;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2258
	page_t *pp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2259
	extern void kobj_boot_unmountroot(void);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2260
	extern dev_t rootdev;
7515
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2261
#if !defined(__xpv)
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2262
	pfn_t	pfn;
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2263
#endif
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2264
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2265
	/* unmount boot ramdisk and release kmem usage */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2266
	kobj_boot_unmountroot();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2267
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2268
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2269
	 * We're finished using the boot loader so free its pages.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2270
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2271
	PRM_POINT("Unmapping lower boot pages");
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2272
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2273
	clear_boot_mappings(0, _userlimit);
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2274
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2275
	postbootkernelbase = kernelbase;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2276
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2277
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2278
	 * If root isn't on ramdisk, destroy the hardcoded
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2279
	 * ramdisk node now and release the memory. Else,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2280
	 * ramdisk memory is kept in rd_pages.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2281
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2282
	root_is_ramdisk = (getmajor(rootdev) == ddi_name_to_major("ramdisk"));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2283
	if (!root_is_ramdisk) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2284
		dev_info_t *dip = ddi_find_devinfo("ramdisk", -1, 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2285
		ASSERT(dip && ddi_get_parent(dip) == ddi_root_node());
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2286
		ndi_rele_devi(dip);	/* held from ddi_find_devinfo */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2287
		(void) ddi_remove_child(dip, 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2288
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2289
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2290
	PRM_POINT("Releasing boot pages");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2291
	while (bootpages) {
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2292
		extern uint64_t ramdisk_start, ramdisk_end;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2293
		pp = bootpages;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2294
		bootpages = pp->p_next;
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2295
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2296
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2297
		/* Keep pages for the lower 64K */
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2298
		if (pp_in_range(pp, 0, 0x40000)) {
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2299
			pp->p_next = lower_pages;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2300
			lower_pages = pp;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2301
			lower_pages_count++;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2302
			continue;
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2303
		}
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2304
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2305
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2306
		if (root_is_ramdisk && pp_in_range(pp, ramdisk_start,
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2307
		    ramdisk_end)) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2308
			pp->p_next = rd_pages;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2309
			rd_pages = pp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2310
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2311
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2312
		pp->p_next = (struct page *)0;
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2313
		pp->p_prev = (struct page *)0;
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2314
		PP_CLRBOOTPAGES(pp);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2315
		page_free(pp, 1);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2316
	}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2317
	PRM_POINT("Boot pages released");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2318
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2319
#if !defined(__xpv)
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2320
/* XXPV -- note this following bunch of code needs to be revisited in Xen 3.0 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2321
	/*
7515
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2322
	 * Find 1 page below 1 MB so that other processors can boot up or
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2323
	 * so that any processor can resume.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2324
	 * Make sure it has a kernel VA as well as a 1:1 mapping.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2325
	 * We should have just free'd one up.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2326
	 */
7656
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2327
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2328
	/*
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2329
	 * 0x10 pages is 64K.  Leave the bottom 64K alone
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2330
	 * for BIOS.
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2331
	 */
2621e50fdf4a PSARC 2008/382 Fast Reboot
Sherry Moore <Sherry.Moore@Sun.COM>
parents: 7532
diff changeset
  2332
	for (pfn = 0x10; pfn < btop(1*1024*1024); pfn++) {
7515
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2333
		if (page_numtopp_alloc(pfn) == NULL)
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2334
			continue;
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2335
		rm_platter_va = i86devmap(pfn, 1,
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2336
		    PROT_READ | PROT_WRITE | PROT_EXEC);
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2337
		rm_platter_pa = ptob(pfn);
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2338
		hat_devload(kas.a_hat,
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2339
		    (caddr_t)(uintptr_t)rm_platter_pa, MMU_PAGESIZE,
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2340
		    pfn, PROT_READ | PROT_WRITE | PROT_EXEC,
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2341
		    HAT_LOAD_NOCONSIST);
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2342
		break;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2343
	}
7515
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2344
	if (pfn == btop(1*1024*1024) && use_mp)
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2345
		panic("No page below 1M available for starting "
77c791f55203 6738439 Interrupt state incorrectly restored to deactivated cpus on system resume
Seth Goldberg <Seth.Goldberg@Sun.COM>
parents: 7349
diff changeset
  2346
		    "other processors or for resuming from system-suspend");
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2347
#endif	/* !__xpv */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2348
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2349
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2350
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2351
 * Initialize the platform-specific parts of a page_t.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2352
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2353
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2354
add_physmem_cb(page_t *pp, pfn_t pnum)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2355
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2356
	pp->p_pagenum = pnum;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2357
	pp->p_mapping = NULL;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2358
	pp->p_embed = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2359
	pp->p_share = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2360
	pp->p_mlentry = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2361
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2362
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2363
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2364
 * kphysm_init() initializes physical memory.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2365
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2366
static pgcnt_t
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2367
kphysm_init(
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2368
	page_t *pp,
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2369
	pgcnt_t npages)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2370
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2371
	struct memlist	*pmem;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2372
	struct memseg	*cur_memseg;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2373
	pfn_t		base_pfn;
9732
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2374
	pfn_t		end_pfn;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2375
	pgcnt_t		num;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2376
	pgcnt_t		pages_done = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2377
	uint64_t	addr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2378
	uint64_t	size;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2379
	extern pfn_t	ddiphysmin;
9732
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2380
	extern int	mnode_xwa;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2381
	int		ms = 0, me = 0;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2382
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2383
	ASSERT(page_hash != NULL && page_hashsz != 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2384
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2385
	cur_memseg = memseg_base;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2386
	for (pmem = phys_avail; pmem && npages; pmem = pmem->next) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2387
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2388
		 * In a 32 bit kernel can't use higher memory if we're
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2389
		 * not booting in PAE mode. This check takes care of that.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2390
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2391
		addr = pmem->address;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2392
		size = pmem->size;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2393
		if (btop(addr) > physmax)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2394
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2395
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2396
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2397
		 * align addr and size - they may not be at page boundaries
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2398
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2399
		if ((addr & MMU_PAGEOFFSET) != 0) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2400
			addr += MMU_PAGEOFFSET;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2401
			addr &= ~(uint64_t)MMU_PAGEOFFSET;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2402
			size -= addr - pmem->address;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2403
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2404
810
b238ce84deac 6342422 kernel panic with patch 118844-19 on Gateway 600YG
kchow
parents: 783
diff changeset
  2405
		/* only process pages below or equal to physmax */
b238ce84deac 6342422 kernel panic with patch 118844-19 on Gateway 600YG
kchow
parents: 783
diff changeset
  2406
		if ((btop(addr + size) - 1) > physmax)
b238ce84deac 6342422 kernel panic with patch 118844-19 on Gateway 600YG
kchow
parents: 783
diff changeset
  2407
			size = ptob(physmax - btop(addr) + 1);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2408
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2409
		num = btop(size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2410
		if (num == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2411
			continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2412
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2413
		if (num > npages)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2414
			num = npages;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2415
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2416
		npages -= num;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2417
		pages_done += num;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2418
		base_pfn = btop(addr);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2419
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2420
		if (prom_debug)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2421
			prom_printf("MEMSEG addr=0x%" PRIx64
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2422
			    " pgs=0x%lx pfn 0x%lx-0x%lx\n",
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2423
			    addr, num, base_pfn, base_pfn + num);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2424
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2425
		/*
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2426
		 * Ignore pages below ddiphysmin to simplify ddi memory
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2427
		 * allocation with non-zero addr_lo requests.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2428
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2429
		if (base_pfn < ddiphysmin) {
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2430
			if (base_pfn + num <= ddiphysmin)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2431
				continue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2432
			pp += (ddiphysmin - base_pfn);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2433
			num -= (ddiphysmin - base_pfn);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2434
			base_pfn = ddiphysmin;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2435
		}
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2436
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2437
		/*
9732
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2438
		 * mnode_xwa is greater than 1 when large pages regions can
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2439
		 * cross memory node boundaries. To prevent the formation
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2440
		 * of these large pages, configure the memsegs based on the
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2441
		 * memory node ranges which had been made non-contiguous.
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2442
		 */
9732
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2443
		if (mnode_xwa > 1) {
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2444
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2445
			end_pfn = base_pfn + num - 1;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2446
			ms = PFN_2_MEM_NODE(base_pfn);
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2447
			me = PFN_2_MEM_NODE(end_pfn);
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2448
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2449
			if (ms != me) {
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2450
				/*
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2451
				 * current range spans more than 1 memory node.
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2452
				 * Set num to only the pfn range in the start
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2453
				 * memory node.
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2454
				 */
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2455
				num = mem_node_config[ms].physmax - base_pfn
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2456
				    + 1;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2457
				ASSERT(end_pfn > mem_node_config[ms].physmax);
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2458
			}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2459
		}
9732
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2460
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2461
		for (;;) {
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2462
			/*
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2463
			 * Build the memsegs entry
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2464
			 */
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2465
			cur_memseg->pages = pp;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2466
			cur_memseg->epages = pp + num;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2467
			cur_memseg->pages_base = base_pfn;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2468
			cur_memseg->pages_end = base_pfn + num;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2469
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2470
			/*
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2471
			 * Insert into memseg list in decreasing pfn range
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2472
			 * order. Low memory is typically more fragmented such
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2473
			 * that this ordering keeps the larger ranges at the
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2474
			 * front of the list for code that searches memseg.
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2475
			 * This ASSERTS that the memsegs coming in from boot
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2476
			 * are in increasing physical address order and not
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2477
			 * contiguous.
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2478
			 */
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2479
			if (memsegs != NULL) {
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2480
				ASSERT(cur_memseg->pages_base >=
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2481
				    memsegs->pages_end);
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2482
				cur_memseg->next = memsegs;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2483
			}
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2484
			memsegs = cur_memseg;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2485
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2486
			/*
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2487
			 * add_physmem() initializes the PSM part of the page
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2488
			 * struct by calling the PSM back with add_physmem_cb().
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2489
			 * In addition it coalesces pages into larger pages as
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2490
			 * it initializes them.
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2491
			 */
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2492
			add_physmem(pp, num, base_pfn);
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2493
			cur_memseg++;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2494
			availrmem_initial += num;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2495
			availrmem += num;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2496
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2497
			pp += num;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2498
			if (ms >= me)
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2499
				break;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2500
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2501
			/* process next memory node range */
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2502
			ms++;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2503
			base_pfn = mem_node_config[ms].physbase;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2504
			num = MIN(mem_node_config[ms].physmax,
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2505
			    end_pfn) - base_pfn + 1;
256da057a700 6843675 1g page workaround needed on systems that have 1g aligned regions straddling multiple NUMA nodes
Kit Chow <Kit.Chow@Sun.COM>
parents: 9652
diff changeset
  2506
		}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2507
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2508
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2509
	PRM_DEBUG(availrmem_initial);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2510
	PRM_DEBUG(availrmem);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2511
	PRM_DEBUG(freemem);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2512
	build_pfn_hash();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2513
	return (pages_done);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2514
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2515
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2516
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2517
 * Kernel VM initialization.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2518
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2519
static void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2520
kvm_init(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2521
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2522
	ASSERT((((uintptr_t)s_text) & MMU_PAGEOFFSET) == 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2523
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2524
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2525
	 * Put the kernel segments in kernel address space.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2526
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2527
	rw_enter(&kas.a_lock, RW_WRITER);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2528
	as_avlinit(&kas);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2529
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2530
	(void) seg_attach(&kas, s_text, e_moddata - s_text, &ktextseg);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2531
	(void) segkmem_create(&ktextseg);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2532
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2533
	(void) seg_attach(&kas, (caddr_t)valloc_base, valloc_sz, &kvalloc);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2534
	(void) segkmem_create(&kvalloc);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2535
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2536
	(void) seg_attach(&kas, kernelheap,
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2537
	    ekernelheap - kernelheap, &kvseg);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2538
	(void) segkmem_create(&kvseg);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2539
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2540
	if (core_size > 0) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2541
		PRM_POINT("attaching kvseg_core");
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2542
		(void) seg_attach(&kas, (caddr_t)core_base, core_size,
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2543
		    &kvseg_core);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2544
		(void) segkmem_create(&kvseg_core);
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2545
	}
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2546
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2547
	if (segziosize > 0) {
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2548
		PRM_POINT("attaching segzio");
3290
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2549
		(void) seg_attach(&kas, segzio_base, mmu_ptob(segziosize),
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2550
		    &kzioseg);
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2551
		(void) segkmem_zio_create(&kzioseg);
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2552
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2553
		/* create zio area covering new segment */
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2554
		segkmem_zio_init(segzio_base, mmu_ptob(segziosize));
256464cbb73c 4894692 caching data in heap inflates crash dump
johansen
parents: 2991
diff changeset
  2555
	}
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2556
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2557
	(void) seg_attach(&kas, kdi_segdebugbase, kdi_segdebugsize, &kdebugseg);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2558
	(void) segkmem_create(&kdebugseg);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2559
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2560
	rw_exit(&kas.a_lock);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2561
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2562
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2563
	 * Ensure that the red zone at kernelbase is never accessible.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2564
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2565
	PRM_POINT("protecting redzone");
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2566
	(void) as_setprot(&kas, (caddr_t)kernelbase, KERNEL_REDZONE_SIZE, 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2567
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2568
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2569
	 * Make the text writable so that it can be hot patched by DTrace.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2570
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2571
	(void) as_setprot(&kas, s_text, e_modtext - s_text,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2572
	    PROT_READ | PROT_WRITE | PROT_EXEC);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2573
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2574
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2575
	 * Make data writable until end.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2576
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2577
	(void) as_setprot(&kas, s_data, e_moddata - s_data,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2578
	    PROT_READ | PROT_WRITE | PROT_EXEC);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2579
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2580
5084
7d838c5c0eed PSARC 2006/260 Solaris on Xen
johnlev
parents: 4878
diff changeset
  2581
#ifndef __xpv
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2582
/*
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2583
 * Solaris adds an entry for Write Combining caching to the PAT
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2584
 */
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2585
static uint64_t pat_attr_reg = PAT_DEFAULT_ATTRIBUTE;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2586
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2587
void
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2588
pat_sync(void)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2589
{
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2590
	ulong_t	cr0, cr0_orig, cr4;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2591
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2592
	if (!(x86_feature & X86_PAT))
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2593
		return;
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2594
	cr0_orig = cr0 = getcr0();
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2595
	cr4 = getcr4();
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2596
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2597
	/* disable caching and flush all caches and TLBs */
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2598
	cr0 |= CR0_CD;
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2599
	cr0 &= ~CR0_NW;
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2600
	setcr0(cr0);
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2601
	invalidate_cache();
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2602
	if (cr4 & CR4_PGE) {
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2603
		setcr4(cr4 & ~(ulong_t)CR4_PGE);
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2604
		setcr4(cr4);
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2605
	} else {
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2606
		reload_cr3();
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2607
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2608
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2609
	/* add our entry to the PAT */
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2610
	wrmsr(REG_PAT, pat_attr_reg);
770
0eda482eb80f 6311933 rdmsr/wrmsr do not need to set/pass values via memory pointers
kucharsk
parents: 437
diff changeset
  2611
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2612
	/* flush TLBs and cache again, then reenable cr0 caching */
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2613
	if (cr4 & CR4_PGE) {
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2614
		setcr4(cr4 & ~(ulong_t)CR4_PGE);
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2615
		setcr4(cr4);
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2616
	} else {
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2617
		reload_cr3();
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2618
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2619
	invalidate_cache();
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2620
	setcr0(cr0_orig);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2621
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2622
5159
6cdd421a2458 6590353 ancient mtrr crud in i86pc/os/startup.c must die
johnlev
parents: 5129
diff changeset
  2623
#endif /* !__xpv */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2624
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2625
#if defined(_SOFT_HOSTID)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2626
/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2627
 * On platforms that do not have a hardware serial number, attempt
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2628
 * to set one based on the contents of /etc/hostid.  If this file does
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2629
 * not exist, assume that we are to generate a new hostid and set
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2630
 * it in the kernel, for subsequent saving by a userland process
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2631
 * once the system is up and the root filesystem is mounted r/w.
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2632
 *
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2633
 * In order to gracefully support upgrade on OpenSolaris, if
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2634
 * /etc/hostid does not exist, we will attempt to get a serial number
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2635
 * using the legacy method (/kernel/misc/sysinit).
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2636
 *
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2637
 * In an attempt to make the hostid less prone to abuse
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2638
 * (for license circumvention, etc), we store it in /etc/hostid
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2639
 * in rot47 format.
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2640
 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2641
extern volatile unsigned long tenmicrodata;
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2642
static int atoi(char *);
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2643
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2644
static int32_t
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2645
set_soft_hostid(void)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2646
{
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2647
	struct _buf *file;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2648
	char tokbuf[MAXNAMELEN];
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2649
	token_t token;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2650
	int done = 0;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2651
	u_longlong_t tmp;
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2652
	int i;
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  2653
	int32_t hostid = (int32_t)HW_INVALID_HOSTID;
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2654
	unsigned char *c;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2655
	hrtime_t tsc;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2656
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2657
	/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2658
	 * If /etc/hostid file not found, we'd like to get a pseudo
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2659
	 * random number to use at the hostid.  A nice way to do this
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2660
	 * is to read the real time clock.  To remain xen-compatible,
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2661
	 * we can't poke the real hardware, so we use tsc_read() to
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2662
	 * read the real time clock.  However, there is an ominous
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2663
	 * warning in tsc_read that says it can return zero, so we
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2664
	 * deal with that possibility by falling back to using the
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2665
	 * (hopefully random enough) value in tenmicrodata.
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2666
	 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2667
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2668
	if ((file = kobj_open_file(hostid_file)) == (struct _buf *)-1) {
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2669
		/*
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2670
		 * hostid file not found - try to load sysinit module
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2671
		 * and see if it has a nonzero hostid value...use that
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2672
		 * instead of generating a new hostid here if so.
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2673
		 */
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2674
		if ((i = modload("misc", "sysinit")) != -1) {
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2675
			if (strlen(hw_serial) > 0)
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2676
				hostid = (int32_t)atoi(hw_serial);
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2677
			(void) modunload(i);
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2678
		}
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  2679
		if (hostid == HW_INVALID_HOSTID) {
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2680
			tsc = tsc_read();
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2681
			if (tsc == 0)	/* tsc_read can return zero sometimes */
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2682
				hostid = (int32_t)tenmicrodata & 0x0CFFFFF;
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2683
			else
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2684
				hostid = (int32_t)tsc & 0x0CFFFFF;
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2685
		}
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2686
	} else {
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2687
		/* hostid file found */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2688
		while (!done) {
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2689
			token = kobj_lex(file, tokbuf, sizeof (tokbuf));
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2690
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2691
			switch (token) {
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2692
			case POUND:
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2693
				/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2694
				 * skip comments
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2695
				 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2696
				kobj_find_eol(file);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2697
				break;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2698
			case STRING:
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2699
				/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2700
				 * un-rot47 - obviously this
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2701
				 * nonsense is ascii-specific
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2702
				 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2703
				for (c = (unsigned char *)tokbuf;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2704
				    *c != '\0'; c++) {
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2705
					*c += 47;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2706
					if (*c > '~')
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2707
						*c -= 94;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2708
					else if (*c < '!')
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2709
						*c += 94;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2710
				}
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2711
				/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2712
				 * now we should have a real number
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2713
				 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2714
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2715
				if (kobj_getvalue(tokbuf, &tmp) != 0)
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2716
					kobj_file_err(CE_WARN, file,
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2717
					    "Bad value %s for hostid",
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2718
					    tokbuf);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2719
				else
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2720
					hostid = (int32_t)tmp;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2721
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2722
				break;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2723
			case EOF:
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2724
				done = 1;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2725
				/* FALLTHROUGH */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2726
			case NEWLINE:
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2727
				kobj_newline(file);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2728
				break;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2729
			default:
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2730
				break;
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2731
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2732
			}
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2733
		}
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  2734
		if (hostid == HW_INVALID_HOSTID) /* didn't find a hostid */
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2735
			kobj_file_err(CE_WARN, file,
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2736
			    "hostid missing or corrupt");
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2737
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2738
		kobj_close_file(file);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2739
	}
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2740
	/*
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2741
	 * hostid is now the value read from /etc/hostid, or the
8662
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  2742
	 * new hostid we generated in this routine or HW_INVALID_HOSTID if not
18153249ee93 PSARC/2008/647 Configurable Hostids for Non-Global Zones
jv227347 <Jordan.Vaughan@Sun.com>
parents: 8285
diff changeset
  2743
	 * set.
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2744
	 */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2745
	return (hostid);
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2746
}
7942
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2747
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2748
static int
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2749
atoi(char *p)
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2750
{
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2751
	int i = 0;
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2752
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2753
	while (*p != '\0')
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2754
		i = 10 * i + (*p++ - '0');
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2755
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2756
	return (i);
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2757
}
422b01fe8860 6761478 In OpenSolaris, new hostids are being generated even if there is already a hostid on system
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7730
diff changeset
  2758
7720
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2759
#endif /* _SOFT_HOSTID */
8b0e0a8b0931 6559979 Replace sysinit ELF file with simpler mechanism on X86 boxes
Ken Erickson <Ken.Erickson@Sun.COM>
parents: 7692
diff changeset
  2760
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2761
void
1676
37f4a3e2bd99 PSARC/2002/762 Layered Trusted Solaris
jpk
parents: 1582
diff changeset
  2762
get_system_configuration(void)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2763
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2764
	char	prop[32];
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2765
	u_longlong_t nodes_ll, cpus_pernode_ll, lvalue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2766
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2767
	if (BOP_GETPROPLEN(bootops, "nodes") > sizeof (prop) ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2768
	    BOP_GETPROP(bootops, "nodes", prop) < 0 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2769
	    kobj_getvalue(prop, &nodes_ll) == -1 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2770
	    nodes_ll > MAXNODES ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2771
	    BOP_GETPROPLEN(bootops, "cpus_pernode") > sizeof (prop) ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2772
	    BOP_GETPROP(bootops, "cpus_pernode", prop) < 0 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2773
	    kobj_getvalue(prop, &cpus_pernode_ll) == -1) {
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2774
		system_hardware.hd_nodes = 1;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2775
		system_hardware.hd_cpus_per_node = 0;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2776
	} else {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2777
		system_hardware.hd_nodes = (int)nodes_ll;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2778
		system_hardware.hd_cpus_per_node = (int)cpus_pernode_ll;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2779
	}
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2780
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2781
	if (BOP_GETPROPLEN(bootops, "kernelbase") > sizeof (prop) ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2782
	    BOP_GETPROP(bootops, "kernelbase", prop) < 0 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2783
	    kobj_getvalue(prop, &lvalue) == -1)
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2784
		eprom_kernelbase = NULL;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2785
	else
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2786
		eprom_kernelbase = (uintptr_t)lvalue;
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2787
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2788
	if (BOP_GETPROPLEN(bootops, "segmapsize") > sizeof (prop) ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2789
	    BOP_GETPROP(bootops, "segmapsize", prop) < 0 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2790
	    kobj_getvalue(prop, &lvalue) == -1)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2791
		segmapsize = SEGMAPDEFAULT;
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2792
	else
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2793
		segmapsize = (uintptr_t)lvalue;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2794
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2795
	if (BOP_GETPROPLEN(bootops, "segmapfreelists") > sizeof (prop) ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2796
	    BOP_GETPROP(bootops, "segmapfreelists", prop) < 0 ||
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2797
	    kobj_getvalue(prop, &lvalue) == -1)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2798
		segmapfreelists = 0;	/* use segmap driver default */
4828
f987c1d28068 6582841 boot_/final_kerneheap and kernelheap_extend() nonsense needs to be ripped out
josephb
parents: 4748
diff changeset
  2799
	else
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2800
		segmapfreelists = (int)lvalue;
1417
fa316336e215 6377034 setting physmem in /etc/system does not have desired effect on x86
kchow
parents: 1414
diff changeset
  2801
4004
027a924f9ee3 6539804 panic[cpu0]/thread=fffffffffbc27f40: boot_mapin(): No pp for pfnum = 1ff849
josephb
parents: 3717
diff changeset
  2802
	/* physmem used to be here, but moved much earlier to fakebop.c */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2803
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2804
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2805
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2806
 * Add to a memory list.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2807
 * start = start of new memory segment
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2808
 * len = length of new memory segment in bytes
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2809
 * new = pointer to a new struct memlist
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2810
 * memlistp = memory list to which to add segment.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2811
 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2812
void
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2813
memlist_add(
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2814
	uint64_t start,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2815
	uint64_t len,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2816
	struct memlist *new,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2817
	struct memlist **memlistp)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2818
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2819
	struct memlist *cur;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2820
	uint64_t end = start + len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2821
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2822
	new->address = start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2823
	new->size = len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2824
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2825
	cur = *memlistp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2826
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2827
	while (cur) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2828
		if (cur->address >= end) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2829
			new->next = cur;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2830
			*memlistp = new;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2831
			new->prev = cur->prev;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2832
			cur->prev = new;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2833
			return;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2834
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2835
		ASSERT(cur->address + cur->size <= start);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2836
		if (cur->next == NULL) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2837
			cur->next = new;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2838
			new->prev = cur;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2839
			new->next = NULL;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2840
			return;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2841
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2842
		memlistp = &cur->next;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2843
		cur = cur->next;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2844
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2845
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2846
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2847
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2848
kobj_vmem_init(vmem_t **text_arena, vmem_t **data_arena)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2849
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2850
	size_t tsize = e_modtext - modtext;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2851
	size_t dsize = e_moddata - moddata;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2852
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2853
	*text_arena = vmem_create("module_text", tsize ? modtext : NULL, tsize,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2854
	    1, segkmem_alloc, segkmem_free, heaptext_arena, 0, VM_SLEEP);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2855
	*data_arena = vmem_create("module_data", dsize ? moddata : NULL, dsize,
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2856
	    1, segkmem_alloc, segkmem_free, heap32_arena, 0, VM_SLEEP);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2857
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2858
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2859
caddr_t
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2860
kobj_text_alloc(vmem_t *arena, size_t size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2861
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2862
	return (vmem_alloc(arena, size, VM_SLEEP | VM_BESTFIT));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2863
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2864
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2865
/*ARGSUSED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2866
caddr_t
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2867
kobj_texthole_alloc(caddr_t addr, size_t size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2868
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2869
	panic("unexpected call to kobj_texthole_alloc()");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2870
	/*NOTREACHED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2871
	return (0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2872
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2873
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2874
/*ARGSUSED*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2875
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2876
kobj_texthole_free(caddr_t addr, size_t size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2877
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2878
	panic("unexpected call to kobj_texthole_free()");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2879
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2880
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2881
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2882
 * This is called just after configure() in startup().
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2883
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2884
 * The ISALIST concept is a bit hopeless on Intel, because
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2885
 * there's no guarantee of an ever-more-capable processor
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2886
 * given that various parts of the instruction set may appear
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2887
 * and disappear between different implementations.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2888
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2889
 * While it would be possible to correct it and even enhance
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2890
 * it somewhat, the explicit hardware capability bitmask allows
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2891
 * more flexibility.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2892
 *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2893
 * So, we just leave this alone.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2894
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2895
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2896
setx86isalist(void)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2897
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2898
	char *tp;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2899
	size_t len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2900
	extern char *isa_list;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2901
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2902
#define	TBUFSIZE	1024
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2903
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2904
	tp = kmem_alloc(TBUFSIZE, KM_SLEEP);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2905
	*tp = '\0';
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2906
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2907
#if defined(__amd64)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2908
	(void) strcpy(tp, "amd64 ");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2909
#endif
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2910
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2911
	switch (x86_vendor) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2912
	case X86_VENDOR_Intel:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2913
	case X86_VENDOR_AMD:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2914
	case X86_VENDOR_TM:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2915
		if (x86_feature & X86_CMOV) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2916
			/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2917
			 * Pentium Pro or later
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2918
			 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2919
			(void) strcat(tp, "pentium_pro");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2920
			(void) strcat(tp, x86_feature & X86_MMX ?
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2921
			    "+mmx pentium_pro " : " ");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2922
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2923
		/*FALLTHROUGH*/
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2924
	case X86_VENDOR_Cyrix:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2925
		/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2926
		 * The Cyrix 6x86 does not have any Pentium features
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2927
		 * accessible while not at privilege level 0.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2928
		 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2929
		if (x86_feature & X86_CPUID) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2930
			(void) strcat(tp, "pentium");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2931
			(void) strcat(tp, x86_feature & X86_MMX ?
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2932
			    "+mmx pentium " : " ");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2933
		}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2934
		break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2935
	default:
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2936
		break;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2937
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2938
	(void) strcat(tp, "i486 i386 i86");
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2939
	len = strlen(tp) + 1;   /* account for NULL at end of string */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2940
	isa_list = strcpy(kmem_alloc(len, KM_SLEEP), tp);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2941
	kmem_free(tp, TBUFSIZE);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2942
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2943
#undef TBUFSIZE
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2944
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2945
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2946
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2947
#ifdef __amd64
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2948
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2949
void *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2950
device_arena_alloc(size_t size, int vm_flag)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2951
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2952
	return (vmem_alloc(device_arena, size, vm_flag));
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2953
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2954
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2955
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2956
device_arena_free(void *vaddr, size_t size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2957
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2958
	vmem_free(device_arena, vaddr, size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2959
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2960
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2961
#else /* __i386 */
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2962
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2963
void *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2964
device_arena_alloc(size_t size, int vm_flag)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2965
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2966
	caddr_t	vaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2967
	uintptr_t v;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2968
	size_t	start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2969
	size_t	end;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2970
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2971
	vaddr = vmem_alloc(heap_arena, size, vm_flag);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2972
	if (vaddr == NULL)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2973
		return (NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2974
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2975
	v = (uintptr_t)vaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2976
	ASSERT(v >= kernelbase);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2977
	ASSERT(v + size <= valloc_base);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2978
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2979
	start = btop(v - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2980
	end = btop(v + size - 1 - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2981
	ASSERT(start < toxic_bit_map_len);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2982
	ASSERT(end < toxic_bit_map_len);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2983
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2984
	while (start <= end) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2985
		BT_ATOMIC_SET(toxic_bit_map, start);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2986
		++start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2987
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2988
	return (vaddr);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2989
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2990
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2991
void
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2992
device_arena_free(void *vaddr, size_t size)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2993
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2994
	uintptr_t v = (uintptr_t)vaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2995
	size_t	start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2996
	size_t	end;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2997
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  2998
	ASSERT(v >= kernelbase);
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  2999
	ASSERT(v + size <= valloc_base);
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3000
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3001
	start = btop(v - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3002
	end = btop(v + size - 1 - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3003
	ASSERT(start < toxic_bit_map_len);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3004
	ASSERT(end < toxic_bit_map_len);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3005
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3006
	while (start <= end) {
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3007
		ASSERT(BT_TEST(toxic_bit_map, start) != 0);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3008
		BT_ATOMIC_CLEAR(toxic_bit_map, start);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3009
		++start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3010
	}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3011
	vmem_free(heap_arena, vaddr, size);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3012
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3013
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3014
/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3015
 * returns 1st address in range that is in device arena, or NULL
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3016
 * if len is not NULL it returns the length of the toxic range
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3017
 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3018
void *
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3019
device_arena_contains(void *vaddr, size_t size, size_t *len)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3020
{
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3021
	uintptr_t v = (uintptr_t)vaddr;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3022
	uintptr_t eaddr = v + size;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3023
	size_t start;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3024
	size_t end;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3025
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3026
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3027
	 * if called very early by kmdb, just return NULL
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3028
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3029
	if (toxic_bit_map == NULL)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3030
		return (NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3031
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3032
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3033
	 * First check if we're completely outside the bitmap range.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3034
	 */
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  3035
	if (v >= valloc_base || eaddr < kernelbase)
0
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3036
		return (NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3037
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3038
	/*
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3039
	 * Trim ends of search to look at only what the bitmap covers.
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3040
	 */
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3041
	if (v < kernelbase)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3042
		v = kernelbase;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3043
	start = btop(v - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3044
	end = btop(eaddr - kernelbase);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3045
	if (end >= toxic_bit_map_len)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3046
		end = toxic_bit_map_len;
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3047
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3048
	if (bt_range(toxic_bit_map, &start, &end, end) == 0)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3049
		return (NULL);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3050
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3051
	v = kernelbase + ptob(start);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3052
	if (len != NULL)
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3053
		*len = ptob(end - start);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3054
	return ((void *)v);
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3055
}
68f95e015346 OpenSolaris Launch
stevel@tonic-gate
parents:
diff changeset
  3056
3446
5903aece022d PSARC 2006/469 EOF and removal of eeprom -I
mrj
parents: 3434
diff changeset
  3057
#endif	/* __i386 */