aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-06-04 00:48:15 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-06-04 00:48:15 +0300
commit52e5c94314fa8e10efded82db85d181ed32f00bd (patch)
tree869dd5a01c24effe32266518d057c87106c73a44 /common
parent3ace1ddd76b9c04f3ed23883de6279b4485612e8 (diff)
downloadkmi-52e5c94314fa8e10efded82db85d181ed32f00bd.tar.gz
kmi-52e5c94314fa8e10efded82db85d181ed32f00bd.zip
visionfive2 boots until debugging is initialized
Diffstat (limited to 'common')
-rw-r--r--common/debug.c14
-rw-r--r--common/string.c8
2 files changed, 17 insertions, 5 deletions
diff --git a/common/debug.c b/common/debug.c
index 2cd4570..346934a 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -123,6 +123,12 @@ static struct uart_8250 *port = 0;
*/
static int __serial_tx_empty()
{
+ /**
+ * @todo visionfive2 loops on lsr indefinitely, why?
+ * answer: because apparently visionfive2 uart has reg-shift = 2,
+ * meaning the registers are spaced apart more in memory than my naive
+ * struct.
+ * */
return port->lsr & LSR_THRE;
}
@@ -177,7 +183,13 @@ static struct dbg_info __dbg_from_fdt(const void *fdt)
const char *stdout =
fdt_getprop(fdt, chosen_offset, "stdout-path", NULL);
- int stdout_offset = fdt_path_offset(fdt, stdout);
+ /* discard options */
+ size_t baselen = strlen(stdout);
+ const char *options = strchr(stdout, ':');
+ if (options)
+ baselen = options - stdout;
+
+ int stdout_offset = fdt_path_offset_namelen(fdt, stdout, baselen);
/* get serial device type */
const char *dev_name = (const char *)fdt_getprop(fdt, stdout_offset,
diff --git a/common/string.c b/common/string.c
index a76c875..359a938 100644
--- a/common/string.c
+++ b/common/string.c
@@ -105,13 +105,13 @@ __weak char *strchr(const char *str, int chr)
const char *s1 = str;
ssize_t num = strlen(s1);
- while (num-- && *(s1--) != chr)
+ while (num-- && *(s1++) != chr)
;
if (num < 0)
return 0;
- return (char *)(s1 + 1);
+ return (char *)(s1 - 1);
}
#undef strtok
@@ -339,10 +339,10 @@ static int __hexval(char c)
return c - '0';
if (c >= 'a' && c <= 'f')
- return c - 'a';
+ return 10 + c - 'a';
if (c >= 'A' && c <= 'F')
- return c - 'A';
+ return 10 + c - 'A';
return -1;
}