Subversion Repositories Kolibri OS

Rev

Rev 1633 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. #include <ddk.h>
  3. #include <linux/errno.h>
  4. #include <mutex.h>
  5. #include <pci.h>
  6. #include <syscall.h>
  7.  
  8.  
  9. int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
  10. {
  11.     *val = PciRead8(dev->busnr, dev->devfn, where);
  12.     return 0;
  13. }
  14.  
  15. int pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
  16. {
  17.  
  18.     if ( where & 1)
  19.         return PCIBIOS_BAD_REGISTER_NUMBER;
  20.     *val = PciRead16(dev->busnr, dev->devfn, where);
  21.     return 0;
  22. }
  23.  
  24. int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val)
  25. {
  26.  
  27.     if ( where & 3)
  28.         return PCIBIOS_BAD_REGISTER_NUMBER;
  29.     *val = PciRead32(dev->busnr, dev->devfn, where);
  30.     return 0;
  31. }
  32.  
  33. int pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
  34. {
  35.     PciWrite8(dev->busnr, dev->devfn, where, val);
  36.     return 0;
  37. };
  38.  
  39. int pci_write_config_word(struct pci_dev *dev, int where, u16 val)
  40. {
  41.     if ( where & 1)
  42.         return PCIBIOS_BAD_REGISTER_NUMBER;
  43.     PciWrite16(dev->busnr, dev->devfn, where, val);
  44.     return 0;
  45. }
  46.  
  47. int pci_write_config_dword(struct pci_dev *dev, int where,
  48.                      u32 val)
  49. {
  50.     if ( where & 3)
  51.         return PCIBIOS_BAD_REGISTER_NUMBER;
  52.     PciWrite32(dev->busnr, dev->devfn, where, val);
  53.     return 0;
  54. }
  55.  
  56.  
  57. int pci_bus_read_config_byte (struct pci_bus *bus, u32 devfn,
  58.                               int pos, u8 *value)
  59. {
  60. //    raw_spin_lock_irqsave(&pci_lock, flags);
  61.     *value = PciRead8(bus->number, devfn, pos);
  62. //    raw_spin_unlock_irqrestore(&pci_lock, flags);
  63.     return 0;
  64. }
  65.  
  66. int pci_bus_read_config_word (struct pci_bus *bus, u32 devfn,
  67.                               int pos, u16 *value)
  68. {
  69.     if ( pos & 1)
  70.         return PCIBIOS_BAD_REGISTER_NUMBER;
  71.  
  72. //    raw_spin_lock_irqsave(&pci_lock, flags);
  73.     *value = PciRead16(bus->number, devfn, pos);
  74. //    raw_spin_unlock_irqrestore(&pci_lock, flags);
  75.     return 0;
  76. }
  77.  
  78.  
  79. int pci_bus_read_config_dword (struct pci_bus *bus, u32 devfn,
  80.                               int pos, u16 *value)
  81. {
  82.     if ( pos & 3)
  83.         return PCIBIOS_BAD_REGISTER_NUMBER;
  84.  
  85. //    raw_spin_lock_irqsave(&pci_lock, flags);
  86.     *value = PciRead32(bus->number, devfn, pos);
  87. //    raw_spin_unlock_irqrestore(&pci_lock, flags);
  88.     return 0;
  89. }
  90.