4 * For architectures where we want to allow direct access
5 * to the PCI config stuff - it would probably be preferable
6 * on PCs too, but there people just do it by hand with the
7 * magic northbridge registers..
10 #include <linux/sched.h>
11 #include <linux/errno.h>
12 #include <linux/pci.h>
13 #include <linux/smp_lock.h>
14 #include <linux/syscalls.h>
15 #include <asm/uaccess.h>
19 sys_pciconfig_read(unsigned long bus, unsigned long dfn,
20 unsigned long off, unsigned long len,
30 if (!capable(CAP_SYS_ADMIN))
34 dev = pci_find_slot(bus, dfn);
41 cfg_ret = pci_read_config_byte(dev, off, &byte);
44 cfg_ret = pci_read_config_word(dev, off, &word);
47 cfg_ret = pci_read_config_dword(dev, off, &dword);
57 if (cfg_ret != PCIBIOS_SUCCESSFUL)
62 err = put_user(byte, (unsigned char __user *)buf);
65 err = put_user(word, (unsigned short __user *)buf);
68 err = put_user(dword, (unsigned int __user *)buf);
74 /* ??? XFree86 doesn't even check the return value. They
75 just look for 0xffffffff in the output, since that's what
76 they get instead of a machine check on x86. */
79 put_user(-1, (unsigned char __user *)buf);
82 put_user(-1, (unsigned short __user *)buf);
85 put_user(-1, (unsigned int __user *)buf);
92 sys_pciconfig_write(unsigned long bus, unsigned long dfn,
93 unsigned long off, unsigned long len,
102 if (!capable(CAP_SYS_ADMIN))
105 dev = pci_find_slot(bus, dfn);
112 err = get_user(byte, (u8 __user *)buf);
115 err = pci_write_config_byte(dev, off, byte);
116 if (err != PCIBIOS_SUCCESSFUL)
121 err = get_user(word, (u16 __user *)buf);
124 err = pci_write_config_word(dev, off, word);
125 if (err != PCIBIOS_SUCCESSFUL)
130 err = get_user(dword, (u32 __user *)buf);
133 err = pci_write_config_dword(dev, off, dword);
134 if (err != PCIBIOS_SUCCESSFUL)