machdep.c (fb112f72a824de17d18b973c66cf85a2a2d1a023) machdep.c (698c14e189107f370e0b4523a914d3916d46e603)
1/*-
2 * Copyright (c) 2014 Andrew Turner
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
1/*-
2 * Copyright (c) 2014 Andrew Turner
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include "opt_acpi.h"
28#include "opt_platform.h"
29#include "opt_ddb.h"
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD$");
33
34#include <sys/param.h>
35#include <sys/systm.h>

--- 41 unchanged lines hidden (view full) ---

77#include <machine/pcb.h>
78#include <machine/reg.h>
79#include <machine/vmparam.h>
80
81#ifdef VFP
82#include <machine/vfp.h>
83#endif
84
29#include "opt_platform.h"
30#include "opt_ddb.h"
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD$");
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 41 unchanged lines hidden (view full) ---

78#include <machine/pcb.h>
79#include <machine/reg.h>
80#include <machine/vmparam.h>
81
82#ifdef VFP
83#include <machine/vfp.h>
84#endif
85
86#ifdef DEV_ACPI
87#include <contrib/dev/acpica/include/acpi.h>
88#include <machine/acpica_machdep.h>
89#endif
90
85#ifdef FDT
86#include <dev/fdt/fdt_common.h>
87#include <dev/ofw/openfirm.h>
88#endif
89
91#ifdef FDT
92#include <dev/fdt/fdt_common.h>
93#include <dev/ofw/openfirm.h>
94#endif
95
96
97enum arm64_bus arm64_bus_method = ARM64_BUS_NONE;
98
90struct pcpu __pcpu[MAXCPU];
91
92static struct trapframe proc0_tf;
93
94vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2];
95vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2];
96
97int early_boot = 1;

--- 699 unchanged lines hidden (view full) ---

797 if (OF_install(OFW_FDT, 0) == FALSE)
798 panic("Cannot install FDT");
799
800 if (OF_init((void *)dtbp) != 0)
801 panic("OF_init failed with the found device tree");
802}
803#endif
804
99struct pcpu __pcpu[MAXCPU];
100
101static struct trapframe proc0_tf;
102
103vm_paddr_t phys_avail[PHYS_AVAIL_SIZE + 2];
104vm_paddr_t dump_avail[PHYS_AVAIL_SIZE + 2];
105
106int early_boot = 1;

--- 699 unchanged lines hidden (view full) ---

806 if (OF_install(OFW_FDT, 0) == FALSE)
807 panic("Cannot install FDT");
808
809 if (OF_init((void *)dtbp) != 0)
810 panic("OF_init failed with the found device tree");
811}
812#endif
813
814static bool
815bus_probe(void)
816{
817 bool has_acpi, has_fdt;
818 char *order, *env;
819
820 has_acpi = has_fdt = false;
821
822#ifdef FDT
823 has_fdt = (OF_peer(0) != 0);
824#endif
825#ifdef DEV_ACPI
826 has_acpi = (acpi_find_table(ACPI_SIG_SPCR) != 0);
827#endif
828
829 env = kern_getenv("kern.cfg.order");
830 if (env != NULL) {
831 order = env;
832 while (order != NULL) {
833 if (has_acpi &&
834 strncmp(order, "acpi", 4) == 0 &&
835 (order[4] == ',' || order[4] == '\0')) {
836 arm64_bus_method = ARM64_BUS_ACPI;
837 break;
838 }
839 if (has_fdt &&
840 strncmp(order, "fdt", 3) == 0 &&
841 (order[3] == ',' || order[3] == '\0')) {
842 arm64_bus_method = ARM64_BUS_FDT;
843 break;
844 }
845 order = strchr(order, ',');
846 }
847 freeenv(env);
848
849 /* If we set the bus method it is valid */
850 if (arm64_bus_method != ARM64_BUS_NONE)
851 return (true);
852 }
853 /* If no order or an invalid order was set use the default */
854 if (arm64_bus_method == ARM64_BUS_NONE) {
855 if (has_fdt)
856 arm64_bus_method = ARM64_BUS_FDT;
857 else if (has_acpi)
858 arm64_bus_method = ARM64_BUS_ACPI;
859 }
860
861 /*
862 * If no option was set the default is valid, otherwise we are
863 * setting one to get cninit() working, then calling panic to tell
864 * the user about the invalid bus setup.
865 */
866 return (env == NULL);
867}
868
805static void
806cache_setup(void)
807{
808 int dcache_line_shift, icache_line_shift, dczva_line_shift;
809 uint32_t ctr_el0;
810 uint32_t dczid_el0;
811
812 ctr_el0 = READ_SPECIALREG(ctr_el0);

--- 31 unchanged lines hidden (view full) ---

844 struct pcpu *pcpup;
845#ifdef FDT
846 struct mem_region mem_regions[FDT_MEM_REGIONS];
847 int mem_regions_sz;
848#endif
849 vm_offset_t lastaddr;
850 caddr_t kmdp;
851 vm_paddr_t mem_len;
869static void
870cache_setup(void)
871{
872 int dcache_line_shift, icache_line_shift, dczva_line_shift;
873 uint32_t ctr_el0;
874 uint32_t dczid_el0;
875
876 ctr_el0 = READ_SPECIALREG(ctr_el0);

--- 31 unchanged lines hidden (view full) ---

908 struct pcpu *pcpup;
909#ifdef FDT
910 struct mem_region mem_regions[FDT_MEM_REGIONS];
911 int mem_regions_sz;
912#endif
913 vm_offset_t lastaddr;
914 caddr_t kmdp;
915 vm_paddr_t mem_len;
916 bool valid;
852 int i;
853
854 /* Set the module data location */
855 preload_metadata = (caddr_t)(uintptr_t)(abp->modulep);
856
857 /* Find the kernel address */
858 kmdp = preload_search_by_type("elf kernel");
859 if (kmdp == NULL)

--- 56 unchanged lines hidden (view full) ---

916 cache_setup();
917
918 /* Bootstrap enough of pmap to enter the kernel proper */
919 pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt,
920 KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
921
922 devmap_bootstrap(0, NULL);
923
917 int i;
918
919 /* Set the module data location */
920 preload_metadata = (caddr_t)(uintptr_t)(abp->modulep);
921
922 /* Find the kernel address */
923 kmdp = preload_search_by_type("elf kernel");
924 if (kmdp == NULL)

--- 56 unchanged lines hidden (view full) ---

981 cache_setup();
982
983 /* Bootstrap enough of pmap to enter the kernel proper */
984 pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt,
985 KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
986
987 devmap_bootstrap(0, NULL);
988
989 valid = bus_probe();
990
924 cninit();
925
991 cninit();
992
993 if (!valid)
994 panic("Invalid bus configuration: %s",
995 kern_getenv("kern.cfg.order"));
996
926 init_proc0(abp->kern_stack);
927 msgbufinit(msgbufp, msgbufsize);
928 mutex_init();
929 init_param2(physmem);
930
931 dbg_monitor_init();
932 kdb_init();
933

--- 103 unchanged lines hidden ---
997 init_proc0(abp->kern_stack);
998 msgbufinit(msgbufp, msgbufsize);
999 mutex_init();
1000 init_param2(physmem);
1001
1002 dbg_monitor_init();
1003 kdb_init();
1004

--- 103 unchanged lines hidden ---