git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: shell and signal demo as loadable user executable
[lunaix-os.git]
/
lunaix-os
/
kernel
/
tty
/
lxconsole.c
diff --git
a/lunaix-os/kernel/tty/lxconsole.c
b/lunaix-os/kernel/tty/lxconsole.c
index 3404450048a9802cd638e0bdac58170db5abc902..0d7439be4542554b427ad998f9690d7c65fc9c85 100644
(file)
--- a/
lunaix-os/kernel/tty/lxconsole.c
+++ b/
lunaix-os/kernel/tty/lxconsole.c
@@
-1,3
+1,14
@@
+/**
+ * @file lxconsole.c
+ * @author Lunaixsky (lunaxisky@qq.com)
+ * @brief Provides simple terminal support
+ * @version 0.1
+ * @date 2023-06-18
+ *
+ * @copyright Copyright (c) 2023
+ *
+ */
+
#include <klibc/string.h>
#include <lunaix/device.h>
#include <lunaix/input.h>
#include <klibc/string.h>
#include <lunaix/device.h>
#include <lunaix/input.h>
@@
-8,11
+19,10
@@
#include <lunaix/mm/valloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/sched.h>
#include <lunaix/mm/valloc.h>
#include <lunaix/mm/vmm.h>
#include <lunaix/sched.h>
+#include <lunaix/signal.h>
#include <lunaix/tty/console.h>
#include <lunaix/tty/tty.h>
#include <lunaix/tty/console.h>
#include <lunaix/tty/tty.h>
-#include <lunaix/lxsignal.h>
-
static struct console lx_console;
int
static struct console lx_console;
int
@@
-29,7
+39,7
@@
static volatile char ttychr;
static volatile pid_t fg_pgid = 0;
static volatile pid_t fg_pgid = 0;
-inline void
+
static
inline void
print_control_code(const char cntrl)
{
console_write_char('^');
print_control_code(const char cntrl)
{
console_write_char('^');
@@
-39,8
+49,8
@@
print_control_code(const char cntrl)
int
__lxconsole_listener(struct input_device* dev)
{
int
__lxconsole_listener(struct input_device* dev)
{
- u
int
32_t key = dev->current_pkt.sys_code;
- u
int
32_t type = dev->current_pkt.pkt_type;
+ u32_t key = dev->current_pkt.sys_code;
+ u32_t type = dev->current_pkt.pkt_type;
kbd_kstate_t state = key >> 16;
ttychr = key & 0xff;
key = key & 0xffff;
kbd_kstate_t state = key >> 16;
ttychr = key & 0xff;
key = key & 0xffff;
@@
-86,7
+96,7
@@
done:
}
int
}
int
-__tty_exec_cmd(struct device* dev, u
int
32_t req, va_list args)
+__tty_exec_cmd(struct device* dev, u32_t req, va_list args)
{
switch (req) {
case TIOCGPGRP:
{
switch (req) {
case TIOCGPGRP:
@@
-119,10
+129,28
@@
lxconsole_init()
fifo_init(&lx_console.input, valloc(4096), 4096, 0);
lx_console.flush_timer = NULL;
fifo_init(&lx_console.input, valloc(4096), 4096, 0);
lx_console.flush_timer = NULL;
+}
+
+int
+__tty_write_pg(struct device* dev, void* buf, size_t offset)
+{
+ return __tty_write(dev, buf, offset, PG_SIZE);
+}
+int
+__tty_read_pg(struct device* dev, void* buf, size_t offset)
+{
+ return __tty_read(dev, buf, offset, PG_SIZE);
+}
+
+void
+lxconsole_spawn_ttydev()
+{
struct device* tty_dev = device_addseq(NULL, &lx_console, "tty");
tty_dev->write = __tty_write;
struct device* tty_dev = device_addseq(NULL, &lx_console, "tty");
tty_dev->write = __tty_write;
+ tty_dev->write_page = __tty_write_pg;
tty_dev->read = __tty_read;
tty_dev->read = __tty_read;
+ tty_dev->read_page = __tty_read_pg;
tty_dev->exec_cmd = __tty_exec_cmd;
waitq_init(&lx_reader);
tty_dev->exec_cmd = __tty_exec_cmd;
waitq_init(&lx_reader);
@@
-294,6
+322,10
@@
console_write(struct console* console, uint8_t* data, size_t size)
console->wnd_start = rd_ptr;
fbuf->flags |= FIFO_DIRTY;
mutex_unlock(&fbuf->lock);
console->wnd_start = rd_ptr;
fbuf->flags |= FIFO_DIRTY;
mutex_unlock(&fbuf->lock);
+
+ if (!lx_console.flush_timer) {
+ console_flush();
+ }
}
void
}
void