summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/include/ctype.h104
-rw-r--r--src/share/docs/kernel/iotap_naming.md25
-rw-r--r--src/sys/arch/amd64/isa/i8042.c2
-rw-r--r--src/sys/include/io/cons/cons.h2
-rw-r--r--src/sys/include/sys/fbdev.h2
-rw-r--r--src/sys/io/cons/cons.c66
6 files changed, 199 insertions, 2 deletions
diff --git a/src/lib/libc/include/ctype.h b/src/lib/libc/include/ctype.h
new file mode 100644
index 0000000..eafbedd
--- /dev/null
+++ b/src/lib/libc/include/ctype.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2025 Ian Marco Moffett and L5 engineers
+ * 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 the project 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 _CTYPE_H
+#define _CTYPE_H 1
+
+#include <sys/param.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+__always_inline static inline int
+__isascii(int c)
+{
+ return c >= 0 && c <= 127;
+}
+
+__always_inline static inline int
+__tolower(int c)
+{
+ return c | 0x20;
+}
+
+__always_inline static inline int
+__toupper(int c)
+{
+ return c & ~0x20;
+}
+
+__always_inline static inline int
+__isalpha(int c)
+{
+ c = __tolower(c);
+ return c >= 'a' && c <= 'z';
+}
+
+__always_inline static inline int
+__isdigit(int c)
+{
+ return c >= '0' && c <= '9';
+}
+
+__always_inline static inline int
+__isspace(int c)
+{
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ case '\v':
+ return 1;
+
+ return 0;
+ }
+}
+
+__END_DECLS
+
+/* Conver char to lowercase */
+#define tolower(C) __tolower((C))
+
+/* Conver char to uppercase */
+#define toupper(C) __toupper((C))
+
+/* Is alphabetical? */
+#define isalpha(C) __isalpha((C))
+
+/* Is a digit? */
+#define isdigit(C) __isdigit((C))
+
+/* Is a space? */
+#define isspace(C) __isspace((C))
+
+/* Is ascii? */
+#define isascii(C) __isascii((C))
+
+#endif /* _CTYPE_H */
diff --git a/src/share/docs/kernel/iotap_naming.md b/src/share/docs/kernel/iotap_naming.md
new file mode 100644
index 0000000..d33faa7
--- /dev/null
+++ b/src/share/docs/kernel/iotap_naming.md
@@ -0,0 +1,25 @@
+# I/O tap naming standard
+
+Author: Ian Marco Moffett and the OSMORA Standards Group
+
+## Convention
+
+All names must be delimited with the '.' character. For example,
+all input devices must be named at 'input.*'
+
+
+## Common prefixes / classes
+
+```
+input.* - input devices
+output.* - output devices
+```
+
+## Standard input device list
+
+- iokbd: Integrated keyboard
+
+## Standard output device list
+
+- fbdev: Framebuffer devices:
+ [subnames: fbdev.attr (attributes)]
diff --git a/src/sys/arch/amd64/isa/i8042.c b/src/sys/arch/amd64/isa/i8042.c
index 9bbd85d..f1dc3a0 100644
--- a/src/sys/arch/amd64/isa/i8042.c
+++ b/src/sys/arch/amd64/isa/i8042.c
@@ -292,7 +292,7 @@ static struct iotap_ops tap_port0_ops = {
};
static struct iotap_desc tap_port0 = {
- .name = "i8042.port.0",
+ .name = "input.igkbd",
.ops = &tap_port0_ops
};
diff --git a/src/sys/include/io/cons/cons.h b/src/sys/include/io/cons/cons.h
index 4ae99a0..6b5c4f1 100644
--- a/src/sys/include/io/cons/cons.h
+++ b/src/sys/include/io/cons/cons.h
@@ -39,6 +39,8 @@ struct cons_scr {
struct bootvar_fb fbvars;
size_t text_x;
size_t text_y;
+ size_t cursor_x;
+ size_t cursor_y;
size_t max_col;
size_t max_row;
uint32_t scr_bg;
diff --git a/src/sys/include/sys/fbdev.h b/src/sys/include/sys/fbdev.h
index 2acddbf..e6f5d8f 100644
--- a/src/sys/include/sys/fbdev.h
+++ b/src/sys/include/sys/fbdev.h
@@ -35,7 +35,7 @@
#include <stdint.h>
#endif /* !_KERNEL */
-#define FBDEV_NSO "video:attr"
+#define FBDEV_NSO "output.fbdev.attr"
struct fb_info {
uint32_t width;
diff --git a/src/sys/io/cons/cons.c b/src/sys/io/cons/cons.c
index d9ebb5c..a2b37c3 100644
--- a/src/sys/io/cons/cons.c
+++ b/src/sys/io/cons/cons.c
@@ -42,6 +42,9 @@
#define FONT_WIDTH 8
#define FONT_HEIGHT 20
+#define CURSOR_WIDTH FONT_WIDTH
+#define CURSOR_HEIGHT 4
+
struct cons_scr g_root_scr;
/* Forward declarations */
@@ -64,6 +67,53 @@ fb_get_index(uint32_t pitch, uint32_t x, uint32_t y)
}
/*
+ * Invert an RGB color
+ *
+ * @rgb: Color to invert
+ *
+ * Returns inverted color code (RGB)
+ */
+__always_inline static inline uint32_t
+rgb_invert(uint32_t rgb)
+{
+ return (0xFFFFFF - rgb);
+}
+
+/*
+ * Draw the text cursor onto the screen
+ *
+ * @scr: Screen to draw onto
+ * @hide: True if it should be hidden
+ */
+static void
+cons_draw_cursor(struct cons_scr *scr, bool hide)
+{
+ struct bootvar_fb *fbvars;
+ uint32_t *fbio, idx;
+ uint32_t color;
+
+ if (scr == NULL) {
+ return;
+ }
+
+ fbvars = &scr->fbvars;
+ fbio = fbvars->io;
+
+ for (uint32_t cy = 0; cy < CURSOR_HEIGHT; ++cy) {
+ for (uint32_t cx = 0; cx < CURSOR_WIDTH; ++cx) {
+ idx = fb_get_index(
+ fbvars->pitch,
+ cx + scr->cursor_x,
+ (cy + scr->cursor_y) + FONT_HEIGHT / 2
+ );
+
+ color = (hide) ? scr->scr_bg : rgb_invert(scr->scr_bg);
+ fbio[idx] = color;
+ }
+ }
+}
+
+/*
* Write a newline onto the console and handle
* Y overflows
*
@@ -75,12 +125,22 @@ cons_newline(struct cons_scr *scr)
scr->text_x = 0;
scr->text_y += FONT_HEIGHT;
+ cons_draw_cursor(scr, true);
+ scr->cursor_y += FONT_HEIGHT;
+ scr->cursor_x = 0;
+
/* Handle console y overflow */
if (scr->text_y >= scr->max_row - FONT_HEIGHT) {
scr->text_x = 0;
scr->text_y = 0;
+
+ scr->cursor_x = 0;
+ scr->cursor_y = 0;
fill_screen(scr, scr->scr_bg);
}
+
+ /* Redraw the cursor */
+ cons_draw_cursor(scr, false);
}
/*
@@ -152,6 +212,10 @@ cons_putch(struct cons_scr *scr, struct cons_ch *ch)
x = ch->x;
y = ch->y;
+ /* Update the cursor */
+ cons_draw_cursor(scr, true);
+ scr->cursor_x += FONT_WIDTH;
+
/* Begin the plotting */
for (int cy = 0; cy < hdr->csize; ++cy) {
for (int cx = 0; cx < 8; ++cx) {
@@ -162,6 +226,8 @@ cons_putch(struct cons_scr *scr, struct cons_ch *ch)
fbio[idx] = color;
}
}
+
+ cons_draw_cursor(scr, false);
}
/*