From 20c1a6d14c9447b87394221fa42a0e85aca1b060 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Thu, 24 Jan 2013 17:56:32 -0600 Subject: use a linked list to hold data, utilize Linux api --- main.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index db38aa8..cb751d0 100644 --- a/main.h +++ b/main.h @@ -2,26 +2,50 @@ #define _HELLOMAIN_H_ #include +#include + +/* + * Macros to aid with debugging + */ +#ifdef HELLO_DEBUG + #define PDEBUG(fmt, args...) printk( KERN_DEBUG "[hello] " fmt, ##args) +#else + #define PDEBUG(fmt, args...) /* not debugging: nothing */ +#endif #ifndef HELLO_MAJOR #define HELLO_MAJOR 0 /* let kernel choose, unless user really defined it */ #endif -#define HELLO_KERNEL_BUFF_LEN 1024 +/* + * Allow user to define size of node using a #define, or passing -D compiler + * flag + */ +#ifndef HELLO_NODE_CHUNK_SIZE +#define HELLO_NODE_CHUNK_SIZE 256 +#endif extern int hello_major; extern int hello_minor; extern char *magicstr; +/* node to be used with Linux api for circular linked lists */ +struct hello_ll +{ + char *chunk; + struct list_head list; +}; + struct hello_dev { dev_t devnum; struct semaphore sem; struct cdev cdev; /* char device */ /* for r/w operations */ - char hello_buffer[HELLO_KERNEL_BUFF_LEN]; - size_t buff_index; + struct hello_ll *mylist; + int chunk_sz; + size_t ll_size; }; /* function prototypes */ -- cgit v1.2.3