Make cpu_reset, most of initarm and the kvm init code common.
Add MP hooks for cpu_need_resced Add idlestck which is allocated in arm32_kvminit
This commit is contained in:
parent
27c8dedaa5
commit
1f4278e180
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: arm_machdep.c,v 1.35 2012/08/29 23:10:31 matt Exp $ */
|
/* $NetBSD: arm_machdep.c,v 1.36 2012/08/31 23:59:51 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.35 2012/08/29 23:10:31 matt Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.36 2012/08/31 23:59:51 matt Exp $");
|
||||||
|
|
||||||
#include <sys/exec.h>
|
#include <sys/exec.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
|
@ -87,6 +87,8 @@ __KERNEL_RCSID(0, "$NetBSD: arm_machdep.c,v 1.35 2012/08/29 23:10:31 matt Exp $"
|
||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
#include <sys/evcnt.h>
|
#include <sys/evcnt.h>
|
||||||
#include <sys/cpu.h>
|
#include <sys/cpu.h>
|
||||||
|
#include <sys/atomic.h>
|
||||||
|
#include <sys/kcpuset.h>
|
||||||
|
|
||||||
#ifdef EXEC_AOUT
|
#ifdef EXEC_AOUT
|
||||||
#include <sys/exec_aout.h>
|
#include <sys/exec_aout.h>
|
||||||
|
@ -211,20 +213,73 @@ startlwp(void *arg)
|
||||||
void
|
void
|
||||||
cpu_need_resched(struct cpu_info *ci, int flags)
|
cpu_need_resched(struct cpu_info *ci, int flags)
|
||||||
{
|
{
|
||||||
bool immed = (flags & RESCHED_IMMED) != 0;
|
struct lwp * const l = ci->ci_data.cpu_onproc;
|
||||||
|
const bool immed = (flags & RESCHED_IMMED) != 0;
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
struct cpu_info * const cur_ci = curcpu();
|
||||||
|
u_long ipi = IPI_NOP;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (__predict_false((l->l_pflag & LP_INTR) != 0)) {
|
||||||
|
/*
|
||||||
|
* No point doing anything, it will switch soon.
|
||||||
|
* Also here to prevent an assertion failure in
|
||||||
|
* kpreempt() due to preemption being set on a
|
||||||
|
* soft interrupt LWP.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ci->ci_want_resched && !immed)
|
if (ci->ci_want_resched && !immed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (l == ci->ci_data.cpu_idlelwp) {
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
/*
|
||||||
|
* If the other CPU is idling, it must be waiting for an
|
||||||
|
* event. So give it one.
|
||||||
|
*/
|
||||||
|
if (ci != cur_ci)
|
||||||
|
goto send_ipi;
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
atomic_swap_uint(&ci->ci_want_resched, 1);
|
||||||
|
#else
|
||||||
ci->ci_want_resched = 1;
|
ci->ci_want_resched = 1;
|
||||||
if (curlwp != ci->ci_data.cpu_idlelwp)
|
#endif
|
||||||
setsoftast();
|
if (flags & RESCHED_KPREEMPT) {
|
||||||
|
#ifdef __HAVE_PREEMPTION
|
||||||
|
atomic_or_uint(&l->l_dopreempt, DOPREEMPT_ACITBE);
|
||||||
|
if (ci == cur_ci) {
|
||||||
|
softint_trigger(SOFTINT_KPREEMPT);
|
||||||
|
} else {
|
||||||
|
ipi = IPI_KPREEMPT;
|
||||||
|
goto send_ipi;
|
||||||
|
}
|
||||||
|
#endif /* __HAVE_PREEMPTION */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ci->ci_astpending = 1;
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
if (ci == curcpu() || !immed)
|
||||||
|
return;
|
||||||
|
ipi = IPI_AST;
|
||||||
|
|
||||||
|
send_ipi:
|
||||||
|
intr_ipi_send(ci->ci_kcpuset, ipi);
|
||||||
|
#endif /* MULTIPROCESSOR */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
cpu_intr_p(void)
|
cpu_intr_p(void)
|
||||||
{
|
{
|
||||||
return curcpu()->ci_intr_depth != 0;
|
struct cpu_info * const ci = curcpu();
|
||||||
|
#ifdef __HAVE_PIC_FAST_SOFTINTS
|
||||||
|
if (ci->ci_cpl < IPL_VM)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
return ci->ci_intr_depth != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -0,0 +1,354 @@
|
||||||
|
/* $NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
|
||||||
|
* Written by Hiroyuki Bessho for Genetec Corporation.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of Genetec Corporation may not be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed for the NetBSD Project by
|
||||||
|
* Wasabi Systems, Inc.
|
||||||
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997,1998 Mark Brinicombe.
|
||||||
|
* Copyright (c) 1997,1998 Causality Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Mark Brinicombe
|
||||||
|
* for the NetBSD Project.
|
||||||
|
* 4. The name of the company nor the name of the author may be used to
|
||||||
|
* endorse or promote products derived from this software without specific
|
||||||
|
* prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 Microsoft
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Microsoft
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__KERNEL_RCSID(1, "$NetBSD: arm32_boot.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/cpu.h>
|
||||||
|
#include <sys/intr.h>
|
||||||
|
|
||||||
|
#include <uvm/uvm_extern.h>
|
||||||
|
|
||||||
|
#include <arm/undefined.h>
|
||||||
|
#include <arm/arm32/machdep.h>
|
||||||
|
|
||||||
|
#include <machine/db_machdep.h>
|
||||||
|
#include <ddb/db_extern.h>
|
||||||
|
|
||||||
|
#include <machine/bootconfig.h>
|
||||||
|
|
||||||
|
vaddr_t
|
||||||
|
initarm_common(vaddr_t kvm_base, vsize_t kvm_size,
|
||||||
|
const struct boot_physmem *bp, size_t nbp)
|
||||||
|
{
|
||||||
|
struct bootmem_info * const bmi = &bootmem_info;
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("nfreeblocks = %u, free_pages = %d (%#x)\n",
|
||||||
|
bmi->bmi_nfreeblocks, bmi->bmi_freepages,
|
||||||
|
bmi->bmi_freepages);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Moved from cpu_startup() as data_abort_handler() references
|
||||||
|
* this during uvm init.
|
||||||
|
*/
|
||||||
|
uvm_lwp_setuarea(&lwp0, kernelstack.pv_va);
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("bootstrap done.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
arm32_vector_init(systempage.pv_va, ARM_VEC_ALL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pages were allocated during the secondary bootstrap for the
|
||||||
|
* stacks for different CPU modes.
|
||||||
|
* We must now set the r13 registers in the different CPU modes to
|
||||||
|
* point to these stacks.
|
||||||
|
* Since the ARM stacks use STMFD etc. we must set r13 to the top end
|
||||||
|
* of the stack memory.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("init subsystems: stacks ");
|
||||||
|
#endif
|
||||||
|
set_stackptr(PSR_FIQ32_MODE,
|
||||||
|
fiqstack.pv_va + FIQ_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_IRQ32_MODE,
|
||||||
|
irqstack.pv_va + IRQ_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_ABT32_MODE,
|
||||||
|
abtstack.pv_va + ABT_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_UND32_MODE,
|
||||||
|
undstack.pv_va + UND_STACK_SIZE * PAGE_SIZE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Well we should set a data abort handler.
|
||||||
|
* Once things get going this will change as we will need a proper
|
||||||
|
* handler.
|
||||||
|
* Until then we will use a handler that just panics but tells us
|
||||||
|
* why.
|
||||||
|
* Initialisation of the vectors will just panic on a data abort.
|
||||||
|
* This just fills in a slightly better one.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("vectors ");
|
||||||
|
#endif
|
||||||
|
data_abort_handler_address = (u_int)data_abort_handler;
|
||||||
|
prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
|
||||||
|
undefined_handler_address = (u_int)undefinedinstruction_bounce;
|
||||||
|
|
||||||
|
/* Initialise the undefined instruction handlers */
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("undefined ");
|
||||||
|
#endif
|
||||||
|
undefined_init();
|
||||||
|
|
||||||
|
/* Load memory into UVM. */
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("page ");
|
||||||
|
#endif
|
||||||
|
uvm_setpagesize(); /* initialize PAGE_SIZE-dependent variables */
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("pmap_physload ");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (bp == NULL) {
|
||||||
|
KASSERT(nbp == 0);
|
||||||
|
for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
|
||||||
|
pv_addr_t * const pv = &bmi->bmi_freeblocks[i];
|
||||||
|
const paddr_t start = atop(pv->pv_pa);
|
||||||
|
const paddr_t end = start + atop(pv->pv_size);
|
||||||
|
|
||||||
|
uvm_page_physload(start, end, start, end,
|
||||||
|
VM_FREELIST_DEFAULT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; nbp-- > 0; bp++) {
|
||||||
|
const paddr_t start = bp->bp_start;
|
||||||
|
const paddr_t end = start + bp->bp_pages;
|
||||||
|
|
||||||
|
if (start < end) {
|
||||||
|
KASSERT(bp->bp_freelist < VM_NFREELIST);
|
||||||
|
uvm_page_physload(start, end, start, end,
|
||||||
|
bp->bp_freelist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Boot strap pmap telling it where the kernel page table is */
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("pmap ");
|
||||||
|
#endif
|
||||||
|
pmap_bootstrap(kvm_base, kvm_base + kvm_size);
|
||||||
|
|
||||||
|
#ifdef __HAVE_MEMORY_DISK__
|
||||||
|
md_root_setconf(memory_disk, sizeof memory_disk);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOTHOWTO
|
||||||
|
boothowto |= BOOTHOWTO;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef KGDB
|
||||||
|
if (boothowto & RB_KDB) {
|
||||||
|
kgdb_debug_init = 1;
|
||||||
|
kgdb_connect(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DDB
|
||||||
|
db_machine_init();
|
||||||
|
ddb_init(0, NULL, NULL);
|
||||||
|
|
||||||
|
if (boothowto & RB_KDB)
|
||||||
|
Debugger();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("done.\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* We return the new stack pointer address */
|
||||||
|
return kernelstack.pv_va + USPACE_SVC_STACK_TOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
/*
|
||||||
|
* When we are called, the MMU and caches are on and we are running on the stack
|
||||||
|
* of the idlelwp for this cpu.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
cpu_hatch(struct cpu_info *ci, cpuid_t cpuid, void (*md_cpu_init)(struct cpu_info *))
|
||||||
|
{
|
||||||
|
KASSERT(cpu_index(ci) == cpuid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Raise our IPL to the max
|
||||||
|
*/
|
||||||
|
splhigh();
|
||||||
|
|
||||||
|
printf("%s(%s): ", __func__, ci->ci_data.cpu_name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure we have the right vector page.
|
||||||
|
*/
|
||||||
|
printf(" vectors");
|
||||||
|
arm32_vector_init(systempage.pv_va, ARM_VEC_ALL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the stack for each mode (we are already running on the SVC32
|
||||||
|
* stack of the idlelwp).
|
||||||
|
*/
|
||||||
|
printf(" stacks");
|
||||||
|
set_stackptr(PSR_FIQ32_MODE,
|
||||||
|
fiqstack.pv_va + cpu_index(ci) * FIQ_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_IRQ32_MODE,
|
||||||
|
irqstack.pv_va + cpu_index(ci) * IRQ_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_ABT32_MODE,
|
||||||
|
abtstack.pv_va + cpu_index(ci) * ABT_STACK_SIZE * PAGE_SIZE);
|
||||||
|
set_stackptr(PSR_UND32_MODE,
|
||||||
|
undstack.pv_va + cpu_index(ci) * UND_STACK_SIZE * PAGE_SIZE);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* Now that we are going to apart of the kernel,
|
||||||
|
* take out the kernel lock.
|
||||||
|
*/
|
||||||
|
printf(" kernel_lock");
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
|
#endif
|
||||||
|
#ifdef CPU_CORTEX
|
||||||
|
if (CPU_ID_CORTEX_P(ci->ci_arm_cpuid)) {
|
||||||
|
/*
|
||||||
|
* Start and reset the PMC Cycle Counter.
|
||||||
|
*/
|
||||||
|
armreg_pmcr_write(ARM11_PMCCTL_E|ARM11_PMCCTL_P|ARM11_PMCCTL_C);
|
||||||
|
armreg_pmcntenset_write(CORTEX_CNTENS_C);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf(" interrupts");
|
||||||
|
/*
|
||||||
|
* Let the interrupts do what they need to on this CPU.
|
||||||
|
*/
|
||||||
|
intr_cpu_init(ci);
|
||||||
|
|
||||||
|
printf(" md(%p)", md_cpu_init);
|
||||||
|
if (md_cpu_init != NULL)
|
||||||
|
(*md_cpu_init)(ci);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* Tell the MI code we are alive!
|
||||||
|
*/
|
||||||
|
printf(" mi_cpu");
|
||||||
|
mi_cpu_running(ci);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf(" done!\n");
|
||||||
|
}
|
||||||
|
#endif /* MULTIPROCESSOR */
|
|
@ -0,0 +1,866 @@
|
||||||
|
/* $NetBSD: arm32_kvminit.c,v 1.1 2012/08/31 23:59:51 matt Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
|
||||||
|
* Written by Hiroyuki Bessho for Genetec Corporation.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of Genetec Corporation may not be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed for the NetBSD Project by
|
||||||
|
* Wasabi Systems, Inc.
|
||||||
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997,1998 Mark Brinicombe.
|
||||||
|
* Copyright (c) 1997,1998 Causality Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Mark Brinicombe
|
||||||
|
* for the NetBSD Project.
|
||||||
|
* 4. The name of the company nor the name of the author may be used to
|
||||||
|
* endorse or promote products derived from this software without specific
|
||||||
|
* prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 Microsoft
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Microsoft
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/device.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/bus.h>
|
||||||
|
|
||||||
|
#include <dev/cons.h>
|
||||||
|
|
||||||
|
#include <uvm/uvm_extern.h>
|
||||||
|
|
||||||
|
#include <arm/db_machdep.h>
|
||||||
|
#include <arm/undefined.h>
|
||||||
|
#include <arm/bootconfig.h>
|
||||||
|
#include <arm/arm32/machdep.h>
|
||||||
|
|
||||||
|
#include "ksyms.h"
|
||||||
|
|
||||||
|
struct bootmem_info bootmem_info;
|
||||||
|
|
||||||
|
paddr_t msgbufphys;
|
||||||
|
paddr_t physical_start;
|
||||||
|
paddr_t physical_end;
|
||||||
|
|
||||||
|
extern char etext[];
|
||||||
|
extern char __data_start[], _edata[];
|
||||||
|
extern char __bss_start[], __bss_end__[];
|
||||||
|
extern char _end[];
|
||||||
|
|
||||||
|
/* Page tables for mapping kernel VM */
|
||||||
|
#define KERNEL_L2PT_VMDATA_NUM 8 /* start with 32MB of KVM */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros to translate between physical and virtual for a subset of the
|
||||||
|
* kernel address space. *Not* for general use.
|
||||||
|
*/
|
||||||
|
#define KERN_VTOPHYS(bmi, va) \
|
||||||
|
((paddr_t)((vaddr_t)(va) - KERNEL_BASE + (bmi)->bmi_start))
|
||||||
|
#define KERN_PHYSTOV(bmi, pa) \
|
||||||
|
((vaddr_t)((paddr_t)(pa) - (bmi)->bmi_start + KERNEL_BASE))
|
||||||
|
|
||||||
|
void
|
||||||
|
arm32_bootmem_init(paddr_t memstart, psize_t memsize, vsize_t kernelstart)
|
||||||
|
{
|
||||||
|
struct bootmem_info * const bmi = &bootmem_info;
|
||||||
|
pv_addr_t *pv = bmi->bmi_freeblocks;
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: memstart=%#lx, memsize=%#lx, kernelstart=%#lx\n",
|
||||||
|
__func__, memstart, memsize, kernelstart);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
physical_start = bmi->bmi_start = memstart;
|
||||||
|
physical_end = bmi->bmi_end = memstart + memsize;
|
||||||
|
physmem = memsize / PAGE_SIZE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Let's record where the kernel lives.
|
||||||
|
*/
|
||||||
|
bmi->bmi_kernelstart = kernelstart;
|
||||||
|
bmi->bmi_kernelend = KERN_VTOPHYS(bmi, round_page((vaddr_t)_end));
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: kernelend=%#lx\n", __func__, bmi->bmi_kernelend);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now the rest of the free memory must be after the kernel.
|
||||||
|
*/
|
||||||
|
pv->pv_pa = bmi->bmi_kernelend;
|
||||||
|
pv->pv_va = KERN_PHYSTOV(bmi, pv->pv_pa);
|
||||||
|
pv->pv_size = bmi->bmi_end - bmi->bmi_kernelend;
|
||||||
|
bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
|
||||||
|
__func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
|
||||||
|
pv->pv_pa + pv->pv_size - 1, pv->pv_va);
|
||||||
|
#endif
|
||||||
|
pv++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a free block for any memory before the kernel.
|
||||||
|
*/
|
||||||
|
if (bmi->bmi_start < bmi->bmi_kernelstart) {
|
||||||
|
pv->pv_pa = bmi->bmi_start;
|
||||||
|
pv->pv_va = KERNEL_BASE;
|
||||||
|
pv->pv_size = bmi->bmi_kernelstart - bmi->bmi_start;
|
||||||
|
bmi->bmi_freepages += pv->pv_size / PAGE_SIZE;
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding %lu free pages: [%#lx..%#lx] (VA %#lx)\n",
|
||||||
|
__func__, pv->pv_size / PAGE_SIZE, pv->pv_pa,
|
||||||
|
pv->pv_pa + pv->pv_size - 1, pv->pv_va);
|
||||||
|
#endif
|
||||||
|
pv++;
|
||||||
|
}
|
||||||
|
|
||||||
|
bmi->bmi_nfreeblocks = pv - bmi->bmi_freeblocks;
|
||||||
|
|
||||||
|
SLIST_INIT(&bmi->bmi_freechunks);
|
||||||
|
SLIST_INIT(&bmi->bmi_chunks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
concat_pvaddr(pv_addr_t *acc_pv, pv_addr_t *pv)
|
||||||
|
{
|
||||||
|
if (acc_pv->pv_pa + acc_pv->pv_size == pv->pv_pa
|
||||||
|
&& acc_pv->pv_va + acc_pv->pv_size == pv->pv_va
|
||||||
|
&& acc_pv->pv_prot == pv->pv_prot
|
||||||
|
&& acc_pv->pv_cache == pv->pv_cache) {
|
||||||
|
#ifdef VERBOSE_INIT_ARMX
|
||||||
|
printf("%s: appending pv %p (%#lx..%#lx) to %#lx..%#lx\n",
|
||||||
|
__func__, pv, pv->pv_pa, pv->pv_pa + pv->pv_size + 1,
|
||||||
|
acc_pv->pv_pa, acc_pv->pv_pa + acc_pv->pv_size + 1);
|
||||||
|
#endif
|
||||||
|
acc_pv->pv_size += pv->pv_size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_pages(struct bootmem_info *bmi, pv_addr_t *pv)
|
||||||
|
{
|
||||||
|
pv_addr_t **pvp = &SLIST_FIRST(&bmi->bmi_chunks);
|
||||||
|
while ((*pvp) != 0 && (*pvp)->pv_va <= pv->pv_va) {
|
||||||
|
pv_addr_t * const pv0 = (*pvp);
|
||||||
|
KASSERT(SLIST_NEXT(pv0, pv_list) == NULL || pv0->pv_pa < SLIST_NEXT(pv0, pv_list)->pv_pa);
|
||||||
|
if (concat_pvaddr(pv0, pv)) {
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
|
||||||
|
__func__, "appending", pv,
|
||||||
|
pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
|
||||||
|
pv0->pv_pa, pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
|
||||||
|
#endif
|
||||||
|
pv = SLIST_NEXT(pv0, pv_list);
|
||||||
|
if (pv != NULL && concat_pvaddr(pv0, pv)) {
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: %s pv %p (%#lx..%#lx) to %#lx..%#lx\n",
|
||||||
|
__func__, "merging", pv,
|
||||||
|
pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
|
||||||
|
pv0->pv_pa,
|
||||||
|
pv0->pv_pa + pv0->pv_size - pv->pv_size - 1);
|
||||||
|
#endif
|
||||||
|
SLIST_REMOVE_AFTER(pv0, pv_list);
|
||||||
|
SLIST_INSERT_HEAD(&bmi->bmi_freechunks, pv, pv_list);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
KASSERT(pv->pv_va != (*pvp)->pv_va);
|
||||||
|
pvp = &SLIST_NEXT(*pvp, pv_list);
|
||||||
|
}
|
||||||
|
KASSERT((*pvp) == NULL || pv->pv_va < (*pvp)->pv_va);
|
||||||
|
pv_addr_t * const new_pv = SLIST_FIRST(&bmi->bmi_freechunks);
|
||||||
|
KASSERT(new_pv != NULL);
|
||||||
|
SLIST_REMOVE_HEAD(&bmi->bmi_freechunks, pv_list);
|
||||||
|
*new_pv = *pv;
|
||||||
|
SLIST_NEXT(new_pv, pv_list) = *pvp;
|
||||||
|
(*pvp) = new_pv;
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding pv %p (pa %#lx, va %#lx, %lu pages) ",
|
||||||
|
__func__, new_pv, new_pv->pv_pa, new_pv->pv_va,
|
||||||
|
new_pv->pv_size / PAGE_SIZE);
|
||||||
|
if (SLIST_NEXT(new_pv, pv_list))
|
||||||
|
printf("before pa %#lx\n", SLIST_NEXT(new_pv, pv_list)->pv_pa);
|
||||||
|
else
|
||||||
|
printf("at tail\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
valloc_pages(struct bootmem_info *bmi, pv_addr_t *pv, size_t npages,
|
||||||
|
int prot, int cache)
|
||||||
|
{
|
||||||
|
size_t nbytes = npages * PAGE_SIZE;
|
||||||
|
pv_addr_t *free_pv = bmi->bmi_freeblocks;
|
||||||
|
size_t free_idx = 0;
|
||||||
|
static bool l1pt_found;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we haven't allcoated the kernel L1 page table and we are aligned
|
||||||
|
* at a L1 table boundary, alloc the memory for it.
|
||||||
|
*/
|
||||||
|
if (!l1pt_found
|
||||||
|
&& (free_pv->pv_pa & (L1_TABLE_SIZE - 1)) == 0
|
||||||
|
&& free_pv->pv_size >= L1_TABLE_SIZE) {
|
||||||
|
l1pt_found = true;
|
||||||
|
valloc_pages(bmi, &kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
|
||||||
|
add_pages(bmi, &kernel_l1pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (nbytes > free_pv->pv_size) {
|
||||||
|
free_pv++;
|
||||||
|
free_idx++;
|
||||||
|
if (free_idx == bmi->bmi_nfreeblocks) {
|
||||||
|
panic("%s: could not allocate %zu bytes",
|
||||||
|
__func__, nbytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pv->pv_pa = free_pv->pv_pa;
|
||||||
|
pv->pv_va = free_pv->pv_va;
|
||||||
|
pv->pv_size = nbytes;
|
||||||
|
pv->pv_prot = prot;
|
||||||
|
pv->pv_cache = cache;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If PTE_PAGETABLE uses the same cache modes as PTE_CACHE
|
||||||
|
* just use PTE_CACHE.
|
||||||
|
*/
|
||||||
|
if (cache == PTE_PAGETABLE
|
||||||
|
&& pte_l1_s_cache_mode == pte_l1_s_cache_mode_pt
|
||||||
|
&& pte_l2_l_cache_mode == pte_l2_l_cache_mode_pt
|
||||||
|
&& pte_l2_s_cache_mode == pte_l2_s_cache_mode_pt)
|
||||||
|
pv->pv_cache = PTE_CACHE;
|
||||||
|
|
||||||
|
free_pv->pv_pa += nbytes;
|
||||||
|
free_pv->pv_va += nbytes;
|
||||||
|
free_pv->pv_size -= nbytes;
|
||||||
|
if (free_pv->pv_size == 0) {
|
||||||
|
--bmi->bmi_nfreeblocks;
|
||||||
|
for (; free_idx < bmi->bmi_nfreeblocks; free_idx++) {
|
||||||
|
free_pv[0] = free_pv[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bmi->bmi_freepages -= npages;
|
||||||
|
|
||||||
|
memset((void *)pv->pv_va, 0, nbytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
arm32_kernel_vm_init(vaddr_t kernel_vm_base, vaddr_t vectors, vaddr_t iovbase,
|
||||||
|
const struct pmap_devmap *devmap, bool mapallmem_p)
|
||||||
|
{
|
||||||
|
struct bootmem_info * const bmi = &bootmem_info;
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
const size_t cpu_num = arm_cpu_max + 1;
|
||||||
|
#else
|
||||||
|
const size_t cpu_num = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate the number of L2 pages needed for mapping the
|
||||||
|
* kernel + data + stuff
|
||||||
|
*/
|
||||||
|
size_t kernel_size = bmi->bmi_kernelend;
|
||||||
|
kernel_size -= (bmi->bmi_kernelstart & -L2_S_SEGSIZE);
|
||||||
|
kernel_size += L1_TABLE_SIZE;
|
||||||
|
kernel_size += round_page(MSGBUFSIZE);
|
||||||
|
kernel_size +=
|
||||||
|
cpu_num * (ABT_STACK_SIZE + FIQ_STACK_SIZE + IRQ_STACK_SIZE
|
||||||
|
+ UND_STACK_SIZE + UPAGES) * PAGE_SIZE;
|
||||||
|
kernel_size += 0x10000; /* slop */
|
||||||
|
kernel_size += (kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE;
|
||||||
|
kernel_size = round_page(kernel_size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now we know how many L2 pages it will take.
|
||||||
|
*/
|
||||||
|
const size_t KERNEL_L2PT_KERNEL_NUM =
|
||||||
|
(kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE;
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: %zu L2 pages are needed to map %#zx kernel bytes\n",
|
||||||
|
__func__, KERNEL_L2PT_KERNEL_NUM, kernel_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
KASSERT(KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM < __arraycount(bmi->bmi_l2pts));
|
||||||
|
pv_addr_t * const kernel_l2pt = bmi->bmi_l2pts;
|
||||||
|
pv_addr_t * const vmdata_l2pt = kernel_l2pt + KERNEL_L2PT_KERNEL_NUM;
|
||||||
|
pv_addr_t msgbuf;
|
||||||
|
pv_addr_t text;
|
||||||
|
pv_addr_t data;
|
||||||
|
pv_addr_t chunks[KERNEL_L2PT_KERNEL_NUM+KERNEL_L2PT_VMDATA_NUM+11];
|
||||||
|
#if ARM_MMU_XSCALE == 1
|
||||||
|
pv_addr_t minidataclean;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to allocate some fixed page tables to get the kernel going.
|
||||||
|
*
|
||||||
|
* We are going to allocate our bootstrap pages from the beginning of
|
||||||
|
* the free space that we just calculated. We allocate one page
|
||||||
|
* directory and a number of page tables and store the physical
|
||||||
|
* addresses in the kernel_l2pt_table array.
|
||||||
|
*
|
||||||
|
* The kernel page directory must be on a 16K boundary. The page
|
||||||
|
* tables must be on 4K boundaries. What we do is allocate the
|
||||||
|
* page directory on the first 16K boundary that we encounter, and
|
||||||
|
* the page tables on 4K boundaries otherwise. Since we allocate
|
||||||
|
* at least 3 L2 page tables, we are guaranteed to encounter at
|
||||||
|
* least one 16K aligned region.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: allocating page tables for", __func__);
|
||||||
|
#endif
|
||||||
|
for (size_t i = 0; i < __arraycount(chunks); i++) {
|
||||||
|
SLIST_INSERT_HEAD(&bmi->bmi_freechunks, &chunks[i], pv_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* As we allocate the memory, make sure that we don't walk over
|
||||||
|
* our temporary first level translation table.
|
||||||
|
*/
|
||||||
|
|
||||||
|
kernel_l1pt.pv_pa = 0;
|
||||||
|
kernel_l1pt.pv_va = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First allocate L2 page for the vectors.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf(" vector");
|
||||||
|
#endif
|
||||||
|
valloc_pages(bmi, &bmi->bmi_vector_l2pt, L2_TABLE_SIZE / PAGE_SIZE,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
|
||||||
|
add_pages(bmi, &bmi->bmi_vector_l2pt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate the L2 pages, but if we get to a page that aligned for a
|
||||||
|
* L1 page table, we will allocate pages for it first and allocate
|
||||||
|
* L2 page.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf(" kernel");
|
||||||
|
#endif
|
||||||
|
for (size_t idx = 0; idx <= KERNEL_L2PT_KERNEL_NUM; ++idx) {
|
||||||
|
valloc_pages(bmi, &kernel_l2pt[idx], L2_TABLE_SIZE / PAGE_SIZE,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
|
||||||
|
add_pages(bmi, &kernel_l2pt[idx]);
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf(" vm");
|
||||||
|
#endif
|
||||||
|
for (size_t idx = 0; idx <= KERNEL_L2PT_VMDATA_NUM; ++idx) {
|
||||||
|
valloc_pages(bmi, &vmdata_l2pt[idx], L2_TABLE_SIZE / PAGE_SIZE,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
|
||||||
|
add_pages(bmi, &vmdata_l2pt[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If someone wanted a L2 page for I/O, allocate it now.
|
||||||
|
*/
|
||||||
|
if (iovbase != 0) {
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf(" io");
|
||||||
|
#endif
|
||||||
|
valloc_pages(bmi, &bmi->bmi_io_l2pt, L2_TABLE_SIZE / PAGE_SIZE,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
|
||||||
|
add_pages(bmi, &bmi->bmi_io_l2pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VERBOSE_ARM_INIT
|
||||||
|
printf("%s: allocating stacks\n", __func__);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Allocate stacks for all modes */
|
||||||
|
valloc_pages(bmi, &abtstack, ABT_STACK_SIZE * cpu_num,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &abtstack);
|
||||||
|
valloc_pages(bmi, &fiqstack, FIQ_STACK_SIZE * cpu_num,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &fiqstack);
|
||||||
|
valloc_pages(bmi, &irqstack, IRQ_STACK_SIZE * cpu_num,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &irqstack);
|
||||||
|
valloc_pages(bmi, &undstack, UND_STACK_SIZE * cpu_num,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &undstack);
|
||||||
|
valloc_pages(bmi, &idlestack, UPAGES * cpu_num, /* SVC32 */
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &idlestack);
|
||||||
|
valloc_pages(bmi, &kernelstack, UPAGES, /* SVC32 */
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &kernelstack);
|
||||||
|
|
||||||
|
/* Allocate the message buffer from the end of memory. */
|
||||||
|
const size_t msgbuf_pgs = round_page(MSGBUFSIZE) / PAGE_SIZE;
|
||||||
|
valloc_pages(bmi, &msgbuf, msgbuf_pgs,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
add_pages(bmi, &msgbuf);
|
||||||
|
msgbufphys = msgbuf.pv_pa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocate a page for the system vector page.
|
||||||
|
* This page will just contain the system vectors and can be
|
||||||
|
* shared by all processes.
|
||||||
|
*/
|
||||||
|
valloc_pages(bmi, &systempage, 1, VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
systempage.pv_va = vectors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the caller needed a few extra pages for some reason, allocate
|
||||||
|
* them now.
|
||||||
|
*/
|
||||||
|
#if ARM_MMU_XSCALE == 1
|
||||||
|
#if (ARM_NMMUS > 1)
|
||||||
|
if (xscale_use_minidata)
|
||||||
|
#endif
|
||||||
|
valloc_pages(bmi, extrapv, nextrapages,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ok we have allocated physical pages for the primary kernel
|
||||||
|
* page tables and stacks. Let's just confirm that.
|
||||||
|
*/
|
||||||
|
if (kernel_l1pt.pv_va == 0
|
||||||
|
&& (!kernel_l1pt.pv_pa || (kernel_l1pt.pv_pa & (L1_TABLE_SIZE - 1)) != 0))
|
||||||
|
panic("%s: Failed to allocate or align the kernel "
|
||||||
|
"page directory", __func__);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("Creating L1 page table at 0x%08lx\n", kernel_l1pt.pv_pa);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now we start construction of the L1 page table
|
||||||
|
* We start by mapping the L2 page tables into the L1.
|
||||||
|
* This means that we can replace L1 mappings later on if necessary
|
||||||
|
*/
|
||||||
|
vaddr_t l1pt_va = kernel_l1pt.pv_va;
|
||||||
|
paddr_t l1pt_pa = kernel_l1pt.pv_pa;
|
||||||
|
|
||||||
|
/* Map the L2 pages tables in the L1 page table */
|
||||||
|
pmap_link_l2pt(l1pt_va, systempage.pv_va & -L2_S_SEGSIZE,
|
||||||
|
&bmi->bmi_vector_l2pt);
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx\n",
|
||||||
|
__func__, bmi->bmi_vector_l2pt.pv_va, bmi->bmi_vector_l2pt.pv_pa,
|
||||||
|
systempage.pv_va);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const vaddr_t kernel_base =
|
||||||
|
KERN_PHYSTOV(bmi, bmi->bmi_kernelstart & -L2_S_SEGSIZE);
|
||||||
|
for (size_t idx = 0; idx < KERNEL_L2PT_KERNEL_NUM; idx++) {
|
||||||
|
pmap_link_l2pt(l1pt_va, kernel_base + idx * L2_S_SEGSIZE,
|
||||||
|
&kernel_l2pt[idx]);
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx\n",
|
||||||
|
__func__, kernel_l2pt[idx].pv_va, kernel_l2pt[idx].pv_pa,
|
||||||
|
kernel_base + idx * L2_S_SEGSIZE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t idx = 0; idx < KERNEL_L2PT_VMDATA_NUM; idx++) {
|
||||||
|
pmap_link_l2pt(l1pt_va, kernel_vm_base + idx * L2_S_SEGSIZE,
|
||||||
|
&vmdata_l2pt[idx]);
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx\n",
|
||||||
|
__func__, vmdata_l2pt[idx].pv_va, vmdata_l2pt[idx].pv_pa,
|
||||||
|
kernel_vm_base + idx * L2_S_SEGSIZE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (iovbase) {
|
||||||
|
pmap_link_l2pt(l1pt_va, iovbase & -L2_S_SEGSIZE, &bmi->bmi_io_l2pt);
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding L2 pt (VA %#lx, PA %#lx) for VA %#lx\n",
|
||||||
|
__func__, bmi->bmi_io_l2pt.pv_va, bmi->bmi_io_l2pt.pv_pa,
|
||||||
|
iovbase & -L2_S_SEGSIZE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update the top of the kernel VM */
|
||||||
|
pmap_curmaxkvaddr =
|
||||||
|
kernel_vm_base + (KERNEL_L2PT_VMDATA_NUM * L2_S_SEGSIZE);
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("Mapping kernel\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern char etext[], _end[];
|
||||||
|
size_t totalsize = bmi->bmi_kernelend - bmi->bmi_kernelstart;
|
||||||
|
size_t textsize = KERN_VTOPHYS(bmi, (uintptr_t)etext) - bmi->bmi_kernelstart;
|
||||||
|
|
||||||
|
textsize = (textsize + PGOFSET) & ~PGOFSET;
|
||||||
|
|
||||||
|
/* start at offset of kernel in RAM */
|
||||||
|
|
||||||
|
text.pv_pa = bmi->bmi_kernelstart;
|
||||||
|
text.pv_va = KERN_PHYSTOV(bmi, bmi->bmi_kernelstart);
|
||||||
|
text.pv_size = textsize;
|
||||||
|
text.pv_prot = VM_PROT_READ|VM_PROT_WRITE; /* XXX VM_PROT_EXECUTE */
|
||||||
|
text.pv_cache = PTE_CACHE;
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding chunk for kernel text %#lx..%#lx (VA %#lx)\n",
|
||||||
|
__func__, text.pv_pa, text.pv_pa + text.pv_size - 1, text.pv_va);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
add_pages(bmi, &text);
|
||||||
|
|
||||||
|
data.pv_pa = text.pv_pa + textsize;
|
||||||
|
data.pv_va = text.pv_va + textsize;
|
||||||
|
data.pv_size = totalsize - textsize;
|
||||||
|
data.pv_prot = VM_PROT_READ|VM_PROT_WRITE;
|
||||||
|
data.pv_cache = PTE_CACHE;
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: adding chunk for kernel data/bss %#lx..%#lx (VA %#lx)\n",
|
||||||
|
__func__, data.pv_pa, data.pv_pa + data.pv_size - 1, data.pv_va);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
add_pages(bmi, &data);
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("Listing Chunks\n");
|
||||||
|
{
|
||||||
|
pv_addr_t *pv;
|
||||||
|
SLIST_FOREACH(pv, &bmi->bmi_chunks, pv_list) {
|
||||||
|
printf("%s: pv %p: chunk VA %#lx..%#lx "
|
||||||
|
"(PA %#lx, prot %d, cache %d)\n",
|
||||||
|
__func__, pv, pv->pv_va, pv->pv_va + pv->pv_size - 1,
|
||||||
|
pv->pv_pa, pv->pv_prot, pv->pv_cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\nMapping Chunks\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
pv_addr_t cur_pv;
|
||||||
|
pv_addr_t *pv = SLIST_FIRST(&bmi->bmi_chunks);
|
||||||
|
if (!mapallmem_p || pv->pv_pa == bmi->bmi_start) {
|
||||||
|
cur_pv = *pv;
|
||||||
|
pv = SLIST_NEXT(pv, pv_list);
|
||||||
|
} else {
|
||||||
|
cur_pv.pv_va = kernel_base;
|
||||||
|
cur_pv.pv_pa = bmi->bmi_start;
|
||||||
|
cur_pv.pv_size = pv->pv_pa - bmi->bmi_start;
|
||||||
|
cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
|
||||||
|
cur_pv.pv_cache = PTE_CACHE;
|
||||||
|
}
|
||||||
|
while (pv != NULL) {
|
||||||
|
if (mapallmem_p) {
|
||||||
|
if (concat_pvaddr(&cur_pv, pv)) {
|
||||||
|
pv = SLIST_NEXT(pv, pv_list);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (cur_pv.pv_pa + cur_pv.pv_size < pv->pv_pa) {
|
||||||
|
/*
|
||||||
|
* See if we can extend the current pv to emcompass the
|
||||||
|
* hole, and if so do it and retry the concatenation.
|
||||||
|
*/
|
||||||
|
if (cur_pv.pv_prot == (VM_PROT_READ|VM_PROT_WRITE)
|
||||||
|
&& cur_pv.pv_cache == PTE_CACHE) {
|
||||||
|
cur_pv.pv_size = pv->pv_pa - cur_pv.pv_va;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We couldn't so emit the current chunk and then
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: mapping chunk VA %#lx..%#lx "
|
||||||
|
"(PA %#lx, prot %d, cache %d)\n",
|
||||||
|
__func__,
|
||||||
|
cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
|
||||||
|
cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
#endif
|
||||||
|
pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
|
||||||
|
cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set the current chunk to the hole and try again.
|
||||||
|
*/
|
||||||
|
cur_pv.pv_pa += cur_pv.pv_size;
|
||||||
|
cur_pv.pv_va += cur_pv.pv_size;
|
||||||
|
cur_pv.pv_size = pv->pv_pa - cur_pv.pv_va;
|
||||||
|
cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
|
||||||
|
cur_pv.pv_cache = PTE_CACHE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The new pv didn't concatenate so emit the current one
|
||||||
|
* and use the new pv as the current pv.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: mapping chunk VA %#lx..%#lx "
|
||||||
|
"(PA %#lx, prot %d, cache %d)\n",
|
||||||
|
__func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
|
||||||
|
cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
#endif
|
||||||
|
pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
|
||||||
|
cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
cur_pv = *pv;
|
||||||
|
pv = SLIST_NEXT(pv, pv_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are mapping all of memory, let's map the rest of memory.
|
||||||
|
*/
|
||||||
|
if (mapallmem_p && cur_pv.pv_pa + cur_pv.pv_size < bmi->bmi_end) {
|
||||||
|
if (cur_pv.pv_prot == (VM_PROT_READ | VM_PROT_WRITE)
|
||||||
|
&& cur_pv.pv_cache == PTE_CACHE) {
|
||||||
|
cur_pv.pv_size = bmi->bmi_end - cur_pv.pv_pa;
|
||||||
|
} else {
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: mapping chunk VA %#lx..%#lx "
|
||||||
|
"(PA %#lx, prot %d, cache %d)\n",
|
||||||
|
__func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
|
||||||
|
cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
#endif
|
||||||
|
pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
|
||||||
|
cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
cur_pv.pv_pa += cur_pv.pv_size;
|
||||||
|
cur_pv.pv_va += cur_pv.pv_size;
|
||||||
|
cur_pv.pv_size = bmi->bmi_end - cur_pv.pv_pa;
|
||||||
|
cur_pv.pv_prot = VM_PROT_READ | VM_PROT_WRITE;
|
||||||
|
cur_pv.pv_cache = PTE_CACHE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now we map the final chunk.
|
||||||
|
*/
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("%s: mapping last chunk VA %#lx..%#lx (PA %#lx, prot %d, cache %d)\n",
|
||||||
|
__func__, cur_pv.pv_va, cur_pv.pv_va + cur_pv.pv_size - 1,
|
||||||
|
cur_pv.pv_pa, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
#endif
|
||||||
|
pmap_map_chunk(l1pt_va, cur_pv.pv_va, cur_pv.pv_pa,
|
||||||
|
cur_pv.pv_size, cur_pv.pv_prot, cur_pv.pv_cache);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now we map the stuff that isn't directly after the kernel
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Map the vector page. */
|
||||||
|
pmap_map_entry(l1pt_va, systempage.pv_va, systempage.pv_pa,
|
||||||
|
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
|
||||||
|
|
||||||
|
/* Map the Mini-Data cache clean area. */
|
||||||
|
#if ARM_MMU_XSCALE == 1
|
||||||
|
#if (ARM_NMMUS > 1)
|
||||||
|
if (xscale_use_minidata)
|
||||||
|
#endif
|
||||||
|
xscale_setup_minidata(l1_va, minidataclean.pv_va,
|
||||||
|
minidataclean.pv_pa);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Map integrated peripherals at same address in first level page
|
||||||
|
* table so that we can continue to use console.
|
||||||
|
*/
|
||||||
|
if (devmap)
|
||||||
|
pmap_devmap_bootstrap(l1pt_va, devmap);
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
/* Tell the user about where all the bits and pieces live. */
|
||||||
|
printf("%22s Physical Virtual Num\n", " ");
|
||||||
|
printf("%22s Starting Ending Starting Ending Pages\n", " ");
|
||||||
|
|
||||||
|
static const char mem_fmt[] =
|
||||||
|
"%20s: 0x%08lx 0x%08lx 0x%08lx 0x%08lx %u\n";
|
||||||
|
static const char mem_fmt_nov[] =
|
||||||
|
"%20s: 0x%08lx 0x%08lx %zu\n";
|
||||||
|
|
||||||
|
printf(mem_fmt, "SDRAM", bmi->bmi_start, bmi->bmi_end - 1,
|
||||||
|
KERN_PHYSTOV(bmi, bmi->bmi_start), KERN_PHYSTOV(bmi, bmi->bmi_end - 1),
|
||||||
|
physmem);
|
||||||
|
printf(mem_fmt, "text section",
|
||||||
|
text.pv_pa, text.pv_pa + text.pv_size - 1,
|
||||||
|
text.pv_va, text.pv_va + text.pv_size - 1,
|
||||||
|
(int)(text.pv_size / PAGE_SIZE));
|
||||||
|
printf(mem_fmt, "data section",
|
||||||
|
KERN_VTOPHYS(bmi, __data_start), KERN_VTOPHYS(bmi, _edata),
|
||||||
|
(vaddr_t)__data_start, (vaddr_t)_edata,
|
||||||
|
(int)((round_page((vaddr_t)_edata)
|
||||||
|
- trunc_page((vaddr_t)__data_start)) / PAGE_SIZE));
|
||||||
|
printf(mem_fmt, "bss section",
|
||||||
|
KERN_VTOPHYS(bmi, __bss_start), KERN_VTOPHYS(bmi, __bss_end__),
|
||||||
|
(vaddr_t)__bss_start, (vaddr_t)__bss_end__,
|
||||||
|
(int)((round_page((vaddr_t)__bss_end__)
|
||||||
|
- trunc_page((vaddr_t)__bss_start)) / PAGE_SIZE));
|
||||||
|
printf(mem_fmt, "L1 page directory",
|
||||||
|
kernel_l1pt.pv_pa, kernel_l1pt.pv_pa + L1_TABLE_SIZE - 1,
|
||||||
|
kernel_l1pt.pv_va, kernel_l1pt.pv_va + L1_TABLE_SIZE - 1,
|
||||||
|
L1_TABLE_SIZE / PAGE_SIZE);
|
||||||
|
printf(mem_fmt, "Exception Vectors",
|
||||||
|
systempage.pv_pa, systempage.pv_pa + PAGE_SIZE - 1,
|
||||||
|
systempage.pv_va, systempage.pv_va + PAGE_SIZE - 1,
|
||||||
|
1);
|
||||||
|
printf(mem_fmt, "FIQ stack (CPU 0)",
|
||||||
|
fiqstack.pv_pa, fiqstack.pv_pa + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
fiqstack.pv_va, fiqstack.pv_va + (FIQ_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
FIQ_STACK_SIZE);
|
||||||
|
printf(mem_fmt, "IRQ stack (CPU 0)",
|
||||||
|
irqstack.pv_pa, irqstack.pv_pa + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
irqstack.pv_va, irqstack.pv_va + (IRQ_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
IRQ_STACK_SIZE);
|
||||||
|
printf(mem_fmt, "ABT stack (CPU 0)",
|
||||||
|
abtstack.pv_pa, abtstack.pv_pa + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
abtstack.pv_va, abtstack.pv_va + (ABT_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
ABT_STACK_SIZE);
|
||||||
|
printf(mem_fmt, "UND stack (CPU 0)",
|
||||||
|
undstack.pv_pa, undstack.pv_pa + (UND_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
undstack.pv_va, undstack.pv_va + (UND_STACK_SIZE * PAGE_SIZE) - 1,
|
||||||
|
UND_STACK_SIZE);
|
||||||
|
printf(mem_fmt, "IDLE stack (CPU 0)",
|
||||||
|
idlestack.pv_pa, idlestack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
|
||||||
|
idlestack.pv_va, idlestack.pv_va + (UPAGES * PAGE_SIZE) - 1,
|
||||||
|
UPAGES);
|
||||||
|
printf(mem_fmt, "SVC stack",
|
||||||
|
kernelstack.pv_pa, kernelstack.pv_pa + (UPAGES * PAGE_SIZE) - 1,
|
||||||
|
kernelstack.pv_va, kernelstack.pv_va + (UPAGES * PAGE_SIZE) - 1,
|
||||||
|
UPAGES);
|
||||||
|
printf(mem_fmt_nov, "Message Buffer",
|
||||||
|
msgbufphys, msgbufphys + msgbuf_pgs * PAGE_SIZE - 1, msgbuf_pgs);
|
||||||
|
for (size_t i = 0; i < bmi->bmi_nfreeblocks; i++) {
|
||||||
|
pv = &bmi->bmi_freeblocks[i];
|
||||||
|
|
||||||
|
printf(mem_fmt_nov, "Free Memory",
|
||||||
|
pv->pv_pa, pv->pv_pa + pv->pv_size - 1,
|
||||||
|
pv->pv_size / PAGE_SIZE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Now we have the real page tables in place so we can switch to them.
|
||||||
|
* Once this is done we will be running with the REAL kernel page
|
||||||
|
* tables.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Switch tables */
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("switching to new L1 page table @%#lx...", l1pt_pa);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
|
||||||
|
cpu_setttb(l1pt_pa);
|
||||||
|
cpu_tlb_flushID();
|
||||||
|
cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
|
||||||
|
|
||||||
|
#ifdef VERBOSE_INIT_ARM
|
||||||
|
printf("OK.\n");
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: arm32_machdep.c,v 1.82 2012/08/16 18:22:39 matt Exp $ */
|
/* $NetBSD: arm32_machdep.c,v 1.83 2012/08/31 23:59:51 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994-1998 Mark Brinicombe.
|
* Copyright (c) 1994-1998 Mark Brinicombe.
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.82 2012/08/16 18:22:39 matt Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.83 2012/08/31 23:59:51 matt Exp $");
|
||||||
|
|
||||||
#include "opt_modular.h"
|
#include "opt_modular.h"
|
||||||
#include "opt_md.h"
|
#include "opt_md.h"
|
||||||
|
@ -61,7 +61,10 @@ __KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.82 2012/08/16 18:22:39 matt Exp
|
||||||
#include <sys/device.h>
|
#include <sys/device.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/cpu.h>
|
#include <sys/cpu.h>
|
||||||
|
#include <sys/intr.h>
|
||||||
#include <sys/module.h>
|
#include <sys/module.h>
|
||||||
|
#include <sys/atomic.h>
|
||||||
|
#include <sys/xcall.h>
|
||||||
|
|
||||||
#include <uvm/uvm_extern.h>
|
#include <uvm/uvm_extern.h>
|
||||||
|
|
||||||
|
@ -88,6 +91,7 @@ pv_addr_t abtstack;
|
||||||
pv_addr_t fiqstack;
|
pv_addr_t fiqstack;
|
||||||
pv_addr_t irqstack;
|
pv_addr_t irqstack;
|
||||||
pv_addr_t undstack;
|
pv_addr_t undstack;
|
||||||
|
pv_addr_t idlestack;
|
||||||
|
|
||||||
void * msgbufaddr;
|
void * msgbufaddr;
|
||||||
extern paddr_t msgbufphys;
|
extern paddr_t msgbufphys;
|
||||||
|
@ -97,7 +101,6 @@ int kernel_debug = 0;
|
||||||
/* exported variable to be filled in by the bootloaders */
|
/* exported variable to be filled in by the bootloaders */
|
||||||
char *booted_kernel;
|
char *booted_kernel;
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
|
||||||
void data_abort_handler(trapframe_t *frame);
|
void data_abort_handler(trapframe_t *frame);
|
||||||
|
@ -116,29 +119,31 @@ extern void configure(void);
|
||||||
void
|
void
|
||||||
arm32_vector_init(vaddr_t va, int which)
|
arm32_vector_init(vaddr_t va, int which)
|
||||||
{
|
{
|
||||||
extern unsigned int page0[], page0_data[];
|
if (CPU_IS_PRIMARY(curcpu())) {
|
||||||
unsigned int *vectors = (int *) va;
|
extern unsigned int page0[], page0_data[];
|
||||||
unsigned int *vectors_data = vectors + (page0_data - page0);
|
unsigned int *vectors = (int *) va;
|
||||||
int vec;
|
unsigned int *vectors_data = vectors + (page0_data - page0);
|
||||||
|
int vec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop through the vectors we're taking over, and copy the
|
* Loop through the vectors we're taking over, and copy the
|
||||||
* vector's insn and data word.
|
* vector's insn and data word.
|
||||||
*/
|
*/
|
||||||
for (vec = 0; vec < ARM_NVEC; vec++) {
|
for (vec = 0; vec < ARM_NVEC; vec++) {
|
||||||
if ((which & (1 << vec)) == 0) {
|
if ((which & (1 << vec)) == 0) {
|
||||||
/* Don't want to take over this vector. */
|
/* Don't want to take over this vector. */
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
vectors[vec] = page0[vec];
|
||||||
|
vectors_data[vec] = page0_data[vec];
|
||||||
}
|
}
|
||||||
vectors[vec] = page0[vec];
|
|
||||||
vectors_data[vec] = page0_data[vec];
|
/* Now sync the vectors. */
|
||||||
|
cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
|
||||||
|
|
||||||
|
vector_page = va;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now sync the vectors. */
|
|
||||||
cpu_icache_sync_range(va, (ARM_NVEC * 2) * sizeof(u_int));
|
|
||||||
|
|
||||||
vector_page = va;
|
|
||||||
|
|
||||||
if (va == ARM_VECTORS_HIGH) {
|
if (va == ARM_VECTORS_HIGH) {
|
||||||
/*
|
/*
|
||||||
* Assume the MD caller knows what it's doing here, and
|
* Assume the MD caller knows what it's doing here, and
|
||||||
|
@ -212,6 +217,11 @@ cpu_startup(void)
|
||||||
u_int loop;
|
u_int loop;
|
||||||
char pbuf[9];
|
char pbuf[9];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Until we better locking, we have to live under the kernel lock.
|
||||||
|
*/
|
||||||
|
//KERNEL_LOCK(1, NULL);
|
||||||
|
|
||||||
/* Set the CPU control register */
|
/* Set the CPU control register */
|
||||||
cpu_setup(boot_args);
|
cpu_setup(boot_args);
|
||||||
|
|
||||||
|
@ -413,6 +423,7 @@ parse_mi_bootargs(char *args)
|
||||||
#error IPLs are screwed up
|
#error IPLs are screwed up
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_PIC_FAST_SOFTINTS
|
||||||
#define SOFTINT2IPLMAP \
|
#define SOFTINT2IPLMAP \
|
||||||
(((IPL_SOFTSERIAL - IPL_SOFTCLOCK) << (SOFTINT_SERIAL * 4)) | \
|
(((IPL_SOFTSERIAL - IPL_SOFTCLOCK) << (SOFTINT_SERIAL * 4)) | \
|
||||||
((IPL_SOFTNET - IPL_SOFTCLOCK) << (SOFTINT_NET * 4)) | \
|
((IPL_SOFTNET - IPL_SOFTCLOCK) << (SOFTINT_NET * 4)) | \
|
||||||
|
@ -441,7 +452,7 @@ softint_trigger(uintptr_t mask)
|
||||||
void
|
void
|
||||||
softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
|
softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
|
||||||
{
|
{
|
||||||
lwp_t ** lp = &curcpu()->ci_softlwps[level];
|
lwp_t ** lp = &l->l_cpu->ci_softlwps[level];
|
||||||
KASSERT(*lp == NULL || *lp == l);
|
KASSERT(*lp == NULL || *lp == l);
|
||||||
*lp = l;
|
*lp = l;
|
||||||
*machdep = 1 << SOFTINT2IPL(level);
|
*machdep = 1 << SOFTINT2IPL(level);
|
||||||
|
@ -482,6 +493,7 @@ dosoftints(void)
|
||||||
panic("dosoftints wtf (softints=%u?, ipl=%d)", softints, opl);
|
panic("dosoftints wtf (softints=%u?, ipl=%d)", softints, opl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* !__HAVE_PIC_FAST_SOFTINTS */
|
||||||
#endif /* __HAVE_FAST_SOFTINTS */
|
#endif /* __HAVE_FAST_SOFTINTS */
|
||||||
|
|
||||||
#ifdef MODULAR
|
#ifdef MODULAR
|
||||||
|
@ -500,3 +512,52 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot)
|
||||||
|
|
||||||
return (pa < ctob(physmem)) ? 0 : EFAULT;
|
return (pa < ctob(physmem)) ? 0 : EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __HAVE_CPU_UAREA_ALLOC_IDLELWP
|
||||||
|
vaddr_t
|
||||||
|
cpu_uarea_alloc_idlelwp(struct cpu_info *ci)
|
||||||
|
{
|
||||||
|
const vaddr_t va = idlestack.pv_va + ci->ci_cpuid * USPACE;
|
||||||
|
// printf("%s: %s: va=%lx\n", __func__, ci->ci_data.cpu_name, va);
|
||||||
|
return va;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MULTIPROCESSOR
|
||||||
|
void
|
||||||
|
cpu_boot_secondary_processors(void)
|
||||||
|
{
|
||||||
|
uint32_t mbox;
|
||||||
|
kcpuset_copybits(kcpuset_attached, &mbox, sizeof(mbox));
|
||||||
|
atomic_swap_32(&arm_cpu_mbox, mbox);
|
||||||
|
membar_producer();
|
||||||
|
#ifdef _ARM_ARCH_7
|
||||||
|
__asm __volatile("sev; sev; sev");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xc_send_ipi(struct cpu_info *ci)
|
||||||
|
{
|
||||||
|
KASSERT(kpreempt_disabled());
|
||||||
|
KASSERT(curcpu() != ci);
|
||||||
|
|
||||||
|
|
||||||
|
if (ci) {
|
||||||
|
/* Unicast, remote CPU */
|
||||||
|
printf("%s: -> %s", __func__, ci->ci_data.cpu_name);
|
||||||
|
intr_ipi_send(ci->ci_kcpuset, IPI_XCALL);
|
||||||
|
} else {
|
||||||
|
printf("%s: -> !%s", __func__, ci->ci_data.cpu_name);
|
||||||
|
/* Broadcast to all but ourselves */
|
||||||
|
kcpuset_t *kcp;
|
||||||
|
kcpuset_create(&kcp, (ci != NULL));
|
||||||
|
KASSERT(kcp != NULL);
|
||||||
|
kcpuset_copy(kcp, kcpuset_running);
|
||||||
|
kcpuset_clear(kcp, cpu_index(ci));
|
||||||
|
intr_ipi_send(kcp, IPI_XCALL);
|
||||||
|
kcpuset_destroy(kcp);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
#endif /* MULTIPROCESSOR */
|
||||||
|
|
|
@ -0,0 +1,191 @@
|
||||||
|
/* $NetBSD: arm32_reboot.c,v 1.1 2012/08/31 23:59:51 matt Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
|
||||||
|
* Written by Hiroyuki Bessho for Genetec Corporation.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of Genetec Corporation may not be used to endorse or
|
||||||
|
* promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed for the NetBSD Project by
|
||||||
|
* Wasabi Systems, Inc.
|
||||||
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior
|
||||||
|
* written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997,1998 Mark Brinicombe.
|
||||||
|
* Copyright (c) 1997,1998 Causality Limited.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Mark Brinicombe
|
||||||
|
* for the NetBSD Project.
|
||||||
|
* 4. The name of the company nor the name of the author may be used to
|
||||||
|
* endorse or promote products derived from this software without specific
|
||||||
|
* prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2007 Microsoft
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Microsoft
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
|
||||||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__KERNEL_RCSID(0, "$NetBSD: arm32_reboot.c,v 1.1 2012/08/31 23:59:51 matt Exp $");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/device.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/reboot.h>
|
||||||
|
|
||||||
|
#include <dev/cons.h>
|
||||||
|
|
||||||
|
#include <uvm/uvm_extern.h>
|
||||||
|
|
||||||
|
#include <arm/arm32/machdep.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
cpu_reboot(int howto, char *bootstr)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we are still cold then hit the air brakes
|
||||||
|
* and crash to earth fast
|
||||||
|
*/
|
||||||
|
if (cold) {
|
||||||
|
doshutdownhooks();
|
||||||
|
printf("The operating system has halted.\r\n");
|
||||||
|
printf("Please press any key to reboot.\r\n");
|
||||||
|
cngetc();
|
||||||
|
printf("rebooting...\r\n");
|
||||||
|
if (cpu_reset_address)
|
||||||
|
(*cpu_reset_address)();
|
||||||
|
cpu_reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If RB_NOSYNC was not specified sync the discs.
|
||||||
|
* Note: Unless cold is set to 1 here, syslogd will die during the
|
||||||
|
* unmount. It looks like syslogd is getting woken up only to find
|
||||||
|
* that it cannot page part of the binary in as the filesystem has
|
||||||
|
* been unmounted.
|
||||||
|
*/
|
||||||
|
if (!(howto & RB_NOSYNC))
|
||||||
|
bootsync();
|
||||||
|
|
||||||
|
/* Say NO to interrupts */
|
||||||
|
splhigh();
|
||||||
|
|
||||||
|
/* Do a dump if requested. */
|
||||||
|
if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
|
||||||
|
dumpsys();
|
||||||
|
|
||||||
|
/* Run any shutdown hooks */
|
||||||
|
doshutdownhooks();
|
||||||
|
|
||||||
|
/* Make sure IRQ's are disabled */
|
||||||
|
IRQdisable;
|
||||||
|
|
||||||
|
if (howto & RB_HALT) {
|
||||||
|
printf("The operating system has halted.\r\n");
|
||||||
|
printf("Please press any key to reboot.\r\n");
|
||||||
|
cngetc();
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("rebooting...\r\n");
|
||||||
|
if (cpu_reset_address)
|
||||||
|
(*cpu_reset_address)();
|
||||||
|
cpu_reset();
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: genassym.cf,v 1.51 2012/08/29 23:10:31 matt Exp $
|
# $NetBSD: genassym.cf,v 1.52 2012/08/31 23:59:51 matt Exp $
|
||||||
|
|
||||||
# Copyright (c) 1982, 1990 The Regents of the University of California.
|
# Copyright (c) 1982, 1990 The Regents of the University of California.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
@ -66,6 +66,10 @@ ifdef __HAVE_FAST_SOFTINTS
|
||||||
define __HAVE_FAST_SOFTINTS 1
|
define __HAVE_FAST_SOFTINTS 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef __HAVE_PIC_FAST_SOFTINTS
|
||||||
|
define __HAVE_PIC_FAST_SOFTINTS 1
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef __HAVE_UNNESTED_INTRS
|
ifdef __HAVE_UNNESTED_INTRS
|
||||||
define __HAVE_UNNESTED_INTRS 1
|
define __HAVE_UNNESTED_INTRS 1
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: machdep.h,v 1.13 2012/08/29 23:10:31 matt Exp $ */
|
/* $NetBSD: machdep.h,v 1.14 2012/08/31 23:59:52 matt Exp $ */
|
||||||
|
|
||||||
#ifndef _ARM32_BOOT_MACHDEP_H_
|
#ifndef _ARM32_BOOT_MACHDEP_H_
|
||||||
#define _ARM32_BOOT_MACHDEP_H_
|
#define _ARM32_BOOT_MACHDEP_H_
|
||||||
|
@ -27,13 +27,38 @@ extern paddr_t cpu_reset_address_paddr;
|
||||||
|
|
||||||
extern u_int data_abort_handler_address;
|
extern u_int data_abort_handler_address;
|
||||||
extern u_int prefetch_abort_handler_address;
|
extern u_int prefetch_abort_handler_address;
|
||||||
//extern u_int undefined_handler_address;
|
// extern u_int undefined_handler_address;
|
||||||
#define undefined_handler_address (curcpu()->ci_undefsave[2])
|
#define undefined_handler_address (curcpu()->ci_undefsave[2])
|
||||||
|
|
||||||
|
struct bootmem_info {
|
||||||
|
paddr_t bmi_start;
|
||||||
|
paddr_t bmi_kernelstart;
|
||||||
|
paddr_t bmi_kernelend;
|
||||||
|
paddr_t bmi_end;
|
||||||
|
pv_addrqh_t bmi_freechunks;
|
||||||
|
pv_addrqh_t bmi_chunks; /* sorted list of memory to be mapped */
|
||||||
|
pv_addr_t bmi_freeblocks[4];
|
||||||
|
/*
|
||||||
|
* These need to be static for pmap's kernel_pt list.
|
||||||
|
*/
|
||||||
|
pv_addr_t bmi_vector_l2pt;
|
||||||
|
pv_addr_t bmi_io_l2pt;
|
||||||
|
pv_addr_t bmi_l2pts[16];
|
||||||
|
u_int bmi_freepages;
|
||||||
|
u_int bmi_nfreeblocks;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct bootmem_info bootmem_info;
|
||||||
|
|
||||||
extern char *booted_kernel;
|
extern char *booted_kernel;
|
||||||
|
|
||||||
|
extern volatile uint32_t arm_cpu_hatched;
|
||||||
|
extern uint32_t arm_cpu_mbox;
|
||||||
|
extern u_int arm_cpu_max;
|
||||||
|
|
||||||
/* misc prototypes used by the many arm machdeps */
|
/* misc prototypes used by the many arm machdeps */
|
||||||
void cortex_pmc_ccnt_init(void);
|
void cortex_pmc_ccnt_init(void);
|
||||||
|
void cpu_hatch(struct cpu_info *, cpuid_t, void (*)(struct cpu_info *));
|
||||||
void halt(void);
|
void halt(void);
|
||||||
void parse_mi_bootargs(char *);
|
void parse_mi_bootargs(char *);
|
||||||
void data_abort_handler(trapframe_t *);
|
void data_abort_handler(trapframe_t *);
|
||||||
|
@ -46,6 +71,15 @@ void dumpsys(void);
|
||||||
* the structure is
|
* the structure is
|
||||||
*/
|
*/
|
||||||
u_int initarm(void *);
|
u_int initarm(void *);
|
||||||
|
struct pmap_devmap;
|
||||||
|
struct boot_physmem;
|
||||||
|
void arm32_bootmem_init(paddr_t memstart, psize_t memsize, paddr_t kernelstart);
|
||||||
|
void arm32_kernel_vm_init(vaddr_t kvm_base, vaddr_t vectors,
|
||||||
|
vaddr_t iovbase /* (can be zero) */,
|
||||||
|
const struct pmap_devmap *devmap, bool mapallmem_p);
|
||||||
|
vaddr_t initarm_common(vaddr_t kvm_base, vsize_t kvm_size,
|
||||||
|
const struct boot_physmem *bp, size_t nbp);
|
||||||
|
|
||||||
|
|
||||||
/* from arm/arm32/intr.c */
|
/* from arm/arm32/intr.c */
|
||||||
void dosoftints(void);
|
void dosoftints(void);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: bootconfig.h,v 1.5 2009/03/14 14:45:55 dsl Exp $ */
|
/* $NetBSD: bootconfig.h,v 1.6 2012/08/31 23:59:52 matt Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Mark Brinicombe.
|
* Copyright (c) 1994 Mark Brinicombe.
|
||||||
|
@ -44,6 +44,14 @@
|
||||||
#define BOOTOPT_TYPE_HEXINT 4
|
#define BOOTOPT_TYPE_HEXINT 4
|
||||||
#define BOOTOPT_TYPE_MASK 7
|
#define BOOTOPT_TYPE_MASK 7
|
||||||
|
|
||||||
|
struct boot_physmem {
|
||||||
|
paddr_t bp_start; /* starting PFN (not address) */
|
||||||
|
psize_t bp_pages; /* # of pages */
|
||||||
|
u_int bp_freelist; /* VM_FREELIST_ * */
|
||||||
|
u_int bp_flags;
|
||||||
|
#define BOOT_PHYSMEM_CAN_DMA 1 /* Can DMA direct to this memory. */
|
||||||
|
};
|
||||||
|
|
||||||
int get_bootconf_option(char *, const char *, int, void *);
|
int get_bootconf_option(char *, const char *, int, void *);
|
||||||
|
|
||||||
extern char *boot_args;
|
extern char *boot_args;
|
||||||
|
|
Loading…
Reference in New Issue