
#include <linux/config.h>
#include <linux/module.h>

#include <asm/system.h>
#include <asm/segment.h>
#include <asm/io.h>

#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/timer.h>
#include <linux/fcntl.h>
#include <linux/malloc.h>
#include <linux/linkage.h>

#include <linux/miscdevice.h>
#include <linux/lists.h>
#include <linux/ioport.h>

#define __KERNEL_SYSCALLS__
//#include <asm/unistd.h>

#include "gps.h"

#define DEBUG_GPS

#ifdef DEBUG_GPS
#define Dprintk		printk
#else
#define Dprintk
#endif

#define XDprintk if(gps_debug==-1)printk

/*
 * The gps device is one of the misc char devices.
 */
#define GPS_MINOR_DEV   150

/*
 * Forward declarations.
 */
static int   gps_open(struct inode *, struct file *);
static int   gps_read(struct inode *, struct file *, char *, u_long);
static int   gps_ioctl(struct inode *, struct file *, u_int, u_long);

static void  gps_intr(int irq, void *dev_id, struct pt_regs *regs);

/*
 * Driver structures
 */

static struct file_operations gps_fops = {
        NULL,           /* lseek */
        gps_read,
        NULL,           /* write */
        NULL,           /* readdir */
        NULL,           /*  */
        gps_ioctl,
        NULL,           /* mmap */
        gps_open,
        NULL,           /*  */
        NULL,           /* fsync */
        NULL            /* fasync */
};

static struct miscdevice gps_device = {
        GPS_MINOR_DEV,
        "gps",
        &gps_fops
};

unsigned int gps_irq = GPS_IRQ;

/*
 * GPS interrupt handler
 */
static void gps_intr(int irq, void *dev_id, struct pt_regs *regs)
{
  printk("gps_intr\n");
  
}

int gps_init(void)
{
  if(request_irq(gps_irq, gps_intr, SA_INTERRUPT, "gps", NULL))
    {
      printk("GPS: error: IRQ %d is not free\n", gps_irq);
      return -EIO;
    }
  printk("GPS at IRQ %d\n", gps_irq);
  
  //kernel_thread(gps_monitor_thread, NULL, 0);
  
  return 0;
}

static int gps_read(struct inode *inode, struct file *fp, char *buf,
		     u_long count)
{
  printk("gps_read: IMPDEL\n");
  return 0;
}

static int gps_ioctl(struct inode * inode, struct file *filp,
		     u_int cmd, u_long arg)
{
  printk("gps_ioctl: IMPDEL\n");
  return 0;
}

static int gps_open(struct inode * inode, struct file * filp)
{
  printk("gps_open: IMPDEL\n");
  return 0;
}




