diff options
author | Andrew Waterman <andrew@sifive.com> | 2021-03-26 15:19:30 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2021-03-26 15:19:30 -0700 |
commit | 75bbd1ecfac34ed20f88234872f66d7f670da4d2 (patch) | |
tree | e4c0d427d630bbc951cfb4b374641fb509775e90 /pk | |
parent | 168c5cac036cbc92c86f947372441d58ca0d10f2 (diff) | |
download | pk-75bbd1ecfac34ed20f88234872f66d7f670da4d2.zip pk-75bbd1ecfac34ed20f88234872f66d7f670da4d2.tar.gz pk-75bbd1ecfac34ed20f88234872f66d7f670da4d2.tar.bz2 |
pk: support printk before file init
Diffstat (limited to 'pk')
-rw-r--r-- | pk/console.c | 4 | ||||
-rw-r--r-- | pk/file.h | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/pk/console.c b/pk/console.c index 3d3edae..90742d1 100644 --- a/pk/console.c +++ b/pk/console.c @@ -4,6 +4,7 @@ #include "mmap.h" #include "file.h" #include "frontend.h" +#include "bits.h" #include <stdint.h> #include <stdarg.h> @@ -11,7 +12,8 @@ static void vprintk(const char* s, va_list vl) { char out[256]; // XXX int res = vsnprintf(out, sizeof(out), s, vl); - file_write(stderr, out, res < sizeof(out) ? res : sizeof(out)); + int size = MIN(res, sizeof(out)); + frontend_syscall(SYS_write, 2, kva2pa(out), size, 0, 0, 0, 0); } void printk(const char* s, ...) @@ -14,9 +14,6 @@ typedef struct file } file_t; extern file_t files[]; -#define stdin (files + 0) -#define stdout (files + 1) -#define stderr (files + 2) file_t* file_get(int fd); file_t* file_open(const char* fn, int flags, int mode); |