Changeset View
Changeset View
Standalone View
Standalone View
sys/powerpc/powerpc/platform.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_param.h> | |||||
#include <vm/vm_page.h> | #include <vm/vm_page.h> | ||||
#include <vm/vm_phys.h> | |||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/platform.h> | #include <machine/platform.h> | ||||
#include <machine/platformvar.h> | #include <machine/platformvar.h> | ||||
#include <machine/smp.h> | #include <machine/smp.h> | ||||
#include <machine/vmparam.h> | |||||
#include "platform_if.h" | #include "platform_if.h" | ||||
static platform_def_t *plat_def_impl; | static platform_def_t *plat_def_impl; | ||||
static platform_t plat_obj; | static platform_t plat_obj; | ||||
static struct kobj_ops plat_kernel_kops; | static struct kobj_ops plat_kernel_kops; | ||||
static struct platform_kobj plat_kernel_obj; | static struct platform_kobj plat_kernel_obj; | ||||
static char plat_name[64] = ""; | static char plat_name[64] = ""; | ||||
SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RD | CTLFLAG_TUN, | SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RD | CTLFLAG_TUN, | ||||
plat_name, 0, "Platform currently in use"); | plat_name, 0, "Platform currently in use"); | ||||
static struct mem_affinity mem_info[VM_PHYSSEG_MAX + 1]; | |||||
static int vm_locality_table[MAXMEMDOM * MAXMEMDOM]; | |||||
static struct mem_region pregions[PHYS_AVAIL_SZ]; | static struct mem_region pregions[PHYS_AVAIL_SZ]; | ||||
static struct numa_mem_region numa_pregions[PHYS_AVAIL_SZ]; | |||||
static struct mem_region aregions[PHYS_AVAIL_SZ]; | static struct mem_region aregions[PHYS_AVAIL_SZ]; | ||||
static int npregions, naregions; | static int nnumapregions, npregions, naregions; | ||||
/* | /* | ||||
* Memory region utilities: determine if two regions overlap, | * Memory region utilities: determine if two regions overlap, | ||||
* and merge two overlapping regions into one | * and merge two overlapping regions into one | ||||
*/ | */ | ||||
static int | static int | ||||
memr_overlap(struct mem_region *r1, struct mem_region *r2) | memr_overlap(struct mem_region *r1, struct mem_region *r2) | ||||
{ | { | ||||
Show All 24 Lines | mr_cmp(const void *a, const void *b) | ||||
regiona = a; | regiona = a; | ||||
regionb = b; | regionb = b; | ||||
if (regiona->mr_start < regionb->mr_start) | if (regiona->mr_start < regionb->mr_start) | ||||
return (-1); | return (-1); | ||||
else if (regiona->mr_start > regionb->mr_start) | else if (regiona->mr_start > regionb->mr_start) | ||||
return (1); | return (1); | ||||
else | else | ||||
return (0); | return (0); | ||||
} | |||||
void | |||||
markj: Extra newline. | |||||
numa_mem_regions(struct numa_mem_region **phys, int *physsz) | |||||
{ | |||||
struct mem_affinity *mi; | |||||
int i, j, maxdom, ndomain, offset; | |||||
nnumapregions = 0; | |||||
PLATFORM_NUMA_MEM_REGIONS(plat_obj, numa_pregions, &nnumapregions); | |||||
if (physsz != NULL) | |||||
*physsz = nnumapregions; | |||||
if (phys != NULL) | |||||
*phys = numa_pregions; | |||||
if (physsz == NULL || phys == NULL) { | |||||
printf("unset value\n"); | |||||
return; | |||||
Not Done Inline ActionsIt'd probably be nice to say which. markj: It'd probably be nice to say which. | |||||
} | |||||
maxdom = 0; | |||||
for (i = 0; i < nnumapregions; i++) | |||||
if (numa_pregions[i].mr_domain > maxdom) | |||||
maxdom = numa_pregions[i].mr_domain; | |||||
mi = mem_info; | |||||
for (i = 0; i < nnumapregions; i++, mi++) { | |||||
mi->start = numa_pregions[i].mr_start; | |||||
mi->end = numa_pregions[i].mr_start + numa_pregions[i].mr_size; | |||||
mi->domain = numa_pregions[i].mr_domain; | |||||
} | |||||
offset = 0; | |||||
vm_locality_table[offset] = 10; | |||||
ndomain = maxdom + 1; | |||||
if (ndomain > 1) { | |||||
for (i = 0; i < ndomain; i++) { | |||||
for (j = 0; j < ndomain; j++) { | |||||
/* | |||||
* Not sure what these values should actually be | |||||
*/ | |||||
if (i == j) | |||||
vm_locality_table[offset] = 10; | |||||
else | |||||
vm_locality_table[offset] = 21; | |||||
offset++; | |||||
} | |||||
} | |||||
} | |||||
vm_phys_register_domains(ndomain, mem_info, vm_locality_table); | |||||
} | } | ||||
Not Done Inline ActionsThe locality table is optional, you can just pass NULL. markj: The locality table is optional, you can just pass NULL. | |||||
void | void | ||||
mem_regions(struct mem_region **phys, int *physsz, struct mem_region **avail, | mem_regions(struct mem_region **phys, int *physsz, struct mem_region **avail, | ||||
int *availsz) | int *availsz) | ||||
{ | { | ||||
int i, j, still_merging; | int i, j, still_merging; | ||||
if (npregions == 0) { | if (npregions == 0) { | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
PLATFORM_SMP_PROBE_THREADS(plat_obj); | PLATFORM_SMP_PROBE_THREADS(plat_obj); | ||||
} | } | ||||
#ifdef SMP | #ifdef SMP | ||||
struct cpu_group * | struct cpu_group * | ||||
cpu_topo(void) | cpu_topo(void) | ||||
{ | { | ||||
return (PLATFORM_SMP_TOPO(plat_obj)); | return (PLATFORM_SMP_TOPO(plat_obj)); | ||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* Reset back to firmware. | * Reset back to firmware. | ||||
*/ | */ | ||||
void | void | ||||
cpu_reset() | cpu_reset() | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |
Extra newline.