kernel: implement tty driver system

This commit is contained in:
2023-06-10 21:41:07 +01:00
parent e10f11af88
commit d09ad5838e
9 changed files with 198 additions and 54 deletions

View File

@@ -6,6 +6,20 @@
static struct queue consoles;
static spin_lock_t consoles_lock = SPIN_LOCK_INIT;
static void unregister_boot_consoles(void)
{
struct queue_entry *cur = queue_first(&consoles);
while (cur) {
struct queue_entry *next = cur->qe_next;
struct console *con = QUEUE_CONTAINER(struct console, c_list, cur);
if (con->c_flags & CON_BOOT) {
queue_delete(&consoles, cur);
}
cur = next;
}
}
kern_status_t console_register(struct console *con)
{
unsigned long flags;
@@ -19,7 +33,13 @@ kern_status_t console_register(struct console *con)
}
queue_push_back(&consoles, &con->c_list);
if (!(con->c_flags & CON_BOOT)) {
unregister_boot_consoles();
}
spin_unlock_irqrestore(&consoles_lock, flags);
return KERN_OK;
}