diff options
author | Nico Huber <nico.huber@secunet.com> | 2014-07-07 16:33:59 +0200 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2014-07-10 20:55:41 +0200 |
commit | 6e23066d7ac31bd29b328824ec11e7d1252cf41c (patch) | |
tree | 0f30f1245394dcc4205bb58fdc0b8a1d4ef345b5 /payloads | |
parent | 322794243a98a47fe6e3b270277dd049e7d4f22e (diff) |
libpayload: Use unsigned long for BARs in *hci_init()
Using void* for physical addresses leads to much casting and confuses
developers when to convert from physical to virtual addresses or
the other way around. When using plain integers for physical addresses
and pointers for virtual addresses things become much cleaner and we
won't ever end up dereferencing a physical address.
Change-Id: I24cd53b81c7863b6d14f0cbb4ce8937728b37c1c
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: http://review.coreboot.org/6244
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Diffstat (limited to 'payloads')
-rw-r--r-- | payloads/libpayload/drivers/usb/ehci.c | 6 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/ehci.h | 2 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/ohci.c | 6 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/ohci.h | 2 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/usbinit.c | 6 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/xhci.c | 6 | ||||
-rw-r--r-- | payloads/libpayload/drivers/usb/xhci.h | 2 |
7 files changed, 15 insertions, 15 deletions
diff --git a/payloads/libpayload/drivers/usb/ehci.c b/payloads/libpayload/drivers/usb/ehci.c index e58bd38bbb..03d0aef8d6 100644 --- a/payloads/libpayload/drivers/usb/ehci.c +++ b/payloads/libpayload/drivers/usb/ehci.c @@ -724,7 +724,7 @@ static u8 *ehci_poll_intr_queue(void *const queue) } hci_t * -ehci_init (void *bar) +ehci_init (unsigned long physical_bar) { int i; hci_t *controller = new_controller (); @@ -751,7 +751,7 @@ ehci_init (void *bar) controller->create_intr_queue = ehci_create_intr_queue; controller->destroy_intr_queue = ehci_destroy_intr_queue; controller->poll_intr_queue = ehci_poll_intr_queue; - controller->reg_base = (u32)(unsigned long)bar; + controller->reg_base = (u32)physical_bar; for (i = 0; i < 128; i++) { controller->devices[i] = 0; } @@ -822,7 +822,7 @@ ehci_pci_init (pcidev_t addr) /* default value for frame length adjust */ pci_write_config8(addr, FLADJ, FLADJ_framelength(60000)); - controller = ehci_init((void *)(unsigned long)reg_base); + controller = ehci_init((unsigned long)reg_base); return controller; } diff --git a/payloads/libpayload/drivers/usb/ehci.h b/payloads/libpayload/drivers/usb/ehci.h index c1b1fa9f70..aa1bcf770e 100644 --- a/payloads/libpayload/drivers/usb/ehci.h +++ b/payloads/libpayload/drivers/usb/ehci.h @@ -34,7 +34,7 @@ #include <usb/usb.h> hci_t *ehci_pci_init (pcidev_t addr); -hci_t *ehci_init (void *bar); +hci_t *ehci_init (unsigned long physical_bar); void ehci_rh_init (usbdev_t *dev); diff --git a/payloads/libpayload/drivers/usb/ohci.c b/payloads/libpayload/drivers/usb/ohci.c index edd275bb19..84547e6b85 100644 --- a/payloads/libpayload/drivers/usb/ohci.c +++ b/payloads/libpayload/drivers/usb/ohci.c @@ -167,7 +167,7 @@ static const char *direction[] = { #endif hci_t * -ohci_init (void *bar) +ohci_init (unsigned long physical_bar) { int i; @@ -201,7 +201,7 @@ ohci_init (void *bar) init_device_entry (controller, 0); OHCI_INST (controller)->roothub = controller->devices[0]; - controller->reg_base = (u32)(unsigned long)bar; + controller->reg_base = (u32)physical_bar; OHCI_INST (controller)->opreg = (opreg_t*)phys_to_virt(controller->reg_base); usb_debug("OHCI Version %x.%x\n", (OHCI_INST (controller)->opreg->HcRevision >> 4) & 0xf, OHCI_INST (controller)->opreg->HcRevision & 0xf); @@ -263,7 +263,7 @@ ohci_pci_init (pcidev_t addr) * OHCI mandates MMIO, so bit 0 is clear */ reg_base = pci_read_config32 (addr, 0x10) & 0xfffff000; - return ohci_init((void *)(unsigned long)reg_base); + return ohci_init((unsigned long)reg_base); } #endif diff --git a/payloads/libpayload/drivers/usb/ohci.h b/payloads/libpayload/drivers/usb/ohci.h index 9c31d9c015..d810c48a77 100644 --- a/payloads/libpayload/drivers/usb/ohci.h +++ b/payloads/libpayload/drivers/usb/ohci.h @@ -34,7 +34,7 @@ #include <usb/usb.h> hci_t *ohci_pci_init (pcidev_t addr); -hci_t *ohci_init (void *bar); +hci_t *ohci_init (unsigned long physical_bar); void ohci_rh_init (usbdev_t *dev); diff --git a/payloads/libpayload/drivers/usb/usbinit.c b/payloads/libpayload/drivers/usb/usbinit.c index f74a833584..ca0bf76866 100644 --- a/payloads/libpayload/drivers/usb/usbinit.c +++ b/payloads/libpayload/drivers/usb/usbinit.c @@ -160,13 +160,13 @@ static void usb_scan_pci_bus(int bus) static void usb_scan_memory(void) { #ifdef CONFIG_USB_XHCI - xhci_init((void *)(unsigned long)CONFIG_USB_XHCI_BASE_ADDRESS); + xhci_init(CONFIG_USB_XHCI_BASE_ADDRESS); #endif #ifdef CONFIG_USB_EHCI - ehci_init((void *)(unsigned long)CONFIG_USB_EHCI_BASE_ADDRESS); + ehci_init(CONFIG_USB_EHCI_BASE_ADDRESS); #endif #ifdef CONFIG_USB_OHCI - ohci_init((void *)(unsigned long)CONFIG_USB_OHCI_BASE_ADDRESS); + ohci_init(CONFIG_USB_OHCI_BASE_ADDRESS); #endif } #endif diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c index d9ac0a490b..f540230ec2 100644 --- a/payloads/libpayload/drivers/usb/xhci.c +++ b/payloads/libpayload/drivers/usb/xhci.c @@ -143,7 +143,7 @@ xhci_wait_ready(xhci_t *const xhci) } hci_t * -xhci_init (const void *bar) +xhci_init (unsigned long physical_bar) { int i; @@ -192,7 +192,7 @@ xhci_init (const void *bar) goto _free_xhci; } - controller->reg_base = (u32)(unsigned long)bar; + controller->reg_base = (u32)physical_bar; xhci->capreg = phys_to_virt(controller->reg_base); xhci->opreg = ((void *)xhci->capreg) + xhci->capreg->caplength; @@ -310,7 +310,7 @@ xhci_pci_init (pcidev_t addr) fatal("We don't do 64bit addressing.\n"); } - controller = xhci_init((void *)(unsigned long)reg_addr); + controller = xhci_init((unsigned long)reg_addr); controller->pcidev = addr; xhci_switch_ppt_ports(addr); diff --git a/payloads/libpayload/drivers/usb/xhci.h b/payloads/libpayload/drivers/usb/xhci.h index ddc9297b58..5f15da33f6 100644 --- a/payloads/libpayload/drivers/usb/xhci.h +++ b/payloads/libpayload/drivers/usb/xhci.h @@ -34,7 +34,7 @@ #include <usb/usb.h> hci_t *xhci_pci_init (pcidev_t addr); -hci_t *xhci_init (const void *bar); +hci_t *xhci_init (unsigned long physical_bar); void xhci_rh_init (usbdev_t *dev); |