diff options
-rw-r--r-- | kern/cpumap.c | 20 | ||||
-rw-r--r-- | kern/cpumap.h | 5 |
2 files changed, 24 insertions, 1 deletions
diff --git a/kern/cpumap.c b/kern/cpumap.c index a76450b7..68a84ab9 100644 --- a/kern/cpumap.c +++ b/kern/cpumap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Richard Braun. + * Copyright (c) 2013-2014 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,15 +19,33 @@ #include <kern/cpumap.h> #include <kern/error.h> #include <kern/kmem.h> +#include <kern/param.h> #include <kern/stddef.h> +#include <machine/cpu.h> + +static struct cpumap cpumap_active_cpus __read_mostly; static struct kmem_cache cpumap_cache; void cpumap_setup(void) { + unsigned int i, nr_cpus; + kmem_cache_init(&cpumap_cache, "cpumap", sizeof(struct cpumap), 0, NULL, NULL, NULL, 0); + + cpumap_zero(&cpumap_active_cpus); + nr_cpus = cpu_count(); + + for (i = 0; i < nr_cpus; i++) + cpumap_set(&cpumap_active_cpus, i); +} + +const struct cpumap * +cpumap_all(void) +{ + return &cpumap_active_cpus; } int diff --git a/kern/cpumap.h b/kern/cpumap.h index 9cbdfa15..0e57c30d 100644 --- a/kern/cpumap.h +++ b/kern/cpumap.h @@ -140,6 +140,11 @@ cpumap_find_first_zero(const struct cpumap *cpumap) void cpumap_setup(void); /* + * Return a cpumap representing all active processors. + */ +const struct cpumap * cpumap_all(void); + +/* * Allocate a CPU map. * * The new map is uninitialized. |