diff options
-rw-r--r-- | sys/arch/mips64/include/cpu.h | 8 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/cpu.c | 43 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/ip30_machdep.c | 17 |
3 files changed, 47 insertions, 21 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h index d8745b50de0..1e63b266381 100644 --- a/sys/arch/mips64/include/cpu.h +++ b/sys/arch/mips64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.44 2009/11/22 18:33:48 syuu Exp $ */ +/* $OpenBSD: cpu.h,v 1.45 2009/11/24 22:46:59 syuu Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -365,7 +365,7 @@ extern vaddr_t uncached_base; #include <machine/intr.h> struct cpu_info { - struct device ci_dev; /* our device */ + struct device *ci_dev; /* our device */ struct cpu_info *ci_self; /* pointer to this structure */ struct cpu_info *ci_next; /* next cpu */ struct proc *ci_curproc; @@ -397,7 +397,7 @@ extern struct cpu_info *cpu_info_list; #define CPU_INFO_FOREACH(cii, ci) for (cii = 0, ci = cpu_info_list; \ ci != NULL; ci = ci->ci_next) -#define CPU_INFO_UNIT(ci) ((ci)->ci_dev.dv_unit) +#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0) #ifdef MULTIPROCESSOR #define MAXCPUS 4 @@ -412,6 +412,8 @@ void cpu_boot_secondary_processors(void); #define cpu_boot_secondary(ci) hw_cpu_boot_secondary(ci) #define cpu_hatch(ci) hw_cpu_hatch(ci) +vaddr_t smp_malloc(size_t); + #include <sys/mplock.h> #else #define MAXCPUS 1 diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c index 4a9e39254c0..8018883b62c 100644 --- a/sys/arch/mips64/mips64/cpu.c +++ b/sys/arch/mips64/mips64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.17 2009/11/22 19:41:41 syuu Exp $ */ +/* $OpenBSD: cpu.c,v 1.18 2009/11/24 22:46:59 syuu Exp $ */ /* * Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se) @@ -31,6 +31,7 @@ #include <sys/proc.h> #include <sys/user.h> #include <sys/device.h> +#include <sys/malloc.h> #include <machine/cpu.h> #include <machine/autoconf.h> @@ -70,7 +71,7 @@ u_int CpuOnboardCacheOn; /* RM7K */ int cpu_is_rm7k = 0; struct cfattach cpu_ca = { - sizeof(struct cpu_info), cpumatch, cpuattach + sizeof(struct device), cpumatch, cpuattach }; struct cfdriver cpu_cd = { NULL, "cpu", DV_DULL, NULL, 0 @@ -94,7 +95,7 @@ cpumatch(struct device *parent, void *match, void *aux) void cpuattach(struct device *parent, struct device *dev, void *aux) { - struct cpu_info *ci = (struct cpu_info *)dev; + struct cpu_info *ci; int cpuno = dev->dv_unit; int isr16k = 0; int displayver; @@ -105,18 +106,21 @@ cpuattach(struct device *parent, struct device *dev, void *aux) ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY; cpuset_add(&cpus_running, ci); #endif - bcopy(dev, &ci->ci_dev, sizeof *dev); } #ifdef MULTIPROCESSOR else { + ci = (struct cpu_info *)smp_malloc(sizeof(*ci)); + if (ci == NULL) + panic("unable to allocate cpu_info\n"); ci->ci_next = cpu_info_list->ci_next; cpu_info_list->ci_next = ci; ci->ci_flags |= CPUF_PRESENT; + cpu_info[cpuno] = ci; } - cpu_info[cpuno] = ci; #endif ci->ci_self = ci; ci->ci_cpuid = cpuno; + ci->ci_dev = dev; printf(": "); @@ -331,4 +335,33 @@ void cpu_unidle(struct cpu_info *ci) { } + +vaddr_t +smp_malloc(size_t size) +{ + struct pglist mlist; + struct vm_page *m; + int error; + vaddr_t va; + paddr_t pa; + + if (size < PAGE_SIZE) { + va = (vaddr_t)malloc(size, M_DEVBUF, M_NOWAIT); + if (va == NULL) + return NULL; + error = pmap_extract(pmap_kernel(), va, &pa); + if (error == FALSE) + return NULL; + } else { + TAILQ_INIT(&mlist); + error = uvm_pglistalloc(size, 0, -1L, 0, 0, + &mlist, 1, UVM_PLA_NOWAIT); + if (error) + return NULL; + m = TAILQ_FIRST(&mlist); + pa = VM_PAGE_TO_PHYS(m); + } + + return PHYS_TO_XKPHYS(pa, CCA_CACHED); +} #endif diff --git a/sys/arch/sgi/sgi/ip30_machdep.c b/sys/arch/sgi/sgi/ip30_machdep.c index 19c4af6db4d..e58de56008f 100644 --- a/sys/arch/sgi/sgi/ip30_machdep.c +++ b/sys/arch/sgi/sgi/ip30_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30_machdep.c,v 1.22 2009/11/22 22:44:58 syuu Exp $ */ +/* $OpenBSD: ip30_machdep.c,v 1.23 2009/11/24 22:46:59 syuu Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -188,7 +188,7 @@ ip30_autoconf(struct device *parent) config_found(parent, &maa, mbprint); int cpuid; - for(cpuid = 1; cpuid < MAX_CPUS; cpuid++) + for(cpuid = 1; cpuid < MAXCPUS; cpuid++) if (ip30_cpu_exists(cpuid) == 0) { ncpusfound++; #ifdef MULTIPROCESSOR @@ -307,9 +307,6 @@ void hw_cpu_boot_secondary(struct cpu_info *ci) { int cpuid = ci->ci_cpuid; - struct pglist mlist; - struct vm_page *m; - int error; vaddr_t kstack; #ifdef DEBUG @@ -345,15 +342,9 @@ hw_cpu_boot_secondary(struct cpu_info *ci) scachesz, fanloads, launch, rndvz, stackaddr, lparam, rparam, idleflag); #endif - - TAILQ_INIT(&mlist); - error = uvm_pglistalloc(USPACE, 0, -1L, 0, 0, - &mlist, 1, UVM_PLA_WAITOK); - if (error) + kstack = smp_malloc(USPACE); + if (kstack == NULL) panic("unable to allocate idle stack\n"); - - m = TAILQ_FIRST(&mlist); - kstack = (vaddr_t)PHYS_TO_XKPHYS(VM_PAGE_TO_PHYS(m), CCA_CACHED); bzero((char *)kstack, USPACE); *(volatile uint64_t *)(mpconf + MPCONF_STACKADDR(cpuid)) = |