mp_pc.c revision 95c0a3c85cc8a224af0bc2bc1f7400be641f43fc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Welcome to the world of the "real mode platter".
*/
#include <sys/archsystm.h>
#include <sys/machsystm.h>
#include <sys/controlregs.h>
#include <sys/x86_archext.h>
#include <sys/smp_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/mach_mmu.h>
extern void real_mode_start(void);
extern void real_mode_end(void);
/*
* Fill up the real mode platter to make it easy for real mode code to
* kick it off. This area should really be one passed by boot to kernel
* and guaranteed to be below 1MB and aligned to 16 bytes. Should also
* have identical physical and virtual address in paged mode.
*/
int
mach_cpucontext_init(void)
{
return (-1);
/*
* setup secondary cpu bios boot up vector
*/
return (0);
}
void
mach_cpucontext_fini(void)
{
if (warm_reset_vector)
sizeof (warm_reset_vector));
}
#if defined(__amd64)
extern void *long_mode_64(void);
#endif /* __amd64 */
void *
{
struct cpu_tables *ct;
/*
* Allocate space for page directory, stack, tss, gdt and idt.
* The page directory has to be page aligned
*/
#if defined(__amd64)
/*
* #DF (double fault).
*/
#endif /* __i386 */
/*
* Set I/O bit map offset equal to size of TSS segment limit
* for no I/O permission map. This will cause all user I/O
* instructions to generate #gp fault.
*/
/*
* Setup kernel tss.
*/
/*
* Now copy all that we've set up onto the real mode platter
* for the real mode code to digest as part of starting the cpu.
*/
#if defined(__amd64)
if (getcr3() > 0xffffffffUL)
panic("Cannot initialize CPUs; kernel's 64-bit page tables\n"
"located above 4G in physical memory (@ 0x%lx)", getcr3());
/*
* Setup pseudo-descriptors for temporary GDT and IDT for use ONLY
* by code in real_mode_start():
*
* GDT[0]: NULL selector
* GDT[1]: 64-bit CS: Long = 1, Present = 1, bits 12, 11 = 1
*
* Clear the IDT as interrupts will be off and a limit of 0 will cause
* the CPU to triple fault and reset on an NMI, seemingly as reasonable
* a course of action as any other, though it may cause the entire
* platform to reset in some cases...
*/
rm->rm_temp_gdt[0] = 0;
rm->rm_temp_idt_lim = 0;
rm->rm_temp_idt_base = 0;
/*
* Since the CPU needs to jump to protected mode using an identity
* mapped address, we need to calculate it here.
*/
#endif /* __amd64 */
return (ct);
}
/*ARGSUSED*/
void
{
switch (err) {
case 0:
break;
case ETIMEDOUT:
/*
* The processor was poked, but failed to start before
* we gave up waiting for it. In case it starts later,
* don't free anything.
*/
break;
default:
/*
* Some other, passive, error occurred.
*/
break;
}
}
/*
* "Enter monitor." Called via cross-call from stop_other_cpus().
*/
void
mach_cpu_halt(char *msg)
{
if (msg)
/*CONSTANTCONDITION*/
while (1)
;
}
void
mach_cpu_idle(void)
{
i86_halt();
tlb_service();
}
void
mach_cpu_pause(volatile char *safe)
{
/*
* This cpu is now safe.
*/
*safe = PAUSE_WAIT;
membar_enter(); /* make sure stores are flushed */
/*
* Now we wait. When we are allowed to continue, safe
* will be set to PAUSE_IDLE.
*/
while (*safe != PAUSE_IDLE)
SMT_PAUSE();
}
/*
* Power on CPU.
*/
/*ARGSUSED*/
int
{
return (ENOTSUP); /* not supported */
}
/*
* Power off CPU.
*/
/*ARGSUSED*/
int
{
return (ENOTSUP); /* not supported */
}