summaryrefslogtreecommitdiff
path: root/demo/main.c
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-10-03 23:16:08 -0600
committerAlejandro Soto <alejandro@34project.org>2023-10-03 23:16:08 -0600
commit3de42a19661a3d6d24de46ca2920b06e1dc88fe0 (patch)
treeacdd022a14d43d60dbfec1f4df8c634e0d080ec0 /demo/main.c
parent1094451235282af6a9daba2b2a460577f82d289c (diff)
demo: initial commit
Diffstat (limited to 'demo/main.c')
-rw-r--r--demo/main.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/demo/main.c b/demo/main.c
new file mode 100644
index 0000000..b984d6f
--- /dev/null
+++ b/demo/main.c
@@ -0,0 +1,44 @@
+#include "demo.h"
+
+static struct cpu cpu0, cpu1, cpu2, cpu3;
+
+struct cpu *__cpus[] = { &cpu0, &cpu1, &cpu2, &cpu3 };
+
+void bsp_main(void)
+{
+ run_cpu(1);
+
+ while (!cpus_ready());
+ print("booted %u cpus", NUM_CPUS);
+
+ while (1) {
+ }
+}
+
+void ap_main(void)
+{
+ if (this_cpu->num < NUM_CPUS - 1)
+ run_cpu(this_cpu->num + 1);
+
+ halt_cpu(this_cpu->num);
+
+ while (1) {
+ }
+}
+
+void reset(void)
+{
+ if (this_cpu->num == 0) {
+ console_init();
+
+ for (struct cpu **cpu = __cpus; cpu < __cpus + NUM_CPUS; ++cpu) {
+ }
+ }
+
+ print("core taken out of reset");
+
+ if (this_cpu->num == 0)
+ bsp_main();
+ else
+ ap_main();
+}