aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-09-18 22:32:15 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2021-09-19 13:57:57 +0300
commit605c7d9258c129b66b76f1b55a8a6f3cea68c13e (patch)
tree22bd4fad07791d0bb514e711a3c5e185eed586a0 /arch
parentd95c714c8cfdc5818b0e0f0c99cf2e5be66de202 (diff)
downloadkmi-605c7d9258c129b66b76f1b55a8a6f3cea68c13e.tar.gz
kmi-605c7d9258c129b66b76f1b55a8a6f3cea68c13e.zip
Added fdt debug capability
+ For future reference, apos now requires initrd to be found in fdt.
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/conf/apos.its17
-rw-r--r--arch/riscv/conf/boot.cmd2
-rw-r--r--arch/riscv/conf/initrd.txt1
-rw-r--r--arch/riscv/init/init.c68
4 files changed, 57 insertions, 31 deletions
diff --git a/arch/riscv/conf/apos.its b/arch/riscv/conf/apos.its
index c3611dd..7c05044 100644
--- a/arch/riscv/conf/apos.its
+++ b/arch/riscv/conf/apos.its
@@ -18,6 +18,19 @@
algo = "sha1";
};
};
+
+ initrd {
+ description = "Gargabbio initrd";
+ data = /incbin/("initrd.txt");
+ type = "ramdisk";
+ arch = "riscv";
+ os = "apos";
+ compression = "none";
+ load = <0x88300000>;
+ hash-1 {
+ algo = "sha1";
+ };
+ };
};
configurations {
@@ -26,6 +39,10 @@
config {
description = "Default configuration";
kernel = "kernel";
+ ramdisk = "initrd";
+ hash-1 {
+ algo = "sha1";
+ };
};
};
};
diff --git a/arch/riscv/conf/boot.cmd b/arch/riscv/conf/boot.cmd
index 782c1e8..a7517fd 100644
--- a/arch/riscv/conf/boot.cmd
+++ b/arch/riscv/conf/boot.cmd
@@ -1,4 +1,4 @@
fdt move ${fdt_addr} ${fdt_addr_r}
fdt addr ${fdt_addr_r}
load ${devtype} ${devnum} ${kernel_addr_r} apos.itb
-bootm ${kernel_addr_r} - ${fdt_addr_r}
+bootm ${kernel_addr_r} ${kernel_addr_r} ${fdt_addr_r}
diff --git a/arch/riscv/conf/initrd.txt b/arch/riscv/conf/initrd.txt
new file mode 100644
index 0000000..e965047
--- /dev/null
+++ b/arch/riscv/conf/initrd.txt
@@ -0,0 +1 @@
+Hello
diff --git a/arch/riscv/init/init.c b/arch/riscv/init/init.c
index e12c351..105a23d 100644
--- a/arch/riscv/init/init.c
+++ b/arch/riscv/init/init.c
@@ -4,6 +4,7 @@
#include <apos/string.h>
#include <apos/debug.h>
#include <apos/pmem.h>
+#include <apos/utils.h>
#include <libfdt.h>
#include <pages.h>
#include <csr.h>
@@ -19,37 +20,17 @@ struct cell_info {
uint32_t addr_cells;
};
-struct cell_info get_cellinfo(void *fdt, int offset)
+static struct cell_info get_cellinfo(void *fdt, int offset)
{
-
- fdt32_t *size_ptr = 0;
- fdt32_t *addr_ptr = 0;
-
- while (offset) {
- size_ptr = (fdt32_t *) fdt_getprop(fdt, offset,
- "#size-cells", NULL);
-
- addr_ptr = (fdt32_t *) fdt_getprop(fdt, offset,
- "#address-cells", NULL);
-
- if (size_ptr && addr_ptr)
- break;
-
- /* dtc warns that this function is slow, but I don't care */
- offset = fdt_parent_offset(fdt, offset);
- }
-
- struct cell_info ret = {0};
-
- if (size_ptr && addr_ptr){
- ret.size_cells = fdt32_to_cpu(*size_ptr);
- ret.addr_cells = fdt32_to_cpu(*addr_ptr);
- }
+ struct cell_info ret = {
+ fdt_size_cells(fdt, offset),
+ fdt_address_cells(fdt, offset)
+ };
return ret;
}
-struct mem_layout get_memlayout(void *fdt)
+static struct mem_layout get_memlayout(void *fdt)
{
struct cell_info ci = get_cellinfo(fdt, 0);
@@ -82,7 +63,7 @@ struct mem_layout get_memlayout(void *fdt)
/* this should probably be improved in the future, possibly also moved
* somewhere? */
-enum serial_dev_t serial_dev_enum(const char *dev_name)
+static enum serial_dev_t serial_dev_enum(const char *dev_name)
{
if (strncmp("ns16550", dev_name, 7) == 0)
return NS16550A;
@@ -90,7 +71,7 @@ enum serial_dev_t serial_dev_enum(const char *dev_name)
return -1;
}
-void init_debug(void *fdt)
+static void init_debug(void *fdt)
{
int offset = fdt_path_offset(fdt, "/soc/uart");
@@ -114,14 +95,41 @@ void init_debug(void *fdt)
}
#else
-
#define init_debug(...)
-
#endif
+/* TODO: these */
+static pm_t get_kerneltop(void *fdt)
+{
+ return 0;
+}
+
+static pm_t get_initrdtop(void *fdt)
+{
+ return 0;
+}
+
+static pm_t get_fdttop(void *fdt)
+{
+ return 0;
+}
+
+static void setup_pmem(void *fdt)
+{
+ struct mem_layout pmem = get_memlayout(fdt);
+
+ pm_t kernel_top = get_kerneltop(fdt);
+ pm_t initrd_top = get_initrdtop(fdt);
+ pm_t fdt_top = get_fdttop(fdt);
+
+ pm_t top = MAX3(kernel_top, initrd_top, fdt_top);
+}
+
void __noreturn init(void *fdt)
{
init_debug(fdt);
+ dbg_fdt(fdt);
+ setup_pmem(fdt);
/* basic memory layout info */
struct mem_layout pmem = get_memlayout(fdt);