9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e075e52884b4572820ee494451a5994dfaa17d0f
parent 1d00a34a219af5734eba414ba53f4182595b45f6
Author: Ambroise Vincent <ambroise.vincent@arm.com>
Date:   Thu, 25 Apr 2019 12:47:06 +0100

[rom] Write directly to console ctl

Change-Id: I214842dac4d52a7aa97ead34dc7289afb66e7ef6
Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>

Diffstat:
Mdrivers/devcons.c | 14--------------
Mtarget/native/rom.c | 31++++++++++++-------------------
2 files changed, 12 insertions(+), 33 deletions(-)

diff --git a/drivers/devcons.c b/drivers/devcons.c @@ -371,20 +371,6 @@ consread(Chan *c, void *buf, int n) } } -void -conslink(Attr *attr) -{ - Attr *a; - int index = 0; - - for (a = attr; a->key; a++) { - if (!strcmp(a->key, "in")) - consaddin(a->value, strlen(a->value)); - else if (!strcmp(a->key, "out") && index < CONSOUT) - consaddout(a->value, strlen(a->value)); - } -} - const Dev consdevtab = { .id = 's', .walk = conswalk, diff --git a/target/native/rom.c b/target/native/rom.c @@ -83,22 +83,13 @@ info(Mach *mp) mp->sp, mp->stacksiz); } -/* - * TODO: This should be in devc.c. The way the rcode file is parsed should be - * modified to allow that. - */ -typedef struct attr Attr; - -struct attr { - char *key; - char *value; -}; - -extern void conslink(Attr *attr); - static void namespace(void) { + int fd; + static char setin[] = "addin /dev/uart0/raw\n"; + static char setout[] = "addout /dev/uart0/raw\n"; + if (open("#s0/raw", O_READ) != 0) { kerror("#s0/raw read"); goto error; @@ -124,12 +115,14 @@ namespace(void) goto error; } - /* - * TODO: This should be in devc.c. The way the rcode file is parsed should be - * modified to allow that. - */ - // Link required after bind - conslink((Attr []) {{"in", "/dev/uart0/raw"},{"out", "/dev/uart0/raw"},{0}}); + if ((fd = open("/dev/cons/ctl", O_WRITE)) < 0) + goto error; + if (write(fd, setin, sizeof(setin)) < 0) + goto error; + if (write(fd, setout, sizeof(setout)) < 0) + goto error; + if (close(fd) < 0) + goto error; if (mount("#F", "/fip", "/blobs/fip.bin") < 0) goto error;