typedef uint8_t u8;
typedef uint32_t u32;
typedef unsigned short __kernel_mode_t;
typedef __kernel_mode_t mode_t;
typedef long long __kernel_loff_t;
typedef __kernel_loff_t loff_t;
typedef unsigned long __kernel_ino_t;
typedef __kernel_ino_t ino_t;
typedef unsigned short __kernel_uid_t;
typedef __kernel_uid_t uid_t;
struct fown_struct {
int pid; /* pid or -pgrp where SIGIO should be sent */
uid_t uid, euid; /* uid/euid of process setting the owner */
int signum; /* posix.1b rt signal to be delivered on IO */
};
typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t);
typedef unsigned short kdev_t;
typedef unsigned short __kernel_nlink_t;
typedef __kernel_nlink_t nlink_t;
typedef unsigned short __kernel_gid_t;
typedef __kernel_gid_t gid_t;
typedef long __kernel_off_t;
typedef __kernel_off_t off_t;
// Main types
struct file {
struct file *f_next, **f_pprev;
struct dentry *f_dentry;
struct file_operations *f_op;
mode_t f_mode;
loff_t f_pos;
unsigned int f_count, f_flags;
unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
int f_error;
unsigned long f_version;
/* needed for tty driver, and maybe others */
void *private_data;
};
struct file_operations {
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, struct dentry *);
int (*fasync) (int, struct file *, int);
int (*check_media_change) (kdev_t dev);
int (*revalidate) (kdev_t dev);
int (*lock) (struct file *, int, struct file_lock *);
};
struct pci_dev {
struct pci_bus *bus; /* bus this device is on */
struct pci_dev *sibling; /* next device on this bus */
struct pci_dev *next; /* chain of all devices */
void *sysdata; /* hook for sys-specific extension */
struct proc_dir_entry *procent; /* device entry in /proc/bus/pci */
unsigned int devfn; /* encoded device & function index */
unsigned short vendor;
unsigned short device;
// Unofficial: the following member has been renamed
unsigned int class_; /* 3 bytes: (base,sub,prog-if) */
unsigned int hdr_type; /* PCI header type */
unsigned int master : 1; /* set if device is master capable */
/*
* In theory, the irq level can be read from configuration
* space and all would be fine. However, old PCI chips don't
* support these registers and return 0 instead. For example,
* the Vision864-P rev 0 chip can uses INTA, but returns 0 in
* the interrupt line and pin registers. pci_init()
* initializes this field with the value at PCI_INTERRUPT_LINE
* and it is the job of pcibios_fixup() to change it if
* necessary. The field must not be 0 unless the device
* cannot generate interrupts at all.
*/
unsigned int irq; /* irq generated by this device */
/* Base registers for this device, can be adjusted by
* pcibios_fixup() as necessary.
*/
unsigned long base_address[6];
unsigned long rom_address;
};
struct proc_dir_entry {
unsigned short low_ino;
unsigned short namelen;
const char *name;
mode_t mode;
nlink_t nlink;
uid_t uid;
gid_t gid;
unsigned long size;
struct inode_operations * ops;
int (*get_info)(char *, char **, off_t, int, int);
void (*fill_inode)(struct inode *, int);
struct proc_dir_entry *next, *parent, *subdir;
void *data;
int (*read_proc)(char *page, char **start, off_t off,
int count, int *eof, void *data);
int (*write_proc)(struct file *file, const char *buffer,
unsigned long count, void *data);
int (*readlink_proc)(struct proc_dir_entry *de, char *page);
unsigned int count; /* use count */
int deleted; /* delete flag */
};
struct pt_regs {
long ebx;
long ecx;
long edx;
long esi;
long edi;
long ebp;
long eax;
int xds;
int xes;
long orig_eax;
long eip;
int xcs;
long eflags;
long esp;
int xss;
};
struct timer_list {
struct timer_list *next; /* MUST be first element */
struct timer_list *prev;
unsigned long expires;
unsigned long data;
void (*function)(unsigned long);
};
struct wait_queue {
struct task_struct * task;
struct wait_queue * next;
};
typedef struct poll_table_struct {
struct poll_table_struct * next;
unsigned int nr;
struct poll_table_entry * entry;
} poll_table;
typedef struct { unsigned long pgprot; } pgprot_t;
// Prototypes
int /* asmlinkage */ printk(const char * fmt, ...) /* __attribute__ ((format (printf, 1, 2))) */;
int __verify_write(const void * addr, unsigned long size);
int del_timer(struct timer_list * timer);
int pci_read_config_byte(struct pci_dev *dev, u8 where, u8 *val);
int pci_read_config_dword(struct pci_dev *dev, u8 where, u32 *val);
int pcibios_find_device (unsigned short vendor, unsigned short dev_id, unsigned short index, unsigned char *bus, unsigned char *dev_fn);
int pcibios_present (void);
int pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned char *val);
int pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned int *val);
int pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned int val);
int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp);
int proc_unregister(struct proc_dir_entry * dir, int ino);
int register_chrdev(unsigned int major, const char * name, struct file_operations * fops);
int remap_page_range(unsigned long from, unsigned long to, unsigned long size, pgprot_t prot);
int request_irq(unsigned int irq, void (*handler)(int irq, void * dev, struct pt_regs * regs), unsigned long flags, const char *device, void *dev_id);
int sprintf(char * buf, const char * fmt, ...);
int unregister_chrdev(unsigned int major, const char * name);
struct pci_dev * pci_find_device (unsigned int vendor, unsigned int device, struct pci_dev *from);
unsigned long __generic_copy_from_user(void * to, const void * from, unsigned long n);
unsigned long __generic_copy_to_user(void * to, const void * from, unsigned long n);
void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
void * kmalloc(size_t size, int flags);
void /* __fastcall */ __wake_up(struct wait_queue ** p, unsigned int mode);
void /* __fastcall */ interruptible_sleep_on(struct wait_queue ** p);
void __const_udelay(unsigned long usecs);
void __get_user_1(void);
void __pollwait(struct file * filp, struct wait_queue ** wait_address, poll_table *p);
void __put_user_1(void);
void __put_user_4(void);
void __udelay(unsigned long usecs);
void add_timer(struct timer_list * timer);
void free_irq(unsigned int irq, void *dev_id);
void iounmap(void *addr);
void kfree_s(const void *objp, size_t size);