Skip to content

Instantly share code, notes, and snippets.

@neel
Created March 22, 2015 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neel/8777de0ec3f865793aaf to your computer and use it in GitHub Desktop.
Save neel/8777de0ec3f865793aaf to your computer and use it in GitHub Desktop.
#define MY_PCI_DOMAIN_NUM 0x0001
#define MY_PCI_BUS_NUM 0x00
#include <linux/pci.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/pci-ats.h>
#include <linux/pci-acpi.h>
#include <linux/pci-aspm.h>
#include <asm/pci.h>
int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val){
return 0;
}
int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val){
return 0;
}
struct pci_ops my_pci_ops = {};
extern struct bus_type pci_bus_type;
MODULE_LICENSE("Dual BSD/GPL");
struct pci_sysdata my_pci_sd = {};
struct pci_dev my_pci_dev = {};
static int hello_init(void){
struct pci_bus* my_pci_bus;
memset (&my_pci_sd, 0, sizeof (my_pci_sd));
my_pci_sd.domain = MY_PCI_DOMAIN_NUM;
my_pci_sd.node = -1;
printk(KERN_ALERT "Hello, world\n");
memset (&my_pci_ops, 0, sizeof (my_pci_ops));
my_pci_ops.read = pci_read;
my_pci_ops.write = pci_write;
my_pci_bus = pci_scan_bus(MY_PCI_BUS_NUM, &my_pci_ops, &my_pci_sd);
if(my_pci_bus){
printk(KERN_INFO "Successfully created MY PCI bus");
}
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment