summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/cons/cons.c7
-rw-r--r--sys/include/dev/cons/cons.h2
-rw-r--r--sys/include/sys/termios.h54
3 files changed, 62 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);
diff --git a/sys/include/sys/termios.h b/sys/include/sys/termios.h
new file mode 100644
index 0000000..b2d3c8a
--- /dev/null
+++ b/sys/include/sys/termios.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _TERMIOS_H_
+#define _TERMIOS_H_
+
+/*
+ * c_iflag: Input flags
+ */
+#define ISTRIP 0x00000000
+#define ICRNL 0x00000001
+#define ISTRIP 0x00000002
+
+#define NCCS 20
+
+typedef unsigned int cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+struct termios {
+ tcflag_t c_iflag; /* Input flags */
+ tcflag_t c_oflag; /* Output flags */
+ tcflag_t c_cflag; /* Control flags */
+ tcflag_t c_lflag; /* Local flags */
+ c_cc[NCCS];
+};
+
+#endif /* _TERMIOS_H_ */