Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[x86_64] Fix assorted 64-bit compilation errors and warnings
Remove various 32-bit assumptions scattered throughout the codebase.
The code is still not necessarily 64-bit clean, but will at least
compile.
  • Loading branch information
Michael Brown committed Nov 19, 2008
1 parent 7d36a1b commit 0ebbbb9
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 70 deletions.
1 change: 1 addition & 0 deletions src/drivers/infiniband/arbel.c
Expand Up @@ -27,6 +27,7 @@
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/malloc.h>
#include <gpxe/umalloc.h>
Expand Down
1 change: 1 addition & 0 deletions src/drivers/infiniband/hermon.c
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <errno.h>
#include <byteswap.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/malloc.h>
#include <gpxe/umalloc.h>
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/infiniband/linda.c
Expand Up @@ -21,6 +21,7 @@
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/infiniband.h>
#include <gpxe/i2c.h>
Expand Down Expand Up @@ -1065,7 +1066,7 @@ static int linda_post_recv ( struct ib_device *ibdev,
return -EINVAL;
}
if ( len != LINDA_RECV_PAYLOAD_SIZE ) {
DBGC ( linda, "Linda %p QPN %ld wrong RX buffer size (%d)\n",
DBGC ( linda, "Linda %p QPN %ld wrong RX buffer size (%zd)\n",
linda, qp->qpn, len );
return -EINVAL;
}
Expand Down
20 changes: 10 additions & 10 deletions src/drivers/net/dmfe.c
Expand Up @@ -133,14 +133,14 @@
/* Structure/enum declaration ------------------------------- */
struct tx_desc {
u32 tdes0, tdes1, tdes2, tdes3; /* Data for the card */
u32 tx_buf_ptr; /* Data for us */
u32 /* struct tx_desc * */ next_tx_desc;
void * tx_buf_ptr; /* Data for us */
struct tx_desc * next_tx_desc;
} __attribute__ ((aligned(32)));

struct rx_desc {
u32 rdes0, rdes1, rdes2, rdes3; /* Data for the card */
u32 rx_skb_ptr; /* Data for us */
u32 /* struct rx_desc * */ next_rx_desc;
void * rx_skb_ptr; /* Data for us */
struct rx_desc * next_rx_desc;
} __attribute__ ((aligned(32)));

static struct dmfe_private {
Expand Down Expand Up @@ -522,30 +522,30 @@ static void dmfe_descriptor_init(struct nic *nic __unused, unsigned long ioaddr)

/* Init Transmit chain */
for (i = 0; i < TX_DESC_CNT; i++) {
txd[i].tx_buf_ptr = (u32) & txb[i];
txd[i].tx_buf_ptr = &txb[i];
txd[i].tdes0 = cpu_to_le32(0);
txd[i].tdes1 = cpu_to_le32(0x81000000); /* IC, chain */
txd[i].tdes2 = cpu_to_le32(virt_to_bus(&txb[i]));
txd[i].tdes3 = cpu_to_le32(virt_to_bus(&txd[i + 1]));
txd[i].next_tx_desc = virt_to_le32desc(&txd[i + 1]);
txd[i].next_tx_desc = &txd[i + 1];
}
/* Mark the last entry as wrapping the ring */
txd[i - 1].tdes3 = virt_to_le32desc(&txd[0]);
txd[i - 1].next_tx_desc = (u32) & txd[0];
txd[i - 1].next_tx_desc = &txd[0];

/* receive descriptor chain */
for (i = 0; i < RX_DESC_CNT; i++) {
rxd[i].rx_skb_ptr = (u32) & rxb[i * RX_ALLOC_SIZE];
rxd[i].rx_skb_ptr = &rxb[i * RX_ALLOC_SIZE];
rxd[i].rdes0 = cpu_to_le32(0x80000000);
rxd[i].rdes1 = cpu_to_le32(0x01000600);
rxd[i].rdes2 =
cpu_to_le32(virt_to_bus(&rxb[i * RX_ALLOC_SIZE]));
rxd[i].rdes3 = cpu_to_le32(virt_to_bus(&rxd[i + 1]));
rxd[i].next_rx_desc = virt_to_le32desc(&rxd[i + 1]);
rxd[i].next_rx_desc = &rxd[i + 1];
}
/* Mark the last entry as wrapping the ring */
rxd[i - 1].rdes3 = cpu_to_le32(virt_to_bus(&rxd[0]));
rxd[i - 1].next_rx_desc = virt_to_le32desc(&rxd[0]);
rxd[i - 1].next_rx_desc = &rxd[0];

}

Expand Down
7 changes: 4 additions & 3 deletions src/drivers/net/etherfabric.c
Expand Up @@ -22,6 +22,7 @@
#include <assert.h>
#include <byteswap.h>
#include <console.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/malloc.h>
#include <gpxe/ethernet.h>
Expand Down Expand Up @@ -1449,7 +1450,7 @@ falcon_spi_rw ( struct spi_bus* bus, struct spi_device *device,
return -EINVAL;
}

EFAB_TRACE ( "Executing spi command %d on device %d at %d for %d bytes\n",
EFAB_TRACE ( "Executing spi command %d on device %d at %d for %zd bytes\n",
command, device_id, address, len );

/* The bus must be idle */
Expand Down Expand Up @@ -1497,7 +1498,7 @@ falcon_spi_rw ( struct spi_bus* bus, struct spi_device *device,

fail2:
fail1:
EFAB_ERR ( "Failed SPI command %d to device %d address 0x%x len 0x%x\n",
EFAB_ERR ( "Failed SPI command %d to device %d address 0x%x len 0x%zx\n",
command, device_id, address, len );

return rc;
Expand Down Expand Up @@ -3763,7 +3764,7 @@ efab_transmit ( struct net_device *netdev, struct io_buffer *iob )
assert ( tx_queue->buf[buf_id] == NULL );
tx_queue->buf[buf_id] = iob;

EFAB_TRACE ( "tx_buf[%d] for iob %p data %p len %d\n",
EFAB_TRACE ( "tx_buf[%d] for iob %p data %p len %zd\n",
buf_id, iob, iob->data, iob_len ( iob ) );

/* Form the descriptor, and push it to hardware */
Expand Down
5 changes: 3 additions & 2 deletions src/drivers/net/mtnic.c
Expand Up @@ -37,6 +37,7 @@
#include <gpxe/umalloc.h>
#include <byteswap.h>
#include <unistd.h>
#include <gpxe/io.h>
#include <gpxe/pci.h>
#include <gpxe/ethernet.h>
#include <gpxe/netdevice.h>
Expand Down Expand Up @@ -1618,8 +1619,8 @@ mtnic_disable(struct pci_device *pci)

free(priv->cmd.buf);
iounmap(priv->hcr);
ufree((u32)priv->fw.fw_pages.buf);
ufree((u32)priv->fw.extra_pages.buf);
ufree((intptr_t)priv->fw.fw_pages.buf);
ufree((intptr_t)priv->fw.extra_pages.buf);
free(priv->eq.buf);
iounmap(priv->eq_db);
priv->state = CARD_DOWN;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/net/prism2.c
Expand Up @@ -118,7 +118,7 @@ static const char hardcoded_ssid[] = "";
typedef struct hfa384x
{
UINT32 iobase;
UINT32 membase;
void *membase;
UINT16 lastcmd;
UINT16 status; /* in host order */
UINT16 resp0; /* in host order */
Expand Down
9 changes: 3 additions & 6 deletions src/drivers/net/prism2_pci.c
Expand Up @@ -22,14 +22,11 @@ Written by Michael Brown of Fen Systems Ltd

static int prism2_pci_probe ( struct nic *nic, struct pci_device *pci ) {
hfa384x_t *hw = &hw_global;
uint32_t membase = 0; /* Prism2.5 Memory Base */

pci_read_config_dword( pci, PRISM2_PCI_MEM_BASE, &membase);
membase &= PCI_BASE_ADDRESS_MEM_MASK;
hw->membase = (uint32_t) phys_to_virt(membase);
printf ( "Prism2.5 has registers at %#lx\n", hw->membase );
printf ( "Prism2.5 has registers at %#lx\n", pci->membase );
hw->membase = ioremap ( pci->membase, 0x100 );

nic->ioaddr = hw->membase;
nic->ioaddr = pci->membase;
nic->irqno = 0;

return prism2_probe ( nic, hw );
Expand Down
1 change: 0 additions & 1 deletion src/drivers/net/prism2_plx.c
Expand Up @@ -48,7 +48,6 @@ static int prism2_find_plx ( hfa384x_t *hw, struct pci_device *p )
iobase &= PCI_BASE_ADDRESS_IO_MASK;

/* Fill out hw structure */
hw->membase = attr_mem;
hw->iobase = iobase;
printf ( "PLX9052 has local config registers at %#x\n", plx_lcr );
printf ( "Prism2 has attribute memory at %#x and I/O base at %#x\n", attr_mem, iobase );
Expand Down
32 changes: 18 additions & 14 deletions src/drivers/net/via-rhine.c
Expand Up @@ -1194,40 +1194,44 @@ rhine_reset (struct nic *nic)
int ioaddr = tp->ioaddr;
int i, j;
int FDXFlag, CRbak;
int rx_ring_tmp, rx_ring_tmp1;
int tx_ring_tmp, tx_ring_tmp1;
int rx_bufs_tmp, rx_bufs_tmp1;
int tx_bufs_tmp, tx_bufs_tmp1;
void *rx_ring_tmp;
void *tx_ring_tmp;
void *rx_bufs_tmp;
void *tx_bufs_tmp;
unsigned long rx_ring_tmp1;
unsigned long tx_ring_tmp1;
unsigned long rx_bufs_tmp1;
unsigned long tx_bufs_tmp1;

/* printf ("rhine_reset\n"); */
/* Soft reset the chip. */
/*outb(CmdReset, ioaddr + ChipCmd); */

tx_bufs_tmp = (int) rhine_buffers.txbuf;
tx_ring_tmp = (int) rhine_buffers.txdesc;
rx_bufs_tmp = (int) rhine_buffers.rxbuf;
rx_ring_tmp = (int) rhine_buffers.rxdesc;
tx_bufs_tmp = rhine_buffers.txbuf;
tx_ring_tmp = rhine_buffers.txdesc;
rx_bufs_tmp = rhine_buffers.rxbuf;
rx_ring_tmp = rhine_buffers.rxdesc;

/* tune RD TD 32 byte alignment */
rx_ring_tmp1 = (int) virt_to_bus ((char *) rx_ring_tmp);
rx_ring_tmp1 = virt_to_bus ( rx_ring_tmp );
j = (rx_ring_tmp1 + 32) & (~0x1f);
/* printf ("txring[%d]", j); */
tp->rx_ring = (struct rhine_rx_desc *) bus_to_virt (j);

tx_ring_tmp1 = (int) virt_to_bus ((char *) tx_ring_tmp);
tx_ring_tmp1 = virt_to_bus ( tx_ring_tmp );
j = (tx_ring_tmp1 + 32) & (~0x1f);
tp->tx_ring = (struct rhine_tx_desc *) bus_to_virt (j);
/* printf ("rxring[%X]", j); */


tx_bufs_tmp1 = (int) virt_to_bus ((char *) tx_bufs_tmp);
tx_bufs_tmp1 = virt_to_bus ( tx_bufs_tmp );
j = (int) (tx_bufs_tmp1 + 32) & (~0x1f);
tx_bufs_tmp = (int) bus_to_virt (j);
tx_bufs_tmp = bus_to_virt (j);
/* printf ("txb[%X]", j); */

rx_bufs_tmp1 = (int) virt_to_bus ((char *) rx_bufs_tmp);
rx_bufs_tmp1 = virt_to_bus ( rx_bufs_tmp );
j = (int) (rx_bufs_tmp1 + 32) & (~0x1f);
rx_bufs_tmp = (int) bus_to_virt (j);
rx_bufs_tmp = bus_to_virt (j);
/* printf ("rxb[%X][%X]", rx_bufs_tmp1, j); */

for (i = 0; i < RX_RING_SIZE; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/net/via-velocity.c
Expand Up @@ -550,7 +550,7 @@ static void velocity_transmit(struct nic *nic, const char *dest, /* Destination
vptr->td_rings[entry].tdesc0.pktsize = pktlen;
vptr->td_rings[entry].td_buf[0].pa_low = virt_to_bus(ptxb);
vptr->td_rings[entry].td_buf[0].pa_high &=
cpu_to_le32(0xffff0000L);
cpu_to_le32(0xffff0000UL);
vptr->td_rings[entry].td_buf[0].bufsize =
vptr->td_rings[entry].tdesc0.pktsize;
vptr->td_rings[entry].tdesc1.CMDZ = 2;
Expand Down
12 changes: 8 additions & 4 deletions src/include/gpxe/socket.h
Expand Up @@ -7,19 +7,23 @@
*
*/

#include <stdint.h>

/**
* @defgroup commtypes Communication semantics
*
* @{
*/

/** Connection-based, reliable streams */
#define SOCK_STREAM ( ( int ) TCP_SOCK_STREAM )
extern char TCP_SOCK_STREAM[];
extern int tcp_sock_stream;
#define TCP_SOCK_STREAM 0x1
#define SOCK_STREAM tcp_sock_stream

/** Connectionless, unreliable streams */
#define SOCK_DGRAM ( ( int ) UDP_SOCK_DGRAM )
extern char UDP_SOCK_DGRAM[];
extern int udp_sock_dgram;
#define UDP_SOCK_DGRAM 0x2
#define SOCK_DGRAM udp_sock_dgram

/** @} */

Expand Down
43 changes: 25 additions & 18 deletions src/interface/efi/efi_snp.c
Expand Up @@ -173,8 +173,9 @@ efi_snp_initialize ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
container_of ( snp, struct efi_snp_device, snp );
int rc;

DBGC2 ( snpdev, "SNPDEV %p INITIALIZE (%d extra RX, %d extra TX)\n",
snpdev, extra_rx_bufsize, extra_tx_bufsize );
DBGC2 ( snpdev, "SNPDEV %p INITIALIZE (%ld extra RX, %ld extra TX)\n",
snpdev, ( ( unsigned long ) extra_rx_bufsize ),
( ( unsigned long ) extra_tx_bufsize ) );

if ( ( rc = netdev_open ( snpdev->netdev ) ) != 0 ) {
DBGC ( snpdev, "SNPDEV %p could not open %s: %s\n",
Expand Down Expand Up @@ -252,9 +253,9 @@ efi_snp_receive_filters ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, UINT32 enable,
container_of ( snp, struct efi_snp_device, snp );
unsigned int i;

DBGC2 ( snpdev, "SNPDEV %p RECEIVE_FILTERS %08x&~%08x%s %d mcast\n",
DBGC2 ( snpdev, "SNPDEV %p RECEIVE_FILTERS %08x&~%08x%s %ld mcast\n",
snpdev, enable, disable, ( mcast_reset ? " reset" : "" ),
mcast_count );
( ( unsigned long ) mcast_count ) );
for ( i = 0 ; i < mcast_count ; i++ ) {
DBGC2_HDA ( snpdev, i, &mcast[i],
snpdev->netdev->ll_protocol->ll_addr_len );
Expand Down Expand Up @@ -390,8 +391,9 @@ efi_snp_nvdata ( EFI_SIMPLE_NETWORK_PROTOCOL *snp, BOOLEAN read,
struct efi_snp_device *snpdev =
container_of ( snp, struct efi_snp_device, snp );

DBGC2 ( snpdev, "SNPDEV %p NVDATA %s %x+%x\n", snpdev,
( read ? "read" : "write" ), offset, len );
DBGC2 ( snpdev, "SNPDEV %p NVDATA %s %lx+%lx\n", snpdev,
( read ? "read" : "write" ), ( ( unsigned long ) offset ),
( ( unsigned long ) len ) );
if ( ! read )
DBGC2_HDA ( snpdev, offset, data, len );

Expand Down Expand Up @@ -492,7 +494,8 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
int rc;
EFI_STATUS efirc;

DBGC2 ( snpdev, "SNPDEV %p TRANSMIT %p+%x", snpdev, data, len );
DBGC2 ( snpdev, "SNPDEV %p TRANSMIT %p+%lx", snpdev, data,
( ( unsigned long ) len ) );
if ( ll_header_len ) {
if ( ll_src ) {
DBGC2 ( snpdev, " src %s",
Expand All @@ -512,13 +515,14 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
if ( ll_header_len ) {
if ( ll_header_len != ll_protocol->ll_header_len ) {
DBGC ( snpdev, "SNPDEV %p TX invalid header length "
"%d\n", snpdev, ll_header_len );
"%ld\n", snpdev,
( ( unsigned long ) ll_header_len ) );
efirc = EFI_INVALID_PARAMETER;
goto err_sanity;
}
if ( len < ll_header_len ) {
DBGC ( snpdev, "SNPDEV %p invalid packet length %d\n",
snpdev, len );
DBGC ( snpdev, "SNPDEV %p invalid packet length %ld\n",
snpdev, ( ( unsigned long ) len ) );
efirc = EFI_BUFFER_TOO_SMALL;
goto err_sanity;
}
Expand All @@ -541,8 +545,8 @@ efi_snp_transmit ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
/* Allocate buffer */
iobuf = alloc_iob ( len );
if ( ! iobuf ) {
DBGC ( snpdev, "SNPDEV %p TX could not allocate %d-byte "
"buffer\n", snpdev, len );
DBGC ( snpdev, "SNPDEV %p TX could not allocate %ld-byte "
"buffer\n", snpdev, ( ( unsigned long ) len ) );
efirc = EFI_DEVICE_ERROR;
goto err_alloc_iob;
}
Expand Down Expand Up @@ -610,7 +614,8 @@ efi_snp_receive ( EFI_SIMPLE_NETWORK_PROTOCOL *snp,
int rc;
EFI_STATUS efirc;

DBGC2 ( snpdev, "SNPDEV %p RECEIVE %p(+%x)", snpdev, data, *len );
DBGC2 ( snpdev, "SNPDEV %p RECEIVE %p(+%lx)", snpdev, data,
( ( unsigned long ) *len ) );

/* Poll the network device */
efi_snp_poll ( snpdev );
Expand Down Expand Up @@ -741,8 +746,10 @@ efi_snp_netdev ( EFI_DRIVER_BINDING_PROTOCOL *driver, EFI_HANDLE device ) {
driver, device, efi_strerror ( efirc ) );
goto out_no_pci_location;
}
DBGCP ( driver, "SNPDRV %p device %p is PCI %04x:%02x:%02x.%x\n",
driver, device, pci_segment, pci_bus, pci_dev, pci_fn );
DBGCP ( driver, "SNPDRV %p device %p is PCI %04lx:%02lx:%02lx.%lx\n",
driver, device, ( ( unsigned long ) pci_segment ),
( ( unsigned long ) pci_bus ), ( ( unsigned long ) pci_dev ),
( ( unsigned long ) pci_fn ) );

/* Look up corresponding network device */
pci_busdevfn = PCI_BUSDEVFN ( pci_bus, PCI_DEVFN ( pci_dev, pci_fn ) );
Expand Down Expand Up @@ -858,7 +865,7 @@ efi_snp_driver_start ( EFI_DRIVER_BINDING_PROTOCOL *driver,
/* Sanity check */
if ( netdev->ll_protocol->ll_addr_len > sizeof ( EFI_MAC_ADDRESS ) ) {
DBGC ( snpdev, "SNPDEV %p cannot support link-layer address "
"length %zd for %s\n", snpdev,
"length %d for %s\n", snpdev,
netdev->ll_protocol->ll_addr_len, netdev->name );
efirc = EFI_INVALID_PARAMETER;
goto err_ll_addr_len;
Expand Down Expand Up @@ -923,8 +930,8 @@ efi_snp_driver_stop ( EFI_DRIVER_BINDING_PROTOCOL *driver,
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
struct efi_snp_device *snpdev;

DBGCP ( driver, "SNPDRV %p DRIVER_STOP %p (%d %p)\n",
driver, device, num_children, children );
DBGCP ( driver, "SNPDRV %p DRIVER_STOP %p (%ld %p)\n",
driver, device, ( ( unsigned long ) num_children ), children );

/* Locate SNP device */
snpdev = efi_snp_snpdev ( driver, device );
Expand Down

0 comments on commit 0ebbbb9

Please sign in to comment.