Index: sys/powerpc/booke/machdep.c =================================================================== --- sys/powerpc/booke/machdep.c (wersja 192014) +++ sys/powerpc/booke/machdep.c (kopia robocza) @@ -127,11 +127,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include -#include +#include #include #include @@ -157,9 +156,6 @@ extern unsigned char __sbss_start[]; extern unsigned char __sbss_end[]; extern unsigned char _end[]; -extern struct mem_region availmem_regions[]; -extern int availmem_regions_sz; - extern void dcache_enable(void); extern void dcache_inval(void); extern void icache_enable(void); @@ -339,9 +335,7 @@ e500_init(u_int32_t startkernel, u_int32_t endkern struct pcpu *pc; void *kmdp; vm_offset_t end; - struct bi_mem_region *mr; uint32_t csr; - int i; kmdp = NULL; @@ -381,31 +375,9 @@ e500_init(u_int32_t startkernel, u_int32_t endkern while(1); } - /* Initialize memory regions table */ - mr = bootinfo_mr(); - for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) { - if (i == MEM_REGIONS) - break; - if (mr->mem_base < 1048576) { - availmem_regions[i].mr_start = 1048576; - availmem_regions[i].mr_size = mr->mem_size - - (1048576 - mr->mem_base); - } else { - availmem_regions[i].mr_start = mr->mem_base; - availmem_regions[i].mr_size = mr->mem_size; - } - } - availmem_regions_sz = i; - /* Initialize TLB1 handling */ tlb1_init(bootinfo->bi_bar_base); - /* - * Time Base and Decrementer are updated every 8 CCB bus clocks. - * HID0[SEL_TBCLK] = 0 - */ - decr_config(bootinfo->bi_bus_clk / 8); - /* Init params/tunables that can be overridden by the loader. */ init_param1(); @@ -450,6 +422,9 @@ e500_init(u_int32_t startkernel, u_int32_t endkern kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); #endif + /* Initialise platform module */ + platform_probe_and_attach(); + /* Initialise virtual memory. */ pmap_mmu_install(MMU_TYPE_BOOKE, 0); pmap_bootstrap(startkernel, end); Index: sys/powerpc/booke/vm_machdep.c =================================================================== --- sys/powerpc/booke/vm_machdep.c (wersja 192014) +++ sys/powerpc/booke/vm_machdep.c (kopia robocza) @@ -124,7 +124,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include Index: sys/powerpc/booke/clock.c =================================================================== --- sys/powerpc/booke/clock.c (wersja 192014) +++ sys/powerpc/booke/clock.c (kopia robocza) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -123,29 +124,22 @@ void cpu_initclocks(void) { - return; + decr_tc_init(); } void -decr_config (unsigned long freq) -{ - ticks_per_sec = freq; - decr_timecounter.tc_frequency = freq; -} - -void decr_init (void) { + struct cpuref cpu; unsigned int msr; - /* - * Should check for correct CPU here? XXX - */ + if (platform_smp_get_bsp(&cpu) != 0) + platform_smp_first_cpu(&cpu); + ticks_per_sec = platform_timebase_freq(&cpu); + msr = mfmsr(); mtmsr(msr & ~(PSL_EE)); - tc_init(&decr_timecounter); - ns_per_tick = 1000000000 / ticks_per_sec; ticks_per_intr = ticks_per_sec / hz; @@ -173,6 +167,15 @@ mftb (void) return tb; } +void +decr_tc_init(void) +{ + + decr_timecounter.tc_frequency = ticks_per_sec; + tc_init(&decr_timecounter); +} + + static unsigned decr_get_timecount(struct timecounter *tc) { Index: sys/powerpc/booke/pmap.c =================================================================== --- sys/powerpc/booke/pmap.c (wersja 192014) +++ sys/powerpc/booke/pmap.c (kopia robocza) @@ -79,7 +79,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include @@ -122,8 +122,11 @@ vm_size_t kernsize; static vm_offset_t data_start; static vm_size_t data_end; -struct mem_region availmem_regions[MEM_REGIONS]; -int availmem_regions_sz; +/* Phys/avail memory regions. */ +static struct mem_region *availmem_regions; +static int availmem_regions_sz; +static struct mem_region *physmem_regions; +static int physmem_regions_sz; /* Reserved KVA space and mutex for mmu_booke_zero_page. */ static vm_offset_t zero_page_va; @@ -1013,6 +1016,10 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, * align all regions. Non-page aligned memory isn't very interesting * to us. Also, sort the entries for ascending addresses. */ + + /* Retrieve phys/avail mem regions */ + mem_regions(&physmem_regions, &physmem_regions_sz, + &availmem_regions, &availmem_regions_sz); sz = 0; cnt = availmem_regions_sz; debugf("processing avail regions:\n"); Index: sys/powerpc/booke/platform_bare.c =================================================================== --- sys/powerpc/booke/platform_bare.c (wersja 0) +++ sys/powerpc/booke/platform_bare.c (wersja 0) @@ -0,0 +1,185 @@ +/*- + * Copyright (c) 2008-2009 Semihalf, Rafal Jaworowski + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "platform_if.h" + +static int cpu; + +static int bare_probe(platform_t); +static void bare_mem_regions(platform_t, struct mem_region **phys, int *physsz, + struct mem_region **avail, int *availsz); +static u_long bare_timebase_freq(platform_t, struct cpuref *cpuref); +static int bare_smp_first_cpu(platform_t, struct cpuref *cpuref); +static int bare_smp_next_cpu(platform_t, struct cpuref *cpuref); +static int bare_smp_get_bsp(platform_t, struct cpuref *cpuref); +static int bare_smp_start_cpu(platform_t, struct pcpu *cpu); + +static platform_method_t bare_methods[] = { + PLATFORMMETHOD(platform_probe, bare_probe), + PLATFORMMETHOD(platform_mem_regions, bare_mem_regions), + PLATFORMMETHOD(platform_timebase_freq, bare_timebase_freq), + + PLATFORMMETHOD(platform_smp_first_cpu, bare_smp_first_cpu), + PLATFORMMETHOD(platform_smp_next_cpu, bare_smp_next_cpu), + PLATFORMMETHOD(platform_smp_get_bsp, bare_smp_get_bsp), + PLATFORMMETHOD(platform_smp_start_cpu, bare_smp_start_cpu), + + { 0, 0 } +}; + +static platform_def_t bare_platform = { + "bare metal", + bare_methods, + 0 +}; + +PLATFORM_DEF(bare_platform); + +static int +bare_probe(platform_t plat) +{ + + return (BUS_PROBE_GENERIC); +} + +#define MEM_REGIONS 8 +static struct mem_region avail_regions[MEM_REGIONS]; + +void +bare_mem_regions(platform_t plat, struct mem_region **phys, int *physsz, + struct mem_region **avail, int *availsz) +{ + struct bi_mem_region *mr; + int i; + + /* Initialize memory regions table */ + mr = bootinfo_mr(); + for (i = 0; i < bootinfo->bi_mem_reg_no; i++, mr++) { + if (i == MEM_REGIONS) + break; + if (mr->mem_base < 1048576) { + avail_regions[i].mr_start = 1048576; + avail_regions[i].mr_size = mr->mem_size - + (1048576 - mr->mem_base); + } else { + avail_regions[i].mr_start = mr->mem_base; + avail_regions[i].mr_size = mr->mem_size; + } + } + *availsz = i; + *avail = avail_regions; + + /* On the bare metal platform phys == avail memory */ + *physsz = *availsz; + *phys = *avail; +} + +static u_long +bare_timebase_freq(platform_t plat, struct cpuref *cpuref) +{ + u_long ticks = -1; + + /* + * Time Base and Decrementer are updated every 8 CCB bus clocks. + * HID0[SEL_TBCLK] = 0 + */ + ticks = bootinfo->bi_bus_clk / 8; + if (ticks <= 0) + panic("Unable to determine timebase frequency!"); + + return (ticks); +} + +static int +bare_smp_first_cpu(platform_t plat, struct cpuref *cpuref) +{ + + cpu = 0; + cpuref->cr_cpuid = cpu; + cpuref->cr_hwref = cpuref->cr_cpuid; + if (bootverbose) + printf("powerpc_smp_first_cpu: cpuid %d\n", cpuref->cr_cpuid); + cpu++; + + return (0); +} + +static int +bare_smp_next_cpu(platform_t plat, struct cpuref *cpuref) +{ + + if (cpu >= MAXCPU) + return (ENOENT); + + cpuref->cr_cpuid = cpu++; + cpuref->cr_hwref = cpuref->cr_cpuid; + if (bootverbose) + printf("powerpc_smp_next_cpu: cpuid %d\n", cpuref->cr_cpuid); + + return (0); +} + +static int +bare_smp_get_bsp(platform_t plat, struct cpuref *cpuref) +{ + + cpuref->cr_cpuid = mfspr(SPR_PIR); + cpuref->cr_hwref = cpuref->cr_cpuid; + + return (0); +} + +static int +bare_smp_start_cpu(platform_t plat, struct pcpu *pc) +{ + + /* No SMP support */ + return (ENXIO); +} Zmiany atrybutów dla: sys/powerpc/booke/platform_bare.c ___________________________________________________________________ Dodane: svn:mime-type + text/plain Dodane: svn:keywords + FreeBSD=%H Dodane: svn:eol-style + native Index: sys/powerpc/include/spr.h =================================================================== --- sys/powerpc/include/spr.h (wersja 192014) +++ sys/powerpc/include/spr.h (kopia robocza) @@ -419,6 +419,7 @@ #define SPR_DAC2 0x3f7 /* 4.. Data Address Compare 2 */ #define SPR_PIR 0x3ff /* .6. Processor Identification Register */ #elif defined(E500) +#define SPR_PIR 0x11e /* ..8 Processor Identification Register */ #define SPR_DBSR 0x130 /* ..8 Debug Status Register */ #define DBSR_IDE 0x80000000 /* Imprecise debug event. */ #define DBSR_UDE 0x40000000 /* Unconditional debug event. */ Index: sys/powerpc/include/pmap.h =================================================================== --- sys/powerpc/include/pmap.h (wersja 192014) +++ sys/powerpc/include/pmap.h (kopia robocza) @@ -143,7 +143,6 @@ struct md_page { TAILQ_HEAD(, pv_entry) pv_list; }; -#define MEM_REGIONS 8 #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) #endif /* AIM */ Index: sys/powerpc/include/md_var.h =================================================================== --- sys/powerpc/include/md_var.h (wersja 192014) +++ sys/powerpc/include/md_var.h (kopia robocza) @@ -55,7 +55,6 @@ void busdma_swi(void); int is_physical_memory(vm_offset_t addr); int mem_valid(vm_offset_t addr, int len); -void decr_config(unsigned long); void decr_init(void); void decr_tc_init(void); Index: sys/conf/files.powerpc =================================================================== --- sys/conf/files.powerpc (wersja 192014) +++ sys/conf/files.powerpc (kopia robocza) @@ -90,6 +91,7 @@ powerpc/booke/copyinout.c optional e500 powerpc/booke/interrupt.c optional e500 powerpc/booke/locore.S optional e500 no-obj powerpc/booke/machdep.c optional e500 +powerpc/booke/platform_bare.c optional mpc85xx powerpc/booke/pmap.c optional e500 powerpc/booke/swtch.S optional e500 powerpc/booke/trap.c optional e500