summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--demo/demo.h1
-rw-r--r--demo/main.c19
-rw-r--r--demo/smp.c7
3 files changed, 11 insertions, 16 deletions
diff --git a/demo/demo.h b/demo/demo.h
index ca6199e..f01b36c 100644
--- a/demo/demo.h
+++ b/demo/demo.h
@@ -26,7 +26,6 @@ void console_init(void);
void print(const char *fmt, ...);
void read_line(char *vuf, unsigned size);
-int cpus_ready(void);
void run_cpu(unsigned num);
void run_cpus(unsigned mask);
void halt_cpu(unsigned num);
diff --git a/demo/main.c b/demo/main.c
index 10067d2..40e903c 100644
--- a/demo/main.c
+++ b/demo/main.c
@@ -4,6 +4,8 @@ static struct cpu cpu0, cpu1, cpu2, cpu3;
struct cpu *__cpus[] = { &cpu0, &cpu1, &cpu2, &cpu3 };
+volatile static unsigned boot_done;
+
static void cmd_run(char **tokens)
{
unsigned mask;
@@ -53,11 +55,12 @@ static void cmd_cache(char **tokens)
cache_debug(cpu, ptr);
}
-void bsp_main(void)
+static void bsp_main(void)
{
+ boot_done = 0;
run_cpu(1);
- while (!cpus_ready());
+ while (!boot_done);
print("booted %u cpus", NUM_CPUS);
while (1) {
@@ -85,10 +88,12 @@ void bsp_main(void)
}
}
-void ap_main(void)
+static void ap_main(void)
{
if (this_cpu->num < NUM_CPUS - 1)
run_cpu(this_cpu->num + 1);
+ else
+ boot_done = 1;
halt_cpu(this_cpu->num);
@@ -98,14 +103,10 @@ void ap_main(void)
void reset(void)
{
- if (this_cpu->num == 0) {
+ if (this_cpu->num == 0)
console_init();
- for (struct cpu **cpu = __cpus; cpu < __cpus + NUM_CPUS; ++cpu) {
- }
- }
-
- print("core taken out of reset");
+ print("exited reset");
if (this_cpu->num == 0)
bsp_main();
diff --git a/demo/smp.c b/demo/smp.c
index 6f8e54a..4357d35 100644
--- a/demo/smp.c
+++ b/demo/smp.c
@@ -3,11 +3,6 @@
#define SMP_CTRL_BASE 0x30140000
#define SMP_CTRL (*(volatile unsigned *)SMP_CTRL_BASE)
-int cpus_ready(void)
-{
- return SMP_CTRL == 0;
-}
-
void run_cpu(unsigned num)
{
run_cpus(1 << num);
@@ -32,7 +27,7 @@ void run_cpus(unsigned mask)
void halt_cpu(unsigned num)
{
- halt_cpu(1 << num);
+ halt_cpus(1 << num);
}
void halt_cpus(unsigned mask)