Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4909482a2e | |||
| e78aeb66fb |
7 changed files with 91 additions and 11 deletions
|
|
@ -31,17 +31,17 @@ static struct tty_serial_ops fbcon_serial_ops = {
|
||||||
.serial_getchar = fbcon_getchar,
|
.serial_getchar = fbcon_getchar,
|
||||||
};
|
};
|
||||||
|
|
||||||
void fbcon_init(void)
|
struct tty *fbcon_init(void)
|
||||||
{
|
{
|
||||||
if (!fb_res || !fb_res->framebuffer_count)
|
if (!fb_res || !fb_res->framebuffer_count)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
struct limine_framebuffer *fb = fb_res->framebuffers[0];
|
struct limine_framebuffer *fb = fb_res->framebuffers[0];
|
||||||
size_t fb_size = fb->pitch * fb->height;
|
size_t fb_size = fb->pitch * fb->height;
|
||||||
void *fb_virt = map_mmio_dev((paddr_t)TO_PHYS(fb->address), fb_size);
|
void *fb_virt = map_mmio_dev((paddr_t)TO_PHYS(fb->address), fb_size);
|
||||||
|
|
||||||
if (!fb_virt)
|
if (!fb_virt)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
ft_ctx = flanterm_fb_init(
|
ft_ctx = flanterm_fb_init(
|
||||||
NULL, NULL, fb_virt, fb->width, fb->height, fb->pitch, fb->red_mask_size, fb->red_mask_shift, fb->green_mask_size,
|
NULL, NULL, fb_virt, fb->width, fb->height, fb->pitch, fb->red_mask_size, fb->red_mask_shift, fb->green_mask_size,
|
||||||
|
|
@ -49,7 +49,7 @@ void fbcon_init(void)
|
||||||
0, 0, 0, 0, FLANTERM_FB_ROTATE_0);
|
0, 0, 0, 0, FLANTERM_FB_ROTATE_0);
|
||||||
|
|
||||||
if (!ft_ctx)
|
if (!ft_ctx)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
struct tty *fbtty = tty_create("tty1", NULL);
|
struct tty *fbtty = tty_create("tty1", NULL);
|
||||||
|
|
||||||
|
|
@ -57,4 +57,6 @@ void fbcon_init(void)
|
||||||
tty_printf = fbtty;
|
tty_printf = fbtty;
|
||||||
|
|
||||||
kinfo("fbcon: framebuffer console initialized (%lux%lu)\n", fb->width, fb->height);
|
kinfo("fbcon: framebuffer console initialized (%lux%lu)\n", fb->width, fb->height);
|
||||||
|
|
||||||
|
return fbtty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,5 +32,8 @@ void tty_set_cursor_pos(struct tty *tty, int x, int y);
|
||||||
void tty_get_cursor_pos(struct tty *tty, int *row, int *col);
|
void tty_get_cursor_pos(struct tty *tty, int *row, int *col);
|
||||||
void tty_get_size(struct tty *tty, int *rows, int *cols);
|
void tty_get_size(struct tty *tty, int *rows, int *cols);
|
||||||
void tty_setlf(struct tty *tty);
|
void tty_setlf(struct tty *tty);
|
||||||
|
struct tty *tty_tee_create(const char *name);
|
||||||
|
void tty_tee_add(struct tty *tee, struct tty *child);
|
||||||
|
void tty_tee_remove(struct tty *tee, struct tty *child);
|
||||||
|
|
||||||
#endif /* _TTY_H_ */
|
#endif /* _TTY_H_ */
|
||||||
|
|
|
||||||
17
init/main.c
17
init/main.c
|
|
@ -36,8 +36,10 @@
|
||||||
|
|
||||||
typedef void (*initcall_t)(void);
|
typedef void (*initcall_t)(void);
|
||||||
|
|
||||||
|
struct tty *fbcon_init();
|
||||||
|
void arch_ap_startup();
|
||||||
|
|
||||||
extern initcall_t __initcall_start, __initcall_end;
|
extern initcall_t __initcall_start, __initcall_end;
|
||||||
extern void fbcon_init(void);
|
|
||||||
struct tty *tty_printf = NULL;
|
struct tty *tty_printf = NULL;
|
||||||
|
|
||||||
bool kernel_init_ready = false;
|
bool kernel_init_ready = false;
|
||||||
|
|
@ -74,16 +76,19 @@ static void kmain()
|
||||||
tty_layer_init();
|
tty_layer_init();
|
||||||
|
|
||||||
/* init main fallback tty */
|
/* init main fallback tty */
|
||||||
struct tty *main_tty = NULL;
|
struct tty *serial_tty = NULL;
|
||||||
serial_port_tty_init(&main_tty);
|
serial_port_tty_init(&serial_tty);
|
||||||
|
|
||||||
tty_printf = main_tty;
|
struct tty *visual_tty = fbcon_init();
|
||||||
|
|
||||||
fbcon_init();
|
struct tty *tee = tty_tee_create("broadcast");
|
||||||
|
tty_tee_add(tee, serial_tty);
|
||||||
|
tty_tee_add(tee, visual_tty);
|
||||||
|
|
||||||
|
tty_printf = tee;
|
||||||
|
|
||||||
do_initcalls();
|
do_initcalls();
|
||||||
|
|
||||||
void arch_ap_startup();
|
|
||||||
arch_ap_startup();
|
arch_ap_startup();
|
||||||
|
|
||||||
/* do nothing, for now :) */
|
/* do nothing, for now :) */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
obj-y += tee.o
|
||||||
obj-y += tty.o
|
obj-y += tty.o
|
||||||
obj-y += vt100.o
|
obj-y += vt100.o
|
||||||
|
|
||||||
|
|
|
||||||
67
kernel/tty/tee.c
Normal file
67
kernel/tty/tee.c
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#include <kernel/tty.h>
|
||||||
|
#include <kernel/slab.h>
|
||||||
|
#include <lib/list.h>
|
||||||
|
|
||||||
|
static void serial_putchar(struct tty *tty, char c)
|
||||||
|
{
|
||||||
|
list_t *list = tty->priv;
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
list_item_t *item = list->head;
|
||||||
|
while (item) {
|
||||||
|
struct tty *next = item->ptr;
|
||||||
|
next->serial_ops.serial_putchar(next, c);
|
||||||
|
item = item->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static char serial_getchar(struct tty *tty)
|
||||||
|
{
|
||||||
|
/* can't read from a tee, duh */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tty *tty_tee_create(const char *name)
|
||||||
|
{
|
||||||
|
static struct tty_serial_ops ops = {.serial_putchar = serial_putchar, .serial_getchar = serial_getchar};
|
||||||
|
|
||||||
|
list_t *list = kzalloc(sizeof(list_t), ALLOC_KERN);
|
||||||
|
if (!list)
|
||||||
|
return NULL;
|
||||||
|
list_create(list);
|
||||||
|
struct tty *ret = tty_create(name, list);
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
list_destroy(list);
|
||||||
|
kfree(list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret->serial_ops = ops;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tty_tee_add(struct tty *tee, struct tty *child)
|
||||||
|
{
|
||||||
|
list_t *list = tee->priv;
|
||||||
|
list_insert(list, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tty_tee_remove(struct tty *tee, struct tty *child)
|
||||||
|
{
|
||||||
|
list_t *list = tee->priv;
|
||||||
|
if (!list)
|
||||||
|
return;
|
||||||
|
|
||||||
|
list_item_t *item = list->head;
|
||||||
|
while (item) {
|
||||||
|
if (item->ptr == child) {
|
||||||
|
list_remove(item);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
item = item->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
|
serial: yes
|
||||||
timeout: 1
|
timeout: 1
|
||||||
resolution: 1920x1080
|
|
||||||
|
|
||||||
# The entry name that will be displayed in the boot menu.
|
# The entry name that will be displayed in the boot menu.
|
||||||
/vbos
|
/vbos
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ run: edk2-ovmf $(INITRAMFS) $(IMG)
|
||||||
-accel kvm \
|
-accel kvm \
|
||||||
-hda $(IMG) \
|
-hda $(IMG) \
|
||||||
-hdb test_drive.hdd \
|
-hdb test_drive.hdd \
|
||||||
|
-serial stdio \
|
||||||
$(QEMUFLAGS)
|
$(QEMUFLAGS)
|
||||||
|
|
||||||
.PHONY += debug
|
.PHONY += debug
|
||||||
|
|
@ -57,6 +58,7 @@ debug: edk2-ovmf $(IMG)
|
||||||
-drive if=pflash,unit=0,format=raw,file=edk2-ovmf/ovmf-code-$(ARCH).fd,readonly=on \
|
-drive if=pflash,unit=0,format=raw,file=edk2-ovmf/ovmf-code-$(ARCH).fd,readonly=on \
|
||||||
-hda $(IMG) \
|
-hda $(IMG) \
|
||||||
-hdb test_drive.hdd \
|
-hdb test_drive.hdd \
|
||||||
|
-serial stdio \
|
||||||
$(QEMUFLAGS)
|
$(QEMUFLAGS)
|
||||||
|
|
||||||
edk2-ovmf:
|
edk2-ovmf:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue