PCI cleanup

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-11-02 23:42:07 +01:00
parent 6174923799
commit 810d8224cd
4 changed files with 25 additions and 20 deletions

View 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;

View File

@ -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++)
{

View 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

View 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)
@ -45,57 +48,57 @@
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 */