diff options
-rw-r--r-- | sys/dev/cons/cons.c | 7 | ||||
-rw-r--r-- | sys/include/dev/cons/cons.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/sys/dev/cons/cons.c b/sys/dev/cons/cons.c index 0de5590..4b85240 100644 --- a/sys/dev/cons/cons.c +++ b/sys/dev/cons/cons.c @@ -150,12 +150,16 @@ cons_handle_special(struct cons_screen *scr, char c) static int dev_write(dev_t dev, struct sio_txn *sio, int flags) { - char *p = sio->buf; + char *p; + + p = sio->buf; + spinlock_acquire(&g_root_scr.lock); for (size_t i = 0; i < sio->len; ++i) { cons_putch(&g_root_scr, p[i]); } + spinlock_release(&g_root_scr.lock); return sio->len; } @@ -220,6 +224,7 @@ cons_init(void) g_root_scr.nrows = fbdev.height / FONT_HEIGHT; g_root_scr.ncols = fbdev.width / FONT_WIDTH; g_root_scr.fbdev = fbdev; + memset(&g_root_scr.lock, 0, sizeof(g_root_scr.lock)); } /* diff --git a/sys/include/dev/cons/cons.h b/sys/include/dev/cons/cons.h index 3415617..8e2c2c6 100644 --- a/sys/include/dev/cons/cons.h +++ b/sys/include/dev/cons/cons.h @@ -31,6 +31,7 @@ #define _DEV_CONS_H_ #include <sys/types.h> +#include <sys/spinlock.h> #include <dev/video/fbdev.h> struct cons_char { @@ -53,6 +54,7 @@ struct cons_screen { uint32_t curs_col; /* Cursor col */ uint32_t curs_row; /* Cursor row */ struct cons_char last_chr; + struct spinlock lock; }; void cons_init(void); |