From 371af4eef2dfa1facf6645a5704d8a55ff45c965 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Sep 2020 16:58:14 +0100 Subject: [pci] Define pci_ioremap() for mapping PCI bus addresses Define pci_ioremap() as a wrapper around ioremap() that could allow for a non-zero address translation offset. Signed-off-by: Michael Brown --- src/arch/x86/core/pcidirect.c | 1 + src/arch/x86/include/ipxe/pcibios.h | 13 +++++++++++++ src/arch/x86/include/ipxe/pcidirect.h | 13 +++++++++++++ src/arch/x86/interface/pcbios/pcibios.c | 1 + 4 files changed, 28 insertions(+) (limited to 'src/arch') diff --git a/src/arch/x86/core/pcidirect.c b/src/arch/x86/core/pcidirect.c index 0d09be84b..9b8226fea 100644 --- a/src/arch/x86/core/pcidirect.c +++ b/src/arch/x86/core/pcidirect.c @@ -52,3 +52,4 @@ PROVIDE_PCIAPI_INLINE ( direct, pci_read_config_dword ); PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( direct, pci_write_config_dword ); +PROVIDE_PCIAPI_INLINE ( direct, pci_ioremap ); diff --git a/src/arch/x86/include/ipxe/pcibios.h b/src/arch/x86/include/ipxe/pcibios.h index 7e1bcd814..bae4eede1 100644 --- a/src/arch/x86/include/ipxe/pcibios.h +++ b/src/arch/x86/include/ipxe/pcibios.h @@ -132,4 +132,17 @@ PCIAPI_INLINE ( pcbios, pci_write_config_dword ) ( struct pci_device *pci, return pcibios_write ( pci, PCIBIOS_WRITE_CONFIG_DWORD | where, value); } +/** + * Map PCI bus address as an I/O address + * + * @v bus_addr PCI bus address + * @v len Length of region + * @ret io_addr I/O address, or NULL on error + */ +static inline __always_inline void * +PCIAPI_INLINE ( pcbios, pci_ioremap ) ( struct pci_device *pci __unused, + unsigned long bus_addr, size_t len ) { + return ioremap ( bus_addr, len ); +} + #endif /* _IPXE_PCIBIOS_H */ diff --git a/src/arch/x86/include/ipxe/pcidirect.h b/src/arch/x86/include/ipxe/pcidirect.h index d924f2f20..9570fd7d6 100644 --- a/src/arch/x86/include/ipxe/pcidirect.h +++ b/src/arch/x86/include/ipxe/pcidirect.h @@ -138,4 +138,17 @@ PCIAPI_INLINE ( direct, pci_write_config_dword ) ( struct pci_device *pci, return 0; } +/** + * Map PCI bus address as an I/O address + * + * @v bus_addr PCI bus address + * @v len Length of region + * @ret io_addr I/O address, or NULL on error + */ +static inline __always_inline void * +PCIAPI_INLINE ( direct, pci_ioremap ) ( struct pci_device *pci __unused, + unsigned long bus_addr, size_t len ) { + return ioremap ( bus_addr, len ); +} + #endif /* _PCIDIRECT_H */ diff --git a/src/arch/x86/interface/pcbios/pcibios.c b/src/arch/x86/interface/pcbios/pcibios.c index 07ac0c18d..bf812f77f 100644 --- a/src/arch/x86/interface/pcbios/pcibios.c +++ b/src/arch/x86/interface/pcbios/pcibios.c @@ -121,3 +121,4 @@ PROVIDE_PCIAPI_INLINE ( pcbios, pci_read_config_dword ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_byte ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_word ); PROVIDE_PCIAPI_INLINE ( pcbios, pci_write_config_dword ); +PROVIDE_PCIAPI_INLINE ( pcbios, pci_ioremap ); -- cgit v1.2.3-55-g7522 From eecb75ba4809bd5d3e6d63413a45c5fccbda2bc2 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 24 Sep 2020 21:45:03 +0100 Subject: [pci] Update drivers to use pci_ioremap() Signed-off-by: Michael Brown --- src/arch/x86/drivers/xen/hvm.c | 6 ++++-- src/arch/x86/drivers/xen/hvm.h | 2 ++ src/drivers/bus/pcimsix.c | 2 +- src/drivers/bus/virtio-pci.c | 2 +- src/drivers/infiniband/arbel.c | 15 +++++++++------ src/drivers/infiniband/flexboot_nodnic.c | 2 +- src/drivers/infiniband/golan.c | 6 +++--- src/drivers/infiniband/hermon.c | 18 ++++++++++++------ src/drivers/infiniband/linda.c | 2 +- .../infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c | 2 +- src/drivers/infiniband/qib7322.c | 2 +- src/drivers/net/amd8111e.c | 2 +- src/drivers/net/ath/ath5k/ath5k.c | 2 +- src/drivers/net/ath/ath9k/ath9k.c | 2 +- src/drivers/net/b44.c | 2 +- src/drivers/net/bnx2.c | 2 +- src/drivers/net/bnxt/bnxt.c | 2 +- src/drivers/net/ena.c | 2 +- src/drivers/net/etherfabric.c | 2 +- src/drivers/net/exanic.c | 4 ++-- src/drivers/net/forcedeth.c | 2 +- src/drivers/net/icplus.c | 2 +- src/drivers/net/igbvf/igbvf_main.c | 2 +- src/drivers/net/intel.c | 2 +- src/drivers/net/intelx.c | 2 +- src/drivers/net/intelxl.c | 2 +- src/drivers/net/intelxlvf.c | 2 +- src/drivers/net/intelxvf.c | 2 +- src/drivers/net/jme.c | 2 +- src/drivers/net/myson.c | 2 +- src/drivers/net/natsemi.c | 2 +- src/drivers/net/phantom/phantom.c | 2 +- src/drivers/net/prism2_pci.c | 2 +- src/drivers/net/realtek.c | 2 +- src/drivers/net/rhine.c | 2 +- src/drivers/net/sfc/efx_common.c | 2 +- src/drivers/net/sis190.c | 2 +- src/drivers/net/skeleton.c | 2 +- src/drivers/net/skge.c | 5 +++-- src/drivers/net/sky2.c | 2 +- src/drivers/net/tg3/tg3.c | 2 +- src/drivers/net/thunderx.c | 16 ++++++++-------- src/drivers/net/velocity.c | 2 +- src/drivers/net/vmxnet3.c | 8 ++++---- src/drivers/net/vxge/vxge_main.c | 2 +- src/drivers/usb/ehci.c | 2 +- src/drivers/usb/xhci.c | 2 +- 47 files changed, 85 insertions(+), 71 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/drivers/xen/hvm.c b/src/arch/x86/drivers/xen/hvm.c index 57196f555..311f343ca 100644 --- a/src/arch/x86/drivers/xen/hvm.c +++ b/src/arch/x86/drivers/xen/hvm.c @@ -175,7 +175,7 @@ static void * hvm_ioremap ( struct hvm_device *hvm, unsigned int space, } /* Map this space */ - mmio = ioremap ( ( hvm->mmio + hvm->mmio_offset ), len ); + mmio = pci_ioremap ( hvm->pci, ( hvm->mmio + hvm->mmio_offset ), len ); if ( ! mmio ) { DBGC ( hvm, "HVM could not map MMIO space [%08lx,%08lx)\n", ( hvm->mmio + hvm->mmio_offset ), @@ -371,7 +371,8 @@ static int hvm_map_xenstore ( struct hvm_device *hvm ) { xenstore_phys = ( xenstore_pfn * PAGE_SIZE ); /* Map XenStore */ - hvm->xen.store.intf = ioremap ( xenstore_phys, PAGE_SIZE ); + hvm->xen.store.intf = pci_ioremap ( hvm->pci, xenstore_phys, + PAGE_SIZE ); if ( ! hvm->xen.store.intf ) { DBGC ( hvm, "HVM could not map XenStore at [%08lx,%08lx)\n", xenstore_phys, ( xenstore_phys + PAGE_SIZE ) ); @@ -420,6 +421,7 @@ static int hvm_probe ( struct pci_device *pci ) { rc = -ENOMEM; goto err_alloc; } + hvm->pci = pci; hvm->mmio = pci_bar_start ( pci, HVM_MMIO_BAR ); hvm->mmio_len = pci_bar_size ( pci, HVM_MMIO_BAR ); DBGC2 ( hvm, "HVM has MMIO space [%08lx,%08lx)\n", diff --git a/src/arch/x86/drivers/xen/hvm.h b/src/arch/x86/drivers/xen/hvm.h index 72ed94f6d..88e490815 100644 --- a/src/arch/x86/drivers/xen/hvm.h +++ b/src/arch/x86/drivers/xen/hvm.h @@ -39,6 +39,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); struct hvm_device { /** Xen hypervisor */ struct xen_hypervisor xen; + /** PCI device */ + struct pci_device *pci; /** CPUID base */ uint32_t cpuid_base; /** Length of hypercall table */ diff --git a/src/drivers/bus/pcimsix.c b/src/drivers/bus/pcimsix.c index 80893c418..eb0450d91 100644 --- a/src/drivers/bus/pcimsix.c +++ b/src/drivers/bus/pcimsix.c @@ -84,7 +84,7 @@ static void * pci_msix_ioremap ( struct pci_device *pci, struct pci_msix *msix, msix, pci_msix_name ( cfg ), base, bar, offset ); /* Map BAR portion */ - io = ioremap ( ( start + offset ), PCI_MSIX_LEN ); + io = pci_ioremap ( pci, ( start + offset ), PCI_MSIX_LEN ); if ( ! io ) { DBGC ( msix, "MSI-X %p %s could not map %#08lx\n", msix, pci_msix_name ( cfg ), base ); diff --git a/src/drivers/bus/virtio-pci.c b/src/drivers/bus/virtio-pci.c index 402bf4f12..5d2d62750 100644 --- a/src/drivers/bus/virtio-pci.c +++ b/src/drivers/bus/virtio-pci.c @@ -321,7 +321,7 @@ int virtio_pci_map_capability(struct pci_device *pci, int cap, size_t minlen, region->flags = VIRTIO_PCI_REGION_PORT; } else { /* Region mapped into memory space */ - region->base = ioremap(base + offset, length); + region->base = pci_ioremap(pci, base + offset, length); region->flags = VIRTIO_PCI_REGION_MEMORY; } } diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index 98a2b6010..eb7911aa4 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -2059,7 +2059,8 @@ static int arbel_start_firmware ( struct arbel *arbel ) { eq_set_ci_base_addr = ( ( (uint64_t) MLX_GET ( &fw, eq_set_ci_base_addr_h ) << 32 ) | ( (uint64_t) MLX_GET ( &fw, eq_set_ci_base_addr_l ) ) ); - arbel->eq_ci_doorbells = ioremap ( eq_set_ci_base_addr, 0x200 ); + arbel->eq_ci_doorbells = pci_ioremap ( arbel->pci, eq_set_ci_base_addr, + 0x200 ); /* Enable locally-attached memory. Ignore failure; there may * be no attached memory. @@ -3025,6 +3026,8 @@ static void arbel_free ( struct arbel *arbel ) { static int arbel_probe ( struct pci_device *pci ) { struct arbel *arbel; struct ib_device *ibdev; + unsigned long config; + unsigned long uar; int i; int rc; @@ -3041,11 +3044,11 @@ static int arbel_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BARs */ - arbel->config = ioremap ( pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR ), - ARBEL_PCI_CONFIG_BAR_SIZE ); - arbel->uar = ioremap ( ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) + - ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE ), - ARBEL_PCI_UAR_SIZE ); + config = pci_bar_start ( pci, ARBEL_PCI_CONFIG_BAR ); + arbel->config = pci_ioremap ( pci, config, ARBEL_PCI_CONFIG_BAR_SIZE ); + uar = ( pci_bar_start ( pci, ARBEL_PCI_UAR_BAR ) + + ARBEL_PCI_UAR_IDX * ARBEL_PCI_UAR_SIZE ); + arbel->uar = pci_ioremap ( pci, uar, ARBEL_PCI_UAR_SIZE ); /* Allocate Infiniband devices */ for ( i = 0 ; i < ARBEL_NUM_PORTS ; i++ ) { diff --git a/src/drivers/infiniband/flexboot_nodnic.c b/src/drivers/infiniband/flexboot_nodnic.c index 7d039fffc..54b858406 100644 --- a/src/drivers/infiniband/flexboot_nodnic.c +++ b/src/drivers/infiniband/flexboot_nodnic.c @@ -1461,7 +1461,7 @@ static int flexboot_nodnic_alloc_uar ( struct flexboot_nodnic *flexboot_nodnic ) return -EINVAL; } uar->phys = ( pci_bar_start ( pci, FLEXBOOT_NODNIC_HCA_BAR ) + (mlx_uint32)uar->offset ); - uar->virt = ( void * )( ioremap ( uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) ); + uar->virt = ( void * )( pci_ioremap ( pci, uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) ); return status; } diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index e96ba2698..7ab4a4ee6 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -693,7 +693,7 @@ static inline int golan_alloc_uar(struct golan *golan) uar->index = be32_to_cpu(out->uarn) & 0xffffff; uar->phys = (pci_bar_start(golan->pci, GOLAN_HCA_BAR) + (uar->index << GOLAN_PAGE_SHIFT)); - uar->virt = (void *)(ioremap(uar->phys, GOLAN_PAGE_SIZE)); + uar->virt = (void *)(pci_ioremap(golan->pci, uar->phys, GOLAN_PAGE_SIZE)); DBGC( golan , "%s: UAR allocated with index 0x%x\n", __FUNCTION__, uar->index); return 0; @@ -922,8 +922,8 @@ static inline void golan_pci_init(struct golan *golan) adjust_pci_device ( pci ); /* Get HCA BAR */ - golan->iseg = ioremap ( pci_bar_start ( pci, GOLAN_HCA_BAR), - GOLAN_PCI_CONFIG_BAR_SIZE ); + golan->iseg = pci_ioremap ( pci, pci_bar_start ( pci, GOLAN_HCA_BAR), + GOLAN_PCI_CONFIG_BAR_SIZE ); } static inline struct golan *golan_alloc() diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index 9675c156b..b6599588f 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -3782,6 +3782,8 @@ static int hermon_probe ( struct pci_device *pci ) { struct ib_device *ibdev; struct net_device *netdev; struct hermon_port *port; + unsigned long config; + unsigned long uar; unsigned int i; int rc; @@ -3798,10 +3800,12 @@ static int hermon_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BARs */ - hermon->config = ioremap ( pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ), - HERMON_PCI_CONFIG_BAR_SIZE ); - hermon->uar = ioremap ( pci_bar_start ( pci, HERMON_PCI_UAR_BAR ), - HERMON_UAR_NON_EQ_PAGE * HERMON_PAGE_SIZE ); + config = pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ); + hermon->config = pci_ioremap ( pci, config, + HERMON_PCI_CONFIG_BAR_SIZE ); + uar = pci_bar_start ( pci, HERMON_PCI_UAR_BAR ); + hermon->uar = pci_ioremap ( pci, uar, + HERMON_UAR_NON_EQ_PAGE * HERMON_PAGE_SIZE ); /* Reset device */ hermon_reset ( hermon ); @@ -3937,6 +3941,7 @@ static void hermon_remove ( struct pci_device *pci ) { */ static int hermon_bofm_probe ( struct pci_device *pci ) { struct hermon *hermon; + unsigned long config; int rc; /* Allocate Hermon device */ @@ -3952,8 +3957,9 @@ static int hermon_bofm_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BAR */ - hermon->config = ioremap ( pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ), - HERMON_PCI_CONFIG_BAR_SIZE ); + config = pci_bar_start ( pci, HERMON_PCI_CONFIG_BAR ); + hermon->config = pci_ioremap ( pci, config, + HERMON_PCI_CONFIG_BAR_SIZE ); /* Initialise BOFM device */ bofm_init ( &hermon->bofm, pci, &hermon_bofm_operations ); diff --git a/src/drivers/infiniband/linda.c b/src/drivers/infiniband/linda.c index e8d61c865..8c2c090bc 100644 --- a/src/drivers/infiniband/linda.c +++ b/src/drivers/infiniband/linda.c @@ -2335,7 +2335,7 @@ static int linda_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BARs */ - linda->regs = ioremap ( pci->membase, LINDA_BAR0_SIZE ); + linda->regs = pci_ioremap ( pci, pci->membase, LINDA_BAR0_SIZE ); DBGC2 ( linda, "Linda %p has BAR at %08lx\n", linda, pci->membase ); /* Print some general data */ diff --git a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c index b474a4a63..6b42bcafc 100644 --- a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c +++ b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c @@ -115,7 +115,7 @@ mlx_pci_init_priv( mlx_status status = MLX_SUCCESS; adjust_pci_device ( utils->pci ); #ifdef DEVICE_CX3 - utils->config = ioremap ( pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0), + utils->config = pci_ioremap ( utils->pci, pci_bar_start ( utils->pci, PCI_BASE_ADDRESS_0), 0x100000 ); #endif return status; diff --git a/src/drivers/infiniband/qib7322.c b/src/drivers/infiniband/qib7322.c index 18011c19a..a5606dd03 100644 --- a/src/drivers/infiniband/qib7322.c +++ b/src/drivers/infiniband/qib7322.c @@ -2297,7 +2297,7 @@ static int qib7322_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BARs */ - qib7322->regs = ioremap ( pci->membase, QIB7322_BAR0_SIZE ); + qib7322->regs = pci_ioremap ( pci, pci->membase, QIB7322_BAR0_SIZE ); DBGC2 ( qib7322, "QIB7322 %p has BAR at %08lx\n", qib7322, pci->membase ); diff --git a/src/drivers/net/amd8111e.c b/src/drivers/net/amd8111e.c index 693d77d1d..babd12d3c 100644 --- a/src/drivers/net/amd8111e.c +++ b/src/drivers/net/amd8111e.c @@ -664,7 +664,7 @@ static int amd8111e_probe(struct nic *nic, struct pci_device *pdev) memset(lp, 0, sizeof(*lp)); lp->pdev = pdev; lp->nic = nic; - lp->mmio = ioremap(mmio_start, mmio_len); + lp->mmio = pci_ioremap(pdev, mmio_start, mmio_len); lp->opened = 1; adjust_pci_device(pdev); diff --git a/src/drivers/net/ath/ath5k/ath5k.c b/src/drivers/net/ath/ath5k/ath5k.c index a500175a7..d8c47909d 100644 --- a/src/drivers/net/ath/ath5k/ath5k.c +++ b/src/drivers/net/ath/ath5k/ath5k.c @@ -280,7 +280,7 @@ static int ath5k_probe(struct pci_device *pdev) */ pci_write_config_byte(pdev, 0x41, 0); - mem = ioremap(pdev->membase, 0x10000); + mem = pci_ioremap(pdev, pdev->membase, 0x10000); if (!mem) { DBG("ath5k: cannot remap PCI memory region\n"); ret = -EIO; diff --git a/src/drivers/net/ath/ath9k/ath9k.c b/src/drivers/net/ath/ath9k/ath9k.c index 183aa65f6..98b7ecd5a 100644 --- a/src/drivers/net/ath/ath9k/ath9k.c +++ b/src/drivers/net/ath/ath9k/ath9k.c @@ -138,7 +138,7 @@ static int ath_pci_probe(struct pci_device *pdev) if ((val & 0x0000ff00) != 0) pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - mem = ioremap(pdev->membase, 0x10000); + mem = pci_ioremap(pdev, pdev->membase, 0x10000); if (!mem) { DBG("ath9K: PCI memory map error\n") ; ret = -EIO; diff --git a/src/drivers/net/b44.c b/src/drivers/net/b44.c index d9aeb1b4b..e0e6f4642 100644 --- a/src/drivers/net/b44.c +++ b/src/drivers/net/b44.c @@ -673,7 +673,7 @@ static int b44_probe(struct pci_device *pci) bp->pci = pci; /* Map device registers */ - bp->regs = ioremap(pci->membase, B44_REGS_SIZE); + bp->regs = pci_ioremap(pci, pci->membase, B44_REGS_SIZE); if (!bp->regs) { netdev_put(netdev); return -ENOMEM; diff --git a/src/drivers/net/bnx2.c b/src/drivers/net/bnx2.c index 4ebcc52a9..d5783ff99 100644 --- a/src/drivers/net/bnx2.c +++ b/src/drivers/net/bnx2.c @@ -2152,7 +2152,7 @@ bnx2_init_board(struct pci_device *pdev, struct nic *nic) bnx2reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0); bnx2reg_len = MB_GET_CID_ADDR(17); - bp->regview = ioremap(bnx2reg_base, bnx2reg_len); + bp->regview = pci_ioremap(pdev, bnx2reg_base, bnx2reg_len); if (!bp->regview) { printf("Cannot map register space, aborting.\n"); diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index e6bceb970..fe84ea0e4 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -60,7 +60,7 @@ static void *bnxt_pci_base ( struct pci_device *pdev, unsigned int reg ) reg_base = pci_bar_start ( pdev, reg ); reg_size = pci_bar_size ( pdev, reg ); - return ioremap ( reg_base, reg_size ); + return pci_ioremap ( pdev, reg_base, reg_size ); } static int bnxt_get_pci_info ( struct bnxt *bp ) diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 0f25c0beb..5c76eb6fd 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -933,7 +933,7 @@ static int ena_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - ena->regs = ioremap ( pci->membase, ENA_BAR_SIZE ); + ena->regs = pci_ioremap ( pci, pci->membase, ENA_BAR_SIZE ); if ( ! ena->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c index 2cd41d4ca..cd567f1d9 100644 --- a/src/drivers/net/etherfabric.c +++ b/src/drivers/net/etherfabric.c @@ -4150,7 +4150,7 @@ efab_probe ( struct pci_device *pci ) /* Get iobase/membase */ mmio_start = pci_bar_start ( pci, PCI_BASE_ADDRESS_2 ); mmio_len = pci_bar_size ( pci, PCI_BASE_ADDRESS_2 ); - efab->membase = ioremap ( mmio_start, mmio_len ); + efab->membase = pci_ioremap ( pci, mmio_start, mmio_len ); EFAB_TRACE ( "BAR of %lx bytes at phys %lx mapped at %p\n", mmio_len, mmio_start, efab->membase ); diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index 287e14e8d..8849da285 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -800,7 +800,7 @@ static int exanic_probe ( struct pci_device *pci ) { /* Map registers */ regs_bar_start = pci_bar_start ( pci, EXANIC_REGS_BAR ); - exanic->regs = ioremap ( regs_bar_start, EXANIC_REGS_LEN ); + exanic->regs = pci_ioremap ( pci, regs_bar_start, EXANIC_REGS_LEN ); if ( ! exanic->regs ) { rc = -ENODEV; goto err_ioremap_regs; @@ -824,7 +824,7 @@ static int exanic_probe ( struct pci_device *pci ) { /* Map transmit region */ tx_bar_start = pci_bar_start ( pci, EXANIC_TX_BAR ); tx_bar_len = pci_bar_size ( pci, EXANIC_TX_BAR ); - exanic->tx = ioremap ( tx_bar_start, tx_bar_len ); + exanic->tx = pci_ioremap ( pci, tx_bar_start, tx_bar_len ); if ( ! exanic->tx ) { rc = -ENODEV; goto err_ioremap_tx; diff --git a/src/drivers/net/forcedeth.c b/src/drivers/net/forcedeth.c index 7f044b192..94cc6063b 100644 --- a/src/drivers/net/forcedeth.c +++ b/src/drivers/net/forcedeth.c @@ -1762,7 +1762,7 @@ forcedeth_map_regs ( struct forcedeth_private *priv ) } rc = -ENOMEM; - ioaddr = ioremap ( addr, register_size ); + ioaddr = pci_ioremap ( priv->pci_dev, addr, register_size ); if ( ! ioaddr ) { DBG ( "Cannot remap MMIO\n" ); goto err_ioremap; diff --git a/src/drivers/net/icplus.c b/src/drivers/net/icplus.c index 4bed92427..58092fade 100644 --- a/src/drivers/net/icplus.c +++ b/src/drivers/net/icplus.c @@ -726,7 +726,7 @@ static int icplus_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - icp->regs = ioremap ( pci->membase, ICP_BAR_SIZE ); + icp->regs = pci_ioremap ( pci, pci->membase, ICP_BAR_SIZE ); if ( ! icp->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/igbvf/igbvf_main.c b/src/drivers/net/igbvf/igbvf_main.c index fc7021c38..39d4e7f8a 100644 --- a/src/drivers/net/igbvf/igbvf_main.c +++ b/src/drivers/net/igbvf/igbvf_main.c @@ -843,7 +843,7 @@ int igbvf_probe ( struct pci_device *pdev ) DBG ( "mmio_start: %#08lx\n", mmio_start ); DBG ( "mmio_len: %#08lx\n", mmio_len ); - adapter->hw.hw_addr = ioremap ( mmio_start, mmio_len ); + adapter->hw.hw_addr = pci_ioremap ( pdev, mmio_start, mmio_len ); DBG ( "adapter->hw.hw_addr: %p\n", adapter->hw.hw_addr ); if ( ! adapter->hw.hw_addr ) { diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index d9b8b46b7..97f50a943 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -959,7 +959,7 @@ static int intel_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE ); + intel->regs = pci_ioremap ( pci, pci->membase, INTEL_BAR_SIZE ); if ( ! intel->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/intelx.c b/src/drivers/net/intelx.c index 91fb7955f..38e8467a9 100644 --- a/src/drivers/net/intelx.c +++ b/src/drivers/net/intelx.c @@ -405,7 +405,7 @@ static int intelx_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - intel->regs = ioremap ( pci->membase, INTEL_BAR_SIZE ); + intel->regs = pci_ioremap ( pci, pci->membase, INTEL_BAR_SIZE ); if ( ! intel->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index c98ba265c..08c90bc48 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -1673,7 +1673,7 @@ static int intelxl_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - intelxl->regs = ioremap ( pci->membase, INTELXL_BAR_SIZE ); + intelxl->regs = pci_ioremap ( pci, pci->membase, INTELXL_BAR_SIZE ); if ( ! intelxl->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/intelxlvf.c b/src/drivers/net/intelxlvf.c index 8f76daf3d..83e484c8d 100644 --- a/src/drivers/net/intelxlvf.c +++ b/src/drivers/net/intelxlvf.c @@ -612,7 +612,7 @@ static int intelxlvf_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - intelxl->regs = ioremap ( pci->membase, INTELXLVF_BAR_SIZE ); + intelxl->regs = pci_ioremap ( pci, pci->membase, INTELXLVF_BAR_SIZE ); if ( ! intelxl->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/intelxvf.c b/src/drivers/net/intelxvf.c index 2caeec27e..fef3024e9 100644 --- a/src/drivers/net/intelxvf.c +++ b/src/drivers/net/intelxvf.c @@ -456,7 +456,7 @@ static int intelxvf_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - intel->regs = ioremap ( pci->membase, INTELVF_BAR_SIZE ); + intel->regs = pci_ioremap ( pci, pci->membase, INTELVF_BAR_SIZE ); if ( ! intel->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/jme.c b/src/drivers/net/jme.c index 29694b699..b68b96c88 100644 --- a/src/drivers/net/jme.c +++ b/src/drivers/net/jme.c @@ -1191,7 +1191,7 @@ jme_probe(struct pci_device *pci) jme = netdev->priv; pci_set_drvdata(pci, netdev); netdev->dev = &pci->dev; - jme->regs = ioremap(pci->membase, JME_REGS_SIZE); + jme->regs = pci_ioremap(pci, pci->membase, JME_REGS_SIZE); if (!(jme->regs)) { DBG("Mapping PCI resource region error.\n"); rc = -ENOMEM; diff --git a/src/drivers/net/myson.c b/src/drivers/net/myson.c index 84a550596..4dd0aab4a 100644 --- a/src/drivers/net/myson.c +++ b/src/drivers/net/myson.c @@ -606,7 +606,7 @@ static int myson_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - myson->regs = ioremap ( pci->membase, MYSON_BAR_SIZE ); + myson->regs = pci_ioremap ( pci, pci->membase, MYSON_BAR_SIZE ); if ( ! myson->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/natsemi.c b/src/drivers/net/natsemi.c index 9f2c3029c..33cf68b3c 100644 --- a/src/drivers/net/natsemi.c +++ b/src/drivers/net/natsemi.c @@ -853,7 +853,7 @@ static int natsemi_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - natsemi->regs = ioremap ( pci->membase, NATSEMI_BAR_SIZE ); + natsemi->regs = pci_ioremap ( pci, pci->membase, NATSEMI_BAR_SIZE ); if ( ! natsemi->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c index 781049ff4..8f247ff8e 100644 --- a/src/drivers/net/phantom/phantom.c +++ b/src/drivers/net/phantom/phantom.c @@ -1837,7 +1837,7 @@ static int phantom_map_crb ( struct phantom_nic *phantom, return -EINVAL; } - phantom->bar0 = ioremap ( bar0_start, bar0_size ); + phantom->bar0 = pci_ioremap ( pci, bar0_start, bar0_size ); if ( ! phantom->bar0 ) { DBGC ( phantom, "Phantom %p could not map BAR0\n", phantom ); return -EIO; diff --git a/src/drivers/net/prism2_pci.c b/src/drivers/net/prism2_pci.c index 69ddf0fb0..2feb69522 100644 --- a/src/drivers/net/prism2_pci.c +++ b/src/drivers/net/prism2_pci.c @@ -36,7 +36,7 @@ static int prism2_pci_probe ( struct nic *nic, struct pci_device *pci ) { hfa384x_t *hw = &hw_global; printf ( "Prism2.5 has registers at %#lx\n", pci->membase ); - hw->membase = ioremap ( pci->membase, 0x100 ); + hw->membase = pci_ioremap ( pci, pci->membase, 0x100 ); nic->ioaddr = pci->membase; nic->irqno = 0; diff --git a/src/drivers/net/realtek.c b/src/drivers/net/realtek.c index 310b9f96a..0421b4db7 100644 --- a/src/drivers/net/realtek.c +++ b/src/drivers/net/realtek.c @@ -1128,7 +1128,7 @@ static int realtek_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - rtl->regs = ioremap ( pci->membase, RTL_BAR_SIZE ); + rtl->regs = pci_ioremap ( pci, pci->membase, RTL_BAR_SIZE ); if ( ! rtl->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/rhine.c b/src/drivers/net/rhine.c index a1dc58725..cbe21c316 100644 --- a/src/drivers/net/rhine.c +++ b/src/drivers/net/rhine.c @@ -700,7 +700,7 @@ static int rhine_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - rhn->regs = ioremap ( pci->membase, RHINE_BAR_SIZE ); + rhn->regs = pci_ioremap ( pci, pci->membase, RHINE_BAR_SIZE ); rhn->ioaddr = pci->ioaddr; DBGC ( rhn, "RHINE %p regs at %08lx, I/O at %04lx\n", rhn, pci->membase, pci->ioaddr ); diff --git a/src/drivers/net/sfc/efx_common.c b/src/drivers/net/sfc/efx_common.c index 403887707..fd465612e 100644 --- a/src/drivers/net/sfc/efx_common.c +++ b/src/drivers/net/sfc/efx_common.c @@ -85,7 +85,7 @@ void efx_probe(struct net_device *netdev, enum efx_revision revision) efx->mmio_start = pci_bar_start(pci, reg); efx->mmio_len = pci_bar_size(pci, reg); - efx->membase = ioremap(efx->mmio_start, efx->mmio_len); + efx->membase = pci_ioremap(pci, efx->mmio_start, efx->mmio_len); DBGCP(efx, "BAR of %lx bytes at phys %lx mapped at %p\n", efx->mmio_len, efx->mmio_start, efx->membase); diff --git a/src/drivers/net/sis190.c b/src/drivers/net/sis190.c index b92e95f2a..11dda1c97 100644 --- a/src/drivers/net/sis190.c +++ b/src/drivers/net/sis190.c @@ -886,7 +886,7 @@ static int sis190_init_board(struct pci_device *pdev, struct net_device **netdev adjust_pci_device(pdev); - ioaddr = ioremap(pdev->membase, SIS190_REGS_SIZE); + ioaddr = pci_ioremap(pdev, pdev->membase, SIS190_REGS_SIZE); if (!ioaddr) { DBG("sis190: cannot remap MMIO, aborting\n"); rc = -EIO; diff --git a/src/drivers/net/skeleton.c b/src/drivers/net/skeleton.c index 0bae3089c..a76c6e3d9 100644 --- a/src/drivers/net/skeleton.c +++ b/src/drivers/net/skeleton.c @@ -195,7 +195,7 @@ static int skeleton_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - skel->regs = ioremap ( pci->membase, SKELETON_BAR_SIZE ); + skel->regs = pci_ioremap ( pci, pci->membase, SKELETON_BAR_SIZE ); if ( ! skel->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/skge.c b/src/drivers/net/skge.c index c3264225b..c9a7891ba 100755 --- a/src/drivers/net/skge.c +++ b/src/drivers/net/skge.c @@ -2346,8 +2346,9 @@ static int skge_probe(struct pci_device *pdev) hw->pdev = pdev; - hw->regs = (unsigned long)ioremap(pci_bar_start(pdev, PCI_BASE_ADDRESS_0), - SKGE_REG_SIZE); + hw->regs = (unsigned long)pci_ioremap(pdev, + pci_bar_start(pdev, PCI_BASE_ADDRESS_0), + SKGE_REG_SIZE); if (!hw->regs) { DBG(PFX "cannot map device registers\n"); goto err_out_free_hw; diff --git a/src/drivers/net/sky2.c b/src/drivers/net/sky2.c index 211f22466..0d11e17df 100644 --- a/src/drivers/net/sky2.c +++ b/src/drivers/net/sky2.c @@ -2278,7 +2278,7 @@ static int sky2_probe(struct pci_device *pdev) hw->pdev = pdev; - hw->regs = (unsigned long)ioremap(pci_bar_start(pdev, PCI_BASE_ADDRESS_0), 0x4000); + hw->regs = (unsigned long)pci_ioremap(pdev, pci_bar_start(pdev, PCI_BASE_ADDRESS_0), 0x4000); if (!hw->regs) { DBG(PFX "cannot map device registers\n"); goto err_out_free_hw; diff --git a/src/drivers/net/tg3/tg3.c b/src/drivers/net/tg3/tg3.c index 1bed06649..f6c038112 100644 --- a/src/drivers/net/tg3/tg3.c +++ b/src/drivers/net/tg3/tg3.c @@ -771,7 +771,7 @@ static int tg3_init_one(struct pci_device *pdev) reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0); reg_size = pci_bar_size(pdev, PCI_BASE_ADDRESS_0); - tp->regs = ioremap(reg_base, reg_size); + tp->regs = pci_ioremap(pdev, reg_base, reg_size); if (!tp->regs) { DBGC(&pdev->dev, "Failed to remap device registers\n"); errno = -ENOENT; diff --git a/src/drivers/net/thunderx.c b/src/drivers/net/thunderx.c index 9ddb98ab8..1865a9b91 100644 --- a/src/drivers/net/thunderx.c +++ b/src/drivers/net/thunderx.c @@ -645,11 +645,11 @@ static void txnic_poll ( struct txnic *vnic ) { /** * Allocate virtual NIC * - * @v dev Underlying device + * @v pci Underlying PCI device * @v membase Register base address * @ret vnic Virtual NIC, or NULL on failure */ -static struct txnic * txnic_alloc ( struct device *dev, +static struct txnic * txnic_alloc ( struct pci_device *pci, unsigned long membase ) { struct net_device *netdev; struct txnic *vnic; @@ -658,10 +658,10 @@ static struct txnic * txnic_alloc ( struct device *dev, netdev = alloc_etherdev ( sizeof ( *vnic ) ); if ( ! netdev ) goto err_alloc_netdev; - netdev->dev = dev; + netdev->dev = &pci->dev; vnic = netdev->priv; vnic->netdev = netdev; - vnic->name = dev->name; + vnic->name = pci->dev.name; /* Allow caller to reuse netdev->priv. (The generic virtual * NIC code never assumes that netdev->priv==vnic.) @@ -684,7 +684,7 @@ static struct txnic * txnic_alloc ( struct device *dev, goto err_alloc_rq; /* Map registers */ - vnic->regs = ioremap ( membase, TXNIC_VF_BAR_SIZE ); + vnic->regs = pci_ioremap ( pci, membase, TXNIC_VF_BAR_SIZE ); if ( ! vnic->regs ) goto err_ioremap; @@ -1103,7 +1103,7 @@ static int txnic_lmac_probe ( struct txnic_lmac *lmac ) { membase = ( pf->vf_membase + ( lmac->idx * pf->vf_stride ) ); /* Allocate and initialise network device */ - vnic = txnic_alloc ( &bgx->pci->dev, membase ); + vnic = txnic_alloc ( bgx->pci, membase ); if ( ! vnic ) { rc = -ENOMEM; goto err_alloc; @@ -1275,7 +1275,7 @@ static int txnic_pf_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - pf->regs = ioremap ( membase, TXNIC_PF_BAR_SIZE ); + pf->regs = pci_ioremap ( pci, membase, TXNIC_PF_BAR_SIZE ); if ( ! pf->regs ) { rc = -ENODEV; goto err_ioremap; @@ -1633,7 +1633,7 @@ static int txnic_bgx_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - bgx->regs = ioremap ( membase, TXNIC_BGX_BAR_SIZE ); + bgx->regs = pci_ioremap ( pci, membase, TXNIC_BGX_BAR_SIZE ); if ( ! bgx->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/net/velocity.c b/src/drivers/net/velocity.c index 0a2a3ac10..994e07a64 100644 --- a/src/drivers/net/velocity.c +++ b/src/drivers/net/velocity.c @@ -731,7 +731,7 @@ static int velocity_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map registers */ - vlc->regs = ioremap ( pci->membase, VELOCITY_BAR_SIZE ); + vlc->regs = pci_ioremap ( pci, pci->membase, VELOCITY_BAR_SIZE ); vlc->netdev = netdev; /* Reset the NIC */ diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 6a54dbf89..3e0ab03cd 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -641,14 +641,14 @@ static int vmxnet3_probe ( struct pci_device *pci ) { adjust_pci_device ( pci ); /* Map PCI BARs */ - vmxnet->pt = ioremap ( pci_bar_start ( pci, VMXNET3_PT_BAR ), - VMXNET3_PT_LEN ); + vmxnet->pt = pci_ioremap ( pci, pci_bar_start ( pci, VMXNET3_PT_BAR ), + VMXNET3_PT_LEN ); if ( ! vmxnet->pt ) { rc = -ENODEV; goto err_ioremap_pt; } - vmxnet->vd = ioremap ( pci_bar_start ( pci, VMXNET3_VD_BAR ), - VMXNET3_VD_LEN ); + vmxnet->vd = pci_ioremap ( pci, pci_bar_start ( pci, VMXNET3_VD_BAR ), + VMXNET3_VD_LEN ); if ( ! vmxnet->vd ) { rc = -ENODEV; goto err_ioremap_vd; diff --git a/src/drivers/net/vxge/vxge_main.c b/src/drivers/net/vxge/vxge_main.c index 8b099c0e2..631928318 100644 --- a/src/drivers/net/vxge/vxge_main.c +++ b/src/drivers/net/vxge/vxge_main.c @@ -520,7 +520,7 @@ vxge_probe(struct pci_device *pdev) /* sets the bus master */ adjust_pci_device(pdev); - bar0 = ioremap(mmio_start, mmio_len); + bar0 = pci_ioremap(pdev, mmio_start, mmio_len); if (!bar0) { vxge_debug(VXGE_ERR, "%s : cannot remap io memory bar0\n", __func__); diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 29c32b356..15193efe1 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -1989,7 +1989,7 @@ static int ehci_probe ( struct pci_device *pci ) { /* Map registers */ bar_start = pci_bar_start ( pci, EHCI_BAR ); bar_size = pci_bar_size ( pci, EHCI_BAR ); - ehci->regs = ioremap ( bar_start, bar_size ); + ehci->regs = pci_ioremap ( pci, bar_start, bar_size ); if ( ! ehci->regs ) { rc = -ENODEV; goto err_ioremap; diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index aa6ca73c4..c4a1dc337 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -3261,7 +3261,7 @@ static int xhci_probe ( struct pci_device *pci ) { /* Map registers */ bar_start = pci_bar_start ( pci, XHCI_BAR ); bar_size = pci_bar_size ( pci, XHCI_BAR ); - xhci->regs = ioremap ( bar_start, bar_size ); + xhci->regs = pci_ioremap ( pci, bar_start, bar_size ); if ( ! xhci->regs ) { rc = -ENODEV; goto err_ioremap; -- cgit v1.2.3-55-g7522 From be1c87b72237f633c4f4b05bcb133acf2967d788 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 5 Nov 2020 19:08:48 +0000 Subject: [malloc] Rename malloc_dma() to malloc_phys() The malloc_dma() function allocates memory with specified physical alignment, and is typically (though not exclusively) used to allocate memory for DMA. Rename to malloc_phys() to more closely match the functionality, and to create name space for functions that specifically allocate and map DMA-capable buffers. Signed-off-by: Michael Brown --- src/arch/x86/drivers/hyperv/hyperv.c | 12 ++--- src/arch/x86/drivers/xen/hvm.c | 4 +- src/core/iobuf.c | 12 ++--- src/core/malloc.c | 4 +- src/drivers/infiniband/arbel.c | 62 +++++++++++----------- src/drivers/infiniband/golan.c | 58 ++++++++++---------- src/drivers/infiniband/hermon.c | 60 ++++++++++----------- src/drivers/infiniband/linda.c | 16 +++--- .../mlx_utils_flexboot/src/mlx_memory_priv.c | 4 +- src/drivers/infiniband/qib7322.c | 16 +++--- src/drivers/net/3c90x.c | 8 +-- src/drivers/net/ath/ath5k/ath5k.c | 6 +-- src/drivers/net/ath/ath9k/ath9k_init.c | 6 +-- src/drivers/net/atl1e.c | 4 +- src/drivers/net/b44.c | 12 ++--- src/drivers/net/bnxt/bnxt.c | 30 +++++------ src/drivers/net/eepro100.c | 18 +++---- src/drivers/net/ena.c | 24 ++++----- src/drivers/net/etherfabric.c | 4 +- src/drivers/net/exanic.c | 6 +-- src/drivers/net/forcedeth.c | 4 +- src/drivers/net/icplus.c | 6 +-- src/drivers/net/igbvf/igbvf_main.c | 10 ++-- src/drivers/net/intel.c | 4 +- src/drivers/net/intelxl.c | 10 ++-- src/drivers/net/jme.c | 8 +-- src/drivers/net/myri10ge.c | 8 +-- src/drivers/net/myson.c | 6 +-- src/drivers/net/natsemi.c | 6 +-- src/drivers/net/netfront.c | 6 +-- src/drivers/net/pcnet32.c | 8 +-- src/drivers/net/phantom/phantom.c | 16 +++--- src/drivers/net/realtek.c | 10 ++-- src/drivers/net/rhine.c | 4 +- src/drivers/net/rtl818x/rtl818x.c | 12 ++--- src/drivers/net/sfc/efx_hunt.c | 4 +- src/drivers/net/sis190.c | 8 +-- src/drivers/net/skge.c | 4 +- src/drivers/net/sky2.c | 14 ++--- src/drivers/net/tg3/tg3.c | 20 +++---- src/drivers/net/velocity.c | 12 +++-- src/drivers/net/vmxnet3.c | 7 +-- src/drivers/net/vxge/vxge_config.c | 12 ++--- src/drivers/usb/ehci.c | 29 +++++----- src/drivers/usb/uhci.c | 26 ++++----- src/drivers/usb/xhci.c | 42 +++++++-------- src/include/ipxe/malloc.h | 32 +++++------ src/interface/hyperv/vmbus.c | 6 +-- 48 files changed, 350 insertions(+), 350 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/drivers/hyperv/hyperv.c b/src/arch/x86/drivers/hyperv/hyperv.c index 1903d1db2..9d3a42da0 100644 --- a/src/arch/x86/drivers/hyperv/hyperv.c +++ b/src/arch/x86/drivers/hyperv/hyperv.c @@ -83,7 +83,7 @@ hv_alloc_pages ( struct hv_hypervisor *hv, ... ) { /* Allocate and zero pages */ va_start ( args, hv ); for ( i = 0 ; ( ( page = va_arg ( args, void ** ) ) != NULL ); i++ ) { - *page = malloc_dma ( PAGE_SIZE, PAGE_SIZE ); + *page = malloc_phys ( PAGE_SIZE, PAGE_SIZE ); if ( ! *page ) goto err_alloc; memset ( *page, 0, PAGE_SIZE ); @@ -97,7 +97,7 @@ hv_alloc_pages ( struct hv_hypervisor *hv, ... ) { va_start ( args, hv ); for ( ; i >= 0 ; i-- ) { page = va_arg ( args, void ** ); - free_dma ( *page, PAGE_SIZE ); + free_phys ( *page, PAGE_SIZE ); } va_end ( args ); return -ENOMEM; @@ -116,7 +116,7 @@ hv_free_pages ( struct hv_hypervisor *hv, ... ) { va_start ( args, hv ); while ( ( page = va_arg ( args, void * ) ) != NULL ) - free_dma ( page, PAGE_SIZE ); + free_phys ( page, PAGE_SIZE ); va_end ( args ); } @@ -131,8 +131,8 @@ static int hv_alloc_message ( struct hv_hypervisor *hv ) { /* Allocate buffer. Must be aligned to at least 8 bytes and * must not cross a page boundary, so align on its own size. */ - hv->message = malloc_dma ( sizeof ( *hv->message ), - sizeof ( *hv->message ) ); + hv->message = malloc_phys ( sizeof ( *hv->message ), + sizeof ( *hv->message ) ); if ( ! hv->message ) return -ENOMEM; @@ -147,7 +147,7 @@ static int hv_alloc_message ( struct hv_hypervisor *hv ) { static void hv_free_message ( struct hv_hypervisor *hv ) { /* Free buffer */ - free_dma ( hv->message, sizeof ( *hv->message ) ); + free_phys ( hv->message, sizeof ( *hv->message ) ); } /** diff --git a/src/arch/x86/drivers/xen/hvm.c b/src/arch/x86/drivers/xen/hvm.c index 311f343ca..b77cdd14c 100644 --- a/src/arch/x86/drivers/xen/hvm.c +++ b/src/arch/x86/drivers/xen/hvm.c @@ -106,7 +106,7 @@ static int hvm_map_hypercall ( struct hvm_device *hvm ) { /* Allocate pages */ hvm->hypercall_len = ( pages * PAGE_SIZE ); - hvm->xen.hypercall = malloc_dma ( hvm->hypercall_len, PAGE_SIZE ); + hvm->xen.hypercall = malloc_phys ( hvm->hypercall_len, PAGE_SIZE ); if ( ! hvm->xen.hypercall ) { DBGC ( hvm, "HVM could not allocate %d hypercall page(s)\n", pages ); @@ -141,7 +141,7 @@ static int hvm_map_hypercall ( struct hvm_device *hvm ) { static void hvm_unmap_hypercall ( struct hvm_device *hvm ) { /* Free pages */ - free_dma ( hvm->xen.hypercall, hvm->hypercall_len ); + free_phys ( hvm->xen.hypercall, hvm->hypercall_len ); } /** diff --git a/src/core/iobuf.c b/src/core/iobuf.c index 0ee53e038..941bb3446 100644 --- a/src/core/iobuf.c +++ b/src/core/iobuf.c @@ -88,8 +88,8 @@ struct io_buffer * alloc_iob_raw ( size_t len, size_t align, size_t offset ) { len += ( ( - len - offset ) & ( __alignof__ ( *iobuf ) - 1 ) ); /* Allocate memory for buffer plus descriptor */ - data = malloc_dma_offset ( len + sizeof ( *iobuf ), align, - offset ); + data = malloc_phys_offset ( len + sizeof ( *iobuf ), align, + offset ); if ( ! data ) return NULL; iobuf = ( data + len ); @@ -97,14 +97,14 @@ struct io_buffer * alloc_iob_raw ( size_t len, size_t align, size_t offset ) { } else { /* Allocate memory for buffer */ - data = malloc_dma_offset ( len, align, offset ); + data = malloc_phys_offset ( len, align, offset ); if ( ! data ) return NULL; /* Allocate memory for descriptor */ iobuf = malloc ( sizeof ( *iobuf ) ); if ( ! iobuf ) { - free_dma ( data, len ); + free_phys ( data, len ); return NULL; } } @@ -159,12 +159,12 @@ void free_iob ( struct io_buffer *iobuf ) { if ( iobuf->end == iobuf ) { /* Descriptor is inline */ - free_dma ( iobuf->head, ( len + sizeof ( *iobuf ) ) ); + free_phys ( iobuf->head, ( len + sizeof ( *iobuf ) ) ); } else { /* Descriptor is detached */ - free_dma ( iobuf->head, len ); + free_phys ( iobuf->head, len ); free ( iobuf ); } } diff --git a/src/core/malloc.c b/src/core/malloc.c index 0a7843a14..8499ab45a 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -596,8 +596,8 @@ void * malloc ( size_t size ) { * * @v ptr Memory allocated by malloc(), or NULL * - * Memory allocated with malloc_dma() cannot be freed with free(); it - * must be freed with free_dma() instead. + * Memory allocated with malloc_phys() cannot be freed with free(); it + * must be freed with free_phys() instead. * * If @c ptr is NULL, no action is taken. */ diff --git a/src/drivers/infiniband/arbel.c b/src/drivers/infiniband/arbel.c index eb7911aa4..fb48487f3 100644 --- a/src/drivers/infiniband/arbel.c +++ b/src/drivers/infiniband/arbel.c @@ -639,8 +639,8 @@ static int arbel_create_cq ( struct ib_device *ibdev, /* Allocate completion queue itself */ arbel_cq->cqe_size = ( cq->num_cqes * sizeof ( arbel_cq->cqe[0] ) ); - arbel_cq->cqe = malloc_dma ( arbel_cq->cqe_size, - sizeof ( arbel_cq->cqe[0] ) ); + arbel_cq->cqe = malloc_phys ( arbel_cq->cqe_size, + sizeof ( arbel_cq->cqe[0] ) ); if ( ! arbel_cq->cqe ) { rc = -ENOMEM; goto err_cqe; @@ -697,7 +697,7 @@ static int arbel_create_cq ( struct ib_device *ibdev, err_sw2hw_cq: MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE ); MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE ); - free_dma ( arbel_cq->cqe, arbel_cq->cqe_size ); + free_phys ( arbel_cq->cqe, arbel_cq->cqe_size ); err_cqe: free ( arbel_cq ); err_arbel_cq: @@ -737,7 +737,7 @@ static void arbel_destroy_cq ( struct ib_device *ibdev, MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE ); /* Free memory */ - free_dma ( arbel_cq->cqe, arbel_cq->cqe_size ); + free_phys ( arbel_cq->cqe, arbel_cq->cqe_size ); free ( arbel_cq ); /* Mark queue number as free */ @@ -873,8 +873,8 @@ static int arbel_create_send_wq ( struct arbel_send_work_queue *arbel_send_wq, /* Allocate work queue */ arbel_send_wq->wqe_size = ( num_wqes * sizeof ( arbel_send_wq->wqe[0] ) ); - arbel_send_wq->wqe = malloc_dma ( arbel_send_wq->wqe_size, - sizeof ( arbel_send_wq->wqe[0] ) ); + arbel_send_wq->wqe = malloc_phys ( arbel_send_wq->wqe_size, + sizeof ( arbel_send_wq->wqe[0] ) ); if ( ! arbel_send_wq->wqe ) return -ENOMEM; memset ( arbel_send_wq->wqe, 0, arbel_send_wq->wqe_size ); @@ -914,8 +914,8 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq, /* Allocate work queue */ arbel_recv_wq->wqe_size = ( num_wqes * sizeof ( arbel_recv_wq->wqe[0] ) ); - arbel_recv_wq->wqe = malloc_dma ( arbel_recv_wq->wqe_size, - sizeof ( arbel_recv_wq->wqe[0] ) ); + arbel_recv_wq->wqe = malloc_phys ( arbel_recv_wq->wqe_size, + sizeof ( arbel_recv_wq->wqe[0] ) ); if ( ! arbel_recv_wq->wqe ) { rc = -ENOMEM; goto err_alloc_wqe; @@ -927,8 +927,8 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq, ( type == IB_QPT_UD ) ) { arbel_recv_wq->grh_size = ( num_wqes * sizeof ( arbel_recv_wq->grh[0] ) ); - arbel_recv_wq->grh = malloc_dma ( arbel_recv_wq->grh_size, - sizeof ( void * ) ); + arbel_recv_wq->grh = malloc_phys ( arbel_recv_wq->grh_size, + sizeof ( void * ) ); if ( ! arbel_recv_wq->grh ) { rc = -ENOMEM; goto err_alloc_grh; @@ -954,9 +954,9 @@ static int arbel_create_recv_wq ( struct arbel_recv_work_queue *arbel_recv_wq, return 0; - free_dma ( arbel_recv_wq->grh, arbel_recv_wq->grh_size ); + free_phys ( arbel_recv_wq->grh, arbel_recv_wq->grh_size ); err_alloc_grh: - free_dma ( arbel_recv_wq->wqe, arbel_recv_wq->wqe_size ); + free_phys ( arbel_recv_wq->wqe, arbel_recv_wq->wqe_size ); err_alloc_wqe: return rc; } @@ -1102,10 +1102,10 @@ static int arbel_create_qp ( struct ib_device *ibdev, MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE ); MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE ); err_unsupported_address_split: - free_dma ( arbel_qp->recv.grh, arbel_qp->recv.grh_size ); - free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size ); + free_phys ( arbel_qp->recv.grh, arbel_qp->recv.grh_size ); + free_phys ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size ); err_create_recv_wq: - free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size ); + free_phys ( arbel_qp->send.wqe, arbel_qp->send.wqe_size ); err_create_send_wq: free ( arbel_qp ); err_arbel_qp: @@ -1231,9 +1231,9 @@ static void arbel_destroy_qp ( struct ib_device *ibdev, MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE ); /* Free memory */ - free_dma ( arbel_qp->recv.grh, arbel_qp->recv.grh_size ); - free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size ); - free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size ); + free_phys ( arbel_qp->recv.grh, arbel_qp->recv.grh_size ); + free_phys ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size ); + free_phys ( arbel_qp->send.wqe, arbel_qp->send.wqe_size ); free ( arbel_qp ); /* Mark queue number as free */ @@ -1758,8 +1758,8 @@ static int arbel_create_eq ( struct arbel *arbel ) { /* Allocate event queue itself */ arbel_eq->eqe_size = ( ARBEL_NUM_EQES * sizeof ( arbel_eq->eqe[0] ) ); - arbel_eq->eqe = malloc_dma ( arbel_eq->eqe_size, - sizeof ( arbel_eq->eqe[0] ) ); + arbel_eq->eqe = malloc_phys ( arbel_eq->eqe_size, + sizeof ( arbel_eq->eqe[0] ) ); if ( ! arbel_eq->eqe ) { rc = -ENOMEM; goto err_eqe; @@ -1806,7 +1806,7 @@ static int arbel_create_eq ( struct arbel *arbel ) { err_map_eq: arbel_cmd_hw2sw_eq ( arbel, arbel_eq->eqn, &eqctx ); err_sw2hw_eq: - free_dma ( arbel_eq->eqe, arbel_eq->eqe_size ); + free_phys ( arbel_eq->eqe, arbel_eq->eqe_size ); err_eqe: memset ( arbel_eq, 0, sizeof ( *arbel_eq ) ); return rc; @@ -1844,7 +1844,7 @@ static void arbel_destroy_eq ( struct arbel *arbel ) { } /* Free memory */ - free_dma ( arbel_eq->eqe, arbel_eq->eqe_size ); + free_phys ( arbel_eq->eqe, arbel_eq->eqe_size ); memset ( arbel_eq, 0, sizeof ( *arbel_eq ) ); } @@ -2455,7 +2455,7 @@ static int arbel_alloc_icm ( struct arbel *arbel, icm_phys = user_to_phys ( arbel->icm, 0 ); /* Allocate doorbell UAR */ - arbel->db_rec = malloc_dma ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE ); + arbel->db_rec = malloc_phys ( ARBEL_PAGE_SIZE, ARBEL_PAGE_SIZE ); if ( ! arbel->db_rec ) { rc = -ENOMEM; goto err_alloc_doorbell; @@ -2513,7 +2513,7 @@ static int arbel_alloc_icm ( struct arbel *arbel, err_map_icm: arbel_cmd_unmap_icm_aux ( arbel ); err_map_icm_aux: - free_dma ( arbel->db_rec, ARBEL_PAGE_SIZE ); + free_phys ( arbel->db_rec, ARBEL_PAGE_SIZE ); arbel->db_rec= NULL; err_alloc_doorbell: err_alloc_icm: @@ -2536,7 +2536,7 @@ static void arbel_free_icm ( struct arbel *arbel ) { arbel_cmd_unmap_icm ( arbel, ( arbel->icm_len / ARBEL_PAGE_SIZE ), &unmap_icm ); arbel_cmd_unmap_icm_aux ( arbel ); - free_dma ( arbel->db_rec, ARBEL_PAGE_SIZE ); + free_phys ( arbel->db_rec, ARBEL_PAGE_SIZE ); arbel->db_rec = NULL; } @@ -2984,18 +2984,18 @@ static struct arbel * arbel_alloc ( void ) { goto err_arbel; /* Allocate space for mailboxes */ - arbel->mailbox_in = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN ); + arbel->mailbox_in = malloc_phys ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN ); if ( ! arbel->mailbox_in ) goto err_mailbox_in; - arbel->mailbox_out = malloc_dma ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN ); + arbel->mailbox_out = malloc_phys ( ARBEL_MBOX_SIZE, ARBEL_MBOX_ALIGN ); if ( ! arbel->mailbox_out ) goto err_mailbox_out; return arbel; - free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE ); + free_phys ( arbel->mailbox_out, ARBEL_MBOX_SIZE ); err_mailbox_out: - free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE ); + free_phys ( arbel->mailbox_in, ARBEL_MBOX_SIZE ); err_mailbox_in: free ( arbel ); err_arbel: @@ -3011,8 +3011,8 @@ static void arbel_free ( struct arbel *arbel ) { ufree ( arbel->icm ); ufree ( arbel->firmware_area ); - free_dma ( arbel->mailbox_out, ARBEL_MBOX_SIZE ); - free_dma ( arbel->mailbox_in, ARBEL_MBOX_SIZE ); + free_phys ( arbel->mailbox_out, ARBEL_MBOX_SIZE ); + free_phys ( arbel->mailbox_in, ARBEL_MBOX_SIZE ); free ( arbel ); } diff --git a/src/drivers/infiniband/golan.c b/src/drivers/infiniband/golan.c index 7ab4a4ee6..9bd810e23 100755 --- a/src/drivers/infiniband/golan.c +++ b/src/drivers/infiniband/golan.c @@ -585,9 +585,9 @@ static inline int golan_set_access_reg ( struct golan *golan __attribute__ (( un static inline void golan_cmd_uninit ( struct golan *golan ) { - free_dma(golan->mboxes.outbox, GOLAN_PAGE_SIZE); - free_dma(golan->mboxes.inbox, GOLAN_PAGE_SIZE); - free_dma(golan->cmd.addr, GOLAN_PAGE_SIZE); + free_phys(golan->mboxes.outbox, GOLAN_PAGE_SIZE); + free_phys(golan->mboxes.inbox, GOLAN_PAGE_SIZE); + free_phys(golan->cmd.addr, GOLAN_PAGE_SIZE); } /** @@ -602,17 +602,17 @@ static inline int golan_cmd_init ( struct golan *golan ) int rc = 0; uint32_t addr_l_sz; - if (!(golan->cmd.addr = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { + if (!(golan->cmd.addr = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { rc = -ENOMEM; - goto malloc_dma_failed; + goto malloc_phys_failed; } - if (!(golan->mboxes.inbox = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { + if (!(golan->mboxes.inbox = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { rc = -ENOMEM; - goto malloc_dma_inbox_failed; + goto malloc_phys_inbox_failed; } - if (!(golan->mboxes.outbox = malloc_dma(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { + if (!(golan->mboxes.outbox = malloc_phys(GOLAN_PAGE_SIZE , GOLAN_PAGE_SIZE))) { rc = -ENOMEM; - goto malloc_dma_outbox_failed; + goto malloc_phys_outbox_failed; } addr_l_sz = be32_to_cpu(readl(&golan->iseg->cmdq_addr_l_sz)); @@ -629,11 +629,11 @@ static inline int golan_cmd_init ( struct golan *golan ) DBGC( golan , "%s Command interface was initialized\n", __FUNCTION__); return 0; -malloc_dma_outbox_failed: - free_dma(golan->mboxes.inbox, GOLAN_PAGE_SIZE); -malloc_dma_inbox_failed: - free_dma(golan->cmd.addr, GOLAN_PAGE_SIZE); -malloc_dma_failed: +malloc_phys_outbox_failed: + free_phys(golan->mboxes.inbox, GOLAN_PAGE_SIZE); +malloc_phys_inbox_failed: + free_phys(golan->cmd.addr, GOLAN_PAGE_SIZE); +malloc_phys_failed: DBGC (golan ,"%s Failed to initialize command interface (rc = 0x%x)\n", __FUNCTION__, rc); return rc; @@ -743,7 +743,7 @@ static int golan_create_eq(struct golan *golan) eq->cons_index = 0; eq->size = GOLAN_NUM_EQES * sizeof(eq->eqes[0]); - eq->eqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); + eq->eqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); if (!eq->eqes) { rc = -ENOMEM; goto err_create_eq_eqe_alloc; @@ -781,7 +781,7 @@ static int golan_create_eq(struct golan *golan) return 0; err_create_eq_cmd: - free_dma ( eq->eqes , GOLAN_PAGE_SIZE ); + free_phys ( eq->eqes , GOLAN_PAGE_SIZE ); err_create_eq_eqe_alloc: DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc); return rc; @@ -806,7 +806,7 @@ static void golan_destory_eq(struct golan *golan) rc = send_command_and_wait(golan, DEF_CMD_IDX, NO_MBOX, NO_MBOX, __FUNCTION__); GOLAN_PRINT_RC_AND_CMD_STATUS; - free_dma ( golan->eq.eqes , GOLAN_PAGE_SIZE ); + free_phys ( golan->eq.eqes , GOLAN_PAGE_SIZE ); golan->eq.eqn = 0; DBGC( golan, "%s Event queue (0x%x) was destroyed\n", __FUNCTION__, eqn); @@ -962,14 +962,14 @@ static int golan_create_cq(struct ib_device *ibdev, goto err_create_cq; } golan_cq->size = sizeof(golan_cq->cqes[0]) * cq->num_cqes; - golan_cq->doorbell_record = malloc_dma(GOLAN_CQ_DB_RECORD_SIZE, + golan_cq->doorbell_record = malloc_phys(GOLAN_CQ_DB_RECORD_SIZE, GOLAN_CQ_DB_RECORD_SIZE); if (!golan_cq->doorbell_record) { rc = -ENOMEM; goto err_create_cq_db_alloc; } - golan_cq->cqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); + golan_cq->cqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); if (!golan_cq->cqes) { rc = -ENOMEM; goto err_create_cq_cqe_alloc; @@ -1008,9 +1008,9 @@ static int golan_create_cq(struct ib_device *ibdev, return 0; err_create_cq_cmd: - free_dma( golan_cq->cqes , GOLAN_PAGE_SIZE ); + free_phys( golan_cq->cqes , GOLAN_PAGE_SIZE ); err_create_cq_cqe_alloc: - free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE); + free_phys(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE); err_create_cq_db_alloc: free ( golan_cq ); err_create_cq: @@ -1045,8 +1045,8 @@ static void golan_destroy_cq(struct ib_device *ibdev, cq->cqn = 0; ib_cq_set_drvdata(cq, NULL); - free_dma ( golan_cq->cqes , GOLAN_PAGE_SIZE ); - free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE); + free_phys ( golan_cq->cqes , GOLAN_PAGE_SIZE ); + free_phys(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE); free(golan_cq); DBGC (golan, "%s CQ number 0x%x was destroyed\n", __FUNCTION__, cqn); @@ -1138,7 +1138,7 @@ static int golan_create_qp_aux(struct ib_device *ibdev, golan_qp->size = golan_qp->sq.size + golan_qp->rq.size; /* allocate dma memory for WQEs (1 page is enough) - should change it */ - golan_qp->wqes = malloc_dma ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); + golan_qp->wqes = malloc_phys ( GOLAN_PAGE_SIZE, GOLAN_PAGE_SIZE ); if (!golan_qp->wqes) { rc = -ENOMEM; goto err_create_qp_wqe_alloc; @@ -1160,7 +1160,7 @@ static int golan_create_qp_aux(struct ib_device *ibdev, data++; } - golan_qp->doorbell_record = malloc_dma(sizeof(struct golan_qp_db), + golan_qp->doorbell_record = malloc_phys(sizeof(struct golan_qp_db), sizeof(struct golan_qp_db)); if (!golan_qp->doorbell_record) { rc = -ENOMEM; @@ -1213,9 +1213,9 @@ static int golan_create_qp_aux(struct ib_device *ibdev, return 0; err_create_qp_cmd: - free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db)); + free_phys(golan_qp->doorbell_record, sizeof(struct golan_qp_db)); err_create_qp_db_alloc: - free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE ); + free_phys ( golan_qp->wqes, GOLAN_PAGE_SIZE ); err_create_qp_wqe_alloc: err_create_qp_sq_size: err_create_qp_sq_wqe_size: @@ -1422,8 +1422,8 @@ static void golan_destroy_qp(struct ib_device *ibdev, qp->qpn = 0; ib_qp_set_drvdata(qp, NULL); - free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db)); - free_dma ( golan_qp->wqes, GOLAN_PAGE_SIZE ); + free_phys(golan_qp->doorbell_record, sizeof(struct golan_qp_db)); + free_phys ( golan_qp->wqes, GOLAN_PAGE_SIZE ); free(golan_qp); DBGC( golan ,"%s QP 0x%lx was destroyed\n", __FUNCTION__, qpn); diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index b6599588f..fdf2d9dd8 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -864,8 +864,8 @@ static int hermon_create_cq ( struct ib_device *ibdev, } /* Allocate doorbell */ - hermon_cq->doorbell = malloc_dma ( sizeof ( hermon_cq->doorbell[0] ), - sizeof ( hermon_cq->doorbell[0] ) ); + hermon_cq->doorbell = malloc_phys ( sizeof ( hermon_cq->doorbell[0] ), + sizeof ( hermon_cq->doorbell[0] ) ); if ( ! hermon_cq->doorbell ) { rc = -ENOMEM; goto err_doorbell; @@ -874,8 +874,8 @@ static int hermon_create_cq ( struct ib_device *ibdev, /* Allocate completion queue itself */ hermon_cq->cqe_size = ( cq->num_cqes * sizeof ( hermon_cq->cqe[0] ) ); - hermon_cq->cqe = malloc_dma ( hermon_cq->cqe_size, - sizeof ( hermon_cq->cqe[0] ) ); + hermon_cq->cqe = malloc_phys ( hermon_cq->cqe_size, + sizeof ( hermon_cq->cqe[0] ) ); if ( ! hermon_cq->cqe ) { rc = -ENOMEM; goto err_cqe; @@ -925,9 +925,9 @@ static int hermon_create_cq ( struct ib_device *ibdev, err_sw2hw_cq: hermon_free_mtt ( hermon, &hermon_cq->mtt ); err_alloc_mtt: - free_dma ( hermon_cq->cqe, hermon_cq->cqe_size ); + free_phys ( hermon_cq->cqe, hermon_cq->cqe_size ); err_cqe: - free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) ); + free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) ); err_doorbell: free ( hermon_cq ); err_hermon_cq: @@ -962,8 +962,8 @@ static void hermon_destroy_cq ( struct ib_device *ibdev, hermon_free_mtt ( hermon, &hermon_cq->mtt ); /* Free memory */ - free_dma ( hermon_cq->cqe, hermon_cq->cqe_size ); - free_dma ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) ); + free_phys ( hermon_cq->cqe, hermon_cq->cqe_size ); + free_phys ( hermon_cq->doorbell, sizeof ( hermon_cq->doorbell[0] ) ); free ( hermon_cq ); /* Mark queue number as free */ @@ -1128,8 +1128,8 @@ static int hermon_create_qp ( struct ib_device *ibdev, /* Allocate doorbells */ hermon_qp->recv.doorbell = - malloc_dma ( sizeof ( hermon_qp->recv.doorbell[0] ), - sizeof ( hermon_qp->recv.doorbell[0] ) ); + malloc_phys ( sizeof ( hermon_qp->recv.doorbell[0] ), + sizeof ( hermon_qp->recv.doorbell[0] ) ); if ( ! hermon_qp->recv.doorbell ) { rc = -ENOMEM; goto err_recv_doorbell; @@ -1157,8 +1157,8 @@ static int hermon_create_qp ( struct ib_device *ibdev, hermon_qp->wqe_size = ( hermon_qp->send.wqe_size + hermon_qp->recv.wqe_size + hermon_qp->recv.grh_size ); - hermon_qp->wqe = malloc_dma ( hermon_qp->wqe_size, - sizeof ( hermon_qp->send.wqe[0] ) ); + hermon_qp->wqe = malloc_phys ( hermon_qp->wqe_size, + sizeof ( hermon_qp->send.wqe[0] ) ); if ( ! hermon_qp->wqe ) { rc = -ENOMEM; goto err_alloc_wqe; @@ -1248,10 +1248,10 @@ static int hermon_create_qp ( struct ib_device *ibdev, err_rst2init_qp: hermon_free_mtt ( hermon, &hermon_qp->mtt ); err_alloc_mtt: - free_dma ( hermon_qp->wqe, hermon_qp->wqe_size ); + free_phys ( hermon_qp->wqe, hermon_qp->wqe_size ); err_alloc_wqe: - free_dma ( hermon_qp->recv.doorbell, - sizeof ( hermon_qp->recv.doorbell[0] ) ); + free_phys ( hermon_qp->recv.doorbell, + sizeof ( hermon_qp->recv.doorbell[0] ) ); err_recv_doorbell: free ( hermon_qp ); err_hermon_qp: @@ -1363,9 +1363,9 @@ static void hermon_destroy_qp ( struct ib_device *ibdev, hermon_free_mtt ( hermon, &hermon_qp->mtt ); /* Free memory */ - free_dma ( hermon_qp->wqe, hermon_qp->wqe_size ); - free_dma ( hermon_qp->recv.doorbell, - sizeof ( hermon_qp->recv.doorbell[0] ) ); + free_phys ( hermon_qp->wqe, hermon_qp->wqe_size ); + free_phys ( hermon_qp->recv.doorbell, + sizeof ( hermon_qp->recv.doorbell[0] ) ); free ( hermon_qp ); /* Mark queue number as free */ @@ -1887,8 +1887,8 @@ static int hermon_create_eq ( struct hermon *hermon ) { /* Allocate event queue itself */ hermon_eq->eqe_size = ( HERMON_NUM_EQES * sizeof ( hermon_eq->eqe[0] ) ); - hermon_eq->eqe = malloc_dma ( hermon_eq->eqe_size, - sizeof ( hermon_eq->eqe[0] ) ); + hermon_eq->eqe = malloc_phys ( hermon_eq->eqe_size, + sizeof ( hermon_eq->eqe[0] ) ); if ( ! hermon_eq->eqe ) { rc = -ENOMEM; goto err_eqe; @@ -1946,7 +1946,7 @@ static int hermon_create_eq ( struct hermon *hermon ) { err_sw2hw_eq: hermon_free_mtt ( hermon, &hermon_eq->mtt ); err_alloc_mtt: - free_dma ( hermon_eq->eqe, hermon_eq->eqe_size ); + free_phys ( hermon_eq->eqe, hermon_eq->eqe_size ); err_eqe: memset ( hermon_eq, 0, sizeof ( *hermon_eq ) ); return rc; @@ -1986,7 +1986,7 @@ static void hermon_destroy_eq ( struct hermon *hermon ) { hermon_free_mtt ( hermon, &hermon_eq->mtt ); /* Free memory */ - free_dma ( hermon_eq->eqe, hermon_eq->eqe_size ); + free_phys ( hermon_eq->eqe, hermon_eq->eqe_size ); memset ( hermon_eq, 0, sizeof ( *hermon_eq ) ); } @@ -3736,20 +3736,20 @@ static struct hermon * hermon_alloc ( void ) { goto err_hermon; /* Allocate space for mailboxes */ - hermon->mailbox_in = malloc_dma ( HERMON_MBOX_SIZE, - HERMON_MBOX_ALIGN ); + hermon->mailbox_in = malloc_phys ( HERMON_MBOX_SIZE, + HERMON_MBOX_ALIGN ); if ( ! hermon->mailbox_in ) goto err_mailbox_in; - hermon->mailbox_out = malloc_dma ( HERMON_MBOX_SIZE, - HERMON_MBOX_ALIGN ); + hermon->mailbox_out = malloc_phys ( HERMON_MBOX_SIZE, + HERMON_MBOX_ALIGN ); if ( ! hermon->mailbox_out ) goto err_mailbox_out; return hermon; - free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE ); + free_phys ( hermon->mailbox_out, HERMON_MBOX_SIZE ); err_mailbox_out: - free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE ); + free_phys ( hermon->mailbox_in, HERMON_MBOX_SIZE ); err_mailbox_in: free ( hermon ); err_hermon: @@ -3765,8 +3765,8 @@ static void hermon_free ( struct hermon *hermon ) { ufree ( hermon->icm ); ufree ( hermon->firmware_area ); - free_dma ( hermon->mailbox_out, HERMON_MBOX_SIZE ); - free_dma ( hermon->mailbox_in, HERMON_MBOX_SIZE ); + free_phys ( hermon->mailbox_out, HERMON_MBOX_SIZE ); + free_phys ( hermon->mailbox_in, HERMON_MBOX_SIZE ); free ( hermon ); } diff --git a/src/drivers/infiniband/linda.c b/src/drivers/infiniband/linda.c index 8c2c090bc..b275268a2 100644 --- a/src/drivers/infiniband/linda.c +++ b/src/drivers/infiniband/linda.c @@ -531,8 +531,8 @@ static int linda_init_send ( struct linda *linda ) { linda->send_buf[i] = i; /* Allocate space for the SendBufAvail array */ - linda->sendbufavail = malloc_dma ( sizeof ( *linda->sendbufavail ), - LINDA_SENDBUFAVAIL_ALIGN ); + linda->sendbufavail = malloc_phys ( sizeof ( *linda->sendbufavail ), + LINDA_SENDBUFAVAIL_ALIGN ); if ( ! linda->sendbufavail ) { rc = -ENOMEM; goto err_alloc_sendbufavail; @@ -555,7 +555,7 @@ static int linda_init_send ( struct linda *linda ) { return 0; - free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); + free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); err_alloc_sendbufavail: return rc; } @@ -576,7 +576,7 @@ static void linda_fini_send ( struct linda *linda ) { /* Ensure hardware has seen this disable */ linda_readq ( linda, &sendctrl, QIB_7220_SendCtrl_offset ); - free_dma ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); + free_phys ( linda->sendbufavail, sizeof ( *linda->sendbufavail ) ); } /*************************************************************************** @@ -613,8 +613,8 @@ static int linda_create_recv_wq ( struct linda *linda, linda_wq->eager_cons = 0; /* Allocate receive header buffer */ - linda_wq->header = malloc_dma ( LINDA_RECV_HEADERS_SIZE, - LINDA_RECV_HEADERS_ALIGN ); + linda_wq->header = malloc_phys ( LINDA_RECV_HEADERS_SIZE, + LINDA_RECV_HEADERS_ALIGN ); if ( ! linda_wq->header ) { rc = -ENOMEM; goto err_alloc_header; @@ -650,7 +650,7 @@ static int linda_create_recv_wq ( struct linda *linda, virt_to_bus ( &linda_wq->header_prod ) ); return 0; - free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); + free_phys ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); err_alloc_header: return rc; } @@ -679,7 +679,7 @@ static void linda_destroy_recv_wq ( struct linda *linda, mb(); /* Free headers ring */ - free_dma ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); + free_phys ( linda_wq->header, LINDA_RECV_HEADERS_SIZE ); /* Free context */ linda_free_ctx ( linda, ctx ); diff --git a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c index cb9e759bf..e368d459b 100644 --- a/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c +++ b/src/drivers/infiniband/mlx_utils_flexboot/src/mlx_memory_priv.c @@ -61,7 +61,7 @@ mlx_memory_alloc_dma_priv( ) { mlx_status status = MLX_SUCCESS; - *ptr = malloc_dma(size, align); + *ptr = malloc_phys(size, align); if (*ptr == NULL) { status = MLX_OUT_OF_RESOURCES; } else { @@ -78,7 +78,7 @@ mlx_memory_free_dma_priv( ) { mlx_status status = MLX_SUCCESS; - free_dma(ptr, size); + free_phys(ptr, size); return status; } mlx_status diff --git a/src/drivers/infiniband/qib7322.c b/src/drivers/infiniband/qib7322.c index a5606dd03..e3250147d 100644 --- a/src/drivers/infiniband/qib7322.c +++ b/src/drivers/infiniband/qib7322.c @@ -669,8 +669,8 @@ static int qib7322_init_send ( struct qib7322 *qib7322 ) { } /* Allocate space for the SendBufAvail array */ - qib7322->sendbufavail = malloc_dma ( sizeof ( *qib7322->sendbufavail ), - QIB7322_SENDBUFAVAIL_ALIGN ); + qib7322->sendbufavail = malloc_phys ( sizeof ( *qib7322->sendbufavail ), + QIB7322_SENDBUFAVAIL_ALIGN ); if ( ! qib7322->sendbufavail ) { rc = -ENOMEM; goto err_alloc_sendbufavail; @@ -697,7 +697,7 @@ static int qib7322_init_send ( struct qib7322 *qib7322 ) { return 0; - free_dma ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) ); + free_phys ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) ); err_alloc_sendbufavail: qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port1 ); err_create_send_bufs_vl15_port1: @@ -724,7 +724,7 @@ static void qib7322_fini_send ( struct qib7322 *qib7322 ) { /* Ensure hardware has seen this disable */ qib7322_readq ( qib7322, &sendctrl, QIB_7322_SendCtrl_offset ); - free_dma ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) ); + free_phys ( qib7322->sendbufavail, sizeof ( *qib7322->sendbufavail ) ); qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port1 ); qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_vl15_port0 ); qib7322_destroy_send_bufs ( qib7322, qib7322->send_bufs_small ); @@ -767,8 +767,8 @@ static int qib7322_create_recv_wq ( struct ib_device *ibdev, qib7322_wq->eager_cons = 0; /* Allocate receive header buffer */ - qib7322_wq->header = malloc_dma ( QIB7322_RECV_HEADERS_SIZE, - QIB7322_RECV_HEADERS_ALIGN ); + qib7322_wq->header = malloc_phys ( QIB7322_RECV_HEADERS_SIZE, + QIB7322_RECV_HEADERS_ALIGN ); if ( ! qib7322_wq->header ) { rc = -ENOMEM; goto err_alloc_header; @@ -810,7 +810,7 @@ static int qib7322_create_recv_wq ( struct ib_device *ibdev, virt_to_bus ( &qib7322_wq->header_prod ) ); return 0; - free_dma ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE ); + free_phys ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE ); err_alloc_header: return rc; } @@ -846,7 +846,7 @@ static void qib7322_destroy_recv_wq ( struct ib_device *ibdev, mb(); /* Free headers ring */ - free_dma ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE ); + free_phys ( qib7322_wq->header, QIB7322_RECV_HEADERS_SIZE ); } /** diff --git a/src/drivers/net/3c90x.c b/src/drivers/net/3c90x.c index 853de2b52..63e07777f 100644 --- a/src/drivers/net/3c90x.c +++ b/src/drivers/net/3c90x.c @@ -249,7 +249,7 @@ static int a3c90x_setup_tx_ring(struct INF_3C90X *p) { DBGP("a3c90x_setup_tx_ring\n"); p->tx_ring = - malloc_dma(TX_RING_SIZE * sizeof(struct TXD), TX_RING_ALIGN); + malloc_phys(TX_RING_SIZE * sizeof(struct TXD), TX_RING_ALIGN); if (!p->tx_ring) { DBG("Could not allocate TX-ring\n"); @@ -304,7 +304,7 @@ static void a3c90x_free_tx_ring(struct INF_3C90X *p) { DBGP("a3c90x_free_tx_ring\n"); - free_dma(p->tx_ring, TX_RING_SIZE * sizeof(struct TXD)); + free_phys(p->tx_ring, TX_RING_SIZE * sizeof(struct TXD)); p->tx_ring = NULL; /* io_buffers are free()ed by netdev_tx_complete[,_err]() */ } @@ -461,7 +461,7 @@ static int a3c90x_setup_rx_ring(struct INF_3C90X *p) DBGP("a3c90x_setup_rx_ring\n"); p->rx_ring = - malloc_dma(RX_RING_SIZE * sizeof(struct RXD), RX_RING_ALIGN); + malloc_phys(RX_RING_SIZE * sizeof(struct RXD), RX_RING_ALIGN); if (!p->rx_ring) { DBG("Could not allocate RX-ring\n"); @@ -491,7 +491,7 @@ static void a3c90x_free_rx_ring(struct INF_3C90X *p) { DBGP("a3c90x_free_rx_ring\n"); - free_dma(p->rx_ring, RX_RING_SIZE * sizeof(struct RXD)); + free_phys(p->rx_ring, RX_RING_SIZE * sizeof(struct RXD)); p->rx_ring = NULL; } diff --git a/src/drivers/net/ath/ath5k/ath5k.c b/src/drivers/net/ath/ath5k/ath5k.c index d8c47909d..e43eb0aaf 100644 --- a/src/drivers/net/ath/ath5k/ath5k.c +++ b/src/drivers/net/ath/ath5k/ath5k.c @@ -877,7 +877,7 @@ ath5k_desc_alloc(struct ath5k_softc *sc) /* allocate descriptors */ sc->desc_len = sizeof(struct ath5k_desc) * (ATH_TXBUF + ATH_RXBUF + 1); - sc->desc = malloc_dma(sc->desc_len, ATH5K_DESC_ALIGN); + sc->desc = malloc_phys(sc->desc_len, ATH5K_DESC_ALIGN); if (sc->desc == NULL) { DBG("ath5k: can't allocate descriptors\n"); ret = -ENOMEM; @@ -915,7 +915,7 @@ ath5k_desc_alloc(struct ath5k_softc *sc) return 0; err_free: - free_dma(sc->desc, sc->desc_len); + free_phys(sc->desc, sc->desc_len); err: sc->desc = NULL; return ret; @@ -932,7 +932,7 @@ ath5k_desc_free(struct ath5k_softc *sc) ath5k_rxbuf_free(sc, bf); /* Free memory associated with all descriptors */ - free_dma(sc->desc, sc->desc_len); + free_phys(sc->desc, sc->desc_len); free(sc->bufptr); sc->bufptr = NULL; diff --git a/src/drivers/net/ath/ath9k/ath9k_init.c b/src/drivers/net/ath/ath9k/ath9k_init.c index 98a0d6d59..05ed3336a 100644 --- a/src/drivers/net/ath/ath9k/ath9k_init.c +++ b/src/drivers/net/ath/ath9k/ath9k_init.c @@ -223,7 +223,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, } /* allocate descriptors */ - dd->dd_desc = malloc_dma(dd->dd_desc_len, 16); + dd->dd_desc = malloc_phys(dd->dd_desc_len, 16); if (dd->dd_desc == NULL) { error = -ENOMEM; goto fail; @@ -264,7 +264,7 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, } return 0; fail2: - free_dma(dd->dd_desc, dd->dd_desc_len); + free_phys(dd->dd_desc, dd->dd_desc_len); fail: memset(dd, 0, sizeof(*dd)); return error; @@ -588,7 +588,7 @@ void ath_descdma_cleanup(struct ath_softc *sc __unused, struct ath_descdma *dd, struct list_head *head) { - free_dma(dd->dd_desc, dd->dd_desc_len); + free_phys(dd->dd_desc, dd->dd_desc_len); INIT_LIST_HEAD(head); free(dd->dd_bufptr); diff --git a/src/drivers/net/atl1e.c b/src/drivers/net/atl1e.c index d010d8c4a..0f0df5326 100644 --- a/src/drivers/net/atl1e.c +++ b/src/drivers/net/atl1e.c @@ -370,7 +370,7 @@ static void atl1e_free_ring_resources(struct atl1e_adapter *adapter) atl1e_clean_rx_ring(adapter); if (adapter->ring_vir_addr) { - free_dma(adapter->ring_vir_addr, adapter->ring_size); + free_phys(adapter->ring_vir_addr, adapter->ring_size); adapter->ring_vir_addr = NULL; adapter->ring_dma = 0; } @@ -405,7 +405,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter) /* real ring DMA buffer */ size = adapter->ring_size; - adapter->ring_vir_addr = malloc_dma(adapter->ring_size, 32); + adapter->ring_vir_addr = malloc_phys(adapter->ring_size, 32); if (adapter->ring_vir_addr == NULL) { DBG("atl1e: out of memory allocating %d bytes for %s ring\n", diff --git a/src/drivers/net/b44.c b/src/drivers/net/b44.c index e0e6f4642..eaf6d35ce 100644 --- a/src/drivers/net/b44.c +++ b/src/drivers/net/b44.c @@ -436,7 +436,7 @@ static void b44_free_rx_ring(struct b44_private *bp) free_iob(bp->rx_iobuf[i]); bp->rx_iobuf[i] = NULL; } - free_dma(bp->rx, B44_RX_RING_LEN_BYTES); + free_phys(bp->rx, B44_RX_RING_LEN_BYTES); bp->rx = NULL; } } @@ -446,11 +446,11 @@ static int b44_init_rx_ring(struct b44_private *bp) { b44_free_rx_ring(bp); - bp->rx = malloc_dma(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); + bp->rx = malloc_phys(B44_RX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); if (!bp->rx) return -ENOMEM; if (!b44_address_ok(bp->rx)) { - free_dma(bp->rx, B44_RX_RING_LEN_BYTES); + free_phys(bp->rx, B44_RX_RING_LEN_BYTES); return -ENOTSUP; } @@ -468,7 +468,7 @@ static int b44_init_rx_ring(struct b44_private *bp) static void b44_free_tx_ring(struct b44_private *bp) { if (bp->tx) { - free_dma(bp->tx, B44_TX_RING_LEN_BYTES); + free_phys(bp->tx, B44_TX_RING_LEN_BYTES); bp->tx = NULL; } } @@ -478,11 +478,11 @@ static int b44_init_tx_ring(struct b44_private *bp) { b44_free_tx_ring(bp); - bp->tx = malloc_dma(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); + bp->tx = malloc_phys(B44_TX_RING_LEN_BYTES, B44_DMA_ALIGNMENT); if (!bp->tx) return -ENOMEM; if (!b44_address_ok(bp->tx)) { - free_dma(bp->tx, B44_TX_RING_LEN_BYTES); + free_phys(bp->tx, B44_TX_RING_LEN_BYTES); return -ENOTSUP; } diff --git a/src/drivers/net/bnxt/bnxt.c b/src/drivers/net/bnxt/bnxt.c index fe84ea0e4..b8663c00a 100644 --- a/src/drivers/net/bnxt/bnxt.c +++ b/src/drivers/net/bnxt/bnxt.c @@ -495,39 +495,39 @@ void bnxt_free_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); if ( bp->nq.bd_virt ) { - free_dma ( bp->nq.bd_virt, NQ_RING_BUFFER_SIZE ); + free_phys ( bp->nq.bd_virt, NQ_RING_BUFFER_SIZE ); bp->nq.bd_virt = NULL; } if ( bp->cq.bd_virt ) { - free_dma ( bp->cq.bd_virt, CQ_RING_BUFFER_SIZE ); + free_phys ( bp->cq.bd_virt, CQ_RING_BUFFER_SIZE ); bp->cq.bd_virt = NULL; } if ( bp->rx.bd_virt ) { - free_dma ( bp->rx.bd_virt, RX_RING_BUFFER_SIZE ); + free_phys ( bp->rx.bd_virt, RX_RING_BUFFER_SIZE ); bp->rx.bd_virt = NULL; } if ( bp->tx.bd_virt ) { - free_dma ( bp->tx.bd_virt, TX_RING_BUFFER_SIZE ); + free_phys ( bp->tx.bd_virt, TX_RING_BUFFER_SIZE ); bp->tx.bd_virt = NULL; } if ( bp->hwrm_addr_dma ) { - free_dma ( bp->hwrm_addr_dma, DMA_BUFFER_SIZE ); + free_phys ( bp->hwrm_addr_dma, DMA_BUFFER_SIZE ); bp->dma_addr_mapping = 0; bp->hwrm_addr_dma = NULL; } if ( bp->hwrm_addr_resp ) { - free_dma ( bp->hwrm_addr_resp, RESP_BUFFER_SIZE ); + free_phys ( bp->hwrm_addr_resp, RESP_BUFFER_SIZE ); bp->resp_addr_mapping = 0; bp->hwrm_addr_resp = NULL; } if ( bp->hwrm_addr_req ) { - free_dma ( bp->hwrm_addr_req, REQ_BUFFER_SIZE ); + free_phys ( bp->hwrm_addr_req, REQ_BUFFER_SIZE ); bp->req_addr_mapping = 0; bp->hwrm_addr_req = NULL; } @@ -537,14 +537,14 @@ void bnxt_free_mem ( struct bnxt *bp ) int bnxt_alloc_mem ( struct bnxt *bp ) { DBGP ( "%s\n", __func__ ); - bp->hwrm_addr_req = malloc_dma ( REQ_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->hwrm_addr_resp = malloc_dma ( RESP_BUFFER_SIZE, - BNXT_DMA_ALIGNMENT ); - bp->hwrm_addr_dma = malloc_dma ( DMA_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->tx.bd_virt = malloc_dma ( TX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); - bp->rx.bd_virt = malloc_dma ( RX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); - bp->cq.bd_virt = malloc_dma ( CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); - bp->nq.bd_virt = malloc_dma ( NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->hwrm_addr_req = malloc_phys ( REQ_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->hwrm_addr_resp = malloc_phys ( RESP_BUFFER_SIZE, + BNXT_DMA_ALIGNMENT ); + bp->hwrm_addr_dma = malloc_phys ( DMA_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->tx.bd_virt = malloc_phys ( TX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); + bp->rx.bd_virt = malloc_phys ( RX_RING_BUFFER_SIZE, DMA_ALIGN_4K ); + bp->cq.bd_virt = malloc_phys ( CQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); + bp->nq.bd_virt = malloc_phys ( NQ_RING_BUFFER_SIZE, BNXT_DMA_ALIGNMENT ); test_if ( bp->hwrm_addr_req && bp->hwrm_addr_resp && bp->hwrm_addr_dma && diff --git a/src/drivers/net/eepro100.c b/src/drivers/net/eepro100.c index 1046cda39..1a802b590 100644 --- a/src/drivers/net/eepro100.c +++ b/src/drivers/net/eepro100.c @@ -93,7 +93,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); /* * Debugging levels: - * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_dma(), + * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_phys(), * TX overflow, corrupted packets, ... * - DBG2() is for successful events, like packet received, * packet transmitted, and other general notifications. @@ -335,7 +335,7 @@ static int ifec_net_open ( struct net_device *netdev ) ifec_mdio_setup ( netdev, options ); /* Prepare MAC address w/ Individual Address Setup (ias) command.*/ - ias = malloc_dma ( sizeof ( *ias ), CB_ALIGN ); + ias = malloc_phys ( sizeof ( *ias ), CB_ALIGN ); if ( !ias ) { rc = -ENOMEM; goto error; @@ -345,7 +345,7 @@ static int ifec_net_open ( struct net_device *netdev ) memcpy ( ias->ia, netdev->ll_addr, ETH_ALEN ); /* Prepare operating parameters w/ a configure command. */ - cfg = malloc_dma ( sizeof ( *cfg ), CB_ALIGN ); + cfg = malloc_phys ( sizeof ( *cfg ), CB_ALIGN ); if ( !cfg ) { rc = -ENOMEM; goto error; @@ -367,8 +367,8 @@ static int ifec_net_open ( struct net_device *netdev ) DBG ( "Failed to initiate!\n" ); goto error; } - free_dma ( ias, sizeof ( *ias ) ); - free_dma ( cfg, sizeof ( *cfg ) ); + free_phys ( ias, sizeof ( *ias ) ); + free_phys ( cfg, sizeof ( *cfg ) ); DBG2 ( "cfg " ); /* Enable rx by sending ring address to card */ @@ -381,8 +381,8 @@ static int ifec_net_open ( struct net_device *netdev ) return 0; error: - free_dma ( cfg, sizeof ( *cfg ) ); - free_dma ( ias, sizeof ( *ias ) ); + free_phys ( cfg, sizeof ( *cfg ) ); + free_phys ( ias, sizeof ( *ias ) ); ifec_free ( netdev ); ifec_reset ( netdev ); return rc; @@ -703,7 +703,7 @@ static void ifec_free ( struct net_device *netdev ) } /* free TX ring buffer */ - free_dma ( priv->tcbs, TX_RING_BYTES ); + free_phys ( priv->tcbs, TX_RING_BYTES ); priv->tcbs = NULL; } @@ -1025,7 +1025,7 @@ static int ifec_tx_setup ( struct net_device *netdev ) DBGP ( "ifec_tx_setup\n" ); /* allocate tx ring */ - priv->tcbs = malloc_dma ( TX_RING_BYTES, CB_ALIGN ); + priv->tcbs = malloc_phys ( TX_RING_BYTES, CB_ALIGN ); if ( !priv->tcbs ) { DBG ( "TX-ring allocation failed\n" ); return -ENOMEM; diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 5c76eb6fd..12c161522 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -164,7 +164,7 @@ static int ena_create_admin ( struct ena_nic *ena ) { int rc; /* Allocate admin completion queue */ - ena->acq.rsp = malloc_dma ( acq_len, acq_len ); + ena->acq.rsp = malloc_phys ( acq_len, acq_len ); if ( ! ena->acq.rsp ) { rc = -ENOMEM; goto err_alloc_acq; @@ -172,7 +172,7 @@ static int ena_create_admin ( struct ena_nic *ena ) { memset ( ena->acq.rsp, 0, acq_len ); /* Allocate admin queue */ - ena->aq.req = malloc_dma ( aq_len, aq_len ); + ena->aq.req = malloc_phys ( aq_len, aq_len ); if ( ! ena->aq.req ) { rc = -ENOMEM; goto err_alloc_aq; @@ -196,9 +196,9 @@ static int ena_create_admin ( struct ena_nic *ena ) { ena_clear_caps ( ena, ENA_AQ_CAPS ); ena_clear_caps ( ena, ENA_ACQ_CAPS ); - free_dma ( ena->aq.req, aq_len ); + free_phys ( ena->aq.req, aq_len ); err_alloc_aq: - free_dma ( ena->acq.rsp, acq_len ); + free_phys ( ena->acq.rsp, acq_len ); err_alloc_acq: return rc; } @@ -218,8 +218,8 @@ static void ena_destroy_admin ( struct ena_nic *ena ) { wmb(); /* Free queues */ - free_dma ( ena->aq.req, aq_len ); - free_dma ( ena->acq.rsp, acq_len ); + free_phys ( ena->aq.req, aq_len ); + free_phys ( ena->acq.rsp, acq_len ); DBGC ( ena, "ENA %p AQ and ACQ destroyed\n", ena ); } @@ -338,7 +338,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, int rc; /* Allocate submission queue entries */ - sq->sqe.raw = malloc_dma ( sq->len, ENA_ALIGN ); + sq->sqe.raw = malloc_phys ( sq->len, ENA_ALIGN ); if ( ! sq->sqe.raw ) { rc = -ENOMEM; goto err_alloc; @@ -375,7 +375,7 @@ static int ena_create_sq ( struct ena_nic *ena, struct ena_sq *sq, return 0; err_admin: - free_dma ( sq->sqe.raw, sq->len ); + free_phys ( sq->sqe.raw, sq->len ); err_alloc: return rc; } @@ -403,7 +403,7 @@ static int ena_destroy_sq ( struct ena_nic *ena, struct ena_sq *sq ) { return rc; /* Free submission queue entries */ - free_dma ( sq->sqe.raw, sq->len ); + free_phys ( sq->sqe.raw, sq->len ); DBGC ( ena, "ENA %p %s SQ%d destroyed\n", ena, ena_direction ( sq->direction ), sq->id ); @@ -423,7 +423,7 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) { int rc; /* Allocate completion queue entries */ - cq->cqe.raw = malloc_dma ( cq->len, ENA_ALIGN ); + cq->cqe.raw = malloc_phys ( cq->len, ENA_ALIGN ); if ( ! cq->cqe.raw ) { rc = -ENOMEM; goto err_alloc; @@ -461,7 +461,7 @@ static int ena_create_cq ( struct ena_nic *ena, struct ena_cq *cq ) { return 0; err_admin: - free_dma ( cq->cqe.raw, cq->len ); + free_phys ( cq->cqe.raw, cq->len ); err_alloc: return rc; } @@ -488,7 +488,7 @@ static int ena_destroy_cq ( struct ena_nic *ena, struct ena_cq *cq ) { return rc; /* Free completion queue entries */ - free_dma ( cq->cqe.raw, cq->len ); + free_phys ( cq->cqe.raw, cq->len ); DBGC ( ena, "ENA %p CQ%d destroyed\n", ena, cq->id ); return 0; diff --git a/src/drivers/net/etherfabric.c b/src/drivers/net/etherfabric.c index cd567f1d9..e43d4336e 100644 --- a/src/drivers/net/etherfabric.c +++ b/src/drivers/net/etherfabric.c @@ -3025,7 +3025,7 @@ falcon_free_special_buffer ( void *p ) { /* We don't bother cleaning up the buffer table entries - * we're hardly limited */ - free_dma ( p, EFAB_BUF_ALIGN ); + free_phys ( p, EFAB_BUF_ALIGN ); } static void* @@ -3038,7 +3038,7 @@ falcon_alloc_special_buffer ( struct efab_nic *efab, int bytes, unsigned long dma_addr; /* Allocate the buffer, aligned on a buffer address boundary */ - buffer = malloc_dma ( bytes, EFAB_BUF_ALIGN ); + buffer = malloc_phys ( bytes, EFAB_BUF_ALIGN ); if ( ! buffer ) return NULL; diff --git a/src/drivers/net/exanic.c b/src/drivers/net/exanic.c index 8849da285..aaa6a28a1 100644 --- a/src/drivers/net/exanic.c +++ b/src/drivers/net/exanic.c @@ -831,7 +831,7 @@ static int exanic_probe ( struct pci_device *pci ) { } /* Allocate transmit feedback region (shared between all ports) */ - exanic->txf = malloc_dma ( EXANIC_TXF_LEN, EXANIC_ALIGN ); + exanic->txf = malloc_phys ( EXANIC_TXF_LEN, EXANIC_ALIGN ); if ( ! exanic->txf ) { rc = -ENOMEM; goto err_alloc_txf; @@ -853,7 +853,7 @@ static int exanic_probe ( struct pci_device *pci ) { for ( i-- ; i >= 0 ; i-- ) exanic_remove_port ( exanic, i ); exanic_reset ( exanic ); - free_dma ( exanic->txf, EXANIC_TXF_LEN ); + free_phys ( exanic->txf, EXANIC_TXF_LEN ); err_alloc_txf: iounmap ( exanic->tx ); err_ioremap_tx: @@ -882,7 +882,7 @@ static void exanic_remove ( struct pci_device *pci ) { exanic_reset ( exanic ); /* Free transmit feedback region */ - free_dma ( exanic->txf, EXANIC_TXF_LEN ); + free_phys ( exanic->txf, EXANIC_TXF_LEN ); /* Unmap transmit region */ iounmap ( exanic->tx ); diff --git a/src/drivers/net/forcedeth.c b/src/drivers/net/forcedeth.c index 94cc6063b..7fba08a08 100644 --- a/src/drivers/net/forcedeth.c +++ b/src/drivers/net/forcedeth.c @@ -267,7 +267,7 @@ nv_init_rings ( struct forcedeth_private *priv ) /* Allocate ring for both TX and RX */ priv->rx_ring = - malloc_dma ( sizeof(struct ring_desc) * RXTX_RING_SIZE, 32 ); + malloc_phys ( sizeof(struct ring_desc) * RXTX_RING_SIZE, 32 ); if ( ! priv->rx_ring ) goto err_malloc; priv->tx_ring = &priv->rx_ring[RX_RING_SIZE]; @@ -308,7 +308,7 @@ nv_free_rxtx_resources ( struct forcedeth_private *priv ) DBGP ( "nv_free_rxtx_resources\n" ); - free_dma ( priv->rx_ring, sizeof(struct ring_desc) * RXTX_RING_SIZE ); + free_phys ( priv->rx_ring, sizeof(struct ring_desc) * RXTX_RING_SIZE ); for ( i = 0; i < RX_RING_SIZE; i++ ) { free_iob ( priv->rx_iobuf[i] ); diff --git a/src/drivers/net/icplus.c b/src/drivers/net/icplus.c index 58092fade..acd2e2363 100644 --- a/src/drivers/net/icplus.c +++ b/src/drivers/net/icplus.c @@ -343,7 +343,7 @@ static int icplus_create_ring ( struct icplus_nic *icp, struct icplus_ring *ring struct icplus_descriptor *next; /* Allocate descriptor ring */ - ring->entry = malloc_dma ( len, ICP_ALIGN ); + ring->entry = malloc_phys ( len, ICP_ALIGN ); if ( ! ring->entry ) { rc = -ENOMEM; goto err_alloc; @@ -369,7 +369,7 @@ static int icplus_create_ring ( struct icplus_nic *icp, struct icplus_ring *ring ( virt_to_bus ( ring->entry ) + len ) ); return 0; - free_dma ( ring->entry, len ); + free_phys ( ring->entry, len ); ring->entry = NULL; err_alloc: return rc; @@ -386,7 +386,7 @@ static void icplus_destroy_ring ( struct icplus_nic *icp __unused, size_t len = ( sizeof ( ring->entry[0] ) * ICP_NUM_DESC ); /* Free descriptor ring */ - free_dma ( ring->entry, len ); + free_phys ( ring->entry, len ); ring->entry = NULL; } diff --git a/src/drivers/net/igbvf/igbvf_main.c b/src/drivers/net/igbvf/igbvf_main.c index 39d4e7f8a..a5ed0c451 100644 --- a/src/drivers/net/igbvf/igbvf_main.c +++ b/src/drivers/net/igbvf/igbvf_main.c @@ -46,7 +46,7 @@ int igbvf_setup_tx_resources ( struct igbvf_adapter *adapter ) /* Allocate transmit descriptor ring memory. It must not cross a 64K boundary because of hardware errata #23 - so we use malloc_dma() requesting a 128 byte block that is + so we use malloc_phys() requesting a 128 byte block that is 128 byte aligned. This should guarantee that the memory allocated will not cross a 64K boundary, because 128 is an even multiple of 65536 ( 65536 / 128 == 512 ), so all possible @@ -55,7 +55,7 @@ int igbvf_setup_tx_resources ( struct igbvf_adapter *adapter ) */ adapter->tx_base = - malloc_dma ( adapter->tx_ring_size, adapter->tx_ring_size ); + malloc_phys ( adapter->tx_ring_size, adapter->tx_ring_size ); if ( ! adapter->tx_base ) { return -ENOMEM; @@ -78,7 +78,7 @@ void igbvf_free_tx_resources ( struct igbvf_adapter *adapter ) { DBG ( "igbvf_free_tx_resources\n" ); - free_dma ( adapter->tx_base, adapter->tx_ring_size ); + free_phys ( adapter->tx_base, adapter->tx_ring_size ); } /** @@ -93,7 +93,7 @@ void igbvf_free_rx_resources ( struct igbvf_adapter *adapter ) DBG ( "igbvf_free_rx_resources\n" ); - free_dma ( adapter->rx_base, adapter->rx_ring_size ); + free_phys ( adapter->rx_base, adapter->rx_ring_size ); for ( i = 0; i < NUM_RX_DESC; i++ ) { free_iob ( adapter->rx_iobuf[i] ); @@ -574,7 +574,7 @@ int igbvf_setup_rx_resources ( struct igbvf_adapter *adapter ) */ adapter->rx_base = - malloc_dma ( adapter->rx_ring_size, adapter->rx_ring_size ); + malloc_phys ( adapter->rx_ring_size, adapter->rx_ring_size ); if ( ! adapter->rx_base ) { return -ENOMEM; diff --git a/src/drivers/net/intel.c b/src/drivers/net/intel.c index 97f50a943..3a4e4341b 100644 --- a/src/drivers/net/intel.c +++ b/src/drivers/net/intel.c @@ -504,7 +504,7 @@ int intel_create_ring ( struct intel_nic *intel, struct intel_ring *ring ) { * prevent any possible page-crossing errors due to hardware * errata. */ - ring->desc = malloc_dma ( ring->len, ring->len ); + ring->desc = malloc_phys ( ring->len, ring->len ); if ( ! ring->desc ) return -ENOMEM; @@ -553,7 +553,7 @@ void intel_destroy_ring ( struct intel_nic *intel, struct intel_ring *ring ) { intel_reset_ring ( intel, ring->reg ); /* Free descriptor ring */ - free_dma ( ring->desc, ring->len ); + free_phys ( ring->desc, ring->len ); ring->desc = NULL; ring->prod = 0; ring->cons = 0; diff --git a/src/drivers/net/intelxl.c b/src/drivers/net/intelxl.c index 08c90bc48..d16b759e7 100644 --- a/src/drivers/net/intelxl.c +++ b/src/drivers/net/intelxl.c @@ -195,7 +195,7 @@ static int intelxl_alloc_admin ( struct intelxl_nic *intelxl, size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC ); /* Allocate admin queue */ - admin->buf = malloc_dma ( ( buf_len + len ), INTELXL_ALIGN ); + admin->buf = malloc_phys ( ( buf_len + len ), INTELXL_ALIGN ); if ( ! admin->buf ) return -ENOMEM; admin->desc = ( ( ( void * ) admin->buf ) + buf_len ); @@ -277,7 +277,7 @@ static void intelxl_free_admin ( struct intelxl_nic *intelxl __unused, size_t len = ( sizeof ( admin->desc[0] ) * INTELXL_ADMIN_NUM_DESC ); /* Free queue */ - free_dma ( admin->buf, ( buf_len + len ) ); + free_phys ( admin->buf, ( buf_len + len ) ); } /** @@ -926,7 +926,7 @@ int intelxl_alloc_ring ( struct intelxl_nic *intelxl, int rc; /* Allocate descriptor ring */ - ring->desc.raw = malloc_dma ( ring->len, INTELXL_ALIGN ); + ring->desc.raw = malloc_phys ( ring->len, INTELXL_ALIGN ); if ( ! ring->desc.raw ) { rc = -ENOMEM; goto err_alloc; @@ -950,7 +950,7 @@ int intelxl_alloc_ring ( struct intelxl_nic *intelxl, return 0; - free_dma ( ring->desc.raw, ring->len ); + free_phys ( ring->desc.raw, ring->len ); err_alloc: return rc; } @@ -965,7 +965,7 @@ void intelxl_free_ring ( struct intelxl_nic *intelxl __unused, struct intelxl_ring *ring ) { /* Free descriptor ring */ - free_dma ( ring->desc.raw, ring->len ); + free_phys ( ring->desc.raw, ring->len ); ring->desc.raw = NULL; } diff --git a/src/drivers/net/jme.c b/src/drivers/net/jme.c index b68b96c88..c7307728d 100644 --- a/src/drivers/net/jme.c +++ b/src/drivers/net/jme.c @@ -262,7 +262,7 @@ jme_free_tx_resources(struct jme_adapter *jme) sizeof(struct io_buffer *) * jme->tx_ring_size); free(txring->bufinf); } - free_dma(txring->desc, jme->tx_ring_size * TX_DESC_SIZE); + free_phys(txring->desc, jme->tx_ring_size * TX_DESC_SIZE); txring->desc = NULL; txring->dma = 0; txring->bufinf = NULL; @@ -277,7 +277,7 @@ jme_alloc_tx_resources(struct jme_adapter *jme) { struct jme_ring *txring = &jme->txring; - txring->desc = malloc_dma(jme->tx_ring_size * TX_DESC_SIZE, + txring->desc = malloc_phys(jme->tx_ring_size * TX_DESC_SIZE, RING_DESC_ALIGN); if (!txring->desc) { DBG("Can not allocate transmit ring descriptors.\n"); @@ -442,7 +442,7 @@ jme_free_rx_resources(struct jme_adapter *jme) free(rxring->bufinf); } - free_dma(rxring->desc, jme->rx_ring_size * RX_DESC_SIZE); + free_phys(rxring->desc, jme->rx_ring_size * RX_DESC_SIZE); rxring->desc = NULL; rxring->dma = 0; rxring->bufinf = NULL; @@ -458,7 +458,7 @@ jme_alloc_rx_resources(struct jme_adapter *jme) struct jme_ring *rxring = &jme->rxring; struct io_buffer **bufinf; - rxring->desc = malloc_dma(jme->rx_ring_size * RX_DESC_SIZE, + rxring->desc = malloc_phys(jme->rx_ring_size * RX_DESC_SIZE, RING_DESC_ALIGN); if (!rxring->desc) { DBG("Can not allocate receive ring descriptors.\n"); diff --git a/src/drivers/net/myri10ge.c b/src/drivers/net/myri10ge.c index ae6b6c21e..6d0f723f2 100644 --- a/src/drivers/net/myri10ge.c +++ b/src/drivers/net/myri10ge.c @@ -66,7 +66,7 @@ FILE_LICENCE ( GPL2_ONLY ); /* * Debugging levels: - * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_dma(), + * - DBG() is for any errors, i.e. failed alloc_iob(), malloc_phys(), * TX overflow, corrupted packets, ... * - DBG2() is for successful events, like packet received, * packet transmitted, and other general notifications. @@ -918,7 +918,7 @@ static void myri10ge_net_close ( struct net_device *netdev ) /* Release DMAable memory. */ - free_dma ( priv->dma, sizeof ( *priv->dma ) ); + free_phys ( priv->dma, sizeof ( *priv->dma ) ); /* Erase all state from the open. */ @@ -988,7 +988,7 @@ static int myri10ge_net_open ( struct net_device *netdev ) /* Allocate cleared DMAable buffers. */ - priv->dma = malloc_dma ( sizeof ( *priv->dma ) , 128 ); + priv->dma = malloc_phys ( sizeof ( *priv->dma ) , 128 ); if ( !priv->dma ) { rc = -ENOMEM; dbg = "DMA"; @@ -1152,7 +1152,7 @@ abort_with_receives_posted: free_iob ( priv->receive_iob[priv->receives_posted] ); abort_with_dma: /* Because the link is not up, we don't have to reset the NIC here. */ - free_dma ( priv->dma, sizeof ( *priv->dma ) ); + free_phys ( priv->dma, sizeof ( *priv->dma ) ); abort_with_nothing: /* Erase all signs of the failed open. */ memset ( priv, 0, sizeof ( *priv ) ); diff --git a/src/drivers/net/myson.c b/src/drivers/net/myson.c index 4dd0aab4a..4ab2bf345 100644 --- a/src/drivers/net/myson.c +++ b/src/drivers/net/myson.c @@ -165,7 +165,7 @@ static int myson_create_ring ( struct myson_nic *myson, int rc; /* Allocate descriptor ring */ - ring->desc = malloc_dma ( len, MYSON_RING_ALIGN ); + ring->desc = malloc_phys ( len, MYSON_RING_ALIGN ); if ( ! ring->desc ) { rc = -ENOMEM; goto err_alloc; @@ -197,7 +197,7 @@ static int myson_create_ring ( struct myson_nic *myson, return 0; err_64bit: - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); ring->desc = NULL; err_alloc: return rc; @@ -217,7 +217,7 @@ static void myson_destroy_ring ( struct myson_nic *myson, writel ( 0, myson->regs + ring->reg ); /* Free descriptor ring */ - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); ring->desc = NULL; ring->prod = 0; ring->cons = 0; diff --git a/src/drivers/net/natsemi.c b/src/drivers/net/natsemi.c index 33cf68b3c..ba99bc2fe 100644 --- a/src/drivers/net/natsemi.c +++ b/src/drivers/net/natsemi.c @@ -408,7 +408,7 @@ static int natsemi_create_ring ( struct natsemi_nic *natsemi, * ensure that it can't possibly cross the boundary of 32-bit * address space. */ - ring->desc = malloc_dma ( len, len ); + ring->desc = malloc_phys ( len, len ); if ( ! ring->desc ) { rc = -ENOMEM; goto err_alloc; @@ -454,7 +454,7 @@ static int natsemi_create_ring ( struct natsemi_nic *natsemi, return 0; err_64bit: - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); ring->desc = NULL; err_alloc: return rc; @@ -476,7 +476,7 @@ static void natsemi_destroy_ring ( struct natsemi_nic *natsemi, writel ( 0, natsemi->regs + ring->reg + 4 ); /* Free descriptor ring */ - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); ring->desc = NULL; ring->prod = 0; ring->cons = 0; diff --git a/src/drivers/net/netfront.c b/src/drivers/net/netfront.c index b6205542b..be210850a 100644 --- a/src/drivers/net/netfront.c +++ b/src/drivers/net/netfront.c @@ -338,7 +338,7 @@ static int netfront_create_ring ( struct netfront_nic *netfront, ring->id_cons = 0; /* Allocate and initialise shared ring */ - ring->sring.raw = malloc_dma ( PAGE_SIZE, PAGE_SIZE ); + ring->sring.raw = malloc_phys ( PAGE_SIZE, PAGE_SIZE ); if ( ! ring->sring.raw ) { rc = -ENOMEM; goto err_alloc; @@ -368,7 +368,7 @@ static int netfront_create_ring ( struct netfront_nic *netfront, err_write_num: xengrant_invalidate ( xen, ring->ref ); err_permit_access: - free_dma ( ring->sring.raw, PAGE_SIZE ); + free_phys ( ring->sring.raw, PAGE_SIZE ); err_alloc: return rc; } @@ -490,7 +490,7 @@ static void netfront_destroy_ring ( struct netfront_nic *netfront, xengrant_invalidate ( xen, ring->ref ); /* Free page */ - free_dma ( ring->sring.raw, PAGE_SIZE ); + free_phys ( ring->sring.raw, PAGE_SIZE ); ring->sring.raw = NULL; } diff --git a/src/drivers/net/pcnet32.c b/src/drivers/net/pcnet32.c index 2635aaca2..c0dea86a8 100644 --- a/src/drivers/net/pcnet32.c +++ b/src/drivers/net/pcnet32.c @@ -246,7 +246,7 @@ pcnet32_setup_rx_resources ( struct pcnet32_private *priv ) { DBGP ( "pcnet32_setup_rx_resources\n" ); - priv->rx_base = malloc_dma ( RX_RING_BYTES, RX_RING_ALIGN ); + priv->rx_base = malloc_phys ( RX_RING_BYTES, RX_RING_ALIGN ); DBG ( "priv->rx_base = %#08lx\n", virt_to_bus ( priv->rx_base ) ); @@ -270,7 +270,7 @@ pcnet32_free_rx_resources ( struct pcnet32_private *priv ) DBGP ( "pcnet32_free_rx_resources\n" ); - free_dma ( priv->rx_base, RX_RING_BYTES ); + free_phys ( priv->rx_base, RX_RING_BYTES ); for ( i = 0; i < RX_RING_SIZE; i++ ) { free_iob ( priv->rx_iobuf[i] ); @@ -290,7 +290,7 @@ pcnet32_setup_tx_resources ( struct pcnet32_private *priv ) { DBGP ( "pcnet32_setup_tx_resources\n" ); - priv->tx_base = malloc_dma ( TX_RING_BYTES, TX_RING_ALIGN ); + priv->tx_base = malloc_phys ( TX_RING_BYTES, TX_RING_ALIGN ); if ( ! priv->tx_base ) { return -ENOMEM; @@ -312,7 +312,7 @@ pcnet32_free_tx_resources ( struct pcnet32_private *priv ) { DBGP ( "pcnet32_free_tx_resources\n" ); - free_dma ( priv->tx_base, TX_RING_BYTES ); + free_phys ( priv->tx_base, TX_RING_BYTES ); } static int diff --git a/src/drivers/net/phantom/phantom.c b/src/drivers/net/phantom/phantom.c index 8f247ff8e..843459059 100644 --- a/src/drivers/net/phantom/phantom.c +++ b/src/drivers/net/phantom/phantom.c @@ -640,7 +640,7 @@ static int phantom_create_rx_ctx ( struct phantom_nic *phantom ) { int rc; /* Allocate context creation buffer */ - buf = malloc_dma ( sizeof ( *buf ), UNM_DMA_BUFFER_ALIGN ); + buf = malloc_phys ( sizeof ( *buf ), UNM_DMA_BUFFER_ALIGN ); if ( ! buf ) { rc = -ENOMEM; goto out; @@ -716,7 +716,7 @@ static int phantom_create_rx_ctx ( struct phantom_nic *phantom ) { phantom, phantom->sds_irq_mask_crb ); out: - free_dma ( buf, sizeof ( *buf ) ); + free_phys ( buf, sizeof ( *buf ) ); return rc; } @@ -765,7 +765,7 @@ static int phantom_create_tx_ctx ( struct phantom_nic *phantom ) { int rc; /* Allocate context creation buffer */ - buf = malloc_dma ( sizeof ( *buf ), UNM_DMA_BUFFER_ALIGN ); + buf = malloc_phys ( sizeof ( *buf ), UNM_DMA_BUFFER_ALIGN ); if ( ! buf ) { rc = -ENOMEM; goto out; @@ -821,7 +821,7 @@ static int phantom_create_tx_ctx ( struct phantom_nic *phantom ) { phantom, phantom->cds_producer_crb ); out: - free_dma ( buf, sizeof ( *buf ) ); + free_phys ( buf, sizeof ( *buf ) ); return rc; } @@ -1164,8 +1164,8 @@ static int phantom_open ( struct net_device *netdev ) { int rc; /* Allocate and zero descriptor rings */ - phantom->desc = malloc_dma ( sizeof ( *(phantom->desc) ), - UNM_DMA_BUFFER_ALIGN ); + phantom->desc = malloc_phys ( sizeof ( *(phantom->desc) ), + UNM_DMA_BUFFER_ALIGN ); if ( ! phantom->desc ) { rc = -ENOMEM; goto err_alloc_desc; @@ -1208,7 +1208,7 @@ static int phantom_open ( struct net_device *netdev ) { err_create_tx_ctx: phantom_destroy_rx_ctx ( phantom ); err_create_rx_ctx: - free_dma ( phantom->desc, sizeof ( *(phantom->desc) ) ); + free_phys ( phantom->desc, sizeof ( *(phantom->desc) ) ); phantom->desc = NULL; err_alloc_desc: return rc; @@ -1229,7 +1229,7 @@ static void phantom_close ( struct net_device *netdev ) { phantom_del_macaddr ( phantom, netdev->ll_broadcast ); phantom_destroy_tx_ctx ( phantom ); phantom_destroy_rx_ctx ( phantom ); - free_dma ( phantom->desc, sizeof ( *(phantom->desc) ) ); + free_phys ( phantom->desc, sizeof ( *(phantom->desc) ) ); phantom->desc = NULL; /* Flush any uncompleted descriptors */ diff --git a/src/drivers/net/realtek.c b/src/drivers/net/realtek.c index e74128c4c..f432dce5f 100644 --- a/src/drivers/net/realtek.c +++ b/src/drivers/net/realtek.c @@ -514,7 +514,7 @@ static int realtek_create_buffer ( struct realtek_nic *rtl ) { return 0; /* Allocate buffer */ - rtl->rx_buffer = malloc_dma ( len, RTL_RXBUF_ALIGN ); + rtl->rx_buffer = malloc_phys ( len, RTL_RXBUF_ALIGN ); if ( ! rtl->rx_buffer ) { rc = -ENOMEM; goto err_alloc; @@ -539,7 +539,7 @@ static int realtek_create_buffer ( struct realtek_nic *rtl ) { return 0; err_64bit: - free_dma ( rtl->rx_buffer, len ); + free_phys ( rtl->rx_buffer, len ); rtl->rx_buffer = NULL; err_alloc: return rc; @@ -561,7 +561,7 @@ static void realtek_destroy_buffer ( struct realtek_nic *rtl ) { writel ( 0, rtl->regs + RTL_RBSTART ); /* Free buffer */ - free_dma ( rtl->rx_buffer, len ); + free_phys ( rtl->rx_buffer, len ); rtl->rx_buffer = NULL; rtl->rx_offset = 0; } @@ -582,7 +582,7 @@ static int realtek_create_ring ( struct realtek_nic *rtl, return 0; /* Allocate descriptor ring */ - ring->desc = malloc_dma ( ring->len, RTL_RING_ALIGN ); + ring->desc = malloc_phys ( ring->len, RTL_RING_ALIGN ); if ( ! ring->desc ) return -ENOMEM; @@ -623,7 +623,7 @@ static void realtek_destroy_ring ( struct realtek_nic *rtl, writel ( 0, rtl->regs + ring->reg + 4 ); /* Free descriptor ring */ - free_dma ( ring->desc, ring->len ); + free_phys ( ring->desc, ring->len ); ring->desc = NULL; } diff --git a/src/drivers/net/rhine.c b/src/drivers/net/rhine.c index cbe21c316..f4d3a2580 100644 --- a/src/drivers/net/rhine.c +++ b/src/drivers/net/rhine.c @@ -292,7 +292,7 @@ static int rhine_create_ring ( struct rhine_nic *rhn, unsigned int i; /* Allocate descriptors */ - ring->desc = malloc_dma ( len, RHINE_RING_ALIGN ); + ring->desc = malloc_phys ( len, RHINE_RING_ALIGN ); if ( ! ring->desc ) return -ENOMEM; @@ -328,7 +328,7 @@ static void rhine_destroy_ring ( struct rhine_nic *rhn, writel ( 0, rhn->regs + ring->reg ); /* Free descriptor ring */ - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); ring->desc = NULL; ring->prod = 0; ring->cons = 0; diff --git a/src/drivers/net/rtl818x/rtl818x.c b/src/drivers/net/rtl818x/rtl818x.c index f5082084e..599d36fad 100644 --- a/src/drivers/net/rtl818x/rtl818x.c +++ b/src/drivers/net/rtl818x/rtl818x.c @@ -328,8 +328,8 @@ static int rtl818x_init_rx_ring(struct net80211_device *dev) struct rtl818x_rx_desc *entry; int i; - priv->rx_ring = malloc_dma(sizeof(*priv->rx_ring) * RTL818X_RX_RING_SIZE, - RTL818X_RING_ALIGN); + priv->rx_ring = malloc_phys(sizeof(*priv->rx_ring) * RTL818X_RX_RING_SIZE, + RTL818X_RING_ALIGN); priv->rx_ring_dma = virt_to_bus(priv->rx_ring); if (!priv->rx_ring) { DBG("rtl818x %s: cannot allocate RX ring\n", dev->netdev->name); @@ -364,7 +364,7 @@ static void rtl818x_free_rx_ring(struct net80211_device *dev) priv->rx_buf[i] = NULL; } - free_dma(priv->rx_ring, sizeof(*priv->rx_ring) * RTL818X_RX_RING_SIZE); + free_phys(priv->rx_ring, sizeof(*priv->rx_ring) * RTL818X_RX_RING_SIZE); priv->rx_ring = NULL; } @@ -373,8 +373,8 @@ static int rtl818x_init_tx_ring(struct net80211_device *dev) struct rtl818x_priv *priv = dev->priv; int i; - priv->tx_ring = malloc_dma(sizeof(*priv->tx_ring) * RTL818X_TX_RING_SIZE, - RTL818X_RING_ALIGN); + priv->tx_ring = malloc_phys(sizeof(*priv->tx_ring) * RTL818X_TX_RING_SIZE, + RTL818X_RING_ALIGN); priv->tx_ring_dma = virt_to_bus(priv->tx_ring); if (!priv->tx_ring) { DBG("rtl818x %s: cannot allocate TX ring\n", dev->netdev->name); @@ -402,7 +402,7 @@ static void rtl818x_free_tx_ring(struct net80211_device *dev) priv->tx_buf[i] = NULL; } - free_dma(priv->tx_ring, sizeof(*priv->tx_ring) * RTL818X_TX_RING_SIZE); + free_phys(priv->tx_ring, sizeof(*priv->tx_ring) * RTL818X_TX_RING_SIZE); priv->tx_ring = NULL; } diff --git a/src/drivers/net/sfc/efx_hunt.c b/src/drivers/net/sfc/efx_hunt.c index 07dd7dfea..c846379af 100644 --- a/src/drivers/net/sfc/efx_hunt.c +++ b/src/drivers/net/sfc/efx_hunt.c @@ -37,7 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); void efx_hunt_free_special_buffer(void *buf, int bytes) { - free_dma(buf, bytes); + free_phys(buf, bytes); } static void *efx_hunt_alloc_special_buffer(int bytes, @@ -50,7 +50,7 @@ static void *efx_hunt_alloc_special_buffer(int bytes, * buffer will be passed into an MC_CMD_INIT_*Q command to setup the * appropriate type of queue via MCDI. */ - buffer = malloc_dma(bytes, EFX_BUF_ALIGN); + buffer = malloc_phys(bytes, EFX_BUF_ALIGN); if (!buffer) return NULL; diff --git a/src/drivers/net/sis190.c b/src/drivers/net/sis190.c index 11dda1c97..0e4f0762e 100644 --- a/src/drivers/net/sis190.c +++ b/src/drivers/net/sis190.c @@ -552,7 +552,7 @@ static int sis190_open(struct net_device *dev) int rc; /* Allocate TX ring */ - tp->TxDescRing = malloc_dma(TX_RING_BYTES, RING_ALIGNMENT); + tp->TxDescRing = malloc_phys(TX_RING_BYTES, RING_ALIGNMENT); if (!tp->TxDescRing) { DBG("sis190: TX ring allocation failed\n"); rc = -ENOMEM; @@ -561,7 +561,7 @@ static int sis190_open(struct net_device *dev) tp->tx_dma = cpu_to_le32(virt_to_bus(tp->TxDescRing)); /* Allocate RX ring */ - tp->RxDescRing = malloc_dma(RX_RING_BYTES, RING_ALIGNMENT); + tp->RxDescRing = malloc_phys(RX_RING_BYTES, RING_ALIGNMENT); if (!tp->RxDescRing) { DBG("sis190: RX ring allocation failed\n"); rc = -ENOMEM; @@ -600,8 +600,8 @@ static void sis190_free(struct net_device *dev) struct sis190_private *tp = netdev_priv(dev); int i; - free_dma(tp->TxDescRing, TX_RING_BYTES); - free_dma(tp->RxDescRing, RX_RING_BYTES); + free_phys(tp->TxDescRing, TX_RING_BYTES); + free_phys(tp->RxDescRing, RX_RING_BYTES); tp->TxDescRing = NULL; tp->RxDescRing = NULL; diff --git a/src/drivers/net/skge.c b/src/drivers/net/skge.c index c9a7891ba..5aa5e2a6a 100755 --- a/src/drivers/net/skge.c +++ b/src/drivers/net/skge.c @@ -1699,7 +1699,7 @@ void skge_free(struct net_device *dev) free(skge->tx_ring.start); skge->tx_ring.start = NULL; - free_dma(skge->mem, RING_SIZE); + free_phys(skge->mem, RING_SIZE); skge->mem = NULL; skge->dma = 0; } @@ -1714,7 +1714,7 @@ static int skge_up(struct net_device *dev) DBG2(PFX "%s: enabling interface\n", dev->name); - skge->mem = malloc_dma(RING_SIZE, SKGE_RING_ALIGN); + skge->mem = malloc_phys(RING_SIZE, SKGE_RING_ALIGN); skge->dma = virt_to_bus(skge->mem); if (!skge->mem) return -ENOMEM; diff --git a/src/drivers/net/sky2.c b/src/drivers/net/sky2.c index 0d11e17df..9d612c997 100644 --- a/src/drivers/net/sky2.c +++ b/src/drivers/net/sky2.c @@ -1112,10 +1112,10 @@ nomem: /* Free the le and ring buffers */ static void sky2_free_rings(struct sky2_port *sky2) { - free_dma(sky2->rx_le, RX_LE_BYTES); + free_phys(sky2->rx_le, RX_LE_BYTES); free(sky2->rx_ring); - free_dma(sky2->tx_le, TX_RING_SIZE * sizeof(struct sky2_tx_le)); + free_phys(sky2->tx_le, TX_RING_SIZE * sizeof(struct sky2_tx_le)); free(sky2->tx_ring); sky2->tx_le = NULL; @@ -1137,7 +1137,7 @@ static int sky2_up(struct net_device *dev) netdev_link_down(dev); /* must be power of 2 */ - sky2->tx_le = malloc_dma(TX_RING_SIZE * sizeof(struct sky2_tx_le), TX_RING_ALIGN); + sky2->tx_le = malloc_phys(TX_RING_SIZE * sizeof(struct sky2_tx_le), TX_RING_ALIGN); sky2->tx_le_map = virt_to_bus(sky2->tx_le); if (!sky2->tx_le) goto err_out; @@ -1149,7 +1149,7 @@ static int sky2_up(struct net_device *dev) tx_init(sky2); - sky2->rx_le = malloc_dma(RX_LE_BYTES, RX_RING_ALIGN); + sky2->rx_le = malloc_phys(RX_LE_BYTES, RX_RING_ALIGN); sky2->rx_le_map = virt_to_bus(sky2->rx_le); if (!sky2->rx_le) goto err_out; @@ -2285,7 +2285,7 @@ static int sky2_probe(struct pci_device *pdev) } /* ring for status responses */ - hw->st_le = malloc_dma(STATUS_LE_BYTES, STATUS_RING_ALIGN); + hw->st_le = malloc_phys(STATUS_LE_BYTES, STATUS_RING_ALIGN); if (!hw->st_le) goto err_out_iounmap; hw->st_dma = virt_to_bus(hw->st_le); @@ -2344,7 +2344,7 @@ err_out_free_netdev: netdev_put(dev); err_out_free_pci: sky2_write8(hw, B0_CTST, CS_RST_SET); - free_dma(hw->st_le, STATUS_LE_BYTES); + free_phys(hw->st_le, STATUS_LE_BYTES); err_out_iounmap: iounmap((void *)hw->regs); err_out_free_hw: @@ -2373,7 +2373,7 @@ static void sky2_remove(struct pci_device *pdev) sky2_write8(hw, B0_CTST, CS_RST_SET); sky2_read8(hw, B0_CTST); - free_dma(hw->st_le, STATUS_LE_BYTES); + free_phys(hw->st_le, STATUS_LE_BYTES); for (i = hw->ports-1; i >= 0; --i) { netdev_nullify(hw->dev[i]); diff --git a/src/drivers/net/tg3/tg3.c b/src/drivers/net/tg3/tg3.c index f6c038112..cec599c1c 100644 --- a/src/drivers/net/tg3/tg3.c +++ b/src/drivers/net/tg3/tg3.c @@ -42,7 +42,7 @@ void tg3_rx_prodring_fini(struct tg3_rx_prodring_set *tpr) { DBGP("%s\n", __func__); if (tpr->rx_std) { - free_dma(tpr->rx_std, TG3_RX_STD_RING_BYTES(tp)); + free_phys(tpr->rx_std, TG3_RX_STD_RING_BYTES(tp)); tpr->rx_std = NULL; } } @@ -55,7 +55,7 @@ static void tg3_free_consistent(struct tg3 *tp) { DBGP("%s\n", __func__); if (tp->tx_ring) { - free_dma(tp->tx_ring, TG3_TX_RING_BYTES); + free_phys(tp->tx_ring, TG3_TX_RING_BYTES); tp->tx_ring = NULL; } @@ -63,7 +63,7 @@ static void tg3_free_consistent(struct tg3 *tp) tp->tx_buffers = NULL; if (tp->rx_rcb) { - free_dma(tp->rx_rcb, TG3_RX_RCB_RING_BYTES(tp)); + free_phys(tp->rx_rcb, TG3_RX_RCB_RING_BYTES(tp)); tp->rx_rcb_mapping = 0; tp->rx_rcb = NULL; } @@ -71,7 +71,7 @@ static void tg3_free_consistent(struct tg3 *tp) tg3_rx_prodring_fini(&tp->prodring); if (tp->hw_status) { - free_dma(tp->hw_status, TG3_HW_STATUS_SIZE); + free_phys(tp->hw_status, TG3_HW_STATUS_SIZE); tp->status_mapping = 0; tp->hw_status = NULL; } @@ -87,7 +87,7 @@ int tg3_alloc_consistent(struct tg3 *tp) struct tg3_hw_status *sblk; struct tg3_rx_prodring_set *tpr = &tp->prodring; - tp->hw_status = malloc_dma(TG3_HW_STATUS_SIZE, TG3_DMA_ALIGNMENT); + tp->hw_status = malloc_phys(TG3_HW_STATUS_SIZE, TG3_DMA_ALIGNMENT); if (!tp->hw_status) { DBGC(tp->dev, "hw_status alloc failed\n"); goto err_out; @@ -97,7 +97,7 @@ int tg3_alloc_consistent(struct tg3 *tp) memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); sblk = tp->hw_status; - tpr->rx_std = malloc_dma(TG3_RX_STD_RING_BYTES(tp), TG3_DMA_ALIGNMENT); + tpr->rx_std = malloc_phys(TG3_RX_STD_RING_BYTES(tp), TG3_DMA_ALIGNMENT); if (!tpr->rx_std) { DBGC(tp->dev, "rx prodring alloc failed\n"); goto err_out; @@ -109,7 +109,7 @@ int tg3_alloc_consistent(struct tg3 *tp) if (!tp->tx_buffers) goto err_out; - tp->tx_ring = malloc_dma(TG3_TX_RING_BYTES, TG3_DMA_ALIGNMENT); + tp->tx_ring = malloc_phys(TG3_TX_RING_BYTES, TG3_DMA_ALIGNMENT); if (!tp->tx_ring) goto err_out; tp->tx_desc_mapping = virt_to_bus(tp->tx_ring); @@ -123,7 +123,7 @@ int tg3_alloc_consistent(struct tg3 *tp) tp->rx_rcb_prod_idx = &sblk->idx[0].rx_producer; - tp->rx_rcb = malloc_dma(TG3_RX_RCB_RING_BYTES(tp), TG3_DMA_ALIGNMENT); + tp->rx_rcb = malloc_phys(TG3_RX_RCB_RING_BYTES(tp), TG3_DMA_ALIGNMENT); if (!tp->rx_rcb) goto err_out; tp->rx_rcb_mapping = virt_to_bus(tp->rx_rcb); @@ -541,7 +541,7 @@ static int tg3_test_dma(struct tg3 *tp) u32 *buf; int ret = 0; - buf = malloc_dma(TEST_BUFFER_SIZE, TG3_DMA_ALIGNMENT); + buf = malloc_phys(TEST_BUFFER_SIZE, TG3_DMA_ALIGNMENT); if (!buf) { ret = -ENOMEM; goto out_nofree; @@ -708,7 +708,7 @@ static int tg3_test_dma(struct tg3 *tp) } out: - free_dma(buf, TEST_BUFFER_SIZE); + free_phys(buf, TEST_BUFFER_SIZE); out_nofree: return ret; } diff --git a/src/drivers/net/velocity.c b/src/drivers/net/velocity.c index 994e07a64..373714293 100644 --- a/src/drivers/net/velocity.c +++ b/src/drivers/net/velocity.c @@ -320,7 +320,8 @@ static int velocity_alloc_rings ( struct velocity_nic *vlc ) { vlc->rx_prod = 0; vlc->rx_cons = 0; vlc->rx_commit = 0; - vlc->rx_ring = malloc_dma ( VELOCITY_RXDESC_SIZE, VELOCITY_RING_ALIGN ); + vlc->rx_ring = malloc_phys ( VELOCITY_RXDESC_SIZE, + VELOCITY_RING_ALIGN ); if ( ! vlc->rx_ring ) return -ENOMEM; @@ -332,7 +333,8 @@ static int velocity_alloc_rings ( struct velocity_nic *vlc ) { /* Allocate TX descriptor ring */ vlc->tx_prod = 0; vlc->tx_cons = 0; - vlc->tx_ring = malloc_dma ( VELOCITY_TXDESC_SIZE, VELOCITY_RING_ALIGN ); + vlc->tx_ring = malloc_phys ( VELOCITY_TXDESC_SIZE, + VELOCITY_RING_ALIGN ); if ( ! vlc->tx_ring ) { rc = -ENOMEM; goto err_tx_alloc; @@ -356,7 +358,7 @@ static int velocity_alloc_rings ( struct velocity_nic *vlc ) { return 0; err_tx_alloc: - free_dma ( vlc->rx_ring, VELOCITY_RXDESC_SIZE ); + free_phys ( vlc->rx_ring, VELOCITY_RXDESC_SIZE ); return rc; } @@ -482,7 +484,7 @@ static void velocity_close ( struct net_device *netdev ) { writew ( 0, vlc->regs + VELOCITY_RXDESCNUM ); /* Destroy RX ring */ - free_dma ( vlc->rx_ring, VELOCITY_RXDESC_SIZE ); + free_phys ( vlc->rx_ring, VELOCITY_RXDESC_SIZE ); vlc->rx_ring = NULL; vlc->rx_prod = 0; vlc->rx_cons = 0; @@ -499,7 +501,7 @@ static void velocity_close ( struct net_device *netdev ) { writew ( 0, vlc->regs + VELOCITY_TXDESCNUM ); /* Destroy TX ring */ - free_dma ( vlc->tx_ring, VELOCITY_TXDESC_SIZE ); + free_phys ( vlc->tx_ring, VELOCITY_TXDESC_SIZE ); vlc->tx_ring = NULL; vlc->tx_prod = 0; vlc->tx_cons = 0; diff --git a/src/drivers/net/vmxnet3.c b/src/drivers/net/vmxnet3.c index 3e0ab03cd..63bcf0e01 100644 --- a/src/drivers/net/vmxnet3.c +++ b/src/drivers/net/vmxnet3.c @@ -465,7 +465,8 @@ static int vmxnet3_open ( struct net_device *netdev ) { int rc; /* Allocate DMA areas */ - vmxnet->dma = malloc_dma ( sizeof ( *vmxnet->dma ), VMXNET3_DMA_ALIGN ); + vmxnet->dma = malloc_phys ( sizeof ( *vmxnet->dma ), + VMXNET3_DMA_ALIGN ); if ( ! vmxnet->dma ) { DBGC ( vmxnet, "VMXNET3 %p could not allocate DMA area\n", vmxnet ); @@ -542,7 +543,7 @@ static int vmxnet3_open ( struct net_device *netdev ) { err_activate: vmxnet3_flush_tx ( netdev ); vmxnet3_flush_rx ( netdev ); - free_dma ( vmxnet->dma, sizeof ( *vmxnet->dma ) ); + free_phys ( vmxnet->dma, sizeof ( *vmxnet->dma ) ); err_alloc_dma: return rc; } @@ -559,7 +560,7 @@ static void vmxnet3_close ( struct net_device *netdev ) { vmxnet3_command ( vmxnet, VMXNET3_CMD_RESET_DEV ); vmxnet3_flush_tx ( netdev ); vmxnet3_flush_rx ( netdev ); - free_dma ( vmxnet->dma, sizeof ( *vmxnet->dma ) ); + free_phys ( vmxnet->dma, sizeof ( *vmxnet->dma ) ); } /** vmxnet3 net device operations */ diff --git a/src/drivers/net/vxge/vxge_config.c b/src/drivers/net/vxge/vxge_config.c index ba62b508e..f4d217097 100644 --- a/src/drivers/net/vxge/vxge_config.c +++ b/src/drivers/net/vxge/vxge_config.c @@ -624,10 +624,10 @@ __vxge_hw_ring_create(struct __vxge_hw_virtualpath *vpath, hldev = vpath->hldev; vp_id = vpath->vp_id; - ring->rxdl = malloc_dma(sizeof(struct __vxge_hw_ring_block), + ring->rxdl = malloc_phys(sizeof(struct __vxge_hw_ring_block), sizeof(struct __vxge_hw_ring_block)); if (!ring->rxdl) { - vxge_debug(VXGE_ERR, "%s:%d malloc_dma error\n", + vxge_debug(VXGE_ERR, "%s:%d malloc_phys error\n", __func__, __LINE__); status = VXGE_HW_ERR_OUT_OF_MEMORY; goto exit; @@ -667,7 +667,7 @@ enum vxge_hw_status __vxge_hw_ring_delete(struct __vxge_hw_ring *ring) } if (ring->rxdl) { - free_dma(ring->rxdl, sizeof(struct __vxge_hw_ring_block)); + free_phys(ring->rxdl, sizeof(struct __vxge_hw_ring_block)); ring->rxdl = NULL; } ring->rxd_offset = 0; @@ -826,10 +826,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_virtualpath *vpath, fifo->tx_intr_num = (vpath->vp_id * VXGE_HW_MAX_INTR_PER_VP) + VXGE_HW_VPATH_INTR_TX; - fifo->txdl = malloc_dma(sizeof(struct vxge_hw_fifo_txd) + fifo->txdl = malloc_phys(sizeof(struct vxge_hw_fifo_txd) * fifo->depth, fifo->depth); if (!fifo->txdl) { - vxge_debug(VXGE_ERR, "%s:%d malloc_dma error\n", + vxge_debug(VXGE_ERR, "%s:%d malloc_phys error\n", __func__, __LINE__); return VXGE_HW_ERR_OUT_OF_MEMORY; } @@ -846,7 +846,7 @@ enum vxge_hw_status __vxge_hw_fifo_delete(struct __vxge_hw_fifo *fifo) vxge_trace(); if (fifo->txdl) - free_dma(fifo->txdl, + free_phys(fifo->txdl, sizeof(struct vxge_hw_fifo_txd) * fifo->depth); fifo->txdl = NULL; diff --git a/src/drivers/usb/ehci.c b/src/drivers/usb/ehci.c index 15193efe1..77022a47d 100644 --- a/src/drivers/usb/ehci.c +++ b/src/drivers/usb/ehci.c @@ -565,8 +565,8 @@ static int ehci_ring_alloc ( struct ehci_device *ehci, } /* Allocate queue head */ - ring->head = malloc_dma ( sizeof ( *ring->head ), - ehci_align ( sizeof ( *ring->head ) ) ); + ring->head = malloc_phys ( sizeof ( *ring->head ), + ehci_align ( sizeof ( *ring->head ) ) ); if ( ! ring->head ) { rc = -ENOMEM; goto err_alloc_queue; @@ -579,7 +579,7 @@ static int ehci_ring_alloc ( struct ehci_device *ehci, /* Allocate transfer descriptors */ len = ( EHCI_RING_COUNT * sizeof ( ring->desc[0] ) ); - ring->desc = malloc_dma ( len, sizeof ( ring->desc[0] ) ); + ring->desc = malloc_phys ( len, sizeof ( ring->desc[0] ) ); if ( ! ring->desc ) { rc = -ENOMEM; goto err_alloc_desc; @@ -607,10 +607,10 @@ static int ehci_ring_alloc ( struct ehci_device *ehci, return 0; err_unreachable_desc: - free_dma ( ring->desc, len ); + free_phys ( ring->desc, len ); err_alloc_desc: err_unreachable_queue: - free_dma ( ring->head, sizeof ( *ring->head ) ); + free_phys ( ring->head, sizeof ( *ring->head ) ); err_alloc_queue: free ( ring->iobuf ); err_alloc_iobuf: @@ -631,10 +631,11 @@ static void ehci_ring_free ( struct ehci_ring *ring ) { assert ( ring->iobuf[i] == NULL ); /* Free transfer descriptors */ - free_dma ( ring->desc, ( EHCI_RING_COUNT * sizeof ( ring->desc[0] ) ) ); + free_phys ( ring->desc, ( EHCI_RING_COUNT * + sizeof ( ring->desc[0] ) ) ); /* Free queue head */ - free_dma ( ring->head, sizeof ( *ring->head ) ); + free_phys ( ring->head, sizeof ( *ring->head ) ); /* Free I/O buffers */ free ( ring->iobuf ); @@ -1787,8 +1788,8 @@ static int ehci_bus_open ( struct usb_bus *bus ) { assert ( list_empty ( &ehci->periodic ) ); /* Allocate and initialise asynchronous queue head */ - ehci->head = malloc_dma ( sizeof ( *ehci->head ), - ehci_align ( sizeof ( *ehci->head ) ) ); + ehci->head = malloc_phys ( sizeof ( *ehci->head ), + ehci_align ( sizeof ( *ehci->head ) ) ); if ( ! ehci->head ) { rc = -ENOMEM; goto err_alloc_head; @@ -1816,7 +1817,7 @@ static int ehci_bus_open ( struct usb_bus *bus ) { /* Allocate periodic frame list */ frames = EHCI_PERIODIC_FRAMES ( ehci->flsize ); len = ( frames * sizeof ( ehci->frame[0] ) ); - ehci->frame = malloc_dma ( len, EHCI_PAGE_ALIGN ); + ehci->frame = malloc_phys ( len, EHCI_PAGE_ALIGN ); if ( ! ehci->frame ) { rc = -ENOMEM; goto err_alloc_frame; @@ -1836,10 +1837,10 @@ static int ehci_bus_open ( struct usb_bus *bus ) { ehci_stop ( ehci ); err_unreachable_frame: - free_dma ( ehci->frame, len ); + free_phys ( ehci->frame, len ); err_alloc_frame: err_ctrldssegment: - free_dma ( ehci->head, sizeof ( *ehci->head ) ); + free_phys ( ehci->head, sizeof ( *ehci->head ) ); err_alloc_head: return rc; } @@ -1861,10 +1862,10 @@ static void ehci_bus_close ( struct usb_bus *bus ) { ehci_stop ( ehci ); /* Free periodic frame list */ - free_dma ( ehci->frame, ( frames * sizeof ( ehci->frame[0] ) ) ); + free_phys ( ehci->frame, ( frames * sizeof ( ehci->frame[0] ) ) ); /* Free asynchronous schedule */ - free_dma ( ehci->head, sizeof ( *ehci->head ) ); + free_phys ( ehci->head, sizeof ( *ehci->head ) ); } /** diff --git a/src/drivers/usb/uhci.c b/src/drivers/usb/uhci.c index ce2962d36..47474bdc7 100644 --- a/src/drivers/usb/uhci.c +++ b/src/drivers/usb/uhci.c @@ -179,7 +179,7 @@ static int uhci_ring_alloc ( struct uhci_ring *ring ) { memset ( ring, 0, sizeof ( *ring ) ); /* Allocate queue head */ - ring->head = malloc_dma ( sizeof ( *ring->head ), UHCI_ALIGN ); + ring->head = malloc_phys ( sizeof ( *ring->head ), UHCI_ALIGN ); if ( ! ring->head ) { rc = -ENOMEM; goto err_alloc; @@ -194,7 +194,7 @@ static int uhci_ring_alloc ( struct uhci_ring *ring ) { return 0; err_unreachable: - free_dma ( ring->head, sizeof ( *ring->head ) ); + free_phys ( ring->head, sizeof ( *ring->head ) ); err_alloc: return rc; } @@ -213,7 +213,7 @@ static void uhci_ring_free ( struct uhci_ring *ring ) { assert ( ring->xfer[i] == NULL ); /* Free queue head */ - free_dma ( ring->head, sizeof ( *ring->head ) ); + free_phys ( ring->head, sizeof ( *ring->head ) ); } /** @@ -263,7 +263,7 @@ static int uhci_enqueue ( struct uhci_ring *ring, struct io_buffer *iobuf, /* Allocate transfer descriptors */ len = ( count * sizeof ( xfer->desc[0] ) ); - xfer->desc = malloc_dma ( len, UHCI_ALIGN ); + xfer->desc = malloc_phys ( len, UHCI_ALIGN ); if ( ! xfer->desc ) { rc = -ENOMEM; goto err_alloc_desc; @@ -299,7 +299,7 @@ static int uhci_enqueue ( struct uhci_ring *ring, struct io_buffer *iobuf, return 0; err_unreachable_desc: - free_dma ( xfer->desc, len ); + free_phys ( xfer->desc, len ); err_alloc_desc: free ( xfer ); err_alloc_xfer: @@ -377,7 +377,7 @@ static struct io_buffer * uhci_dequeue ( struct uhci_ring *ring ) { /* Free transfer descriptors */ len = ( xfer->prod * sizeof ( xfer->desc[0] ) ); - free_dma ( xfer->desc, len ); + free_phys ( xfer->desc, len ); /* Free transfer */ free ( xfer ); @@ -1312,7 +1312,7 @@ static int uhci_bus_open ( struct usb_bus *bus ) { assert ( list_empty ( &uhci->periodic ) ); /* Allocate and initialise asynchronous queue head */ - uhci->head = malloc_dma ( sizeof ( *uhci->head ), UHCI_ALIGN ); + uhci->head = malloc_phys ( sizeof ( *uhci->head ), UHCI_ALIGN ); if ( ! uhci->head ) { rc = -ENOMEM; goto err_alloc_head; @@ -1324,8 +1324,8 @@ static int uhci_bus_open ( struct usb_bus *bus ) { uhci_async_schedule ( uhci ); /* Allocate periodic frame list */ - uhci->frame = malloc_dma ( sizeof ( *uhci->frame ), - sizeof ( *uhci->frame ) ); + uhci->frame = malloc_phys ( sizeof ( *uhci->frame ), + sizeof ( *uhci->frame ) ); if ( ! uhci->frame ) { rc = -ENOMEM; goto err_alloc_frame; @@ -1343,10 +1343,10 @@ static int uhci_bus_open ( struct usb_bus *bus ) { uhci_stop ( uhci ); err_unreachable_frame: - free_dma ( uhci->frame, sizeof ( *uhci->frame ) ); + free_phys ( uhci->frame, sizeof ( *uhci->frame ) ); err_alloc_frame: err_unreachable_head: - free_dma ( uhci->head, sizeof ( *uhci->head ) ); + free_phys ( uhci->head, sizeof ( *uhci->head ) ); err_alloc_head: return rc; } @@ -1367,10 +1367,10 @@ static void uhci_bus_close ( struct usb_bus *bus ) { uhci_stop ( uhci ); /* Free periodic frame list */ - free_dma ( uhci->frame, sizeof ( *uhci->frame ) ); + free_phys ( uhci->frame, sizeof ( *uhci->frame ) ); /* Free asynchronous schedule */ - free_dma ( uhci->head, sizeof ( *uhci->head ) ); + free_phys ( uhci->head, sizeof ( *uhci->head ) ); } /** diff --git a/src/drivers/usb/xhci.c b/src/drivers/usb/xhci.c index c4a1dc337..7f55a90f2 100644 --- a/src/drivers/usb/xhci.c +++ b/src/drivers/usb/xhci.c @@ -919,7 +919,7 @@ static int xhci_dcbaa_alloc ( struct xhci_device *xhci ) { * with a minimum of 64 bytes). */ len = ( ( xhci->slots + 1 ) * sizeof ( xhci->dcbaa[0] ) ); - xhci->dcbaa = malloc_dma ( len, xhci_align ( len ) ); + xhci->dcbaa = malloc_phys ( len, xhci_align ( len ) ); if ( ! xhci->dcbaa ) { DBGC ( xhci, "XHCI %s could not allocate DCBAA\n", xhci->name ); rc = -ENOMEM; @@ -938,7 +938,7 @@ static int xhci_dcbaa_alloc ( struct xhci_device *xhci ) { return 0; err_writeq: - free_dma ( xhci->dcbaa, len ); + free_phys ( xhci->dcbaa, len ); err_alloc: return rc; } @@ -961,7 +961,7 @@ static void xhci_dcbaa_free ( struct xhci_device *xhci ) { /* Free DCBAA */ len = ( ( xhci->slots + 1 ) * sizeof ( xhci->dcbaa[0] ) ); - free_dma ( xhci->dcbaa, len ); + free_phys ( xhci->dcbaa, len ); } /****************************************************************************** @@ -1002,7 +1002,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { /* Allocate scratchpad array */ array_len = ( xhci->scratchpads * sizeof ( xhci->scratchpad_array[0] )); xhci->scratchpad_array = - malloc_dma ( array_len, xhci_align ( array_len ) ); + malloc_phys ( array_len, xhci_align ( array_len ) ); if ( ! xhci->scratchpad_array ) { DBGC ( xhci, "XHCI %s could not allocate scratchpad buffer " "array\n", xhci->name ); @@ -1027,7 +1027,7 @@ static int xhci_scratchpad_alloc ( struct xhci_device *xhci ) { ( virt_to_phys ( xhci->scratchpad_array ) + array_len ) ); return 0; - free_dma ( xhci->scratchpad_array, array_len ); + free_phys ( xhci->scratchpad_array, array_len ); err_alloc_array: ufree ( xhci->scratchpad ); err_alloc: @@ -1052,7 +1052,7 @@ static void xhci_scratchpad_free ( struct xhci_device *xhci ) { /* Free scratchpad array */ array_len = ( xhci->scratchpads * sizeof ( xhci->scratchpad_array[0] )); - free_dma ( xhci->scratchpad_array, array_len ); + free_phys ( xhci->scratchpad_array, array_len ); /* Free scratchpads */ ufree ( xhci->scratchpad ); @@ -1202,7 +1202,7 @@ static int xhci_ring_alloc ( struct xhci_device *xhci, } /* Allocate TRBs */ - ring->trb = malloc_dma ( ring->len, xhci_align ( ring->len ) ); + ring->trb = malloc_phys ( ring->len, xhci_align ( ring->len ) ); if ( ! ring->trb ) { rc = -ENOMEM; goto err_alloc_trb; @@ -1218,7 +1218,7 @@ static int xhci_ring_alloc ( struct xhci_device *xhci, return 0; - free_dma ( ring->trb, ring->len ); + free_phys ( ring->trb, ring->len ); err_alloc_trb: free ( ring->iobuf ); err_alloc_iobuf: @@ -1256,7 +1256,7 @@ static void xhci_ring_free ( struct xhci_trb_ring *ring ) { assert ( ring->iobuf[i] == NULL ); /* Free TRBs */ - free_dma ( ring->trb, ring->len ); + free_phys ( ring->trb, ring->len ); /* Free I/O buffers */ free ( ring->iobuf ); @@ -1469,7 +1469,7 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) { /* Allocate event ring */ count = ( 1 << XHCI_EVENT_TRBS_LOG2 ); len = ( count * sizeof ( event->trb[0] ) ); - event->trb = malloc_dma ( len, xhci_align ( len ) ); + event->trb = malloc_phys ( len, xhci_align ( len ) ); if ( ! event->trb ) { rc = -ENOMEM; goto err_alloc_trb; @@ -1477,8 +1477,8 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) { memset ( event->trb, 0, len ); /* Allocate event ring segment table */ - event->segment = malloc_dma ( sizeof ( event->segment[0] ), - xhci_align ( sizeof (event->segment[0]))); + event->segment = malloc_phys ( sizeof ( event->segment[0] ), + xhci_align ( sizeof(event->segment[0]))); if ( ! event->segment ) { rc = -ENOMEM; goto err_alloc_segment; @@ -1508,9 +1508,9 @@ static int xhci_event_alloc ( struct xhci_device *xhci ) { err_writeq_erstba: xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) ); err_writeq_erdp: - free_dma ( event->trb, len ); + free_phys ( event->trb, len ); err_alloc_segment: - free_dma ( event->segment, sizeof ( event->segment[0] ) ); + free_phys ( event->segment, sizeof ( event->segment[0] ) ); err_alloc_trb: return rc; } @@ -1531,12 +1531,12 @@ static void xhci_event_free ( struct xhci_device *xhci ) { xhci_writeq ( xhci, 0, xhci->run + XHCI_RUN_ERDP ( 0 ) ); /* Free event ring segment table */ - free_dma ( event->segment, sizeof ( event->segment[0] ) ); + free_phys ( event->segment, sizeof ( event->segment[0] ) ); /* Free event ring */ count = ( 1 << XHCI_EVENT_TRBS_LOG2 ); len = ( count * sizeof ( event->trb[0] ) ); - free_dma ( event->trb, len ); + free_phys ( event->trb, len ); } /** @@ -1948,7 +1948,7 @@ static int xhci_context ( struct xhci_device *xhci, struct xhci_slot *slot, /* Allocate an input context */ len = xhci_input_context_offset ( xhci, XHCI_CTX_END ); - input = malloc_dma ( len, xhci_align ( len ) ); + input = malloc_phys ( len, xhci_align ( len ) ); if ( ! input ) { rc = -ENOMEM; goto err_alloc; @@ -1969,7 +1969,7 @@ static int xhci_context ( struct xhci_device *xhci, struct xhci_slot *slot, goto err_command; err_command: - free_dma ( input, len ); + free_phys ( input, len ); err_alloc: return rc; } @@ -2693,7 +2693,7 @@ static int xhci_device_open ( struct usb_device *usb ) { /* Allocate a device context */ len = xhci_device_context_offset ( xhci, XHCI_CTX_END ); - slot->context = malloc_dma ( len, xhci_align ( len ) ); + slot->context = malloc_phys ( len, xhci_align ( len ) ); if ( ! slot->context ) { rc = -ENOMEM; goto err_alloc_context; @@ -2710,7 +2710,7 @@ static int xhci_device_open ( struct usb_device *usb ) { return 0; xhci->dcbaa[id] = 0; - free_dma ( slot->context, len ); + free_phys ( slot->context, len ); err_alloc_context: xhci->slot[id] = NULL; free ( slot ); @@ -2750,7 +2750,7 @@ static void xhci_device_close ( struct usb_device *usb ) { /* Free slot */ if ( slot->context ) { - free_dma ( slot->context, len ); + free_phys ( slot->context, len ); xhci->dcbaa[id] = 0; } xhci->slot[id] = NULL; diff --git a/src/include/ipxe/malloc.h b/src/include/ipxe/malloc.h index 1878978fd..180ca001d 100644 --- a/src/include/ipxe/malloc.h +++ b/src/include/ipxe/malloc.h @@ -14,7 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /* * Prototypes for the standard functions (malloc() et al) are in * stdlib.h. Include only if you need the - * non-standard functions, such as malloc_dma(). + * non-standard functions, such as malloc_phys(). * */ #include @@ -32,20 +32,18 @@ extern void mpopulate ( void *start, size_t len ); extern void mdumpfree ( void ); /** - * Allocate memory for DMA + * Allocate memory with specified physical alignment and offset * * @v size Requested size * @v align Physical alignment * @v offset Offset from physical alignment * @ret ptr Memory, or NULL * - * Allocates physically-aligned memory for DMA. - * * @c align must be a power of two. @c size may not be zero. */ -static inline void * __malloc malloc_dma_offset ( size_t size, - size_t phys_align, - size_t offset ) { +static inline void * __malloc malloc_phys_offset ( size_t size, + size_t phys_align, + size_t offset ) { void * ptr = alloc_memblock ( size, phys_align, offset ); if ( ptr && size ) VALGRIND_MALLOCLIKE_BLOCK ( ptr, size, 0, 0 ); @@ -53,32 +51,30 @@ static inline void * __malloc malloc_dma_offset ( size_t size, } /** - * Allocate memory for DMA + * Allocate memory with specified physical alignment * * @v size Requested size * @v align Physical alignment * @ret ptr Memory, or NULL * - * Allocates physically-aligned memory for DMA. - * * @c align must be a power of two. @c size may not be zero. */ -static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) { - return malloc_dma_offset ( size, phys_align, 0 ); +static inline void * __malloc malloc_phys ( size_t size, size_t phys_align ) { + return malloc_phys_offset ( size, phys_align, 0 ); } /** - * Free memory allocated with malloc_dma() + * Free memory allocated with malloc_phys() * - * @v ptr Memory allocated by malloc_dma(), or NULL - * @v size Size of memory, as passed to malloc_dma() + * @v ptr Memory allocated by malloc_phys(), or NULL + * @v size Size of memory, as passed to malloc_phys() * - * Memory allocated with malloc_dma() can only be freed with - * free_dma(); it cannot be freed with the standard free(). + * Memory allocated with malloc_phys() can only be freed with + * free_phys(); it cannot be freed with the standard free(). * * If @c ptr is NULL, no action is taken. */ -static inline void free_dma ( void *ptr, size_t size ) { +static inline void free_phys ( void *ptr, size_t size ) { VALGRIND_FREELIKE_BLOCK ( ptr, 0 ); free_memblock ( ptr, size ); } diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c index e50fe9951..86d2a08d7 100644 --- a/src/interface/hyperv/vmbus.c +++ b/src/interface/hyperv/vmbus.c @@ -434,7 +434,7 @@ int vmbus_open ( struct vmbus_device *vmdev, len = ( sizeof ( *vmdev->out ) + out_len + sizeof ( *vmdev->in ) + in_len ); assert ( ( len % PAGE_SIZE ) == 0 ); - ring = malloc_dma ( len, PAGE_SIZE ); + ring = malloc_phys ( len, PAGE_SIZE ); if ( ! ring ) { rc = -ENOMEM; goto err_alloc_ring; @@ -509,7 +509,7 @@ int vmbus_open ( struct vmbus_device *vmdev, err_post_message: vmbus_gpadl_teardown ( vmdev, vmdev->gpadl ); err_establish: - free_dma ( ring, len ); + free_phys ( ring, len ); err_alloc_ring: free ( packet ); err_alloc_packet: @@ -555,7 +555,7 @@ void vmbus_close ( struct vmbus_device *vmdev ) { /* Free ring buffer */ len = ( sizeof ( *vmdev->out ) + vmdev->out_len + sizeof ( *vmdev->in ) + vmdev->in_len ); - free_dma ( vmdev->out, len ); + free_phys ( vmdev->out, len ); vmdev->out = NULL; vmdev->in = NULL; -- cgit v1.2.3-55-g7522 From 79c0173d6df8580ea2e35fc173a5281e65d5321f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 13 Jan 2021 11:50:26 +0000 Subject: [build] Create util/genfsimg for building filesystem-based images Generalise util/geniso, util/gensdsk, and util/genefidsk to create a single script util/genfsimg that can be used to build either FAT filesystem images or ISO images. Extend the functionality to allow for building multi-architecture UEFI bootable ISO images and combined BIOS+UEFI images. For example: ./util/genfsimg -o combined.iso \ bin-x86_64-efi/ipxe.efi \ bin-arm64-efi/ipxe.efi \ bin/ipxe.lkrn would generate a hybrid image that could be used as a CDROM (or hard disk or USB key) on legacy BIOS, x86_64 UEFI, or ARM64 UEFI. Signed-off-by: Michael Brown --- src/Makefile.efi | 6 +- src/arch/x86/Makefile.pcbios | 43 +------- src/util/genefidsk | 60 ---------- src/util/genfsimg | 253 +++++++++++++++++++++++++++++++++++++++++++ src/util/geniso | 141 ------------------------ src/util/gensdsk | 65 ----------- 6 files changed, 260 insertions(+), 308 deletions(-) delete mode 100755 src/util/genefidsk create mode 100755 src/util/genfsimg delete mode 100755 src/util/geniso delete mode 100755 src/util/gensdsk (limited to 'src/arch') diff --git a/src/Makefile.efi b/src/Makefile.efi index 10f3fe74b..4b35381d3 100644 --- a/src/Makefile.efi +++ b/src/Makefile.efi @@ -49,6 +49,6 @@ $(BIN)/efidrv.cab : $(BIN)/alldrv.efis # $(ALL_drv.efi) is not yet defined $(QM)$(ECHO) " [CAB] $@" $(Q)$(LCAB) -n -q $(ALL_drv.efi) $@ -$(BIN)/%.usb : $(BIN)/%.efi - $(QM)$(ECHO) " [GENEFIDSK] $@" - $(Q)bash util/genefidsk -o $@ -b $(EFI_BOOT_FILE) $< +$(BIN)/%.iso $(BIN)/%.usb : $(BIN)/%.efi util/genfsimg + $(QM)$(ECHO) " [GENFSIMG] $@" + $(Q)util/genfsimg -o $@ $< diff --git a/src/arch/x86/Makefile.pcbios b/src/arch/x86/Makefile.pcbios index c44eefc1f..751d7d28c 100644 --- a/src/arch/x86/Makefile.pcbios +++ b/src/arch/x86/Makefile.pcbios @@ -57,46 +57,11 @@ LIST_NAME_mrom := ROMS LIST_NAME_pcirom := ROMS LIST_NAME_isarom := ROMS -# Locations of isolinux files -# -SYSLINUX_DIR_LIST := \ - /usr/lib/syslinux \ - /usr/lib/syslinux/bios \ - /usr/lib/syslinux/modules/bios \ - /usr/share/syslinux \ - /usr/share/syslinux/bios \ - /usr/share/syslinux/modules/bios \ - /usr/local/share/syslinux \ - /usr/local/share/syslinux/bios \ - /usr/local/share/syslinux/modules/bios \ - /usr/lib/ISOLINUX -ISOLINUX_BIN_LIST := \ - $(ISOLINUX_BIN) \ - $(patsubst %,%/isolinux.bin,$(SYSLINUX_DIR_LIST)) -LDLINUX_C32_LIST := \ - $(LDLINUX_C32) \ - $(patsubst %,%/ldlinux.c32,$(SYSLINUX_DIR_LIST)) -ISOLINUX_BIN = $(firstword $(wildcard $(ISOLINUX_BIN_LIST))) -LDLINUX_C32 = $(firstword $(wildcard $(LDLINUX_C32_LIST))) - -# rule to make a non-emulation ISO boot image +# ISO or FAT filesystem images NON_AUTO_MEDIA += iso -%iso: %lkrn util/geniso - $(QM)$(ECHO) " [GENISO] $@" - $(Q)ISOLINUX_BIN=$(ISOLINUX_BIN) LDLINUX_C32=$(LDLINUX_C32) \ - VERSION="$(VERSION)" bash util/geniso -o $@ $< - -# rule to make a floppy emulation ISO boot image -NON_AUTO_MEDIA += liso -%liso: %lkrn util/geniso - $(QM)$(ECHO) " [GENISO] $@" - $(Q)VERSION="$(VERSION)" bash util/geniso -l -o $@ $< - -# rule to make a syslinux floppy image (mountable, bootable) -NON_AUTO_MEDIA += sdsk -%sdsk: %lkrn util/gensdsk - $(QM)$(ECHO) " [GENSDSK] $@" - $(Q)bash util/gensdsk $@ $< +$(BIN)/%.iso $(BIN)/%.sdsk: $(BIN)/%.lkrn util/genfsimg + $(QM)$(ECHO) " [GENFSIMG] $@" + $(Q)util/genfsimg -o $@ $< # rule to write disk images to /dev/fd0 NON_AUTO_MEDIA += fd0 diff --git a/src/util/genefidsk b/src/util/genefidsk deleted file mode 100755 index 7064f99b6..000000000 --- a/src/util/genefidsk +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# -# Generate an EFI bootable disk image - -set -e - -function help() { - echo "Usage: ${0} [OPTIONS] " - echo - echo "where OPTIONS are:" - echo " -h Show this help" - echo " -b Specify boot file name (e.g. bootx64.efi)" - echo " -o FILE Save disk image to file" -} - -BOOT=bootx64.efi - -while getopts "hb:o:" opt; do - case ${opt} in - h) - help - exit 0 - ;; - b) - BOOT="${OPTARG}" - ;; - o) - OUT="${OPTARG}" - ;; - esac -done - -shift $((OPTIND - 1)) -IN=$1 - -if [ -z "${IN}" ]; then - echo "${0}: no input file given" >&2 - help - exit 1 -fi - -if [ -z "${OUT}" ]; then - echo "${0}: no output file given" >&2 - help - exit 1 -fi - -# Create sparse output file -rm -f ${OUT} -truncate -s 1440K ${OUT} - -# Format disk -mformat -i ${OUT} -f 1440 :: - -# Create directory structure -mmd -i ${OUT} ::efi -mmd -i ${OUT} ::efi/boot - -# Copy bootable image -mcopy -i ${OUT} ${IN} ::efi/boot/${BOOT} diff --git a/src/util/genfsimg b/src/util/genfsimg new file mode 100755 index 000000000..e49d4d7ed --- /dev/null +++ b/src/util/genfsimg @@ -0,0 +1,253 @@ +#!/bin/sh +# +# Generate a filesystem-based image + +set -e +set -u + +# Print usage message +# +help() { + echo "usage: ${0} [OPTIONS] foo.lkrn|foo.efi [bar.lkrn|bar.efi,...]" + echo + echo "where OPTIONS are:" + echo " -h show this help" + echo " -o FILE save image to file" + echo " -p PAD pad filesystem (in kB)" +} + +# Get hex word from binary file +# +get_word() { + local FILENAME + local OFFSET + + FILENAME="${1}" + OFFSET="${2}" + + od -j "${OFFSET}" -N 2 -A n -t x1 -- "${FILENAME}" | tr -d " " +} + +# Get appropriate EFI boot filename for CPU architecture +# +efi_boot_name() { + local FILENAME + local PESIG + local ARCH + + FILENAME="${1}" + + PESIG=$(get_word "${FILENAME}" 192) + if [ "${PESIG}" != "5045" ] ; then + echo "${FILENAME}: not an EFI executable" >&2 + exit 1 + fi + ARCH=$(get_word "${FILENAME}" 196) + case "${ARCH}" in + "4c01" ) + echo "BOOTIA32.EFI" + ;; + "6486" ) + echo "BOOTX64.EFI" + ;; + "c201" ) + echo "BOOTARM.EFI" + ;; + "64aa" ) + echo "BOOTAA64.EFI" + ;; + * ) + echo "${FILENAME}: unrecognised EFI architecture ${ARCH}" >&2 + exit 1 + esac +} + +# Copy syslinux file +# +copy_syslinux_file() { + local FILENAME + local DESTDIR + local SRCDIR + + FILENAME="${1}" + DESTDIR="${2}" + + for SRCDIR in \ + /usr/lib/syslinux \ + /usr/lib/syslinux/bios \ + /usr/lib/syslinux/modules/bios \ + /usr/share/syslinux \ + /usr/share/syslinux/bios \ + /usr/share/syslinux/modules/bios \ + /usr/local/share/syslinux \ + /usr/local/share/syslinux/bios \ + /usr/local/share/syslinux/modules/bios \ + /usr/lib/ISOLINUX \ + ; do + if [ -e "${SRCDIR}/${FILENAME}" ] ; then + cp "${SRCDIR}/${FILENAME}" "${DESTDIR}/" + break + fi + done +} + +# Parse command-line options +# +OUTFILE= +PAD=0 +while getopts "hlo:p:" OPTION ; do + case "${OPTION}" in + h) + help + exit 0 + ;; + o) + OUTFILE="${OPTARG}" + ;; + p) + PAD="${OPTARG}" + ;; + *) + help + exit 1 + ;; + esac +done +if [ -z "${OUTFILE}" ]; then + echo "${0}: no output file given" >&2 + help + exit 1 +fi +shift $(( OPTIND - 1 )) + +# Create temporary working directory +# +WORKDIR=$(mktemp -d "${OUTFILE}.XXXXXX") +ISODIR="${WORKDIR}/iso" +FATDIR="${WORKDIR}/fat" +mkdir -p "${ISODIR}" "${FATDIR}" + +# Configure output +# +case "${OUTFILE}" in + *.iso) + ISOIMG="${OUTFILE}" + FATIMG="${ISODIR}/esp.img" + BIOSDIR="${ISODIR}" + SYSLINUXCFG="${ISODIR}/isolinux.cfg" + ;; + *) + ISOIMG= + FATIMG="${OUTFILE}" + BIOSDIR="${FATDIR}" + SYSLINUXCFG="${FATDIR}/syslinux.cfg" + ;; +esac +ISOARGS= + +# Locate required tools +# +if [ -n "${ISOIMG}" ] ; then + MKISOFS= + for CMD in genisoimage mkisofs ; do + if ${CMD} --version >/dev/null 2>/dev/null ; then + MKISOFS="${CMD}" + break + fi + done + if [ -z "${MKISOFS}" ] ; then + echo "${0}: cannot find mkisofs or equivalent" >&2 + exit 1 + fi +fi + +# Copy files to temporary working directory +# +LKRN= +EFI= +for FILENAME ; do + case "${FILENAME}" in + *.lkrn) + DESTDIR="${BIOSDIR}" + DESTFILE=$(basename "${FILENAME}") + if [ -z "${LKRN}" ] ; then + echo "SAY iPXE boot image" > "${SYSLINUXCFG}" + echo "TIMEOUT 30" >> "${SYSLINUXCFG}" + echo "DEFAULT ${DESTFILE}" >> "${SYSLINUXCFG}" + fi + echo "LABEL ${DESTFILE}" >> "${SYSLINUXCFG}" + echo " KERNEL ${DESTFILE}" >> "${SYSLINUXCFG}" + LKRN=1 + ;; + *.efi) + DESTDIR="${FATDIR}/EFI/BOOT" + DESTFILE=$(efi_boot_name "${FILENAME}") + if [ -z "${EFI}" ] ; then + mkdir -p "${DESTDIR}" + fi + EFI=1 + ;; + *) + echo "${0}: unrecognised input filename ${FILENAME}" >&2 + help + exit 1 + ;; + esac + if [ -e "${DESTDIR}/${DESTFILE}" ] ; then + echo "${0}: duplicate ${DESTFILE} from ${FILENAME}" >&2 + exit 1 + fi + cp "${FILENAME}" "${DESTDIR}/${DESTFILE}" +done + +# Configure ISO image, if applicable +# +# Note that the BIOS boot files are required even for an EFI-only ISO, +# since isohybrid will refuse to work without them. +# +if [ -n "${ISOIMG}" ] ; then + copy_syslinux_file "isolinux.bin" "${ISODIR}" + copy_syslinux_file "ldlinux.c32" "${ISODIR}" || true + ISOARGS="${ISOARGS} -no-emul-boot -eltorito-boot isolinux.bin" + ISOARGS="${ISOARGS} -boot-load-size 4 -boot-info-table" + if [ -n "${EFI}" ] ; then + ISOARGS="${ISOARGS} -eltorito-alt-boot -no-emul-boot -efi-boot esp.img" + else + FATIMG= + fi +fi + +# Create FAT filesystem image, if applicable +# +if [ -n "${FATIMG}" ] ; then + FATSIZE=$(du -s -k ${FATDIR} | cut -f1) + FATSIZE=$(( FATSIZE + PAD + 256 )) + touch "${FATIMG}" + if [ "${FATSIZE}" -le "1440" ] ; then + truncate -s 1440K "${FATIMG}" + mformat -f 1440 -i "${FATIMG}" :: + else + truncate -s "${FATSIZE}K" "${FATIMG}" + mformat -i "${FATIMG}" :: + fi + mcopy -i "${FATIMG}" -s "${FATDIR}"/* :: + if [ "${BIOSDIR}" = "${FATDIR}" ] ; then + syslinux "${FATIMG}" + fi +fi + +# Create ISO filesystem image, if applicable +# +if [ -n "${ISOIMG}" ] ; then + "${MKISOFS}" -quiet -volid "iPXE" -preparer "iPXE build system" \ + -appid "iPXE - Open Source Network Boot Firmware" \ + -publisher "ipxe.org" -sysid "iPXE" -J -R -o "${ISOIMG}" \ + ${ISOARGS} "${ISODIR}" + if isohybrid --version >/dev/null 2>/dev/null ; then + isohybrid "${ISOIMG}" + fi +fi + +# Clean up temporary working directory +# +rm -rf "${WORKDIR}" diff --git a/src/util/geniso b/src/util/geniso deleted file mode 100755 index ff090d4a0..000000000 --- a/src/util/geniso +++ /dev/null @@ -1,141 +0,0 @@ -#!/bin/bash -# -# Generate a isolinux ISO boot image - -function help() { - echo "usage: ${0} [OPTIONS] foo.lkrn [bar.lkrn,...]" - echo - echo "where OPTIONS are:" - echo " -h show this help" - echo " -l build legacy image with floppy emulation" - echo " -o FILE save iso image to file" -} - -LEGACY=0 -FIRST="" - -while getopts "hlo:" opt; do - case ${opt} in - h) - help - exit 0 - ;; - l) - LEGACY=1 - ;; - o) - OUT="${OPTARG}" - ;; - esac -done - -shift $((OPTIND - 1)) - -if [ -z "${OUT}" ]; then - echo "${0}: no output file given" >&2 - help - exit 1 -fi - -# There should either be mkisofs or the compatible genisoimage program -for command in genisoimage mkisofs; do - if ${command} --version >/dev/null 2>/dev/null; then - mkisofs=(${command}) - break - fi -done - -if [ -z "${mkisofs}" ]; then - echo "${0}: mkisofs or genisoimage not found, please install or set PATH" >&2 - exit 1 -fi - -dir=$(mktemp -d bin/iso.dir.XXXXXX) -cfg=${dir}/isolinux.cfg - -mkisofs+=(-quiet -l -volid "iPXE" -preparer "iPXE build system" - -appid "iPXE ${VERSION} - Open Source Network Boot Firmware" - -publisher "http://ipxe.org/" -c boot.cat) - -# generate the config -cat > ${cfg} <&2 - continue - fi - b=$(basename ${f}) - g=${b%.lkrn} - g=${g//[^a-z0-9]} - g=${g:0:8}.krn - case "${FIRST}" in - "") - echo "DEFAULT ${b}" - FIRST=${g} - ;; - esac - echo "LABEL ${b}" - echo " KERNEL ${g}" - cp ${f} ${dir}/${g} -done >> ${cfg} - -case "${LEGACY}" in - 1) - # check for mtools - case "$(mtools -V)" in - Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*) - ;; - *) - echo "Mtools version 3.9.9 or later is required" >&2 - exit 1 - ;; - esac - - # generate floppy image - img=${dir}/boot.img - mformat -f 1440 -C -i ${img} :: - - # copy lkrn file to floppy image - for f in ${dir}/*.krn; do - mcopy -m -i ${img} ${f} ::$(basename ${g}) - rm -f ${f} - done - - # copy config file to floppy image - mcopy -i ${img} ${cfg} ::syslinux.cfg - rm -f ${cfg} - - # write syslinux bootloader to floppy image - if ! syslinux ${img}; then - echo "${0}: failed writing syslinux to floppy image ${img}" >&2 - exit 1 - fi - - # generate the iso image - "${mkisofs[@]}" -b boot.img -output ${OUT} ${dir} - ;; - 0) - # copy isolinux bootloader - cp ${ISOLINUX_BIN} ${dir} - - # syslinux 6.x needs a file called ldlinux.c32 - if [ -n "${LDLINUX_C32}" -a -s "${LDLINUX_C32}" ]; then - cp ${LDLINUX_C32} ${dir} - fi - - # generate the iso image - "${mkisofs[@]}" -b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -output ${OUT} ${dir} - - # isohybrid will be used if available - if isohybrid --version >/dev/null 2>/dev/null; then - isohybrid ${OUT} >/dev/null - fi - ;; -esac - -# clean up temporary dir -rm -fr ${dir} diff --git a/src/util/gensdsk b/src/util/gensdsk deleted file mode 100755 index fe302d587..000000000 --- a/src/util/gensdsk +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# -# Generate a syslinux floppy that loads a iPXE image -# -# gensdsk foo.sdsk foo.lkrn -# -# the floppy image is the first argument -# followed by list of .lkrn images -# - -case $# in -0|1) - echo Usage: $0 foo.sdsk foo.lkrn ... - exit 1 - ;; -esac -case "`mtools -V`" in -Mtools\ version\ 3.9.9*|Mtools\ version\ 3.9.1[0-9]*|[mM]tools\ *\ [4-9].*) - ;; -*) - echo Mtools version 3.9.9 or later is required - exit 1 - ;; -esac -img=$1 -shift -dir=`mktemp -d bin/sdsk.dir.XXXXXX` - -mformat -f 1440 -C -i $img :: -cfg=$dir/syslinux.cfg -cat > $cfg <&2 - continue - fi - # shorten name for 8.3 filesystem - b=$(basename $f) - g=${b%.lkrn} - g=${g//[^a-z0-9]} - g=${g:0:8}.krn - case "$first" in - "") - echo DEFAULT $b - ;; - esac - first=$g - echo LABEL $b - echo "" KERNEL $g - mcopy -m -i $img $f ::$g -done >> $cfg -mcopy -i $img $cfg ::syslinux.cfg -if ! syslinux $img -then - exit 1 -fi - -rm -fr $dir -- cgit v1.2.3-55-g7522 From 99ac69b8a9a48207913e98ac6b357c029b0eef81 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Jan 2021 18:03:16 +0000 Subject: [image] Provide image_set_data() Extract part of the logic in initrd_init() to a standalone function image_set_data(). Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 21 +++++++++------------ src/core/image.c | 24 ++++++++++++++++++++++++ src/include/ipxe/image.h | 1 + 3 files changed, 34 insertions(+), 12 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index f96b23af4..4de3bfafe 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -38,7 +38,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include #include /** Command line physical address @@ -202,23 +201,21 @@ static int initrd_init ( void ) { rc = -ENOMEM; goto err_alloc_image; } + + /* Set image name */ if ( ( rc = image_set_name ( image, "" ) ) != 0 ) { DBGC ( colour, "RUNTIME could not set image name: %s\n", strerror ( rc ) ); goto err_set_name; } - /* Allocate and copy initrd content */ - image->data = umalloc ( initrd_len ); - if ( ! image->data ) { - DBGC ( colour, "RUNTIME could not allocate %d bytes for " - "initrd\n", initrd_len ); - rc = -ENOMEM; - goto err_umalloc; + /* Set image content */ + if ( ( rc = image_set_data ( image, phys_to_user ( initrd_phys ), + initrd_len ) ) != 0 ) { + DBGC ( colour, "RUNTIME could not set image data: %s\n", + strerror ( rc ) ); + goto err_set_data; } - image->len = initrd_len; - memcpy_user ( image->data, 0, phys_to_user ( initrd_phys ), 0, - initrd_len ); /* Mark initrd as consumed */ initrd_phys = 0; @@ -236,7 +233,7 @@ static int initrd_init ( void ) { return 0; err_register_image: - err_umalloc: + err_set_data: err_set_name: image_put ( image ); err_alloc_image: diff --git a/src/core/image.c b/src/core/image.c index 078ce1bb9..54b998025 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -175,6 +175,30 @@ int image_set_cmdline ( struct image *image, const char *cmdline ) { return 0; } +/** + * Set image data + * + * @v image Image + * @v data Image data + * @v len Length of image data + * @ret rc Return status code + */ +int image_set_data ( struct image *image, userptr_t data, size_t len ) { + userptr_t new; + + /* (Re)allocate image data */ + new = urealloc ( image->data, len ); + if ( ! new ) + return -ENOMEM; + image->data = new; + + /* Copy in new image data */ + memcpy_user ( image->data, 0, data, 0, len ); + image->len = len; + + return 0; +} + /** * Determine image type * diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index 2e7eb4cee..4c3877607 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -175,6 +175,7 @@ extern struct image * alloc_image ( struct uri *uri ); extern int image_set_uri ( struct image *image, struct uri *uri ); extern int image_set_name ( struct image *image, const char *name ); extern int image_set_cmdline ( struct image *image, const char *cmdline ); +extern int image_set_data ( struct image *image, userptr_t data, size_t len ); extern int register_image ( struct image *image ); extern void unregister_image ( struct image *image ); struct image * find_image ( const char *name ); -- cgit v1.2.3-55-g7522 From 989a7a8032db02eb0524bd78a674d3b087dea3a6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 25 Jan 2021 16:18:28 +0000 Subject: [image] Provide image_memory() Consolidate the remaining logic common to initrd_init() and imgmem() into a shared image_memory() function. Signed-off-by: Michael Brown --- src/arch/x86/core/runtime.c | 44 +++++----------------------------------- src/core/image.c | 44 ++++++++++++++++++++++++++++++++++++++++ src/hci/commands/image_mem_cmd.c | 4 +--- src/include/ipxe/image.h | 2 ++ src/include/usr/imgmgmt.h | 3 +-- src/usr/imgmgmt.c | 41 ++++++++----------------------------- 6 files changed, 62 insertions(+), 76 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 4de3bfafe..02072b5bf 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -179,7 +179,6 @@ static int cmdline_init ( void ) { */ static int initrd_init ( void ) { struct image *image; - int rc; /* Do nothing if no initrd was specified */ if ( ! initrd_phys ) { @@ -193,51 +192,18 @@ static int initrd_init ( void ) { DBGC ( colour, "RUNTIME found initrd at [%x,%x)\n", initrd_phys, ( initrd_phys + initrd_len ) ); - /* Allocate image */ - image = alloc_image ( NULL ); + /* Create initrd image */ + image = image_memory ( "", phys_to_user ( initrd_phys ), + initrd_len ); if ( ! image ) { - DBGC ( colour, "RUNTIME could not allocate image for " - "initrd\n" ); - rc = -ENOMEM; - goto err_alloc_image; - } - - /* Set image name */ - if ( ( rc = image_set_name ( image, "" ) ) != 0 ) { - DBGC ( colour, "RUNTIME could not set image name: %s\n", - strerror ( rc ) ); - goto err_set_name; - } - - /* Set image content */ - if ( ( rc = image_set_data ( image, phys_to_user ( initrd_phys ), - initrd_len ) ) != 0 ) { - DBGC ( colour, "RUNTIME could not set image data: %s\n", - strerror ( rc ) ); - goto err_set_data; + DBGC ( colour, "RUNTIME could not create initrd image\n" ); + return -ENOMEM; } /* Mark initrd as consumed */ initrd_phys = 0; - /* Register image */ - if ( ( rc = register_image ( image ) ) != 0 ) { - DBGC ( colour, "RUNTIME could not register initrd: %s\n", - strerror ( rc ) ); - goto err_register_image; - } - - /* Drop our reference to the image */ - image_put ( image ); - return 0; - - err_register_image: - err_set_data: - err_set_name: - image_put ( image ); - err_alloc_image: - return rc; } /** diff --git a/src/core/image.c b/src/core/image.c index 54b998025..9fe77c54c 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -505,3 +505,47 @@ int image_set_trust ( int require_trusted, int permanent ) { return 0; } + +/** + * Create registered image from block of memory + * + * @v name Name + * @v data Image data + * @v len Length + * @ret image Image, or NULL on error + */ +struct image * image_memory ( const char *name, userptr_t data, size_t len ) { + struct image *image; + int rc; + + /* Allocate image */ + image = alloc_image ( NULL ); + if ( ! image ) { + rc = -ENOMEM; + goto err_alloc_image; + } + + /* Set name */ + if ( ( rc = image_set_name ( image, name ) ) != 0 ) + goto err_set_name; + + /* Set data */ + if ( ( rc = image_set_data ( image, data, len ) ) != 0 ) + goto err_set_data; + + /* Register image */ + if ( ( rc = register_image ( image ) ) != 0 ) + goto err_register; + + /* Drop local reference to image */ + image_put ( image ); + + return image; + + err_register: + err_set_data: + err_set_name: + image_put ( image ); + err_alloc_image: + return NULL; +} diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index 61d50534d..c8bfab1ad 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -60,7 +60,6 @@ static struct command_descriptor imgmem_cmd = */ static int imgmem_exec ( int argc, char **argv ) { struct imgmem_options opts; - struct image *image; unsigned int data; unsigned int len; int rc; @@ -82,8 +81,7 @@ static int imgmem_exec ( int argc, char **argv ) { return rc; /* Create image */ - if ( ( rc = imgmem ( phys_to_user ( data ), len, opts.name, - &image ) ) != 0 ) + if ( ( rc = imgmem ( opts.name, phys_to_user ( data ), len ) ) != 0 ) return rc; return 0; diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index 4c3877607..4fd270081 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -184,6 +184,8 @@ extern int image_replace ( struct image *replacement ); extern int image_select ( struct image *image ); extern struct image * image_find_selected ( void ); extern int image_set_trust ( int require_trusted, int permanent ); +extern struct image * image_memory ( const char *name, userptr_t data, + size_t len ); extern int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ); extern int image_asn1 ( struct image *image, size_t offset, struct asn1_cursor **cursor ); diff --git a/src/include/usr/imgmgmt.h b/src/include/usr/imgmgmt.h index c59cf1a0b..14fb7cbc6 100644 --- a/src/include/usr/imgmgmt.h +++ b/src/include/usr/imgmgmt.h @@ -18,7 +18,6 @@ extern int imgdownload_string ( const char *uri_string, unsigned long timeout, extern int imgacquire ( const char *name, unsigned long timeout, struct image **image ); extern void imgstat ( struct image *image ); -extern int imgmem ( userptr_t data, size_t len, const char *name, - struct image **image ); +extern int imgmem ( const char *name, userptr_t data, size_t len ); #endif /* _USR_IMGMGMT_H */ diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c index bf4c745ea..f8d149153 100644 --- a/src/usr/imgmgmt.c +++ b/src/usr/imgmgmt.c @@ -173,43 +173,20 @@ void imgstat ( struct image *image ) { /** * Create image from block of memory * + * @v name Name * @v data Image data * @v len Length - * @v name Name - * @v image Image to fill in * @ret rc Return status code */ -int imgmem ( userptr_t data, size_t len, const char *name, - struct image **image ) { - int rc; - - /* Allocate image */ - *image = alloc_image ( NULL ); - if ( ! *image ) { - rc = -ENOMEM; - goto err_alloc_image; - } - - /* Set name */ - if ( ( rc = image_set_name ( *image, name ) ) != 0 ) - goto err_set_name; +int imgmem ( const char *name, userptr_t data, size_t len ) { + struct image *image; - /* Set data */ - if ( ( rc = image_set_data ( *image, data, len ) ) != 0 ) { - printf ( "Could not set image data: %s\n", strerror ( rc ) ); - goto err_set_data; - } - - /* Register image */ - if ( ( rc = register_image ( *image ) ) != 0 ) { - printf ( "Could not register image: %s\n", strerror ( rc ) ); - goto err_register_image; + /* Create image */ + image = image_memory ( name, data, len ); + if ( ! image ) { + printf ( "Could not create image\n" ); + return -ENOMEM; } - err_register_image: - err_set_data: - err_set_name: - image_put ( *image ); - err_alloc_image: - return rc; + return 0; } -- cgit v1.2.3-55-g7522 From fe52f8e8bef150c50e88c78ccc1f2b75a8d0f192 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 30 Jan 2021 01:35:27 +0000 Subject: [build] Avoid modifying load addresses when stripping .zinfo section Some versions of objcopy will spuriously complain when asked to extract the .zinfo section since doing so will nominally alter the load addresses of the (non-loadable) .bss.* sections. Avoid these warnings by placing the .zinfo section at the very end of the load memory address space. Allocate non-overlapping load memory addresses for the (non-loadable) .bss.* sections, in the hope of avoiding spurious warnings about overlapping load addresses. Signed-off-by: Michael Brown --- src/arch/x86/scripts/pcbios.lds | 49 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/scripts/pcbios.lds b/src/arch/x86/scripts/pcbios.lds index c9a91c02b..62442138f 100644 --- a/src/arch/x86/scripts/pcbios.lds +++ b/src/arch/x86/scripts/pcbios.lds @@ -58,11 +58,12 @@ SECTIONS { *(SORT(.pci_devlist.*)) *(.prefix.*) _mprefix = .; - } .bss.prefix (NOLOAD) : AT ( _end_lma ) { + } .bss.prefix (NOLOAD) : AT ( _bss_prefix_lma ) { _eprefix = .; } _prefix_filesz = ABSOLUTE ( _mprefix ) - ABSOLUTE ( _prefix ); _prefix_memsz = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _prefix ); + _prefix_padsz = ABSOLUTE ( _eprefix ) - ABSOLUTE ( _mprefix ); /* * The 16-bit (real-mode) code section @@ -82,7 +83,7 @@ SECTIONS { *(.text16) *(.text16.*) _mtext16 = .; - } .bss.text16 (NOLOAD) : AT ( _end_lma ) { + } .bss.text16 (NOLOAD) : AT ( _bss_text16_lma ) { _etext16 = .; } _text16_early_filesz = ABSOLUTE ( _etext16_early ) - ABSOLUTE ( _text16 ); @@ -90,6 +91,7 @@ SECTIONS { _text16_late_filesz = ABSOLUTE ( _mtext16 ) - ABSOLUTE ( _text16_late ); _text16_late_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16_late ); _text16_memsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _text16 ); + _text16_padsz = ABSOLUTE ( _etext16 ) - ABSOLUTE ( _mtext16 ); /* * The 16-bit (real-mode) data section @@ -104,7 +106,7 @@ SECTIONS { *(.data16) *(.data16.*) _mdata16 = .; - } .bss.data16 (NOLOAD) : AT ( _end_lma ) { + } .bss.data16 (NOLOAD) : AT ( _bss_data16_lma ) { *(.bss16) *(.bss16.*) *(.stack16) @@ -114,6 +116,7 @@ SECTIONS { } _data16_filesz = ABSOLUTE ( _mdata16 ) - ABSOLUTE ( _data16 ); _data16_memsz = ABSOLUTE ( _edata16 ) - ABSOLUTE ( _data16 ); + _data16_padsz = ABSOLUTE ( _edata16 ) - ABSOLUTE ( _mdata16 ); /* * The 32-bit sections @@ -135,7 +138,7 @@ SECTIONS { KEEP(*(.provided)) KEEP(*(.provided.*)) _mtextdata = .; - } .bss.textdata (NOLOAD) : AT ( _end_lma ) { + } .bss.textdata (NOLOAD) : AT ( _bss_textdata_lma ) { *(.bss) *(.bss.*) *(COMMON) @@ -157,6 +160,7 @@ SECTIONS { } _textdata_filesz = ABSOLUTE ( _mtextdata ) - ABSOLUTE ( _textdata ); _textdata_memsz = ABSOLUTE ( _etextdata ) - ABSOLUTE ( _textdata ); + _textdata_padsz = ABSOLUTE ( _etextdata ) - ABSOLUTE ( _mtextdata ); /* * Payload prefix @@ -169,11 +173,12 @@ SECTIONS { KEEP(*(.pprefix)) KEEP(*(.pprefix.*)) _mpprefix = .; - } .bss.pprefix (NOLOAD) : AT ( _end_lma ) { + } .bss.pprefix (NOLOAD) : AT ( _bss_pprefix_lma ) { _epprefix = .; } _pprefix_filesz = ABSOLUTE ( _mpprefix ) - ABSOLUTE ( _pprefix ); _pprefix_memsz = ABSOLUTE ( _epprefix ) - ABSOLUTE ( _pprefix ); + _pprefix_padsz = ABSOLUTE ( _epprefix ) - ABSOLUTE ( _mpprefix ); /* * Compressor information block @@ -185,11 +190,12 @@ SECTIONS { KEEP(*(.zinfo)) KEEP(*(.zinfo.*)) _mzinfo = .; - } .bss.zinfo (NOLOAD) : AT ( _end_lma ) { + } .bss.zinfo (NOLOAD) : AT ( _bss_zinfo_lma ) { _ezinfo = .; } _zinfo_filesz = ABSOLUTE ( _mzinfo ) - ABSOLUTE ( _zinfo ); _zinfo_memsz = ABSOLUTE ( _ezinfo ) - ABSOLUTE ( _zinfo ); + _zinfo_padsz = ABSOLUTE ( _ezinfo ) - ABSOLUTE ( _mzinfo ); /* * Weak symbols that need zero values if not otherwise defined @@ -260,7 +266,36 @@ SECTIONS { _textdata_lma = .; . += _textdata_filesz; - _filesz = .; /* Do not include zinfo block in file size */ + _filesz = .; /* Do not include .bss.* or .zinfo in file size */ + + /* + * Dummy load addresses for .bss.* and .zinfo sections + * + */ + + . = ALIGN ( _max_align ); + _bss_prefix_lma = .; + . += _prefix_padsz; + + . = ALIGN ( _max_align ); + _bss_text16_lma = .; + . += _text16_padsz; + + . = ALIGN ( _max_align ); + _bss_data16_lma = .; + . += _data16_padsz; + + . = ALIGN ( _max_align ); + _bss_textdata_lma = .; + . += _textdata_padsz; + + . = ALIGN ( _max_align ); + _bss_pprefix_lma = .; + . += _pprefix_padsz; + + . = ALIGN ( _max_align ); + _bss_zinfo_lma = .; + . += _zinfo_padsz; . = ALIGN ( _max_align ); _zinfo_lma = .; -- cgit v1.2.3-55-g7522 From 82dbca4938704d543d8b7b215708a416b51dbf9d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 30 Jan 2021 11:48:47 +0000 Subject: [build] Allow BIOS linker script to be used with FreeBSD linker Add a few more ABSOLUTE() expressions to convince the FreeBSD linker that already-absolute symbols are, in fact, absolute. Signed-off-by: Michael Brown --- src/arch/x86/scripts/pcbios.lds | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/scripts/pcbios.lds b/src/arch/x86/scripts/pcbios.lds index 62442138f..de59adca9 100644 --- a/src/arch/x86/scripts/pcbios.lds +++ b/src/arch/x86/scripts/pcbios.lds @@ -241,30 +241,30 @@ SECTIONS { . = ALIGN ( _max_align ); _prefix_lma = .; - . += _prefix_filesz; + . += ABSOLUTE ( _prefix_filesz ); . = ALIGN ( _max_align ); _text16_early_lma = .; - . += _text16_early_filesz; + . += ABSOLUTE ( _text16_early_filesz ); . = ALIGN ( _max_align ); . = ALIGN ( _payload_align ); _pprefix_lma = .; - . += _pprefix_filesz; + . += ABSOLUTE ( _pprefix_filesz ); . = ALIGN ( _max_align ); _payload_lma = .; _pprefix_skip = ABSOLUTE ( _payload_lma ) - ABSOLUTE ( _pprefix_lma ); _text16_late_lma = .; - . += _text16_late_filesz; + . += ABSOLUTE ( _text16_late_filesz ); . = ALIGN ( _max_align ); _data16_lma = .; - . += _data16_filesz; + . += ABSOLUTE ( _data16_filesz ); . = ALIGN ( _max_align ); _textdata_lma = .; - . += _textdata_filesz; + . += ABSOLUTE ( _textdata_filesz ); _filesz = .; /* Do not include .bss.* or .zinfo in file size */ @@ -275,31 +275,31 @@ SECTIONS { . = ALIGN ( _max_align ); _bss_prefix_lma = .; - . += _prefix_padsz; + . += ABSOLUTE ( _prefix_padsz ); . = ALIGN ( _max_align ); _bss_text16_lma = .; - . += _text16_padsz; + . += ABSOLUTE ( _text16_padsz ); . = ALIGN ( _max_align ); _bss_data16_lma = .; - . += _data16_padsz; + . += ABSOLUTE ( _data16_padsz ); . = ALIGN ( _max_align ); _bss_textdata_lma = .; - . += _textdata_padsz; + . += ABSOLUTE ( _textdata_padsz ); . = ALIGN ( _max_align ); _bss_pprefix_lma = .; - . += _pprefix_padsz; + . += ABSOLUTE ( _pprefix_padsz ); . = ALIGN ( _max_align ); _bss_zinfo_lma = .; - . += _zinfo_padsz; + . += ABSOLUTE ( _zinfo_padsz ); . = ALIGN ( _max_align ); _zinfo_lma = .; - . += _zinfo_filesz; + . += ABSOLUTE ( _zinfo_filesz ); . = ALIGN ( _max_align ); _end_lma = .; -- cgit v1.2.3-55-g7522 From e80299c56b86d907b1ea226d8214b22da39e0cb6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 4 Feb 2021 02:05:28 +0000 Subject: [build] Work around -fPIE patched versions of gcc on all architectures Several distributions include versions of gcc that are patched to create position-independent executables by default. These have caused multiple problems over the years: see e.g. commits fe61f6d ("[build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie"), 5de1346 ("[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds"), 7c395b0 ("[build] Use -no-pie on newer versions of gcc"), and decee20 ("[build] Disable position-independent code for ARM64 EFI builds"). The build system currently attempts to work around these mildly broken patched versions of gcc for the i386 and arm64 architectures. This misses the relatively obscure bin-x86_64-pcbios build platform, which turns out to also require the same workaround. Attempt to preempt the next such required workaround by moving the existing i386 version to apply to all platforms and all architectures, unless -fpie has been requested explicitly by another Makefile (as is done by arch/x86_64/Makefile.efi). Signed-off-by: Michael Brown --- src/Makefile.housekeeping | 27 +++++++++++++++++++++++++++ src/arch/arm64/Makefile.efi | 4 ---- src/arch/i386/Makefile | 16 ---------------- 3 files changed, 27 insertions(+), 20 deletions(-) (limited to 'src/arch') diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index f379ff4ef..b3fa04527 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -374,6 +374,33 @@ INCDIRS += arch/$(ARCH)/include INCDIRS += arch/$(ARCH)/include/$(PLATFORM) endif +############################################################################### +# +# Especially ugly workarounds + +# Some widespread patched versions of gcc include -fPIE -Wl,-pie by +# default. Note that gcc will exit *successfully* if it fails to +# recognise an option that starts with "no", so we have to test for +# output on stderr instead of checking the exit status. +# +# Current versions of gcc require -no-pie; older versions require +# -nopie. We therefore test for both. +# +# This workaround must be determined only after the +# architecture-specific Makefile has been included, since some +# platforms (e.g. bin-x86_64-efi) will explicitly require the use of +# -fpie. +# +ifeq ($(filter -fpie,$(CFLAGS)),) +ifeq ($(CCTYPE),gcc) +PIE_TEST = [ -z "`$(CC) -fno-PIE -no-pie -x c -c /dev/null -o /dev/null 2>&1`" ] +PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -no-pie') +PIE_TEST2 = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ] +PIE_FLAGS2 := $(shell $(PIE_TEST2) && $(ECHO) '-fno-PIE -nopie') +WORKAROUND_CFLAGS += $(PIE_FLAGS) $(PIE_FLAGS2) +endif +endif + ############################################################################### # # Source file handling diff --git a/src/arch/arm64/Makefile.efi b/src/arch/arm64/Makefile.efi index eb04c0e2f..998a64d03 100644 --- a/src/arch/arm64/Makefile.efi +++ b/src/arch/arm64/Makefile.efi @@ -1,9 +1,5 @@ # -*- makefile -*- : Force emacs to use Makefile mode -# Avoid untranslatable relocations -# -CFLAGS += -fno-pic - # Specify EFI image builder # ELF2EFI = $(ELF2EFI64) diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile index b7c2792d9..e59f05fc8 100644 --- a/src/arch/i386/Makefile +++ b/src/arch/i386/Makefile @@ -69,22 +69,6 @@ CFLAGS += -fshort-wchar # CFLAGS += -Ui386 -# Some widespread patched versions of gcc include -fPIE -Wl,-pie by -# default. Note that gcc will exit *successfully* if it fails to -# recognise an option that starts with "no", so we have to test for -# output on stderr instead of checking the exit status. -# -# Current versions of gcc require -no-pie; older versions require -# -nopie. We therefore test for both. -# -ifeq ($(CCTYPE),gcc) -PIE_TEST = [ -z "`$(CC) -fno-PIE -no-pie -x c -c /dev/null -o /dev/null 2>&1`" ] -PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -no-pie') -PIE_TEST2 = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ] -PIE_FLAGS2 := $(shell $(PIE_TEST2) && $(ECHO) '-fno-PIE -nopie') -WORKAROUND_CFLAGS += $(PIE_FLAGS) $(PIE_FLAGS2) -endif - # i386-specific directories containing source files # SRCDIRS += arch/i386/core -- cgit v1.2.3-55-g7522 From c160fb259378e5f08190db39b5bf4f697f892e7c Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 12 Feb 2021 23:22:54 +0000 Subject: [build] Use .balign directive instead of .align The semantics of the assembler's .align directive vary by CPU architecture. For the ARM builds, it specifies a power of two rather than a number of bytes. This currently leads to the .einfo entries (which do not appear in the final binary) having an alignment of 256 bytes for the ARM builds. Fix by switching to the GNU-specific directive .balign, which is consistent across architectures Signed-off-by: Michael Brown --- src/arch/x86/core/stack.S | 2 +- src/arch/x86/core/stack16.S | 2 +- src/arch/x86/interface/pcbios/e820mangler.S | 2 +- src/arch/x86/interface/pxe/pxe_entry.S | 4 ++-- src/arch/x86/prefix/exeprefix.S | 2 +- src/arch/x86/prefix/mromprefix.S | 2 +- src/arch/x86/prefix/romprefix.S | 8 ++++---- src/arch/x86/prefix/unlzma.S | 2 +- src/arch/x86/transitions/liba20.S | 2 +- src/arch/x86/transitions/librm.S | 6 +++--- src/include/errno.h | 4 ++-- 11 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/core/stack.S b/src/arch/x86/core/stack.S index 995c397ca..baa19ff84 100644 --- a/src/arch/x86/core/stack.S +++ b/src/arch/x86/core/stack.S @@ -13,7 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) **************************************************************************** */ .section ".stack", "aw", @nobits - .align 8 + .balign 8 .globl _stack _stack: .space STACK_SIZE diff --git a/src/arch/x86/core/stack16.S b/src/arch/x86/core/stack16.S index 4bc6f081a..ad67e4f2d 100644 --- a/src/arch/x86/core/stack16.S +++ b/src/arch/x86/core/stack16.S @@ -7,7 +7,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) **************************************************************************** */ .section ".stack16", "aw", @nobits - .align 8 + .balign 8 .globl _stack16 _stack16: .space 4096 diff --git a/src/arch/x86/interface/pcbios/e820mangler.S b/src/arch/x86/interface/pcbios/e820mangler.S index d5d97b482..296a6488b 100644 --- a/src/arch/x86/interface/pcbios/e820mangler.S +++ b/src/arch/x86/interface/pcbios/e820mangler.S @@ -67,7 +67,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) **************************************************************************** */ .section ".data16", "aw", @progbits - .align 16 + .balign 16 .globl hidemem_base .globl hidemem_umalloc .globl hidemem_textdata diff --git a/src/arch/x86/interface/pxe/pxe_entry.S b/src/arch/x86/interface/pxe/pxe_entry.S index 663aa842e..3a5a100e3 100644 --- a/src/arch/x86/interface/pxe/pxe_entry.S +++ b/src/arch/x86/interface/pxe/pxe_entry.S @@ -34,7 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) */ .section ".text16.data", "aw", @progbits .globl ppxe - .align 16 + .balign 16 ppxe: .ascii "!PXE" /* Signature */ .byte pxe_length /* StructLength */ @@ -72,7 +72,7 @@ undiheader: */ .section ".text16.data", "aw", @progbits .globl pxenv - .align 16 + .balign 16 pxenv: .ascii "PXENV+" /* Signature */ .word 0x0201 /* Version */ diff --git a/src/arch/x86/prefix/exeprefix.S b/src/arch/x86/prefix/exeprefix.S index c351456e2..0eab8c12a 100644 --- a/src/arch/x86/prefix/exeprefix.S +++ b/src/arch/x86/prefix/exeprefix.S @@ -110,7 +110,7 @@ overlay: /* Overlay number */ .word 0 - .align 16, 0 + .balign 16, 0 .globl _exe_start _exe_start: diff --git a/src/arch/x86/prefix/mromprefix.S b/src/arch/x86/prefix/mromprefix.S index 2b5c6bf64..d08284d7a 100644 --- a/src/arch/x86/prefix/mromprefix.S +++ b/src/arch/x86/prefix/mromprefix.S @@ -492,7 +492,7 @@ mromheader: .word 0 .size mromheader, . - mromheader - .align 4 + .balign 4 mpciheader: .ascii "PCIR" /* Signature */ .word pci_vendor_id /* Vendor identification */ diff --git a/src/arch/x86/prefix/romprefix.S b/src/arch/x86/prefix/romprefix.S index 3abef0eaf..a9934a725 100644 --- a/src/arch/x86/prefix/romprefix.S +++ b/src/arch/x86/prefix/romprefix.S @@ -88,7 +88,7 @@ checksum: .previous .ifeqs BUSTYPE, "PCIR" - .align 4 + .balign 4 pciheader: .ascii "PCIR" /* Signature */ .word pci_vendor_id /* Vendor identification */ @@ -136,7 +136,7 @@ pci_devlist_end: * BIOSes will scan on 16-byte boundaries rather than using * the offset stored at 0x1a */ - .align 16 + .balign 16 pnpheader: .ascii "$PnP" /* Signature */ .byte 0x01 /* Structure revision */ @@ -184,7 +184,7 @@ prodstr_pci_id: .globl undiheader .weak undiloader - .align 4 + .balign 4 undiheader: .ascii "UNDI" /* Signature */ .byte undiheader_len /* Length of structure */ @@ -199,7 +199,7 @@ undiheader: .equ undiheader_len, . - undiheader .size undiheader, . - undiheader - .align 4 + .balign 4 ipxeheader: .ascii "iPXE" /* Signature */ .byte ipxeheader_len /* Length of structure */ diff --git a/src/arch/x86/prefix/unlzma.S b/src/arch/x86/prefix/unlzma.S index ce18c756f..956eeb24c 100644 --- a/src/arch/x86/prefix/unlzma.S +++ b/src/arch/x86/prefix/unlzma.S @@ -231,7 +231,7 @@ rep_len_dec: .space sizeof__lzma_len_dec literal: .rept ( ( 1 << LZMA_LC ) * 0x300 ) .word 0 .endr - .align 4 + .balign 4 .equ sizeof__lzma_dec, . - lzma_dec .previous diff --git a/src/arch/x86/transitions/liba20.S b/src/arch/x86/transitions/liba20.S index 6c1e1f62f..57603353e 100644 --- a/src/arch/x86/transitions/liba20.S +++ b/src/arch/x86/transitions/liba20.S @@ -285,7 +285,7 @@ enable_a20: ret .section ".text16.early.data", "aw", @progbits - .align 2 + .balign 2 enable_a20_method: .word 0 .size enable_a20_method, . - enable_a20_method diff --git a/src/arch/x86/transitions/librm.S b/src/arch/x86/transitions/librm.S index 9d3eff954..f2fa8c50b 100644 --- a/src/arch/x86/transitions/librm.S +++ b/src/arch/x86/transitions/librm.S @@ -99,7 +99,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) **************************************************************************** */ .section ".data16.gdt", "aw", @progbits - .align 16 + .balign 16 gdt: gdtr: /* The first GDT entry is unused, the GDTR can fit here. */ gdt_limit: .word gdt_length - 1 @@ -224,7 +224,7 @@ RC_TMP_END: /* Shared temporary static buffer */ .section ".bss16.rm_tmpbuf", "aw", @nobits - .align 16 + .balign 16 rm_tmpbuf: .space VC_TMP_END .size rm_tmpbuf, . - rm_tmpbuf @@ -1470,7 +1470,7 @@ interrupt_wrapper: **************************************************************************** */ .section ".pages", "aw", @nobits - .align SIZEOF_PT + .balign SIZEOF_PT /* Page map level 4 entries (PML4Es) * diff --git a/src/include/errno.h b/src/include/errno.h index 342384fa4..decde38ed 100644 --- a/src/include/errno.h +++ b/src/include/errno.h @@ -259,7 +259,7 @@ static inline void eplatform_discard ( int dummy __unused, ... ) {} */ #define __einfo_error( einfo ) ( { \ __asm__ ( ".section \".einfo\", \"\", " PROGBITS_OPS "\n\t" \ - ".align 8\n\t" \ + ".balign 8\n\t" \ "\n1:\n\t" \ ".long ( 4f - 1b )\n\t" \ ".long %c0\n\t" \ @@ -268,7 +268,7 @@ static inline void eplatform_discard ( int dummy __unused, ... ) {} ".long %c1\n\t" \ "\n2:\t.asciz \"" __einfo_desc ( einfo ) "\"\n\t" \ "\n3:\t.asciz \"" __FILE__ "\"\n\t" \ - ".align 8\n\t" \ + ".balign 8\n\t" \ "\n4:\n\t" \ ".previous\n\t" : : \ "i" ( __einfo_errno ( einfo ) ), \ -- cgit v1.2.3-55-g7522 From 1b99ba2a93df92df63a7cddfb1b2cfb7b96be772 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 15 Feb 2021 09:54:03 +0000 Subject: [build] Work around stray sections introduced by some binutils versions Some versions of GNU ld (observed with binutils 2.36 on Arch Linux) introduce a .note.gnu.property section marked as loadable at a high address and with non-empty contents. This adds approximately 128MB of garbage to the BIOS .usb disk images. Fix by using a custom linker script for the prefix-only binaries such as the USB disk partition table and MBR, in order to allow unwanted sections to be explicitly discarded. Reported-by: Christian Hesse Tested-by: Christian Hesse Signed-off-by: Michael Brown --- src/arch/x86/Makefile.pcbios | 11 ++++------- src/arch/x86/scripts/prefixonly.lds | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/arch/x86/scripts/prefixonly.lds (limited to 'src/arch') diff --git a/src/arch/x86/Makefile.pcbios b/src/arch/x86/Makefile.pcbios index 751d7d28c..ed8d554a7 100644 --- a/src/arch/x86/Makefile.pcbios +++ b/src/arch/x86/Makefile.pcbios @@ -4,18 +4,15 @@ # SRCDIRS += arch/x86/drivers/net -# The i386 linker script +# The linker scripts # LDSCRIPT = arch/x86/scripts/pcbios.lds +LDSCRIPT_PREFIX = arch/x86/scripts/prefixonly.lds # Stop ld from complaining about our customised linker script # LDFLAGS += -N --no-check-sections -# Prefix always starts at address zero -# -LDFLAGS += --section-start=.prefix=0 - # Media types. # MEDIA += rom @@ -73,12 +70,12 @@ NON_AUTO_MEDIA += fd0 # Special target for building Master Boot Record binary $(BIN)/mbr.tmp : $(BIN)/mbr.o $(QM)$(ECHO) " [LD] $@" - $(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $< + $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT_PREFIX) -o $@ -e mbr $< # rule to make a USB disk image $(BIN)/usbdisk.tmp : $(BIN)/usbdisk.o $(QM)$(ECHO) " [LD] $@" - $(Q)$(LD) $(LDFLAGS) -o $@ -e mbr $< + $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT_PREFIX) -o $@ -e mbr $< NON_AUTO_MEDIA += usb %usb: $(BIN)/usbdisk.bin %hd diff --git a/src/arch/x86/scripts/prefixonly.lds b/src/arch/x86/scripts/prefixonly.lds new file mode 100644 index 000000000..dce0930b5 --- /dev/null +++ b/src/arch/x86/scripts/prefixonly.lds @@ -0,0 +1,29 @@ +/* -*- ld-script -*- */ + +/* + * Linker script for prefix-only binaries (e.g. USB disk MBR) + * + */ + +SECTIONS { + + .prefix 0x0 : AT ( 0x0 ) { + *(.prefix) + } + + /DISCARD/ : { + *(.comment) + *(.comment.*) + *(.note) + *(.note.*) + *(.eh_frame) + *(.eh_frame.*) + *(.rel) + *(.rel.*) + *(.einfo) + *(.einfo.*) + *(.discard) + *(.discard.*) + } + +} -- cgit v1.2.3-55-g7522 From 057674bb1f766db8b4c6593dc238ea68e4f38028 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 17 Feb 2021 15:59:52 +0000 Subject: [pxe] Split out platform-independent portions of cachedhcp.c Split out the portions of cachedhcp.c that can be shared between BIOS and UEFI (both of which can provide a buffer containing a previously obtained DHCP packet, and neither of which provide a means to determine the length of this DHCP packet). Signed-off-by: Michael Brown --- src/arch/x86/core/cachedhcp.c | 179 ------------------------- src/arch/x86/interface/pcbios/bios_cachedhcp.c | 76 +++++++++++ src/core/cachedhcp.c | 158 ++++++++++++++++++++++ src/include/ipxe/cachedhcp.h | 17 +++ src/include/ipxe/errfile.h | 1 + 5 files changed, 252 insertions(+), 179 deletions(-) delete mode 100644 src/arch/x86/core/cachedhcp.c create mode 100644 src/arch/x86/interface/pcbios/bios_cachedhcp.c create mode 100644 src/core/cachedhcp.c create mode 100644 src/include/ipxe/cachedhcp.h (limited to 'src/arch') diff --git a/src/arch/x86/core/cachedhcp.c b/src/arch/x86/core/cachedhcp.c deleted file mode 100644 index dffafe3c9..000000000 --- a/src/arch/x86/core/cachedhcp.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2013 Michael Brown . - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - * - * You can also choose to distribute this program under the terms of - * the Unmodified Binary Distribution Licence (as given in the file - * COPYING.UBDL), provided that you have satisfied its requirements. - */ - -FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); - -#include -#include -#include -#include -#include -#include -#include - -/** @file - * - * Cached DHCP packet - * - */ - -/** Cached DHCPACK physical address - * - * This can be set by the prefix. - */ -uint32_t __bss16 ( cached_dhcpack_phys ); -#define cached_dhcpack_phys __use_data16 ( cached_dhcpack_phys ) - -/** Colour for debug messages */ -#define colour &cached_dhcpack_phys - -/** Cached DHCPACK */ -static struct dhcp_packet *cached_dhcpack; - -/** - * Cached DHCPACK startup function - * - */ -static void cachedhcp_init ( void ) { - struct dhcp_packet *dhcppkt; - struct dhcp_packet *tmp; - struct dhcphdr *dhcphdr; - size_t max_len; - size_t len; - - /* Do nothing if no cached DHCPACK is present */ - if ( ! cached_dhcpack_phys ) { - DBGC ( colour, "CACHEDHCP found no cached DHCPACK\n" ); - return; - } - - /* No reliable way to determine length before parsing packet; - * start by assuming maximum length permitted by PXE. - */ - max_len = sizeof ( BOOTPLAYER_t ); - - /* Allocate and populate DHCP packet */ - dhcppkt = zalloc ( sizeof ( *dhcppkt ) + max_len ); - if ( ! dhcppkt ) { - DBGC ( colour, "CACHEDHCP could not allocate copy\n" ); - return; - } - dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); - copy_from_user ( dhcphdr, phys_to_user ( cached_dhcpack_phys ), 0, - max_len ); - dhcppkt_init ( dhcppkt, dhcphdr, max_len ); - - /* Shrink packet to required length. If reallocation fails, - * just continue to use the original packet and waste the - * unused space. - */ - len = dhcppkt_len ( dhcppkt ); - assert ( len <= max_len ); - tmp = realloc ( dhcppkt, ( sizeof ( *dhcppkt ) + len ) ); - if ( tmp ) - dhcppkt = tmp; - - /* Reinitialise packet at new address */ - dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); - dhcppkt_init ( dhcppkt, dhcphdr, len ); - - /* Store as cached DHCPACK, and mark original copy as consumed */ - DBGC ( colour, "CACHEDHCP found cached DHCPACK at %08x+%zx\n", - cached_dhcpack_phys, len ); - cached_dhcpack = dhcppkt; - cached_dhcpack_phys = 0; -} - -/** - * Cached DHCPACK startup function - * - */ -static void cachedhcp_startup ( void ) { - - /* If cached DHCP packet was not claimed by any network device - * during startup, then free it. - */ - if ( cached_dhcpack ) { - DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" ); - dhcppkt_put ( cached_dhcpack ); - cached_dhcpack = NULL; - } -} - -/** Cached DHCPACK initialisation function */ -struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = { - .initialise = cachedhcp_init, -}; - -/** Cached DHCPACK startup function */ -struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = { - .name = "cachedhcp", - .startup = cachedhcp_startup, -}; - -/** - * Apply cached DHCPACK to network device, if applicable - * - * @v netdev Network device - * @ret rc Return status code - */ -static int cachedhcp_probe ( struct net_device *netdev ) { - struct ll_protocol *ll_protocol = netdev->ll_protocol; - int rc; - - /* Do nothing unless we have a cached DHCPACK */ - if ( ! cached_dhcpack ) - return 0; - - /* Do nothing unless cached DHCPACK's MAC address matches this - * network device. - */ - if ( memcmp ( netdev->ll_addr, cached_dhcpack->dhcphdr->chaddr, - ll_protocol->ll_addr_len ) != 0 ) { - DBGC ( colour, "CACHEDHCP cached DHCPACK does not match %s\n", - netdev->name ); - return 0; - } - DBGC ( colour, "CACHEDHCP cached DHCPACK is for %s\n", netdev->name ); - - /* Register as DHCP settings for this network device */ - if ( ( rc = register_settings ( &cached_dhcpack->settings, - netdev_settings ( netdev ), - DHCP_SETTINGS_NAME ) ) != 0 ) { - DBGC ( colour, "CACHEDHCP could not register settings: %s\n", - strerror ( rc ) ); - return rc; - } - - /* Claim cached DHCPACK */ - dhcppkt_put ( cached_dhcpack ); - cached_dhcpack = NULL; - - return 0; -} - -/** Cached DHCP packet network device driver */ -struct net_driver cachedhcp_driver __net_driver = { - .name = "cachedhcp", - .probe = cachedhcp_probe, -}; diff --git a/src/arch/x86/interface/pcbios/bios_cachedhcp.c b/src/arch/x86/interface/pcbios/bios_cachedhcp.c new file mode 100644 index 000000000..3d38699f7 --- /dev/null +++ b/src/arch/x86/interface/pcbios/bios_cachedhcp.c @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include + +/** @file + * + * Cached DHCP packet + * + */ + +/** Cached DHCPACK physical address + * + * This can be set by the prefix. + */ +uint32_t __bss16 ( cached_dhcpack_phys ); +#define cached_dhcpack_phys __use_data16 ( cached_dhcpack_phys ) + +/** Colour for debug messages */ +#define colour &cached_dhcpack_phys + +/** + * Cached DHCPACK initialisation function + * + */ +static void cachedhcp_init ( void ) { + int rc; + + /* Do nothing if no cached DHCPACK is present */ + if ( ! cached_dhcpack_phys ) { + DBGC ( colour, "CACHEDHCP found no cached DHCPACK\n" ); + return; + } + + /* Record cached DHCPACK */ + if ( ( rc = cachedhcp_record ( phys_to_user ( cached_dhcpack_phys ), + sizeof ( BOOTPLAYER_t ) ) ) != 0 ) { + DBGC ( colour, "CACHEDHCP could not record DHCPACK: %s\n", + strerror ( rc ) ); + return; + } + + /* Mark as consumed */ + cached_dhcpack_phys = 0; +} + +/** Cached DHCPACK initialisation function */ +struct init_fn cachedhcp_init_fn __init_fn ( INIT_NORMAL ) = { + .initialise = cachedhcp_init, +}; diff --git a/src/core/cachedhcp.c b/src/core/cachedhcp.c new file mode 100644 index 000000000..0e7da4bf2 --- /dev/null +++ b/src/core/cachedhcp.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2013 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * You can also choose to distribute this program under the terms of + * the Unmodified Binary Distribution Licence (as given in the file + * COPYING.UBDL), provided that you have satisfied its requirements. + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include +#include +#include +#include +#include +#include + +/** @file + * + * Cached DHCP packet + * + */ + +/** Cached DHCPACK */ +static struct dhcp_packet *cached_dhcpack; + +/** Colour for debug messages */ +#define colour &cached_dhcpack + +/** + * Record cached DHCPACK + * + * @v data DHCPACK packet buffer + * @v max_len Maximum possible length + * @ret rc Return status code + */ +int cachedhcp_record ( userptr_t data, size_t max_len ) { + struct dhcp_packet *dhcppkt; + struct dhcp_packet *tmp; + struct dhcphdr *dhcphdr; + size_t len; + + /* Allocate and populate DHCP packet */ + dhcppkt = zalloc ( sizeof ( *dhcppkt ) + max_len ); + if ( ! dhcppkt ) { + DBGC ( colour, "CACHEDHCP could not allocate copy\n" ); + return -ENOMEM; + } + dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); + copy_from_user ( dhcphdr, data, 0, max_len ); + dhcppkt_init ( dhcppkt, dhcphdr, max_len ); + + /* Shrink packet to required length. If reallocation fails, + * just continue to use the original packet and waste the + * unused space. + */ + len = dhcppkt_len ( dhcppkt ); + assert ( len <= max_len ); + tmp = realloc ( dhcppkt, ( sizeof ( *dhcppkt ) + len ) ); + if ( tmp ) + dhcppkt = tmp; + + /* Reinitialise packet at new address */ + dhcphdr = ( ( ( void * ) dhcppkt ) + sizeof ( *dhcppkt ) ); + dhcppkt_init ( dhcppkt, dhcphdr, len ); + + /* Store as cached DHCPACK, and mark original copy as consumed */ + DBGC ( colour, "CACHEDHCP found cached DHCPACK at %#08lx+%#zx/%#zx\n", + user_to_phys ( data, 0 ), len, max_len ); + cached_dhcpack = dhcppkt; + + return 0; +} + +/** + * Cached DHCPACK startup function + * + */ +static void cachedhcp_startup ( void ) { + + /* If cached DHCP packet was not claimed by any network device + * during startup, then free it. + */ + if ( cached_dhcpack ) { + DBGC ( colour, "CACHEDHCP freeing unclaimed cached DHCPACK\n" ); + dhcppkt_put ( cached_dhcpack ); + cached_dhcpack = NULL; + } +} + +/** Cached DHCPACK startup function */ +struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = { + .name = "cachedhcp", + .startup = cachedhcp_startup, +}; + +/** + * Apply cached DHCPACK to network device, if applicable + * + * @v netdev Network device + * @ret rc Return status code + */ +static int cachedhcp_probe ( struct net_device *netdev ) { + struct ll_protocol *ll_protocol = netdev->ll_protocol; + int rc; + + /* Do nothing unless we have a cached DHCPACK */ + if ( ! cached_dhcpack ) + return 0; + + /* Do nothing unless cached DHCPACK's MAC address matches this + * network device. + */ + if ( memcmp ( netdev->ll_addr, cached_dhcpack->dhcphdr->chaddr, + ll_protocol->ll_addr_len ) != 0 ) { + DBGC ( colour, "CACHEDHCP cached DHCPACK does not match %s\n", + netdev->name ); + return 0; + } + DBGC ( colour, "CACHEDHCP cached DHCPACK is for %s\n", netdev->name ); + + /* Register as DHCP settings for this network device */ + if ( ( rc = register_settings ( &cached_dhcpack->settings, + netdev_settings ( netdev ), + DHCP_SETTINGS_NAME ) ) != 0 ) { + DBGC ( colour, "CACHEDHCP could not register settings: %s\n", + strerror ( rc ) ); + return rc; + } + + /* Claim cached DHCPACK */ + dhcppkt_put ( cached_dhcpack ); + cached_dhcpack = NULL; + + return 0; +} + +/** Cached DHCP packet network device driver */ +struct net_driver cachedhcp_driver __net_driver = { + .name = "cachedhcp", + .probe = cachedhcp_probe, +}; diff --git a/src/include/ipxe/cachedhcp.h b/src/include/ipxe/cachedhcp.h new file mode 100644 index 000000000..7765c6455 --- /dev/null +++ b/src/include/ipxe/cachedhcp.h @@ -0,0 +1,17 @@ +#ifndef _IPXE_CACHEDHCP_H +#define _IPXE_CACHEDHCP_H + +/** @file + * + * Cached DHCP packet + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +#include +#include + +extern int cachedhcp_record ( userptr_t data, size_t max_len ); + +#endif /* _IPXE_CACHEDHCP_H */ diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index f14cb8619..4c1c334d8 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -76,6 +76,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ERRFILE_dummy_sanboot ( ERRFILE_CORE | 0x00240000 ) #define ERRFILE_fdt ( ERRFILE_CORE | 0x00250000 ) #define ERRFILE_dma ( ERRFILE_CORE | 0x00260000 ) +#define ERRFILE_cachedhcp ( ERRFILE_CORE | 0x00270000 ) #define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 ) #define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 ) -- cgit v1.2.3-55-g7522 From 8446a439b37ae0a70693899363d0ee7c24fba935 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Feb 2021 01:49:23 +0000 Subject: [initrd] Allow for zero-length initrd files A zero-length initrd file will currently cause an endless loop during reshuffling as the empty image is repeatedly swapped with itself. Fix by terminating the inner loop before considering an image as a candidate to be swapped with itself. Reported-by: Pico Mitchell Signed-off-by: Michael Brown --- src/arch/x86/image/initrd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/image/initrd.c b/src/arch/x86/image/initrd.c index 8f6366d3d..49b959a91 100644 --- a/src/arch/x86/image/initrd.c +++ b/src/arch/x86/image/initrd.c @@ -175,18 +175,18 @@ static int initrd_swap_any ( userptr_t free, size_t free_len ) { /* Search for adjacent image */ for_each_image ( high ) { - /* If we have found the adjacent image, swap and exit */ - if ( high->data == adjacent ) { - initrd_swap ( low, high, free, free_len ); - return 1; - } - /* Stop search if all remaining potential * adjacent images are already in the correct * order. */ if ( high == low ) break; + + /* If we have found the adjacent image, swap and exit */ + if ( high->data == adjacent ) { + initrd_swap ( low, high, free, free_len ); + return 1; + } } } -- cgit v1.2.3-55-g7522 From 22bb29eabc2f68f3e60e99df4ef33984b7795a49 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Feb 2021 12:13:12 +0000 Subject: [prefix] Add a generic raw image prefix Provide a generic raw image prefix, which assumes that the iPXE image has been loaded in its entirety on a paragraph boundary. The resulting .raw image can be loaded via RPL using an rpld.conf file such as: HOST { ethernet = 00:00:00:00:00:00/6; FILE { path="ipxe.raw"; load=0x2000; }; execute=0x2000; }; Debugged-by: Johannes Heimansberg Signed-off-by: Michael Brown --- src/arch/x86/prefix/rawprefix.S | 53 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/arch/x86/prefix/rawprefix.S (limited to 'src/arch') diff --git a/src/arch/x86/prefix/rawprefix.S b/src/arch/x86/prefix/rawprefix.S new file mode 100644 index 000000000..4cf5f391e --- /dev/null +++ b/src/arch/x86/prefix/rawprefix.S @@ -0,0 +1,53 @@ +/* + * Raw binary prefix + * + * Assumes that entire image is already loaded as a contiguous block + * on a paragraph boundary and entered in real mode. + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ) + + .text + .arch i386 + .org 0 + .code16 + +#include + + .section ".prefix", "ax", @progbits + .globl _raw_start +_raw_start: + + /* Adjust %cs so that %cs:0000 is the start of the image */ + movw %cs, %ax + call 1f +1: popw %bx + subw $1b, %bx + shrw $4, %bx + addw %bx, %ax + pushw %ax + pushw $2f + lret +2: + /* Install iPXE */ + call install + + /* Set up real-mode stack */ + movw %bx, %ss + movw $_estack16, %sp + + /* Jump to .text16 segment */ + pushw %ax + pushw $1f + lret + .section ".text16", "awx", @progbits +1: + /* Run iPXE */ + virtcall main + + /* Uninstall iPXE */ + call uninstall + + /* Boot next device */ + int $0x18 -- cgit v1.2.3-55-g7522 From e63b8c3302b1e80e14f3d3628ff279f7316ee208 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Feb 2021 14:51:28 +0000 Subject: [librm] Add missing __asmcall on init_idt() The __asmcall declaration has no effect on a void function with no parameters, but should be included for completeness since the function is called directly from assembly code. Signed-off-by: Michael Brown --- src/arch/x86/transitions/librm_mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/arch') diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index f9e1d261a..85cfc8f49 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -118,7 +118,7 @@ void set_interrupt_vector ( unsigned int intr, void *vector ) { * Initialise interrupt descriptor table * */ -void init_idt ( void ) { +__asmcall void init_idt ( void ) { struct interrupt_vector *vec; unsigned int intr; -- cgit v1.2.3-55-g7522 From 900f1f98d3dbb64803e427318ad61c9d7aa6f9bb Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 18 Feb 2021 14:30:27 +0000 Subject: [librm] Test for FXSAVE/FXRSTOR instruction support Assume that preservation of the %xmm registers is unnecessary during installation of iPXE into memory, since this is an operation that by its nature substantially disrupts large portions of the system anyway (such as the E820 memory map). This assumption allows us to utilise the existing CPUID code to check that FXSAVE/FXRSTOR are supported. Test for support during the call to init_librm and store the flag for use during subsequent calls to virt_call. Reduce the scope of TIVOLI_VMM_WORKAROUND to affecting only the call to check_fxsr(), to reduce #ifdef pollution in the remaining code. Debugged-by: Johannes Heimansberg Signed-off-by: Michael Brown --- src/arch/x86/include/ipxe/cpuid.h | 3 +++ src/arch/x86/transitions/librm.S | 23 +++++++++++++++++------ src/arch/x86/transitions/librm_mgmt.c | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/include/ipxe/cpuid.h b/src/arch/x86/include/ipxe/cpuid.h index 0ae572da4..b5403bd9d 100644 --- a/src/arch/x86/include/ipxe/cpuid.h +++ b/src/arch/x86/include/ipxe/cpuid.h @@ -42,6 +42,9 @@ struct x86_features { /** Hypervisor is present */ #define CPUID_FEATURES_INTEL_ECX_HYPERVISOR 0x80000000UL +/** FXSAVE and FXRSTOR are supported */ +#define CPUID_FEATURES_INTEL_EDX_FXSR 0x01000000UL + /** Get largest extended function */ #define CPUID_AMD_MAX_FN 0x80000000UL diff --git a/src/arch/x86/transitions/librm.S b/src/arch/x86/transitions/librm.S index f2fa8c50b..5dacb9b04 100644 --- a/src/arch/x86/transitions/librm.S +++ b/src/arch/x86/transitions/librm.S @@ -210,9 +210,7 @@ VC_TMP_CR3: .space 4 VC_TMP_CR4: .space 4 VC_TMP_EMER: .space 8 .endif -#ifdef TIVOLI_VMM_WORKAROUND VC_TMP_FXSAVE: .space 512 -#endif VC_TMP_END: .previous @@ -350,6 +348,13 @@ init_librm_rmode: /* Initialise IDT */ virtcall init_idt +#ifdef TIVOLI_VMM_WORKAROUND + /* Check for FXSAVE/FXRSTOR */ + clc + virtcall check_fxsr + setnc fxsr_supported +#endif + /* Restore registers */ popl %edi popl %ebx @@ -366,6 +371,10 @@ set_seg_base: roll $16, %eax ret + .section ".data16.fxsr_supported", "awx", @progbits +fxsr_supported: /* FXSAVE/FXRSTOR instructions supported */ + .byte 0 + /**************************************************************************** * real_to_prot (real-mode near call, 32-bit virtual return address) * @@ -1007,10 +1016,11 @@ virt_call: cli movw %cs:rm_ds, %ds -#ifdef TIVOLI_VMM_WORKAROUND /* Preserve FPU, MMX and SSE state in temporary static buffer */ + testb $0xff, fxsr_supported + jz 1f fxsave ( rm_tmpbuf + VC_TMP_FXSAVE ) -#endif +1: /* Preserve GDT and IDT in temporary static buffer */ sidt ( rm_tmpbuf + VC_TMP_IDT ) sgdt ( rm_tmpbuf + VC_TMP_GDT ) @@ -1077,10 +1087,11 @@ vc_rmode: wrmsr .endif -#ifdef TIVOLI_VMM_WORKAROUND /* Restore FPU, MMX and SSE state from temporary static buffer */ + testb $0xff, fxsr_supported + jz 1f fxrstor ( rm_tmpbuf + VC_TMP_FXSAVE ) -#endif +1: /* Restore registers and flags and return */ popl %eax /* skip %cs and %ss */ popw %ds diff --git a/src/arch/x86/transitions/librm_mgmt.c b/src/arch/x86/transitions/librm_mgmt.c index 85cfc8f49..da221e8b1 100644 --- a/src/arch/x86/transitions/librm_mgmt.c +++ b/src/arch/x86/transitions/librm_mgmt.c @@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include +#include /* * This file provides functions for managing librm. @@ -386,6 +387,21 @@ static void iounmap_pages ( volatile const void *io_addr ) { io_addr, first, i ); } +/** + * Check for FXSAVE/FXRSTOR instruction support + * + */ +__asmcall void check_fxsr ( struct i386_all_regs *regs ) { + struct x86_features features; + + /* Check for FXSR bit */ + x86_features ( &features ); + if ( ! ( features.intel.edx & CPUID_FEATURES_INTEL_EDX_FXSR ) ) + regs->flags |= CF; + DBGC ( &features, "FXSAVE/FXRSTOR is%s supported\n", + ( ( regs->flags & CF ) ? " not" : "" ) ); +} + PROVIDE_UACCESS_INLINE ( librm, phys_to_user ); PROVIDE_UACCESS_INLINE ( librm, user_to_phys ); PROVIDE_UACCESS_INLINE ( librm, virt_to_user ); -- cgit v1.2.3-55-g7522 From 16d95227a4b92bba068b43070545b96ce0a90e14 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 27 Feb 2021 15:05:20 +0000 Subject: [bitops] Provide an explicit operand size for bit test instructions Recent versions of the GNU assembler (observed with GNU as 2.35 on Fedora 33) will produce a warning message Warning: no instruction mnemonic suffix given and no register operands; using default for `bts' The operand size affects only the potential range for the bit number. Since we pass the bit number as an unsigned int, it is already constrained to 32 bits for both i386 and x86_64. Silence the assembler warning by specifying an explicit 32-bit operand size (and thereby matching the choice that the assembler would otherwise make automatically). Signed-off-by: Michael Brown --- src/arch/x86/include/bits/bitops.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/include/bits/bitops.h b/src/arch/x86/include/bits/bitops.h index 17dcf1024..f697b8c8f 100644 --- a/src/arch/x86/include/bits/bitops.h +++ b/src/arch/x86/include/bits/bitops.h @@ -29,7 +29,7 @@ set_bit ( unsigned int bit, volatile void *bits ) { uint8_t byte[ ( bit / 8 ) + 1 ]; } *bytes = bits; - __asm__ __volatile__ ( "lock bts %1, %0" + __asm__ __volatile__ ( "lock btsl %k1, %0" : "+m" ( *bytes ) : "Ir" ( bit ) ); } @@ -45,7 +45,7 @@ clear_bit ( unsigned int bit, volatile void *bits ) { uint8_t byte[ ( bit / 8 ) + 1 ]; } *bytes = bits; - __asm__ __volatile__ ( "lock btr %1, %0" + __asm__ __volatile__ ( "lock btrl %k1, %0" : "+m" ( *bytes ) : "Ir" ( bit ) ); } @@ -63,7 +63,7 @@ test_and_set_bit ( unsigned int bit, volatile void *bits ) { } *bytes = bits; int old; - __asm__ __volatile__ ( "lock bts %2, %0\n\t" + __asm__ __volatile__ ( "lock btsl %k2, %0\n\t" "sbb %1, %1\n\t" : "+m" ( *bytes ), "=r" ( old ) : "Ir" ( bit ) ); @@ -84,7 +84,7 @@ test_and_clear_bit ( unsigned int bit, volatile void *bits ) { } *bytes = bits; int old; - __asm__ __volatile__ ( "lock btr %2, %0\n\t" + __asm__ __volatile__ ( "lock btrl %k2, %0\n\t" "sbb %1, %1\n\t" : "+m" ( *bytes ), "=r" ( old ) : "Ir" ( bit ) ); -- cgit v1.2.3-55-g7522 From 040cdd0c658a49694b17a1c0b5439d0bd7805242 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 27 Feb 2021 18:52:11 +0000 Subject: [linux] Add a prefix to all symbols to avoid future name collisions Allow for the possibility of linking to platform libraries for the Linux userspace build by adding an iPXE-specific symbol prefix. Signed-off-by: Michael Brown --- src/Makefile | 1 + src/Makefile.housekeeping | 7 +++++-- src/arch/x86/Makefile.linux | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/arch') diff --git a/src/Makefile b/src/Makefile index 60be873fb..69139dc11 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,6 +10,7 @@ LDFLAGS := HOST_CFLAGS := MAKEDEPS := Makefile CROSS_COMPILE ?= $(CROSS) +SYMBOL_PREFIX := ############################################################################### # diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 2c2c8a1fc..e017c656b 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -1102,9 +1102,10 @@ TGT_LD_ENTRY = _$(TGT_PREFIX)_start # TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) \ $(TGT_LD_DEVLIST) obj_config obj_config_$(PLATFORM),\ - -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \ + -u $(SYMBOL_PREFIX)$(SYM) \ + --defsym check_$(SYM)=$(SYMBOL_PREFIX)$(SYM) ) \ $(patsubst %,--defsym %,$(TGT_LD_IDS)) \ - -e $(TGT_LD_ENTRY) + -e $(SYMBOL_PREFIX)$(TGT_LD_ENTRY) # Calculate list of debugging versions of objects to be included in # the target. @@ -1166,6 +1167,7 @@ $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS) $(Q)$(RM) $(BLIB) $(QM)$(ECHO) " [AR] $@" $(Q)$(AR) rD $@ $(sort $(BLIB_OBJS)) + $(Q)$(OBJCOPY) --prefix-symbols=$(SYMBOL_PREFIX) $@ $(Q)$(RANLIB) -D $@ blib : $(BLIB) @@ -1207,6 +1209,7 @@ $(BIN)/version.%.o : core/version.c $(MAKEDEPS) $(GIT_INDEX) -DVERSION_PATCH=$(VERSION_PATCH) \ -DVERSION="\"$(VERSION)\"" \ -c $< -o $@ + $(Q)$(OBJCOPY) --prefix-symbols=$(SYMBOL_PREFIX) $@ # Build an intermediate object file from the objects required for the # specified target. diff --git a/src/arch/x86/Makefile.linux b/src/arch/x86/Makefile.linux index 1faf84753..3740cc81a 100644 --- a/src/arch/x86/Makefile.linux +++ b/src/arch/x86/Makefile.linux @@ -3,6 +3,8 @@ MEDIA = linux # enable valgrind CFLAGS += -UNVALGRIND +SYMBOL_PREFIX = _ipxe__ + INCDIRS += arch/x86/include/linux SRCDIRS += interface/linux SRCDIRS += drivers/linux -- cgit v1.2.3-55-g7522 From f309d7a7b78eec10621bc71f9401d5b9257f9f39 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 28 Feb 2021 13:45:58 +0000 Subject: [linux] Use host glibc system call wrappers When building as a Linux userspace application, iPXE currently implements its own system calls to the host kernel rather than relying on the host's C library. The output binary is statically linked and has no external dependencies. This matches the general philosophy of other platforms on which iPXE runs, since there are no external libraries available on either BIOS or UEFI bare metal. However, it would be useful for the Linux userspace application to be able to link against host libraries such as libslirp. Modify the build process to perform a two-stage link: first picking out the requested objects in the usual way from blib.a but with relocations left present, then linking again with a helper object to create a standard hosted application. The helper object provides the standard main() entry point and wrappers for the Linux system calls required by the iPXE Linux drivers and interface code. Signed-off-by: Michael Brown --- .github/workflows/build.yml | 4 +- src/Makefile.linux | 39 +++ src/arch/i386/Makefile.linux | 10 +- src/arch/i386/core/linux/linux_syscall.S | 45 --- src/arch/i386/core/linux/linuxprefix.S | 28 -- src/arch/i386/include/bits/linux_api.h | 6 - src/arch/x86/Makefile.linux | 19 +- src/arch/x86/core/linux/linux_api.c | 149 ---------- src/arch/x86/core/linux/linux_strerror.c | 169 ----------- src/arch/x86/include/bits/linux_api_platform.h | 6 - src/arch/x86_64/Makefile.linux | 8 +- src/arch/x86_64/core/linux/linux_syscall.S | 33 --- src/arch/x86_64/core/linux/linuxprefix.S | 25 -- src/arch/x86_64/include/bits/linux_api.h | 6 - src/drivers/linux/af_packet.c | 2 +- src/drivers/linux/tap.c | 2 +- src/hci/linux_args.c | 20 +- src/include/hci/linux_args.h | 31 -- src/include/ipxe/linux_api.h | 86 ++++++ src/include/linux_api.h | 81 ------ src/interface/linux/linux_api.c | 373 +++++++++++++++++++++++++ src/interface/linux/linux_console.c | 2 +- src/interface/linux/linux_entropy.c | 2 +- src/interface/linux/linux_nap.c | 2 +- src/interface/linux/linux_pci.c | 2 +- src/interface/linux/linux_smbios.c | 2 +- src/interface/linux/linux_time.c | 2 +- src/interface/linux/linux_timer.c | 2 +- src/interface/linux/linux_umalloc.c | 2 +- src/interface/linux/linuxprefix.c | 38 +++ 30 files changed, 574 insertions(+), 622 deletions(-) create mode 100644 src/Makefile.linux delete mode 100644 src/arch/i386/core/linux/linux_syscall.S delete mode 100644 src/arch/i386/core/linux/linuxprefix.S delete mode 100644 src/arch/i386/include/bits/linux_api.h delete mode 100644 src/arch/x86/core/linux/linux_api.c delete mode 100644 src/arch/x86/core/linux/linux_strerror.c delete mode 100644 src/arch/x86/include/bits/linux_api_platform.h delete mode 100644 src/arch/x86_64/core/linux/linux_syscall.S delete mode 100644 src/arch/x86_64/core/linux/linuxprefix.S delete mode 100644 src/arch/x86_64/include/bits/linux_api.h delete mode 100644 src/include/hci/linux_args.h create mode 100644 src/include/ipxe/linux_api.h delete mode 100644 src/include/linux_api.h create mode 100644 src/interface/linux/linux_api.c create mode 100644 src/interface/linux/linuxprefix.c (limited to 'src/arch') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d890dfb13..6dc577ef1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,9 +14,11 @@ jobs: fetch-depth: 0 - name: Install packages run: | + sudo dpkg --add-architecture i386 sudo apt update sudo apt install -y -o Acquire::Retries=50 \ - mtools syslinux isolinux libc6-dev-i386 valgrind + mtools syslinux isolinux \ + libc6-dev-i386 libc6-dbg:i386 valgrind - name: Build (BIOS) run: | make -j 4 -C src diff --git a/src/Makefile.linux b/src/Makefile.linux new file mode 100644 index 000000000..4a7837916 --- /dev/null +++ b/src/Makefile.linux @@ -0,0 +1,39 @@ +# -*- makefile -*- : Force emacs to use Makefile mode + +# Prefix all iPXE symbols to avoid collisions with platform libraries +# +SYMBOL_PREFIX = _ipxe__ + +# Enable valgrind +# +CFLAGS += -UNVALGRIND + +# Use a two-stage link +# +LDFLAGS += -r -d + +# Source directories +# +SRCDIRS += drivers/linux +SRCDIRS += interface/linux +NON_AUTO_SRCS += interface/linux/linux_api.c + +# Media types +# +NON_AUTO_MEDIA = linux + +# Compiler flags for building host API wrapper +# +LINUX_CFLAGS += -Os -idirafter include -DSYMBOL_PREFIX=$(SYMBOL_PREFIX) + +# Host API wrapper +# +$(BIN)/linux_api.o : interface/linux/linux_api.c $(MAKEDEPS) + $(QM)$(ECHO) " [BUILD] $@" + $(Q)$(CC) $(LINUX_CFLAGS) $(WORKAROUND_CFLAGS) -o $@ -c $< + +# Rule to generate final binary +# +$(BIN)/%.linux : $(BIN)/%.linux.tmp $(BIN)/linux_api.o + $(QM)$(ECHO) " [FINISH] $@" + $(Q)$(CC) $(LINUX_CFLAGS) $(WORKAROUND_CFLAGS) -o $@ $^ diff --git a/src/arch/i386/Makefile.linux b/src/arch/i386/Makefile.linux index 46328c83b..fe4229e94 100644 --- a/src/arch/i386/Makefile.linux +++ b/src/arch/i386/Makefile.linux @@ -1,6 +1,14 @@ +# -*- makefile -*- : Force emacs to use Makefile mode + +# Linker script +# LDSCRIPT = arch/i386/scripts/linux.lds -SRCDIRS += arch/i386/core/linux +# Compiler flags for building host API wrapper +# +LINUX_CFLAGS += -m32 +# Include generic Linux Makefile +# MAKEDEPS += arch/x86/Makefile.linux include arch/x86/Makefile.linux diff --git a/src/arch/i386/core/linux/linux_syscall.S b/src/arch/i386/core/linux/linux_syscall.S deleted file mode 100644 index 38a3e74bd..000000000 --- a/src/arch/i386/core/linux/linux_syscall.S +++ /dev/null @@ -1,45 +0,0 @@ - - .section ".data" - .globl linux_errno - -linux_errno: .int 0 - - .section ".text" - .code32 - .globl linux_syscall - .type linux_syscall, @function - -linux_syscall: - /* Save registers */ - pushl %ebx - pushl %esi - pushl %edi - pushl %ebp - - movl 20(%esp), %eax // C arg1 -> syscall number - movl 24(%esp), %ebx // C arg2 -> syscall arg1 - movl 28(%esp), %ecx // C arg3 -> syscall arg2 - movl 32(%esp), %edx // C arg4 -> syscall arg3 - movl 36(%esp), %esi // C arg5 -> syscall arg4 - movl 40(%esp), %edi // C arg6 -> syscall arg5 - movl 44(%esp), %ebp // C arg7 -> syscall arg6 - - int $0x80 - - /* Restore registers */ - popl %ebp - popl %edi - popl %esi - popl %ebx - - cmpl $-4095, %eax - jae 1f - ret - -1: - negl %eax - movl %eax, linux_errno - movl $-1, %eax - ret - - .size linux_syscall, . - linux_syscall diff --git a/src/arch/i386/core/linux/linuxprefix.S b/src/arch/i386/core/linux/linuxprefix.S deleted file mode 100644 index 398d3cb21..000000000 --- a/src/arch/i386/core/linux/linuxprefix.S +++ /dev/null @@ -1,28 +0,0 @@ -#include - - .section ".text" - .code32 - .globl _linux_start - .type _linux_start, @function - -_linux_start: - xorl %ebp, %ebp - - popl %esi // save argc - movl %esp, %edi // save argv - - andl $~15, %esp // 16-byte align the stack - - pushl %edi // argv -> C arg2 - pushl %esi // argc -> C arg1 - - call save_args - - /* Our main doesn't use any arguments */ - call main - - movl %eax, %ebx // rc -> syscall arg1 - movl $__NR_exit, %eax - int $0x80 - - .size _linux_start, . - _linux_start diff --git a/src/arch/i386/include/bits/linux_api.h b/src/arch/i386/include/bits/linux_api.h deleted file mode 100644 index dc6e7416e..000000000 --- a/src/arch/i386/include/bits/linux_api.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _I386_LINUX_API_H -#define _I386_LINUX_API_H - -#define __SYSCALL_mmap __NR_mmap2 - -#endif /* _I386_LINUX_API_H */ diff --git a/src/arch/x86/Makefile.linux b/src/arch/x86/Makefile.linux index 3740cc81a..b60065567 100644 --- a/src/arch/x86/Makefile.linux +++ b/src/arch/x86/Makefile.linux @@ -1,15 +1,10 @@ -MEDIA = linux - -# enable valgrind -CFLAGS += -UNVALGRIND - -SYMBOL_PREFIX = _ipxe__ +# -*- makefile -*- : Force emacs to use Makefile mode +# Include x86 Linux headers +# INCDIRS += arch/x86/include/linux -SRCDIRS += interface/linux -SRCDIRS += drivers/linux -SRCDIRS += arch/x86/core/linux -$(BIN)/%.linux : $(BIN)/%.linux.tmp - $(QM)$(ECHO) " [FINISH] $@" - $(Q)$(CP) $< $@ +# Include generic Linux Makefile +# +MAKEDEPS += Makefile.linux +include Makefile.linux diff --git a/src/arch/x86/core/linux/linux_api.c b/src/arch/x86/core/linux/linux_api.c deleted file mode 100644 index 17b1f3fd4..000000000 --- a/src/arch/x86/core/linux/linux_api.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2010 Piotr Jaroszyński - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -FILE_LICENCE ( GPL2_OR_LATER ); - -/** @file - * - * Implementation of most of the linux API. - */ - -#include - -#include -#include -#include - -int linux_open ( const char *pathname, int flags ) { - return linux_syscall ( __NR_open, pathname, flags ); -} - -int linux_close ( int fd ) { - return linux_syscall ( __NR_close, fd ); -} - -off_t linux_lseek ( int fd, off_t offset, int whence ) { - return linux_syscall ( __NR_lseek, fd, offset, whence ); -} - -__kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count ) { - return linux_syscall ( __NR_read, fd, buf, count ); -} - -__kernel_ssize_t linux_write ( int fd, const void *buf, - __kernel_size_t count ) { - return linux_syscall ( __NR_write, fd, buf, count ); -} - -int linux_fcntl ( int fd, int cmd, ... ) { - long arg; - va_list list; - - va_start ( list, cmd ); - arg = va_arg ( list, long ); - va_end ( list ); - - return linux_syscall ( __NR_fcntl, fd, cmd, arg ); -} - -int linux_ioctl ( int fd, int request, ... ) { - void *arg; - va_list list; - - va_start ( list, request ); - arg = va_arg ( list, void * ); - va_end ( list ); - - return linux_syscall ( __NR_ioctl, fd, request, arg ); -} - -int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout ) { - return linux_syscall ( __NR_poll, fds, nfds, timeout ); -} - -int linux_nanosleep ( const struct timespec *req, struct timespec *rem ) { - return linux_syscall ( __NR_nanosleep, req, rem ); -} - -int linux_usleep ( useconds_t usec ) { - struct timespec ts = { - .tv_sec = ( ( long ) ( usec / 1000000 ) ), - .tv_nsec = ( ( long ) ( usec % 1000000 ) * 1000UL ), - }; - - return linux_nanosleep ( &ts, NULL ); -} - -int linux_gettimeofday ( struct timeval *tv, struct timezone *tz ) { - return linux_syscall ( __NR_gettimeofday, tv, tz ); -} - -void * linux_mmap ( void *addr, __kernel_size_t length, int prot, int flags, - int fd, __kernel_off_t offset ) { - return ( void * ) linux_syscall ( __SYSCALL_mmap, addr, length, prot, - flags, fd, offset ); -} - -void * linux_mremap ( void *old_address, __kernel_size_t old_size, - __kernel_size_t new_size, int flags ) { - return ( void * ) linux_syscall ( __NR_mremap, old_address, old_size, - new_size, flags ); -} - -int linux_munmap ( void *addr, __kernel_size_t length ) { - return linux_syscall ( __NR_munmap, addr, length ); -} - -int linux_socket ( int domain, int type_, int protocol ) { -#ifdef __NR_socket - return linux_syscall ( __NR_socket, domain, type_, protocol ); -#else -#ifndef SOCKOP_socket -# define SOCKOP_socket 1 -#endif - unsigned long sc_args[] = { domain, type_, protocol }; - return linux_syscall ( __NR_socketcall, SOCKOP_socket, sc_args ); -#endif -} - -int linux_bind ( int fd, const struct sockaddr *addr, socklen_t addrlen ) { -#ifdef __NR_bind - return linux_syscall ( __NR_bind, fd, addr, addrlen ); -#else -#ifndef SOCKOP_bind -# define SOCKOP_bind 2 -#endif - unsigned long sc_args[] = { fd, (unsigned long)addr, addrlen }; - return linux_syscall ( __NR_socketcall, SOCKOP_bind, sc_args ); -#endif -} - -ssize_t linux_sendto ( int fd, const void *buf, size_t len, int flags, - const struct sockaddr *daddr, socklen_t addrlen ) { -#ifdef __NR_sendto - return linux_syscall ( __NR_sendto, fd, buf, len, flags, - daddr, addrlen ); -#else -#ifndef SOCKOP_sendto -# define SOCKOP_sendto 11 -#endif - unsigned long sc_args[] = { fd, (unsigned long)buf, len, - flags, (unsigned long)daddr, addrlen }; - return linux_syscall ( __NR_socketcall, SOCKOP_sendto, sc_args ); -#endif -} diff --git a/src/arch/x86/core/linux/linux_strerror.c b/src/arch/x86/core/linux/linux_strerror.c deleted file mode 100644 index 24c9b7738..000000000 --- a/src/arch/x86/core/linux/linux_strerror.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (C) 2010 Piotr Jaroszyński - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -FILE_LICENCE(GPL2_OR_LATER); - -/** @file - * - * linux_strerror implementation - */ - -#include -#include - -/** Error names from glibc */ -static const char *errors[] = { - "Success", - "Operation not permitted", - "No such file or directory", - "No such process", - "Interrupted system call", - "Input/output error", - "No such device or address", - "Argument list too long", - "Exec format error", - "Bad file descriptor", - "No child processes", - "Resource temporarily unavailable", - "Cannot allocate memory", - "Permission denied", - "Bad address", - "Block device required", - "Device or resource busy", - "File exists", - "Invalid cross-device link", - "No such device", - "Not a directory", - "Is a directory", - "Invalid argument", - "Too many open files in system", - "Too many open files", - "Inappropriate ioctl for device", - "Text file busy", - "File too large", - "No space left on device", - "Illegal seek", - "Read-only file system", - "Too many links", - "Broken pipe", - "Numerical argument out of domain", - "Numerical result out of range", - "Resource deadlock avoided", - "File name too long", - "No locks available", - "Function not implemented", - "Directory not empty", - "Too many levels of symbolic links", - "", - "No message of desired type", - "Identifier removed", - "Channel number out of range", - "Level 2 not synchronized", - "Level 3 halted", - "Level 3 reset", - "Link number out of range", - "Protocol driver not attached", - "No CSI structure available", - "Level 2 halted", - "Invalid exchange", - "Invalid request descriptor", - "Exchange full", - "No anode", - "Invalid request code", - "Invalid slot", - "", - "Bad font file format", - "Device not a stream", - "No data available", - "Timer expired", - "Out of streams resources", - "Machine is not on the network", - "Package not installed", - "Object is remote", - "Link has been severed", - "Advertise error", - "Srmount error", - "Communication error on send", - "Protocol error", - "Multihop attempted", - "RFS specific error", - "Bad message", - "Value too large for defined data type", - "Name not unique on network", - "File descriptor in bad state", - "Remote address changed", - "Can not access a needed shared library", - "Accessing a corrupted shared library", - ".lib section in a.out corrupted", - "Attempting to link in too many shared libraries", - "Cannot exec a shared library directly", - "Invalid or incomplete multibyte or wide character", - "Interrupted system call should be restarted", - "Streams pipe error", - "Too many users", - "Socket operation on non-socket", - "Destination address required", - "Message too long", - "Protocol wrong type for socket", - "Protocol not available", - "Protocol not supported", - "Socket type not supported", - "Operation not supported", - "Protocol family not supported", - "Address family not supported by protocol", - "Address already in use", - "Cannot assign requested address", - "Network is down", - "Network is unreachable", - "Network dropped connection on reset", - "Software caused connection abort", - "Connection reset by peer", - "No buffer space available", - "Transport endpoint is already connected", - "Transport endpoint is not connected", - "Cannot send after transport endpoint shutdown", - "Too many references: cannot splice", - "Connection timed out", - "Connection refused", - "Host is down", - "No route to host", - "Operation already in progress", - "Operation now in progress", - "Stale NFS file handle", - "Structure needs cleaning", - "Not a XENIX named type file", - "No XENIX semaphores available", - "Is a named type file", - "Remote I/O error", - "Disk quota exceeded", - "No medium found", - "Wrong medium type", -}; - -const char *linux_strerror(int errnum) -{ - static char errbuf[64]; - static int errors_size = sizeof(errors) / sizeof(*errors); - - if (errnum >= errors_size || errnum < 0) { - snprintf(errbuf, sizeof(errbuf), "Error %#08x", errnum); - return errbuf; - } else { - return errors[errnum]; - } -} diff --git a/src/arch/x86/include/bits/linux_api_platform.h b/src/arch/x86/include/bits/linux_api_platform.h deleted file mode 100644 index 4a9ced5e2..000000000 --- a/src/arch/x86/include/bits/linux_api_platform.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _LINUX_API_PLATFORM_H -#define _LINUX_API_PLATFORM_H - -extern int linux_errno; - -#endif /* _LINUX_API_PLATFORM_H */ diff --git a/src/arch/x86_64/Makefile.linux b/src/arch/x86_64/Makefile.linux index 154f9d40d..c41ee49df 100644 --- a/src/arch/x86_64/Makefile.linux +++ b/src/arch/x86_64/Makefile.linux @@ -1,6 +1,10 @@ -LDSCRIPT = arch/x86_64/scripts/linux.lds +# -*- makefile -*- : Force emacs to use Makefile mode -SRCDIRS += arch/x86_64/core/linux +# Linker script +# +LDSCRIPT = arch/x86_64/scripts/linux.lds +# Include generic Linux Makefile +# MAKEDEPS += arch/x86/Makefile.linux include arch/x86/Makefile.linux diff --git a/src/arch/x86_64/core/linux/linux_syscall.S b/src/arch/x86_64/core/linux/linux_syscall.S deleted file mode 100644 index d2805f94c..000000000 --- a/src/arch/x86_64/core/linux/linux_syscall.S +++ /dev/null @@ -1,33 +0,0 @@ - - .section ".data" - .globl linux_errno - -linux_errno: .int 0 - - .section ".text" - .code64 - .globl linux_syscall - .type linux_syscall, @function - -linux_syscall: - movq %rdi, %rax // C arg1 -> syscall number - movq %rsi, %rdi // C arg2 -> syscall arg1 - movq %rdx, %rsi // C arg3 -> syscall arg2 - movq %rcx, %rdx // C arg4 -> syscall arg3 - movq %r8, %r10 // C arg5 -> syscall arg4 - movq %r9, %r8 // C arg6 -> syscall arg5 - movq 8(%rsp), %r9 // C arg7 -> syscall arg6 - - syscall - - cmpq $-4095, %rax - jae 1f - ret - -1: - negq %rax - movl %eax, linux_errno - movq $-1, %rax - ret - - .size linux_syscall, . - linux_syscall diff --git a/src/arch/x86_64/core/linux/linuxprefix.S b/src/arch/x86_64/core/linux/linuxprefix.S deleted file mode 100644 index ec8a9decd..000000000 --- a/src/arch/x86_64/core/linux/linuxprefix.S +++ /dev/null @@ -1,25 +0,0 @@ -#include - - .section ".text" - .code64 - .globl _linux_start - .type _linux_start, @function - -_linux_start: - xorq %rbp, %rbp - - popq %rdi // argc -> C arg1 - movq %rsp, %rsi // argv -> C arg2 - - andq $~15, %rsp // 16-byte align the stack - - call save_args - - /* Our main doesn't use any arguments */ - call main - - movq %rax, %rdi // rc -> syscall arg1 - movq $__NR_exit, %rax - syscall - - .size _linux_start, . - _linux_start diff --git a/src/arch/x86_64/include/bits/linux_api.h b/src/arch/x86_64/include/bits/linux_api.h deleted file mode 100644 index 589fb5808..000000000 --- a/src/arch/x86_64/include/bits/linux_api.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _X86_64_LINUX_API_H -#define _X86_64_LINUX_API_H - -#define __SYSCALL_mmap __NR_mmap - -#endif /* _X86_64_LINUX_API_H */ diff --git a/src/drivers/linux/af_packet.c b/src/drivers/linux/af_packet.c index 65aafc5b1..9fa6ef2a5 100644 --- a/src/drivers/linux/af_packet.c +++ b/src/drivers/linux/af_packet.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/drivers/linux/tap.c b/src/drivers/linux/tap.c index db3b7955b..ff1e08bdb 100644 --- a/src/drivers/linux/tap.c +++ b/src/drivers/linux/tap.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/hci/linux_args.c b/src/hci/linux_args.c index 5f903e3b6..12020bd0b 100644 --- a/src/hci/linux_args.c +++ b/src/hci/linux_args.c @@ -18,7 +18,6 @@ FILE_LICENCE(GPL2_OR_LATER); -#include #include #include #include @@ -27,21 +26,8 @@ FILE_LICENCE(GPL2_OR_LATER); #include #include -/** Saved argc */ -static int saved_argc = 0; -/** Saved argv */ -static char ** saved_argv; - -/** - * Save argc and argv for later access. - * - * To be called by linuxprefix - */ -__asmcall void save_args(int argc, char **argv) -{ - saved_argc = argc; - saved_argv = argv; -} +int linux_argc; +char **linux_argv; /** Supported command-line options */ static struct option options[] = { @@ -138,7 +124,7 @@ void linux_args_parse() while (1) { int option_index = 0; - c = getopt_long(saved_argc, saved_argv, "", options, &option_index); + c = getopt_long(linux_argc, linux_argv, "", options, &option_index); if (c == -1) break; diff --git a/src/include/hci/linux_args.h b/src/include/hci/linux_args.h deleted file mode 100644 index ae1ed0526..000000000 --- a/src/include/hci/linux_args.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2010 Piotr Jaroszyński - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef _HCI_LINUX_ARGS_H -#define _HCI_LINUX_ARGS_H - -FILE_LICENCE(GPL2_OR_LATER); - -/** - * Save argc and argv for later access. - * - * To be called by linuxprefix - */ -extern __asmcall void save_args(int argc, char **argv); - -#endif /* _HCI_LINUX_ARGS_H */ diff --git a/src/include/ipxe/linux_api.h b/src/include/ipxe/linux_api.h new file mode 100644 index 000000000..ea247a613 --- /dev/null +++ b/src/include/ipxe/linux_api.h @@ -0,0 +1,86 @@ +#ifndef _IPXE_LINUX_API_H +#define _IPXE_LINUX_API_H + +/* + * Copyright (C) 2010 Piotr Jaroszyński . + * Copyright (C) 2021 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** @file + * + * Linux host API + * + * This file is included from both the iPXE build environment and the + * host build environment. + * + */ + +#if __STDC_HOSTED__ +#define __asmcall +#define FILE_LICENCE(x) +#endif + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include + +#if ! __STDC_HOSTED__ +#define __KERNEL_STRICT_NAMES +#include +#include +#include +#include +#include +#include +#define MAP_FAILED ( ( void * ) -1 ) +#endif + +struct sockaddr; + +extern int linux_errno; +extern int linux_argc; +extern char **linux_argv; + +extern int __asmcall linux_open ( const char *pathname, int flags, ... ); +extern int __asmcall linux_close ( int fd ); +extern off_t __asmcall linux_lseek ( int fd, off_t offset, int whence ); +extern ssize_t __asmcall linux_read ( int fd, void *buf, size_t count ); +extern ssize_t __asmcall linux_write ( int fd, const void *buf, size_t count ); +extern int __asmcall linux_fcntl ( int fd, int cmd, ... ); +extern int __asmcall linux_ioctl ( int fd, unsigned long request, ... ); +extern int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds, + int timeout ); +extern int __asmcall linux_nanosleep ( const struct timespec *req, + struct timespec *rem ); +extern int __asmcall linux_usleep ( unsigned int usec ); +extern int __asmcall linux_gettimeofday ( struct timeval *tv, + struct timezone *tz ); +extern void * __asmcall linux_mmap ( void *addr, size_t length, int prot, + int flags, int fd, off_t offset ); +extern void * __asmcall linux_mremap ( void *old_address, size_t old_size, + size_t new_size, int flags, ... ); +extern int __asmcall linux_munmap ( void *addr, size_t length ); +extern int __asmcall linux_socket ( int domain, int type, int protocol ); +extern int __asmcall linux_bind ( int sockfd, const struct sockaddr *addr, + size_t addrlen ); +extern ssize_t __asmcall linux_sendto ( int sockfd, const void *buf, + size_t len, int flags, + const struct sockaddr *dest_addr, + size_t addrlen ); +extern const char * __asmcall linux_strerror ( int linux_errno ); + +#endif /* _IPXE_LINUX_API_H */ diff --git a/src/include/linux_api.h b/src/include/linux_api.h deleted file mode 100644 index fe9fa910f..000000000 --- a/src/include/linux_api.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2010 Piotr Jaroszyński - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef _LINUX_API_H -#define _LINUX_API_H - -/** * @file - * - * Linux API prototypes. - * Most of the functions map directly to linux syscalls and are the equivalent - * of POSIX functions with the linux_ prefix removed. - */ - -FILE_LICENCE(GPL2_OR_LATER); - -#include -#include - -#include - -#define __KERNEL_STRICT_NAMES -#include -#include -typedef __kernel_pid_t pid_t; -typedef __kernel_suseconds_t suseconds_t; -typedef __kernel_loff_t loff_t; -#include -#include -#include -#include -#include -typedef unsigned long nfds_t; -typedef uint32_t useconds_t; -typedef uint32_t socklen_t; -struct sockaddr; -#define MAP_FAILED ( ( void * ) -1 ) -#define SEEK_SET 0 - -extern long linux_syscall ( int number, ... ); - -extern int linux_open ( const char *pathname, int flags ); -extern int linux_close ( int fd ); -extern off_t linux_lseek ( int fd, off_t offset, int whence ); -extern __kernel_ssize_t linux_read ( int fd, void *buf, __kernel_size_t count ); -extern __kernel_ssize_t linux_write ( int fd, const void *buf, - __kernel_size_t count ); -extern int linux_fcntl ( int fd, int cmd, ... ); -extern int linux_ioctl ( int fd, int request, ... ); -extern int linux_poll ( struct pollfd *fds, nfds_t nfds, int timeout ); -extern int linux_nanosleep ( const struct timespec *req, struct timespec *rem ); -extern int linux_usleep ( useconds_t usec ); -extern int linux_gettimeofday ( struct timeval *tv, struct timezone *tz ); -extern void * linux_mmap ( void *addr, __kernel_size_t length, int prot, - int flags, int fd, off_t offset ); -extern void * linux_mremap ( void *old_address, __kernel_size_t old_size, - __kernel_size_t new_size, int flags ); -extern int linux_munmap ( void *addr, __kernel_size_t length ); -extern int linux_socket ( int domain, int type_, int protocol ); -extern int linux_bind ( int fd, const struct sockaddr *addr, - socklen_t addrlen ); -extern ssize_t linux_sendto ( int fd, const void *buf, size_t len, int flags, - const struct sockaddr *daddr, socklen_t addrlen ); - -extern const char * linux_strerror ( int errnum ); - -#endif /* _LINUX_API_H */ diff --git a/src/interface/linux/linux_api.c b/src/interface/linux/linux_api.c new file mode 100644 index 000000000..4ab3c6603 --- /dev/null +++ b/src/interface/linux/linux_api.c @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2010 Piotr Jaroszyński . + * Copyright (C) 2021 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** @file + * + * Linux host API + * + */ + +/** Construct prefixed symbol name */ +#define _C1( x, y ) x ## y +#define _C2( x, y ) _C1 ( x, y ) + +/** Construct prefixed symbol name for iPXE symbols */ +#define IPXE_SYM( symbol ) _C2 ( SYMBOL_PREFIX, symbol ) + +/** Provide a prefixed symbol alias visible to iPXE code */ +#define PROVIDE_IPXE_SYM( symbol ) \ + extern typeof ( symbol ) IPXE_SYM ( symbol ) \ + __attribute__ (( alias ( #symbol) )) + +/** Most recent system call error */ +int linux_errno __attribute__ (( nocommon )); + +/****************************************************************************** + * + * Host entry point + * + ****************************************************************************** + */ + +extern int IPXE_SYM ( _linux_start ) ( int argc, char **argv ); + +/** + * Main entry point + * + * @v argc Argument count + * @v argv Argument list + * @ret rc Exit status + */ +int main ( int argc, char **argv ) { + + return IPXE_SYM ( _linux_start ) ( argc, argv ); +} + +/****************************************************************************** + * + * System call wrappers + * + ****************************************************************************** + */ + +/** + * Wrap open() + * + */ +int __asmcall linux_open ( const char *pathname, int flags, ... ) { + va_list args; + mode_t mode; + int ret; + + va_start ( args, flags ); + mode = va_arg ( args, mode_t ); + va_end ( args ); + ret = open ( pathname, flags, mode ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap close() + * + */ +int __asmcall linux_close ( int fd ) { + int ret; + + ret = close ( fd ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap lseek() + * + */ +off_t __asmcall linux_lseek ( int fd, off_t offset, int whence ) { + off_t ret; + + ret = lseek ( fd, offset, whence ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap read() + * + */ +ssize_t __asmcall linux_read ( int fd, void *buf, size_t count ) { + ssize_t ret; + + ret = read ( fd, buf, count ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap write() + * + */ +ssize_t __asmcall linux_write ( int fd, const void *buf, size_t count ) { + ssize_t ret; + + ret = write ( fd, buf, count ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap fcntl() + * + */ +int __asmcall linux_fcntl ( int fd, int cmd, ... ) { + va_list args; + long arg; + int ret; + + va_start ( args, cmd ); + arg = va_arg ( args, long ); + va_end ( args ); + ret = fcntl ( fd, cmd, arg ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap ioctl() + * + */ +int __asmcall linux_ioctl ( int fd, unsigned long request, ... ) { + va_list args; + void *arg; + int ret; + + va_start ( args, request ); + arg = va_arg ( args, void * ); + va_end ( args ); + ret = ioctl ( fd, request, arg ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap poll() + * + */ +int __asmcall linux_poll ( struct pollfd *fds, unsigned int nfds, + int timeout ) { + int ret; + + ret = poll ( fds, nfds, timeout ); + if ( ret == -1 ) + linux_errno = errno; +} + +/** + * Wrap nanosleep() + * + */ +int __asmcall linux_nanosleep ( const struct timespec *req, + struct timespec *rem ) { + int ret; + + ret = nanosleep ( req, rem ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap usleep() + * + */ +int __asmcall linux_usleep ( unsigned int usec ) { + int ret; + + ret = usleep ( usec ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap gettimeofday() + * + */ +int __asmcall linux_gettimeofday ( struct timeval *tv, struct timezone *tz ) { + int ret; + + ret = gettimeofday ( tv, tz ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap mmap() + * +*/ +void * __asmcall linux_mmap ( void *addr, size_t length, int prot, int flags, + int fd, off_t offset ) { + void *ret; + + ret = mmap ( addr, length, prot, flags, fd, offset ); + if ( ret == MAP_FAILED ) + linux_errno = errno; + return ret; +} + +/** + * Wrap mremap() + * + */ +void * __asmcall linux_mremap ( void *old_address, size_t old_size, + size_t new_size, int flags, ... ) { + va_list args; + void *new_address; + void *ret; + + va_start ( args, flags ); + new_address = va_arg ( args, void * ); + va_end ( args ); + ret = mremap ( old_address, old_size, new_size, flags, new_address ); + if ( ret == MAP_FAILED ) + linux_errno = errno; + return ret; +} + +/** + * Wrap munmap() + * + */ +int __asmcall linux_munmap ( void *addr, size_t length ) { + int ret; + + ret = munmap ( addr, length ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap socket() + * + */ +int __asmcall linux_socket ( int domain, int type, int protocol ) { + int ret; + + ret = socket ( domain, type, protocol ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap bind() + * + */ +int __asmcall linux_bind ( int sockfd, const struct sockaddr *addr, + size_t addrlen ) { + int ret; + + ret = bind ( sockfd, addr, addrlen ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/** + * Wrap sendto() + * + */ +ssize_t __asmcall linux_sendto ( int sockfd, const void *buf, size_t len, + int flags, const struct sockaddr *dest_addr, + size_t addrlen ) { + ssize_t ret; + + ret = sendto ( sockfd, buf, len, flags, dest_addr, addrlen ); + if ( ret == -1 ) + linux_errno = errno; + return ret; +} + +/****************************************************************************** + * + * C library wrappers + * + ****************************************************************************** + */ + +/** + * Wrap strerror() + * + */ +const char * __asmcall linux_strerror ( int linux_errno ) { + + return strerror ( linux_errno ); +} + +/****************************************************************************** + * + * Symbol aliases + * + ****************************************************************************** + */ + +PROVIDE_IPXE_SYM ( linux_errno ); +PROVIDE_IPXE_SYM ( linux_open ); +PROVIDE_IPXE_SYM ( linux_close ); +PROVIDE_IPXE_SYM ( linux_lseek ); +PROVIDE_IPXE_SYM ( linux_read ); +PROVIDE_IPXE_SYM ( linux_write ); +PROVIDE_IPXE_SYM ( linux_fcntl ); +PROVIDE_IPXE_SYM ( linux_ioctl ); +PROVIDE_IPXE_SYM ( linux_poll ); +PROVIDE_IPXE_SYM ( linux_nanosleep ); +PROVIDE_IPXE_SYM ( linux_usleep ); +PROVIDE_IPXE_SYM ( linux_gettimeofday ); +PROVIDE_IPXE_SYM ( linux_mmap ); +PROVIDE_IPXE_SYM ( linux_mremap ); +PROVIDE_IPXE_SYM ( linux_munmap ); +PROVIDE_IPXE_SYM ( linux_socket ); +PROVIDE_IPXE_SYM ( linux_bind ); +PROVIDE_IPXE_SYM ( linux_sendto ); +PROVIDE_IPXE_SYM ( linux_strerror ); diff --git a/src/interface/linux/linux_console.c b/src/interface/linux/linux_console.c index 5294fca79..d5415b61c 100644 --- a/src/interface/linux/linux_console.c +++ b/src/interface/linux/linux_console.c @@ -28,7 +28,7 @@ FILE_LICENCE(GPL2_OR_LATER); #include #include -#include +#include #include #include diff --git a/src/interface/linux/linux_entropy.c b/src/interface/linux/linux_entropy.c index 0f8e45d36..257e993a0 100644 --- a/src/interface/linux/linux_entropy.c +++ b/src/interface/linux/linux_entropy.c @@ -31,7 +31,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#include +#include #include /** Entropy source filename */ diff --git a/src/interface/linux/linux_nap.c b/src/interface/linux/linux_nap.c index f1d3cd962..3e77bc7f1 100644 --- a/src/interface/linux/linux_nap.c +++ b/src/interface/linux/linux_nap.c @@ -21,7 +21,7 @@ FILE_LICENCE(GPL2_OR_LATER); #include -#include +#include /** @file * diff --git a/src/interface/linux/linux_pci.c b/src/interface/linux/linux_pci.c index 0c140cb89..99c629c19 100644 --- a/src/interface/linux/linux_pci.c +++ b/src/interface/linux/linux_pci.c @@ -26,7 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include +#include #include #include diff --git a/src/interface/linux/linux_smbios.c b/src/interface/linux/linux_smbios.c index 6e5174d23..494a60bd9 100644 --- a/src/interface/linux/linux_smbios.c +++ b/src/interface/linux/linux_smbios.c @@ -20,7 +20,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include -#include +#include #include #include diff --git a/src/interface/linux/linux_time.c b/src/interface/linux/linux_time.c index 9e99fe9cd..9d410f8e0 100644 --- a/src/interface/linux/linux_time.c +++ b/src/interface/linux/linux_time.c @@ -32,7 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include #include -#include +#include #include /** diff --git a/src/interface/linux/linux_timer.c b/src/interface/linux/linux_timer.c index 9c5e96f2b..418fd046a 100644 --- a/src/interface/linux/linux_timer.c +++ b/src/interface/linux/linux_timer.c @@ -21,7 +21,7 @@ FILE_LICENCE(GPL2_OR_LATER); #include #include -#include +#include /** @file * diff --git a/src/interface/linux/linux_umalloc.c b/src/interface/linux/linux_umalloc.c index aa0052c53..a7250fa5b 100644 --- a/src/interface/linux/linux_umalloc.c +++ b/src/interface/linux/linux_umalloc.c @@ -29,7 +29,7 @@ FILE_LICENCE(GPL2_OR_LATER); #include #include -#include +#include /** Special address returned for empty allocations */ #define NOWHERE ((void *)-1) diff --git a/src/interface/linux/linuxprefix.c b/src/interface/linux/linuxprefix.c new file mode 100644 index 000000000..f38236202 --- /dev/null +++ b/src/interface/linux/linuxprefix.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2021 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include +#include + +/** + * Linux entry point + * + * @v argc Argument count + * @v argv Argument list + * @ret rc Return status code + */ +int __asmcall _linux_start ( int argc, char **argv ) { + + /* Store command-line arguments */ + linux_argc = argc; + linux_argv = argv; + + /* Run iPXE */ + return main(); +} -- cgit v1.2.3-55-g7522 From 9776f6ece1104cc32de3249844a8a7387112f32f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 1 Mar 2021 00:08:23 +0000 Subject: [acpi] Allow for platforms that provide ACPI tables individually The ACPI API currently expects platforms to provide access to a single contiguous ACPI table. Some platforms (e.g. Linux userspace) do not provide a convenient way to obtain the entire ACPI table, but do provide access to individual tables. All iPXE consumers of the ACPI API require access only to individual tables. Redefine the internal API to make acpi_find() an API method, with all existing implementations delegating to the current RSDT-based implementation. Signed-off-by: Michael Brown --- src/arch/x86/include/ipxe/rsdp.h | 13 +++++++++++++ src/arch/x86/interface/pcbios/rsdp.c | 1 + src/core/acpi.c | 4 ++-- src/core/null_acpi.c | 2 +- src/include/ipxe/acpi.h | 12 +++++++++++- src/include/ipxe/efi/efi_acpi.h | 13 +++++++++++++ src/include/ipxe/null_acpi.h | 6 ++++-- src/interface/efi/efi_acpi.c | 1 + 8 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/include/ipxe/rsdp.h b/src/arch/x86/include/ipxe/rsdp.h index 7e32c0011..14afcd774 100644 --- a/src/arch/x86/include/ipxe/rsdp.h +++ b/src/arch/x86/include/ipxe/rsdp.h @@ -15,4 +15,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ACPI_PREFIX_rsdp __rsdp_ #endif +/** + * Locate ACPI table + * + * @v signature Requested table signature + * @v index Requested index of table with this signature + * @ret table Table, or UNULL if not found + */ +static inline __attribute__ (( always_inline )) userptr_t +ACPI_INLINE ( rsdp, acpi_find ) ( uint32_t signature, unsigned int index ) { + + return acpi_find_via_rsdt ( signature, index ); +} + #endif /* _IPXE_RSDP_H */ diff --git a/src/arch/x86/interface/pcbios/rsdp.c b/src/arch/x86/interface/pcbios/rsdp.c index 8da0b5588..3c67b7525 100644 --- a/src/arch/x86/interface/pcbios/rsdp.c +++ b/src/arch/x86/interface/pcbios/rsdp.c @@ -123,3 +123,4 @@ static userptr_t rsdp_find_rsdt ( void ) { } PROVIDE_ACPI ( rsdp, acpi_find_rsdt, rsdp_find_rsdt ); +PROVIDE_ACPI_INLINE ( rsdp, acpi_find ); diff --git a/src/core/acpi.c b/src/core/acpi.c index 75511736d..52eb63a04 100644 --- a/src/core/acpi.c +++ b/src/core/acpi.c @@ -83,13 +83,13 @@ void acpi_fix_checksum ( struct acpi_header *acpi ) { } /** - * Locate ACPI table + * Locate ACPI table via RSDT * * @v signature Requested table signature * @v index Requested index of table with this signature * @ret table Table, or UNULL if not found */ -userptr_t acpi_find ( uint32_t signature, unsigned int index ) { +userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ) { struct acpi_header acpi; struct acpi_rsdt *rsdtab; typeof ( rsdtab->entry[0] ) entry; diff --git a/src/core/null_acpi.c b/src/core/null_acpi.c index 90c784855..acca37872 100644 --- a/src/core/null_acpi.c +++ b/src/core/null_acpi.c @@ -1,3 +1,3 @@ #include -PROVIDE_ACPI_INLINE ( null, acpi_find_rsdt ); +PROVIDE_ACPI_INLINE ( null, acpi_find ); diff --git a/src/include/ipxe/acpi.h b/src/include/ipxe/acpi.h index f979ace45..6d19f05fa 100644 --- a/src/include/ipxe/acpi.h +++ b/src/include/ipxe/acpi.h @@ -355,6 +355,8 @@ struct acpi_model { #define PROVIDE_ACPI_INLINE( _subsys, _api_func ) \ PROVIDE_SINGLE_API_INLINE ( ACPI_PREFIX_ ## _subsys, _api_func ) +extern userptr_t acpi_find_via_rsdt ( uint32_t signature, unsigned int index ); + /* Include all architecture-independent ACPI API headers */ #include #include @@ -369,13 +371,21 @@ struct acpi_model { */ userptr_t acpi_find_rsdt ( void ); +/** + * Locate ACPI table + * + * @v signature Requested table signature + * @v index Requested index of table with this signature + * @ret table Table, or UNULL if not found + */ +userptr_t acpi_find ( uint32_t signature, unsigned int index ); + extern struct acpi_descriptor * acpi_describe ( struct interface *interface ); #define acpi_describe_TYPE( object_type ) \ typeof ( struct acpi_descriptor * ( object_type ) ) extern void acpi_fix_checksum ( struct acpi_header *acpi ); -extern userptr_t acpi_find ( uint32_t signature, unsigned int index ); extern int acpi_sx ( uint32_t signature ); extern void acpi_add ( struct acpi_descriptor *desc ); extern void acpi_del ( struct acpi_descriptor *desc ); diff --git a/src/include/ipxe/efi/efi_acpi.h b/src/include/ipxe/efi/efi_acpi.h index 01456f137..a698863a6 100644 --- a/src/include/ipxe/efi/efi_acpi.h +++ b/src/include/ipxe/efi/efi_acpi.h @@ -15,4 +15,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ACPI_PREFIX_efi __efi_ #endif +/** + * Locate ACPI table + * + * @v signature Requested table signature + * @v index Requested index of table with this signature + * @ret table Table, or UNULL if not found + */ +static inline __attribute__ (( always_inline )) userptr_t +ACPI_INLINE ( efi, acpi_find ) ( uint32_t signature, unsigned int index ) { + + return acpi_find_via_rsdt ( signature, index ); +} + #endif /* _IPXE_EFI_ACPI_H */ diff --git a/src/include/ipxe/null_acpi.h b/src/include/ipxe/null_acpi.h index 1e469e33d..cedb02839 100644 --- a/src/include/ipxe/null_acpi.h +++ b/src/include/ipxe/null_acpi.h @@ -15,8 +15,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #define ACPI_PREFIX_null __null_ #endif -static inline __always_inline userptr_t -ACPI_INLINE ( null, acpi_find_rsdt ) ( void ) { +static inline __attribute__ (( always_inline )) userptr_t +ACPI_INLINE ( null, acpi_find ) ( uint32_t signature __unused, + unsigned int index __unused ) { + return UNULL; } diff --git a/src/interface/efi/efi_acpi.c b/src/interface/efi/efi_acpi.c index a347eaf3a..07a225632 100644 --- a/src/interface/efi/efi_acpi.c +++ b/src/interface/efi/efi_acpi.c @@ -54,3 +54,4 @@ static userptr_t efi_find_rsdt ( void ) { } PROVIDE_ACPI ( efi, acpi_find_rsdt, efi_find_rsdt ); +PROVIDE_ACPI_INLINE ( efi, acpi_find ); -- cgit v1.2.3-55-g7522 From 916ebef1984e9caa05646463734b51202b405774 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 2 Mar 2021 10:15:23 +0000 Subject: [build] Allow __asmcall to be used as a type attribute The "used" attribute can be applied only to functions or variables, which prevents the use of __asmcall as a type attribute. Fix by removing "used" from the definition of __asmcall for i386 and x86_64 architectures, and adding explicit __used annotations where necessary. Signed-off-by: Michael Brown --- src/arch/i386/include/bits/compiler.h | 2 +- src/arch/x86/interface/pcbios/bios_console.c | 2 +- src/arch/x86/interface/pcbios/int13.c | 2 +- src/arch/x86/interface/syslinux/comboot_call.c | 6 +++--- src/arch/x86/transitions/librm_test.c | 3 ++- src/arch/x86_64/include/bits/compiler.h | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/arch') diff --git a/src/arch/i386/include/bits/compiler.h b/src/arch/i386/include/bits/compiler.h index 7c4a09396..87201135f 100644 --- a/src/arch/i386/include/bits/compiler.h +++ b/src/arch/i386/include/bits/compiler.h @@ -9,7 +9,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY /** Declare a function with standard calling conventions */ -#define __asmcall __attribute__ (( used, cdecl, regparm(0) )) +#define __asmcall __attribute__ (( cdecl, regparm(0) )) /** * Declare a function with libgcc implicit linkage diff --git a/src/arch/x86/interface/pcbios/bios_console.c b/src/arch/x86/interface/pcbios/bios_console.c index 52a02fba5..80ebf330e 100644 --- a/src/arch/x86/interface/pcbios/bios_console.c +++ b/src/arch/x86/interface/pcbios/bios_console.c @@ -443,7 +443,7 @@ struct console_driver bios_console __console_driver = { * * @v ix86 Registers as passed to INT 16 */ -static __asmcall void bios_inject ( struct i386_all_regs *ix86 ) { +static __asmcall __used void bios_inject ( struct i386_all_regs *ix86 ) { unsigned int discard_a; unsigned int scancode; unsigned int i; diff --git a/src/arch/x86/interface/pcbios/int13.c b/src/arch/x86/interface/pcbios/int13.c index ca789a0d1..30530e197 100644 --- a/src/arch/x86/interface/pcbios/int13.c +++ b/src/arch/x86/interface/pcbios/int13.c @@ -1064,7 +1064,7 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev, * INT 13 handler * */ -static __asmcall void int13 ( struct i386_all_regs *ix86 ) { +static __asmcall __used void int13 ( struct i386_all_regs *ix86 ) { int command = ix86->regs.ah; unsigned int bios_drive = ix86->regs.dl; struct san_device *sandev; diff --git a/src/arch/x86/interface/syslinux/comboot_call.c b/src/arch/x86/interface/syslinux/comboot_call.c index e70f200e3..dc308dafe 100644 --- a/src/arch/x86/interface/syslinux/comboot_call.c +++ b/src/arch/x86/interface/syslinux/comboot_call.c @@ -220,7 +220,7 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) { /** * Terminate program interrupt handler */ -static __asmcall void int20 ( struct i386_all_regs *ix86 __unused ) { +static __asmcall __used void int20 ( struct i386_all_regs *ix86 __unused ) { rmlongjmp ( comboot_return, COMBOOT_EXIT ); } @@ -228,7 +228,7 @@ static __asmcall void int20 ( struct i386_all_regs *ix86 __unused ) { /** * DOS-compatible API */ -static __asmcall void int21 ( struct i386_all_regs *ix86 ) { +static __asmcall __used void int21 ( struct i386_all_regs *ix86 ) { ix86->flags |= CF; switch ( ix86->regs.ah ) { @@ -311,7 +311,7 @@ __weak int pxe_api_call_weak ( struct i386_all_regs *ix86 __unused ) { /** * SYSLINUX API */ -static __asmcall void int22 ( struct i386_all_regs *ix86 ) { +static __asmcall __used void int22 ( struct i386_all_regs *ix86 ) { ix86->flags |= CF; switch ( ix86->regs.ax ) { diff --git a/src/arch/x86/transitions/librm_test.c b/src/arch/x86/transitions/librm_test.c index 77cf8022c..347d86a15 100644 --- a/src/arch/x86/transitions/librm_test.c +++ b/src/arch/x86/transitions/librm_test.c @@ -58,7 +58,8 @@ static struct profiler virt_call_profiler __profiler = { .name = "virt_call" }; /** * Dummy function for profiling tests */ -static __asmcall void librm_test_call ( struct i386_all_regs *ix86 __unused ) { +static __asmcall __used void +librm_test_call ( struct i386_all_regs *ix86 __unused ) { /* Do nothing */ } diff --git a/src/arch/x86_64/include/bits/compiler.h b/src/arch/x86_64/include/bits/compiler.h index 46985da3e..5129f90d0 100644 --- a/src/arch/x86_64/include/bits/compiler.h +++ b/src/arch/x86_64/include/bits/compiler.h @@ -9,7 +9,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #ifndef ASSEMBLY /** Declare a function with standard calling conventions */ -#define __asmcall __attribute__ (( used, regparm(0) )) +#define __asmcall __attribute__ (( regparm(0) )) /** Declare a function with libgcc implicit linkage */ #define __libgcc -- cgit v1.2.3-55-g7522