From 8cbf32f110d47136d853ee88b74103445732a62e Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Tue, 8 May 2018 11:43:34 +0200 Subject: Create surface scaffold --- Kbuild | 2 +- char.c | 39 +++++++++++++++++++++++++++++++++++++-- surface.c | 8 ++++++++ surface.h | 8 ++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 surface.c create mode 100644 surface.h diff --git a/Kbuild b/Kbuild index fdebf0f..0fa0a82 100644 --- a/Kbuild +++ b/Kbuild @@ -1,2 +1,2 @@ obj-m := harddoom.o -harddoom-objs := harddoom_main.o pci.o char.o harddoomdev.o +harddoom-objs := harddoom_main.o pci.o char.o harddoomdev.o surface.o diff --git a/char.c b/char.c index db8ffcc..881c3d0 100644 --- a/char.c +++ b/char.c @@ -4,8 +4,10 @@ #include #include +#include "doomdev.h" #include "util.h" #include "pci.h" +#include "surface.h" #define DOOMDEV_COUNT 256 #define DOOMDEV_NAME "doom" @@ -14,16 +16,49 @@ dev_t first; int major; int next_minor = 0; -long doom_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +long doom_create_surface(struct file *filp, unsigned long arg) +{ + struct doomdev_ioctl_create_surface *params; + params = (struct doomdev_ioctl_create_surface *)arg; + return new_surface(params); +} + +long doom_create_texture(struct file *filp, unsigned long arg) { return -1; } -int doom_open(struct inode *inode, struct file *filp) +long doom_create_flat(struct file *filp, unsigned long arg) { return -1; } +long doom_create_colormaps(struct file *filp, unsigned long arg) +{ + return -1; +} + +long doom_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + switch (cmd) { + case DOOMDEV_IOCTL_CREATE_SURFACE: + return doom_create_surface(filp, arg); + case DOOMDEV_IOCTL_CREATE_TEXTURE: + return doom_create_texture(filp, arg); + case DOOMDEV_IOCTL_CREATE_FLAT: + return doom_create_flat(filp, arg); + case DOOMDEV_IOCTL_CREATE_COLORMAPS: + return doom_create_colormaps(filp, arg); + default: + return -EINVAL; + } +} + +int doom_open(struct inode *inode, struct file *filp) +{ + return 0; +} + struct file_operations doomdev_fops = { .owner = THIS_MODULE, .unlocked_ioctl = doom_ioctl, diff --git a/surface.c b/surface.c new file mode 100644 index 0000000..3c24871 --- /dev/null +++ b/surface.c @@ -0,0 +1,8 @@ +#include + +#include "surface.h" + +int new_surface(struct doomdev_ioctl_create_surface *params) +{ + return -1; +} diff --git a/surface.h b/surface.h new file mode 100644 index 0000000..db9c80c --- /dev/null +++ b/surface.h @@ -0,0 +1,8 @@ +#ifndef SURFACE_H +#define SURFACE_H + +#include "doomdev.h" + +int new_surface(struct doomdev_ioctl_create_surface *params); + +#endif -- cgit v1.2.3