kexts: add generic vga/fb tty driver
This commit is contained in:
8
kexts/drivers/tty/serialcon/extension.yaml
Normal file
8
kexts/drivers/tty/serialcon/extension.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
name: serialcon
|
||||
description: |
|
||||
Serial port console.
|
||||
id: net.doorstuck.socks.serialcon
|
||||
license: BSD-3-Clause
|
||||
copyright: Copyright © Max Wash 2023
|
||||
sources:
|
||||
- main.c
|
||||
38
kexts/drivers/tty/serialcon/main.c
Normal file
38
kexts/drivers/tty/serialcon/main.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <socks/printk.h>
|
||||
#include <socks/device.h>
|
||||
#include <socks/kext.h>
|
||||
#include <socks/tty.h>
|
||||
#include <socks/libc/stdio.h>
|
||||
|
||||
static struct tty_driver *serialcon_driver = NULL;
|
||||
|
||||
static kern_status_t online(struct kext *self)
|
||||
{
|
||||
serialcon_driver = tty_driver_create(self, "ttyS");
|
||||
if (!serialcon_driver) {
|
||||
return KERN_NO_MEMORY;
|
||||
}
|
||||
|
||||
tty_driver_register(serialcon_driver);
|
||||
|
||||
struct device *ttyS0 = tty_device_create();
|
||||
struct device *ttyS1 = tty_device_create();
|
||||
struct device *ttyS2 = tty_device_create();
|
||||
struct device *ttyS3 = tty_device_create();
|
||||
|
||||
snprintf(ttyS0->dev_name, sizeof ttyS0->dev_name, "ttyS0");
|
||||
snprintf(ttyS1->dev_name, sizeof ttyS1->dev_name, "ttyS1");
|
||||
snprintf(ttyS2->dev_name, sizeof ttyS2->dev_name, "ttyS2");
|
||||
snprintf(ttyS3->dev_name, sizeof ttyS3->dev_name, "ttyS3");
|
||||
|
||||
tty_device_register(ttyS0, serialcon_driver, misc_device());
|
||||
tty_device_register(ttyS1, serialcon_driver, misc_device());
|
||||
tty_device_register(ttyS2, serialcon_driver, misc_device());
|
||||
tty_device_register(ttyS3, serialcon_driver, misc_device());
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
DEFINE_KEXT("net.doorstuck.socks.serialcon",
|
||||
online, NULL,
|
||||
KEXT_NO_DEPENDENCIES);
|
||||
Reference in New Issue
Block a user