39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#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);
|