summaryrefslogtreecommitdiff
path: root/common/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/main.c')
-rw-r--r--common/main.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/common/main.c b/common/main.c
index a8fdf58..b53c4b0 100644
--- a/common/main.c
+++ b/common/main.c
@@ -57,6 +57,7 @@ extern char __image_copy_end[];
extern void __NO_RETURN tb_boot_linux(uintptr_t ep, uintptr_t fw_arg);
extern uintptr_t tb_dtb_relocate(uintptr_t dtb, void *scratch,
size_t scratch_size, size_t grow);
+extern int tb_gic_init(uintptr_t gicd, uintptr_t gicc);
extern int tb_dtb_add_chosen_prop(uintptr_t dtb, const char *name,
const void *val, size_t len);
static size_t initrd_size;
@@ -66,6 +67,23 @@ void tashaboot_main(uintptr_t fw_arg)
struct tb_image img;
int ret;
+ /*
+ * the console uart the machine named, before the first
+ * print. the base is the first reg pair of the pl011
+ * node, the same walk the gic used, no board hardcodes.
+ */
+ {
+ extern int tb_dtb_find_reg0(uintptr_t dtb,
+ const char *name,
+ uintptr_t *addr, size_t *size);
+ extern void tb_console_set_pl011(uintptr_t base);
+ uintptr_t uart = 0;
+ size_t usz = 0;
+
+ if (tb_dtb_find_reg0(fw_arg, "pl011", &uart, &usz) == 0)
+ tb_console_set_pl011(uart);
+ }
+
if (tb_console_init())
return;
@@ -165,6 +183,31 @@ void tashaboot_main(uintptr_t fw_arg)
}
fw_arg = newdtb;
+
+ /*
+ * the interrupt controller the machine told us
+ * about, found by name, the reg pair read with the
+ * root cell counts. the gic goes into the defined
+ * off state before the kernel brings its own irq
+ * handling up.
+ */
+ {
+ extern int tb_dtb_find_reg0(uintptr_t dtb,
+ const char *name,
+ uintptr_t *addr,
+ size_t *size);
+ uintptr_t gicd = 0;
+ uintptr_t gicc = 0;
+ size_t sz = 0;
+
+ if (tb_dtb_find_reg0(fw_arg, "intc", &gicd, &sz) == 0 &&
+ sz >= 0x10000) {
+ gicc = gicd + 0x10000;
+ tb_gic_init(gicd, gicc);
+ dprintf(ALWAYS, "gic: %lx off\n",
+ (unsigned long)gicd);
+ }
+ }
}
/*
@@ -210,6 +253,21 @@ void tashaboot_main(uintptr_t fw_arg)
dprintf(ALWAYS, "loaded %llu bytes at %lx, entry %lx\n",
(unsigned long long)img.size, img.load, img.ep);
+
+#ifdef TB_TEST_SMC
+ {
+ register uint64_t r0 asm("x0") = 0x84000000;
+ register uint64_t r1 asm("x1") = 0;
+ register uint64_t r2 asm("x2") = 0;
+ register uint64_t r3 asm("x3") = 0;
+
+ asm volatile("smc #0"
+ : "+r"(r0), "+r"(r1), "+r"(r2), "+r"(r3));
+ dprintf(ALWAYS, "smc conduit: psci version %lx\n",
+ (unsigned long)r0);
+ }
+#endif
+
dprintf(ALWAYS, "jumping\n");
tb_boot_linux(img.ep, fw_arg);