]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
PCI cleanup
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 2 Nov 2009 22:42:07 +0000 (23:42 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 2 Nov 2009 22:42:07 +0000 (23:42 +0100)
bus/bonito.c
bus/pci.c
include/grub/i386/pci.h
include/grub/mips/yeeloong/pci.h

index a7a530de1c1b70aefad39777995d6c24f92fbc58..3f794c45a9e01568b20c9e5bfb3e41d6accd23cf 100644 (file)
@@ -42,7 +42,7 @@ write_bases (void)
   GRUB_MACHINE_PCI_IO_CTRL_REG = reg;
 }
 
-void *
+volatile void *
 grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
                           grub_addr_t base, grub_size_t size)
 {
@@ -75,7 +75,7 @@ grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
 
 void
 grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
-                            void *mem __attribute__ ((unused)),
+                            volatile void *mem __attribute__ ((unused)),
                             grub_size_t size __attribute__ ((unused)))
 {
   int i;
index fe4cad181f4a684cbfc24dad1cc0def319a1c6a8..08bc90ab227395495ded98f996e9b1ba0ad315dd 100644 (file)
--- a/bus/pci.c
+++ b/bus/pci.c
@@ -35,9 +35,9 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
   grub_pci_id_t id;
   grub_uint32_t hdr;
 
-  for (dev.bus = 0; dev.bus < 256; dev.bus++)
+  for (dev.bus = 0; dev.bus < GRUB_PCI_NUM_BUS; dev.bus++)
     {
-      for (dev.device = 0; dev.device < 32; dev.device++)
+      for (dev.device = 0; dev.device < GRUB_PCI_NUM_DEVICES; dev.device++)
        {
          for (dev.function = 0; dev.function < 8; dev.function++)
            {
index 5b5f5f0dfa4d7bc432ce2cc1c3e523992d97f10d..a62adf5073e75fab882a7e5287b087f8076cf254 100644 (file)
@@ -24,6 +24,8 @@
 
 #define GRUB_PCI_ADDR_REG      0xcf8
 #define GRUB_PCI_DATA_REG      0xcfc
+#define GRUB_PCI_NUM_BUS        256
+#define GRUB_PCI_NUM_DEVICES    32
 
 static inline grub_uint32_t
 grub_pci_read (grub_pci_address_t addr)
@@ -67,12 +69,12 @@ grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
   grub_outb (data, GRUB_PCI_DATA_REG + (addr & 3));
 }
 
-static inline void *
+static inline volatile void *
 grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
                           grub_addr_t base,
                           grub_size_t size __attribute__ ((unused)))
 {
-  return (void *) base;
+  return (volatile void *) base;
 }
 
 static inline void
index 9970d6ee06f5f17a98aa7a38e89646fda5ef7a5b..8ba9f39d8cb7cf539d1d54aa7ef8f7dbdb9587df 100644 (file)
@@ -22,6 +22,9 @@
 #include <grub/types.h>
 #include <grub/cpu/io.h>
 
+#define GRUB_PCI_NUM_BUS        1
+#define GRUB_PCI_NUM_DEVICES    16
+
 #define GRUB_MACHINE_PCI_CONFSPACE        0xbfe80000
 #define GRUB_MACHINE_PCI_CONF_CTRL_REG    (*(volatile grub_uint32_t *) 0xbfe00118)
 #define GRUB_MACHINE_PCI_IO_CTRL_REG      (*(volatile grub_uint32_t *) 0xbfe00110)
 static inline grub_uint32_t
 grub_pci_read (grub_pci_address_t addr)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   return *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                                     | (addr & 0xffff));
+                                     | (addr & 0x03ff));
 }
 
 static inline grub_uint16_t
 grub_pci_read_word (grub_pci_address_t addr)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   return *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                                     | (addr & 0xffff));
+                                     | (addr & 0x03ff));
 }
 
 static inline grub_uint8_t
 grub_pci_read_byte (grub_pci_address_t addr)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   return *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                                    | (addr & 0xffff));
+                                    | (addr & 0x03ff));
 }
 
 static inline void
 grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                              | (addr & 0xffff)) = data;
+                              | (addr & 0x03ff)) = data;
 }
 
 static inline void
 grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                              | (addr & 0xffff)) = data;
+                              | (addr & 0x03ff)) = data;
 }
 
 static inline void
 grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
 {
-  GRUB_MACHINE_PCI_CONF_CTRL_REG = addr >> 16;
+  GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
   *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
-                             | (addr & 0xffff)) = data;
+                             | (addr & 0x03ff)) = data;
 }
 
-void *
+volatile void *
 grub_pci_device_map_range (grub_pci_device_t dev __attribute__ ((unused)),
                           grub_addr_t base, grub_size_t size);
 void
 grub_pci_device_unmap_range (grub_pci_device_t dev __attribute__ ((unused)),
-                            void *mem,
+                            volatile void *mem,
                             grub_size_t size __attribute__ ((unused)));
 
 #endif /* GRUB_MACHINE_PCI_H */