2008-03-03 17:17:00 +00:00
|
|
|
/*-
|
2012-05-30 17:34:40 +00:00
|
|
|
* Copyright (C) 2006-2012 Semihalf
|
2008-03-03 17:17:00 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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 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 Benno Rice
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``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 TOOLS GMBH 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.
|
|
|
|
* $NetBSD: machdep.c,v 1.74.2.1 2000/11/01 16:13:48 tv Exp $
|
|
|
|
*/
|
|
|
|
/*-
|
|
|
|
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
|
|
|
* Copyright (C) 1995, 1996 TooLs GmbH.
|
|
|
|
* 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 TooLs GmbH.
|
|
|
|
* 4. The name of TooLs GmbH may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include "opt_compat.h"
|
2009-04-21 17:04:01 +00:00
|
|
|
#include "opt_ddb.h"
|
2015-04-18 21:39:17 +00:00
|
|
|
#include "opt_hwpmc_hooks.h"
|
2008-03-03 17:17:00 +00:00
|
|
|
#include "opt_kstack_pages.h"
|
2011-01-17 23:54:50 +00:00
|
|
|
#include "opt_platform.h"
|
2008-03-03 17:17:00 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/bio.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/cons.h>
|
|
|
|
#include <sys/cpu.h>
|
|
|
|
#include <sys/kdb.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
2013-03-09 02:32:23 +00:00
|
|
|
#include <sys/rwlock.h>
|
2008-03-03 17:17:00 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/exec.h>
|
|
|
|
#include <sys/ktr.h>
|
2010-06-30 18:03:42 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
2008-03-03 17:17:00 +00:00
|
|
|
#include <sys/sysproto.h>
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
#include <sys/sysent.h>
|
|
|
|
#include <sys/imgact.h>
|
|
|
|
#include <sys/msgbuf.h>
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_pager.h>
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/kdb.h>
|
|
|
|
#include <machine/reg.h>
|
|
|
|
#include <machine/vmparam.h>
|
|
|
|
#include <machine/spr.h>
|
|
|
|
#include <machine/hid.h>
|
|
|
|
#include <machine/psl.h>
|
|
|
|
#include <machine/trap.h>
|
|
|
|
#include <machine/md_var.h>
|
|
|
|
#include <machine/mmuvar.h>
|
|
|
|
#include <machine/sigframe.h>
|
2012-05-30 17:34:40 +00:00
|
|
|
#include <machine/machdep.h>
|
2008-03-03 17:17:00 +00:00
|
|
|
#include <machine/metadata.h>
|
2009-05-14 00:34:26 +00:00
|
|
|
#include <machine/platform.h>
|
2008-03-03 17:17:00 +00:00
|
|
|
|
|
|
|
#include <sys/linker.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
|
2013-10-26 19:50:40 +00:00
|
|
|
#include <contrib/libfdt/libfdt.h>
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
#include <dev/fdt/fdt_common.h>
|
|
|
|
#include <dev/ofw/openfirm.h>
|
|
|
|
|
2009-04-21 17:04:01 +00:00
|
|
|
#ifdef DDB
|
2014-09-25 08:28:10 +00:00
|
|
|
#include <ddb/ddb.h>
|
2009-04-21 17:04:01 +00:00
|
|
|
#endif
|
|
|
|
|
2008-03-03 17:17:00 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#define debugf(fmt, args...) printf(fmt, ##args)
|
|
|
|
#else
|
|
|
|
#define debugf(fmt, args...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern unsigned char _etext[];
|
|
|
|
extern unsigned char _edata[];
|
|
|
|
extern unsigned char __bss_start[];
|
|
|
|
extern unsigned char __sbss_start[];
|
|
|
|
extern unsigned char __sbss_end[];
|
|
|
|
extern unsigned char _end[];
|
2015-04-30 01:24:25 +00:00
|
|
|
extern vm_offset_t __endkernel;
|
2008-03-03 17:17:00 +00:00
|
|
|
|
2011-01-17 23:54:50 +00:00
|
|
|
/*
|
|
|
|
* Bootinfo is passed to us by legacy loaders. Save the address of the
|
|
|
|
* structure to handle backward compatibility.
|
|
|
|
*/
|
|
|
|
uint32_t *bootinfo;
|
|
|
|
|
2008-03-03 17:17:00 +00:00
|
|
|
void print_kernel_section_addr(void);
|
2008-12-17 15:31:15 +00:00
|
|
|
void print_kenv(void);
|
2016-01-04 02:20:14 +00:00
|
|
|
uintptr_t booke_init(u_long, u_long);
|
2015-03-05 05:53:08 +00:00
|
|
|
void ivor_setup(void);
|
|
|
|
|
|
|
|
extern void *interrupt_vector_base;
|
|
|
|
extern void *int_critical_input;
|
|
|
|
extern void *int_machine_check;
|
|
|
|
extern void *int_data_storage;
|
|
|
|
extern void *int_instr_storage;
|
|
|
|
extern void *int_external_input;
|
|
|
|
extern void *int_alignment;
|
Add more interrupts handled for booke.
e500mc, e5500, and e6500 all use the normal FPU, with the same behavior as AIM
hardware. e6500 also supports Altivec, so, although we don't yet have e6500
hardware to test on, add these IVORs as well. Theoretically, since it boots the
same as a e5500, it should work, single-threaded, single-core, with full altivec
support as of this commit.
With this commit, and some other patches to be committed shortly FreeBSD now
boots on the P5020, single-core, all the way to user space, and should boot just
fine on e500mc.
Relnotes: Yes (e500mc, e5500 support)
Sponsored by: Alex Perez/Inertial Computing
2015-12-11 01:23:18 +00:00
|
|
|
extern void *int_fpu;
|
2015-03-05 05:53:08 +00:00
|
|
|
extern void *int_program;
|
|
|
|
extern void *int_syscall;
|
|
|
|
extern void *int_decrementer;
|
|
|
|
extern void *int_fixed_interval_timer;
|
|
|
|
extern void *int_watchdog;
|
|
|
|
extern void *int_data_tlb_error;
|
|
|
|
extern void *int_inst_tlb_error;
|
|
|
|
extern void *int_debug;
|
2017-02-01 03:29:13 +00:00
|
|
|
extern void *int_debug_ed;
|
Add more interrupts handled for booke.
e500mc, e5500, and e6500 all use the normal FPU, with the same behavior as AIM
hardware. e6500 also supports Altivec, so, although we don't yet have e6500
hardware to test on, add these IVORs as well. Theoretically, since it boots the
same as a e5500, it should work, single-threaded, single-core, with full altivec
support as of this commit.
With this commit, and some other patches to be committed shortly FreeBSD now
boots on the P5020, single-core, all the way to user space, and should boot just
fine on e500mc.
Relnotes: Yes (e500mc, e5500 support)
Sponsored by: Alex Perez/Inertial Computing
2015-12-11 01:23:18 +00:00
|
|
|
extern void *int_vec;
|
|
|
|
extern void *int_vecast;
|
2015-04-18 21:39:17 +00:00
|
|
|
#ifdef HWPMC_HOOKS
|
|
|
|
extern void *int_performance_counter;
|
|
|
|
#endif
|
2015-03-05 05:53:08 +00:00
|
|
|
|
|
|
|
#define SET_TRAP(ivor, handler) \
|
|
|
|
KASSERT(((uintptr_t)(&handler) & ~0xffffUL) == \
|
|
|
|
((uintptr_t)(&interrupt_vector_base) & ~0xffffUL), \
|
|
|
|
("Handler " #handler " too far from interrupt vector base")); \
|
|
|
|
mtspr(ivor, (uintptr_t)(&handler) & 0xffffUL);
|
|
|
|
|
2017-11-26 03:53:20 +00:00
|
|
|
uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp,
|
|
|
|
vm_offset_t mdp_cookie);
|
2015-04-30 01:24:25 +00:00
|
|
|
void booke_cpu_init(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
booke_cpu_init(void)
|
|
|
|
{
|
|
|
|
|
2016-01-02 18:15:10 +00:00
|
|
|
cpu_features |= PPC_FEATURE_BOOKE;
|
|
|
|
|
2015-04-30 01:24:25 +00:00
|
|
|
pmap_mmu_install(MMU_TYPE_BOOKE, BUS_PROBE_GENERIC);
|
|
|
|
}
|
|
|
|
|
2015-03-05 05:53:08 +00:00
|
|
|
void
|
|
|
|
ivor_setup(void)
|
|
|
|
{
|
|
|
|
|
Introduce 64-bit PowerPC Book-E support
Extend the Book-E pmap to support 64-bit operation. Much of this was taken from
Juniper's Junos FreeBSD port. It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index). In practice this may not be a problem
given the expanded address space. However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space. Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.
This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
(total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
a 32-bit init with 64-bit children.
Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.
Reviewed by: stevek
Obtained from: Juniper (in part)
MFC after: 2 months
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D9433
2017-03-17 21:40:14 +00:00
|
|
|
mtspr(SPR_IVPR, ((uintptr_t)&interrupt_vector_base) & ~0xffffUL);
|
2015-03-05 05:53:08 +00:00
|
|
|
|
|
|
|
SET_TRAP(SPR_IVOR0, int_critical_input);
|
|
|
|
SET_TRAP(SPR_IVOR1, int_machine_check);
|
|
|
|
SET_TRAP(SPR_IVOR2, int_data_storage);
|
|
|
|
SET_TRAP(SPR_IVOR3, int_instr_storage);
|
|
|
|
SET_TRAP(SPR_IVOR4, int_external_input);
|
|
|
|
SET_TRAP(SPR_IVOR5, int_alignment);
|
|
|
|
SET_TRAP(SPR_IVOR6, int_program);
|
|
|
|
SET_TRAP(SPR_IVOR8, int_syscall);
|
|
|
|
SET_TRAP(SPR_IVOR10, int_decrementer);
|
|
|
|
SET_TRAP(SPR_IVOR11, int_fixed_interval_timer);
|
|
|
|
SET_TRAP(SPR_IVOR12, int_watchdog);
|
|
|
|
SET_TRAP(SPR_IVOR13, int_data_tlb_error);
|
|
|
|
SET_TRAP(SPR_IVOR14, int_inst_tlb_error);
|
|
|
|
SET_TRAP(SPR_IVOR15, int_debug);
|
2015-04-18 21:39:17 +00:00
|
|
|
#ifdef HWPMC_HOOKS
|
|
|
|
SET_TRAP(SPR_IVOR35, int_performance_counter);
|
|
|
|
#endif
|
Add more interrupts handled for booke.
e500mc, e5500, and e6500 all use the normal FPU, with the same behavior as AIM
hardware. e6500 also supports Altivec, so, although we don't yet have e6500
hardware to test on, add these IVORs as well. Theoretically, since it boots the
same as a e5500, it should work, single-threaded, single-core, with full altivec
support as of this commit.
With this commit, and some other patches to be committed shortly FreeBSD now
boots on the P5020, single-core, all the way to user space, and should boot just
fine on e500mc.
Relnotes: Yes (e500mc, e5500 support)
Sponsored by: Alex Perez/Inertial Computing
2015-12-11 01:23:18 +00:00
|
|
|
switch ((mfpvr() >> 16) & 0xffff) {
|
|
|
|
case FSL_E6500:
|
|
|
|
SET_TRAP(SPR_IVOR32, int_vec);
|
|
|
|
SET_TRAP(SPR_IVOR33, int_vecast);
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case FSL_E500mc:
|
|
|
|
case FSL_E5500:
|
|
|
|
SET_TRAP(SPR_IVOR7, int_fpu);
|
2017-02-01 03:29:13 +00:00
|
|
|
SET_TRAP(SPR_IVOR15, int_debug_ed);
|
Create a new MACHINE_ARCH for Freescale PowerPC e500v2
Summary:
The Freescale e500v2 PowerPC core does not use a standard FPU.
Instead, it uses a Signal Processing Engine (SPE)--a DSP-style vector processor
unit, which doubles as a FPU. The PowerPC SPE ABI is incompatible with the
stock powerpc ABI, so a new MACHINE_ARCH was created to deal with this.
Additionaly, the SPE opcodes overlap with Altivec, so these are mutually
exclusive. Taking advantage of this fact, a new file, powerpc/booke/spe.c, was
created with the same function set as in powerpc/powerpc/altivec.c, so it
becomes effectively a drop-in replacement. setjmp/longjmp were modified to save
the upper 32-bits of the now-64-bit GPRs (upper 32-bits are only accessible by
the SPE).
Note: This does _not_ support the SPE in the e500v1, as the e500v1 SPE does not
support double-precision floating point.
Also, without a new MACHINE_ARCH it would be impossible to provide binary
packages which utilize the SPE.
Additionally, no work has been done to support ports, work is needed for this.
This also means no newer gcc can yet be used. However, gcc's powerpc support
has been refactored which would make adding a powerpcspe-freebsd target very
easy.
Test Plan:
This was lightly tested on a RouterBoard RB800 and an AmigaOne A1222
(P1022-based) board, compiled against the new ABI. Base system utilities
(/bin/sh, /bin/ls, etc) still function appropriately, the system is able to boot
multiuser.
Reviewed By: bdrewery, imp
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D5683
2016-10-22 01:57:15 +00:00
|
|
|
break;
|
|
|
|
case FSL_E500v1:
|
|
|
|
case FSL_E500v2:
|
|
|
|
SET_TRAP(SPR_IVOR32, int_vec);
|
|
|
|
break;
|
Add more interrupts handled for booke.
e500mc, e5500, and e6500 all use the normal FPU, with the same behavior as AIM
hardware. e6500 also supports Altivec, so, although we don't yet have e6500
hardware to test on, add these IVORs as well. Theoretically, since it boots the
same as a e5500, it should work, single-threaded, single-core, with full altivec
support as of this commit.
With this commit, and some other patches to be committed shortly FreeBSD now
boots on the P5020, single-core, all the way to user space, and should boot just
fine on e500mc.
Relnotes: Yes (e500mc, e5500 support)
Sponsored by: Alex Perez/Inertial Computing
2015-12-11 01:23:18 +00:00
|
|
|
}
|
Introduce 64-bit PowerPC Book-E support
Extend the Book-E pmap to support 64-bit operation. Much of this was taken from
Juniper's Junos FreeBSD port. It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index). In practice this may not be a problem
given the expanded address space. However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space. Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.
This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
(total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
a 32-bit init with 64-bit children.
Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.
Reviewed by: stevek
Obtained from: Juniper (in part)
MFC after: 2 months
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D9433
2017-03-17 21:40:14 +00:00
|
|
|
|
|
|
|
#ifdef __powerpc64__
|
|
|
|
/* Set 64-bit interrupt mode. */
|
|
|
|
mtspr(SPR_EPCR, mfspr(SPR_EPCR) | EPCR_ICM);
|
|
|
|
#endif
|
2015-03-05 05:53:08 +00:00
|
|
|
}
|
2008-03-03 17:17:00 +00:00
|
|
|
|
2013-10-26 19:50:40 +00:00
|
|
|
static int
|
|
|
|
booke_check_for_fdt(uint32_t arg1, vm_offset_t *dtbp)
|
|
|
|
{
|
|
|
|
void *ptr;
|
2016-08-24 03:51:40 +00:00
|
|
|
int fdt_size;
|
2013-10-26 19:50:40 +00:00
|
|
|
|
|
|
|
if (arg1 % 8 != 0)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
ptr = (void *)pmap_early_io_map(arg1, PAGE_SIZE);
|
|
|
|
if (fdt_check_header(ptr) != 0)
|
|
|
|
return (-1);
|
|
|
|
|
2016-08-24 03:51:40 +00:00
|
|
|
/*
|
|
|
|
* Read FDT total size from the header of FDT.
|
|
|
|
* This for sure hits within first page which is
|
|
|
|
* already mapped.
|
|
|
|
*/
|
|
|
|
fdt_size = fdt_totalsize((void *)ptr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ok, arg1 points to FDT, so we need to map it in.
|
|
|
|
* First, unmap this page and then map FDT again with full size
|
|
|
|
*/
|
|
|
|
pmap_early_io_unmap((vm_offset_t)ptr, PAGE_SIZE);
|
|
|
|
ptr = (void *)pmap_early_io_map(arg1, fdt_size);
|
2013-10-26 19:50:40 +00:00
|
|
|
*dtbp = (vm_offset_t)ptr;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2015-04-30 01:24:25 +00:00
|
|
|
uintptr_t
|
2016-01-04 02:20:14 +00:00
|
|
|
booke_init(u_long arg1, u_long arg2)
|
2008-03-03 17:17:00 +00:00
|
|
|
{
|
2015-04-30 01:24:25 +00:00
|
|
|
uintptr_t ret;
|
|
|
|
void *mdp;
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
vm_offset_t dtbp, end;
|
2008-03-03 17:17:00 +00:00
|
|
|
|
2011-05-28 04:10:44 +00:00
|
|
|
end = (uintptr_t)_end;
|
Convert Freescale PowerPC platforms to FDT convention.
The following systems are affected:
- MPC8555CDS
- MPC8572DS
This overhaul covers the following major changes:
- All integrated peripherals drivers for Freescale MPC85XX SoC, which are
currently in the FreeBSD source tree are reworked and adjusted so they
derive config data out of the device tree blob (instead of hard coded /
tabelarized values).
- This includes: LBC, PCI / PCI-Express, I2C, DS1553, OpenPIC, TSEC, SEC,
QUICC, UART, CFI.
- Thanks to the common FDT infrastrucutre (fdtbus, simplebus) we retire
ocpbus(4) driver, which was based on hard-coded config data.
Note that world for these platforms has to be built WITH_FDT.
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
2010-07-11 21:08:29 +00:00
|
|
|
dtbp = (vm_offset_t)NULL;
|
2008-03-03 17:17:00 +00:00
|
|
|
|
2013-10-26 19:50:40 +00:00
|
|
|
/* Set up TLB initially */
|
|
|
|
bootinfo = NULL;
|
2015-04-30 01:24:25 +00:00
|
|
|
bzero(__sbss_start, __sbss_end - __sbss_start);
|
|
|
|
bzero(__bss_start, _end - __bss_start);
|
2013-10-26 19:50:40 +00:00
|
|
|
tlb1_init();
|
|
|
|
|
2011-05-28 04:10:44 +00:00
|
|
|
/*
|
|
|
|
* Handle the various ways we can get loaded and started:
|
|
|
|
* - FreeBSD's loader passes the pointer to the metadata
|
|
|
|
* in arg1, with arg2 undefined. arg1 has a value that's
|
|
|
|
* relative to the kernel's link address (i.e. larger
|
|
|
|
* than 0xc0000000).
|
|
|
|
* - Juniper's loader passes the metadata pointer in arg2
|
|
|
|
* and sets arg1 to zero. This is to signal that the
|
|
|
|
* loader maps the kernel and starts it at its link
|
|
|
|
* address (unlike the FreeBSD loader).
|
|
|
|
* - U-Boot passes the standard argc and argv parameters
|
|
|
|
* in arg1 and arg2 (resp). arg1 is between 1 and some
|
|
|
|
* relatively small number, such as 64K. arg2 is the
|
|
|
|
* physical address of the argv vector.
|
2013-10-26 19:50:40 +00:00
|
|
|
* - ePAPR loaders pass an FDT blob in r3 (arg1) and the magic hex
|
2015-12-11 01:34:13 +00:00
|
|
|
* string 0x45504150 ('EPAP') in r6 (which has been lost by now).
|
2013-10-26 19:50:40 +00:00
|
|
|
* r4 (arg2) is supposed to be set to zero, but is not always.
|
2011-05-28 04:10:44 +00:00
|
|
|
*/
|
2013-10-26 19:50:40 +00:00
|
|
|
|
|
|
|
if (arg1 == 0) /* Juniper loader */
|
2011-05-28 04:10:44 +00:00
|
|
|
mdp = (void *)arg2;
|
2013-10-26 19:50:40 +00:00
|
|
|
else if (booke_check_for_fdt(arg1, &dtbp) == 0) { /* ePAPR */
|
|
|
|
end = roundup(end, 8);
|
|
|
|
memmove((void *)end, (void *)dtbp, fdt_totalsize((void *)dtbp));
|
|
|
|
dtbp = end;
|
|
|
|
end += fdt_totalsize((void *)dtbp);
|
2015-04-30 01:24:25 +00:00
|
|
|
__endkernel = end;
|
2013-10-26 19:50:40 +00:00
|
|
|
mdp = NULL;
|
2016-01-10 18:00:01 +00:00
|
|
|
} else if (arg1 > (uintptr_t)btext) /* FreeBSD loader */
|
2013-10-26 19:50:40 +00:00
|
|
|
mdp = (void *)arg1;
|
2011-05-28 04:10:44 +00:00
|
|
|
else /* U-Boot */
|
|
|
|
mdp = NULL;
|
|
|
|
|
2015-12-30 03:43:25 +00:00
|
|
|
/* Default to 32 byte cache line size. */
|
|
|
|
switch ((mfpvr()) >> 16) {
|
|
|
|
case FSL_E500mc:
|
|
|
|
case FSL_E5500:
|
|
|
|
case FSL_E6500:
|
|
|
|
cacheline_size = 64;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-11-26 03:53:20 +00:00
|
|
|
/*
|
|
|
|
* Last element is a magic cookie that indicates that the metadata
|
|
|
|
* pointer is meaningful.
|
|
|
|
*/
|
|
|
|
ret = powerpc_init(dtbp, 0, 0, mdp, (mdp == NULL) ? 0 : 0xfb5d104d);
|
2016-01-04 01:33:07 +00:00
|
|
|
|
2015-12-30 03:43:25 +00:00
|
|
|
/* Enable caches */
|
2012-05-30 17:34:40 +00:00
|
|
|
booke_enable_l1_cache();
|
2015-12-30 03:43:25 +00:00
|
|
|
booke_enable_l2_cache();
|
|
|
|
|
|
|
|
booke_enable_bpred();
|
2008-03-08 05:36:25 +00:00
|
|
|
|
2015-04-30 01:24:25 +00:00
|
|
|
return (ret);
|
2008-03-03 17:17:00 +00:00
|
|
|
}
|
|
|
|
|
2009-05-21 11:43:37 +00:00
|
|
|
#define RES_GRANULE 32
|
Introduce 64-bit PowerPC Book-E support
Extend the Book-E pmap to support 64-bit operation. Much of this was taken from
Juniper's Junos FreeBSD port. It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index). In practice this may not be a problem
given the expanded address space. However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space. Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.
This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
(total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
a 32-bit init with 64-bit children.
Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.
Reviewed by: stevek
Obtained from: Juniper (in part)
MFC after: 2 months
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D9433
2017-03-17 21:40:14 +00:00
|
|
|
extern uintptr_t tlb0_miss_locks[];
|
2009-05-21 11:43:37 +00:00
|
|
|
|
2008-03-03 17:17:00 +00:00
|
|
|
/* Initialise a struct pcpu. */
|
|
|
|
void
|
|
|
|
cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
|
|
|
|
{
|
|
|
|
|
2009-01-13 15:41:58 +00:00
|
|
|
pcpu->pc_tid_next = TID_MIN;
|
2009-05-21 11:43:37 +00:00
|
|
|
|
|
|
|
#ifdef SMP
|
Introduce 64-bit PowerPC Book-E support
Extend the Book-E pmap to support 64-bit operation. Much of this was taken from
Juniper's Junos FreeBSD port. It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index). In practice this may not be a problem
given the expanded address space. However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space. Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.
This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
(total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
a 32-bit init with 64-bit children.
Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.
Reviewed by: stevek
Obtained from: Juniper (in part)
MFC after: 2 months
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D9433
2017-03-17 21:40:14 +00:00
|
|
|
uintptr_t *ptr;
|
|
|
|
int words_per_gran = RES_GRANULE / sizeof(uintptr_t);
|
2009-05-21 11:43:37 +00:00
|
|
|
|
|
|
|
ptr = &tlb0_miss_locks[cpuid * words_per_gran];
|
|
|
|
pcpu->pc_booke_tlb_lock = ptr;
|
2010-11-11 13:35:23 +00:00
|
|
|
*ptr = TLB_UNLOCKED;
|
2009-05-21 11:43:37 +00:00
|
|
|
*(ptr + 1) = 0; /* recurse counter */
|
|
|
|
#endif
|
2008-03-03 17:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Shutdown the CPU as much as possible. */
|
|
|
|
void
|
|
|
|
cpu_halt(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
mtmsr(mfmsr() & ~(PSL_CE | PSL_EE | PSL_ME | PSL_DE));
|
2012-05-26 13:36:18 +00:00
|
|
|
while (1)
|
|
|
|
;
|
2008-03-03 17:17:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ptrace_single_step(struct thread *td)
|
|
|
|
{
|
|
|
|
struct trapframe *tf;
|
|
|
|
|
|
|
|
tf = td->td_frame;
|
|
|
|
tf->srr1 |= PSL_DE;
|
2009-02-27 12:08:24 +00:00
|
|
|
tf->cpu.booke.dbcr0 |= (DBCR0_IDM | DBCR0_IC);
|
2008-03-03 17:17:00 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ptrace_clear_single_step(struct thread *td)
|
|
|
|
{
|
|
|
|
struct trapframe *tf;
|
|
|
|
|
|
|
|
tf = td->td_frame;
|
|
|
|
tf->srr1 &= ~PSL_DE;
|
2009-02-27 12:08:24 +00:00
|
|
|
tf->cpu.booke.dbcr0 &= ~(DBCR0_IDM | DBCR0_IC);
|
2008-03-03 17:17:00 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
kdb_cpu_clear_singlestep(void)
|
|
|
|
{
|
|
|
|
register_t r;
|
|
|
|
|
|
|
|
r = mfspr(SPR_DBCR0);
|
|
|
|
mtspr(SPR_DBCR0, r & ~DBCR0_IC);
|
|
|
|
kdb_frame->srr1 &= ~PSL_DE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
kdb_cpu_set_singlestep(void)
|
|
|
|
{
|
|
|
|
register_t r;
|
|
|
|
|
|
|
|
r = mfspr(SPR_DBCR0);
|
|
|
|
mtspr(SPR_DBCR0, r | DBCR0_IC | DBCR0_IDM);
|
|
|
|
kdb_frame->srr1 |= PSL_DE;
|
|
|
|
}
|
|
|
|
|