Browse Source

meep

master
James Bruska 5 years ago
parent
commit
9b23201859
  1. 41
      src/devrogue.c
  2. 27
      src/devrogue.h

41
src/devrogue.c

@ -0,0 +1,41 @@
MODULE_LICENSE("GPL"); // Currently using the MIT license
MODULE_AUTHOR("James Bruska and Robert Newman");
MODULE_DESCRIPTION("Dev Rouge: A kernel space rogue-like game");
MODULE_VERSION("0.1");
static devrogue_arg_t rogue_actions;
long ioctl_funcs( struct file *fp, unsigned int cmd, unsigned long arg ) {
int ret = 0;
devrogue_arg_t* rogue_actions_user = (devrogue *) arg;
if (rogue_actions_user == NULL) {
printk_d("User did not pass in arg\n");
return (-EINVAL);
}
if (copy_from_user(&rogue_actions, rogue_actions_user, sizeof(devrogue_arg_t)) != 0)
{
printk_d("lprof_ioctl: Could not copy cmd from userspace\n");
return (-EINVAL);
}
switch( cmd ) {
case IOCTL_ACTIONS:
printk( KERN_INFO "IT DOES A THINGS\n" );
break;
default:
printk( KERN_INFO "Invalid command\n" );
break;
}
struct file_operations fops = {
open: open,
read: read,
unlocked_ioctl: ioctl_funcs,
release: release
};
}

27
src/devrogue.h

@ -0,0 +1,27 @@
#ifndef DEVROUGE_H
#define DEVROUGE_H
#include <linux/ioctl.h>
#define IOC_MAGIC 'k'
#define IOCTL_ACTIONS _IOW(IOC_MAGIC, 0, char *)
#define DEVICE_NAME "devRouge"
#define DEVICE_PATH "/dev/" DEVICE_NAME
typedef struct
{
unsigned int move_dir;
unsigned int action;
} devrouge_arg_t;
#define DEBUG
#ifdef DEBUG
#define printk_d(...) printk(KERN_INFO "DevRouge: " __VA_ARGS__)
#else
#define printk_d(...)
#endif // DEBUG
#endif // DEVROUGE_H
Loading…
Cancel
Save