Skip to content

Instantly share code, notes, and snippets.

@tetsu-koba tetsu-koba/00_uio_ko
Last active Jan 15, 2018

Embed
What would you like to do?
kernel module to register UIO
kernel module to register UIO
KDIR := $(CURDIR)/../../../kernel/linux-3.18.y/
TARGET := uioko.ko
obj-m += uioko.o
.PHONY : all clean install
all : $(TARGET)
$(TARGET):
$(MAKE) -C $(KDIR) M=$(CURDIR) modules
clean:
$(MAKE) -C $(KDIR) M=$(CURDIR) clean
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/uio_driver.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Tetsuyuki Kobayashi");
MODULE_DESCRIPTION("Register UIO");
static struct uio_info mydev_mem = {
.name = "my_device",
.version = "0.1",
.irq = UIO_IRQ_NONE,
};
static struct resource uio_resources[] = {
[0] = {
.name = "peri_pmc",
.start = 0x120a0000,
.end = 0x120a0fff,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "DUMMY",
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device my_dev = {
.name = "uio_pdrv_genirq",
.id = -1,
.dev = {
.platform_data = &mydev_mem,
},
.resource = uio_resources,
.num_resources = ARRAY_SIZE(uio_resources),
};
static int __init uio_init(void)
{
printk(KERN_INFO "uio_init\n");
return platform_device_register(&my_dev);
}
static void __exit uio_cleanup(void)
{
printk(KERN_INFO "uio_cleanup\n");
platform_device_unregister(&my_dev);
}
module_init(uio_init);
module_exit(uio_cleanup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.