aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/debug.c9
-rw-r--r--common/fdt.c15
-rw-r--r--common/main.c7
-rw-r--r--common/pmem.c8
-rw-r--r--common/proc.c6
5 files changed, 20 insertions, 25 deletions
diff --git a/common/debug.c b/common/debug.c
index ff9dc18..526bfdc 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -199,14 +199,15 @@ static struct dbg_info __dbg_from_fdt(const void *fdt)
enum serial_dev dev = __serial_dev_enum(dev_name);
/* get serial device address */
- struct cell_info ci = get_reginfo(fdt, stdout);
- void *reg_ptr = (void *)fdt_getprop(fdt, stdout_offset, "reg", NULL);
+ const void *reg_ptr = fdt_getprop(fdt, stdout_offset, "reg", NULL);
+ struct cell_info ci = get_cellinfo(fdt, stdout_offset);
pm_t dbg_ptr = (pm_t)fdt_load_reg_addr(ci, reg_ptr, 0);
/* get serial device offset if present */
size_t shift = 0;
- void *shift_ptr = (void *)fdt_getprop(fdt, stdout_offset, "reg-shift",
- NULL);
+ const void *shift_ptr = fdt_getprop(fdt, stdout_offset, "reg-shift",
+ NULL);
+
if (shift_ptr)
shift = (size_t)fdt_load_int32_ptr(shift_ptr);
diff --git a/common/fdt.c b/common/fdt.c
index 3f20d72..677be7b 100644
--- a/common/fdt.c
+++ b/common/fdt.c
@@ -13,18 +13,3 @@ struct cell_info get_cellinfo(const void *fdt, const int offset)
return (struct cell_info){ fdt_size_cells(fdt, offset),
fdt_address_cells(fdt, offset) };
}
-
-/* how "reg" is interpreted depends on the parent node */
-struct cell_info get_reginfo(const void *fdt, const char *path)
-{
- const char *i = strrchr(path, '/');
- if (!i)
- return (struct cell_info){ 0, 0 };
-
- size_t baselen = i - path;
- if (baselen == 0)
- /* root node */
- baselen = 1;
-
- return get_cellinfo(fdt, fdt_path_offset_namelen(fdt, path, baselen));
-}
diff --git a/common/main.c b/common/main.c
index 30d9ed5..7291387 100644
--- a/common/main.c
+++ b/common/main.c
@@ -15,6 +15,7 @@
#include <kmi/irq.h>
#include <arch/arch.h>
#include <arch/proc.h>
+#include <arch/smp.h>
#include <libfdt.h>
/**
@@ -51,9 +52,9 @@ void __main main(void *fdt, uintptr_t ram_base)
init_irq(fdt);
init_timer(fdt);
init_proc(fdt);
- /* free temporary virtual memory now that we're in the init process
- * space */
- destroy_vmem(b);
+
+ /* try to bring up other cores on system */
+ smp_bringup(b, fdt);
/* start running init program */
run_init(cur_tcb(), fdt);
diff --git a/common/pmem.c b/common/pmem.c
index 02c5146..ed79e4a 100644
--- a/common/pmem.c
+++ b/common/pmem.c
@@ -550,7 +550,7 @@ static void __mark_area_used(pm_t base, pm_t top)
static void __mark_reserved_mem(void *fdt)
{
int rmem_offset = fdt_path_offset(fdt, "/reserved-memory");
- struct cell_info ci = get_reginfo(fdt, "/reserved-memory");
+ struct cell_info ci = get_cellinfo(fdt, rmem_offset);
int node = 0;
fdt_for_each_subnode(node, fdt, rmem_offset) {
@@ -576,10 +576,12 @@ static void __mark_reserved_mem(void *fdt)
*/
static pm_t __get_ramtop(void *fdt)
{
- struct cell_info ci = get_reginfo(fdt, "/memory");
int mem_offset = fdt_path_offset(fdt, "/memory");
- uint8_t *mem_reg = (uint8_t *)fdt_getprop(fdt, mem_offset, "reg", NULL);
+ const void *mem_reg = fdt_getprop(fdt, mem_offset, "reg", NULL);
+ /* here we actually want the root offset because /memory itself doesn't
+ * have children, I guess? */
+ struct cell_info ci = get_cellinfo(fdt, fdt_path_offset(fdt, "/"));
pm_t base = (pm_t)fdt_load_reg_addr(ci, mem_reg, 0);
return (pm_t)fdt_load_reg_size(ci, mem_reg, 0) + base;
}
diff --git a/common/proc.c b/common/proc.c
index 0f0c7f8..e6c2769 100644
--- a/common/proc.c
+++ b/common/proc.c
@@ -36,6 +36,12 @@ stat_t init_proc(void *fdt)
if (!t)
return ERR_OOMEM;
+ /* we're the first cpu, so we always have ID 0 */
+ t->cpu_id = 0;
+
+ /* force tcb for core */
+ tcb_assign(t);
+
/* set current tcb */
use_tcb(t);