From 2d5c48691453a05ffb3a264f75e71490166f819a Mon Sep 17 00:00:00 2001 From: Nick Withers Date: Thu, 27 Nov 2014 17:39:36 +1100 Subject: Use fixed-width C99 types for PowerPC in_be16() and co. Also use the const qualifier on the address pointer's target in in_*() Closes #2128 --- .../lib/libbsp/powerpc/beatnik/marvell/discovery.c | 9 +++--- .../lib/libbsp/powerpc/beatnik/marvell/gt_timer.c | 4 +-- c/src/lib/libbsp/powerpc/beatnik/marvell/gti2c.c | 6 ++-- .../libbsp/powerpc/beatnik/network/if_gfe/if_gfe.c | 2 +- .../powerpc/beatnik/network/porting/rtemscompat.h | 20 ++++++------- c/src/lib/libbsp/powerpc/beatnik/pci/gt_pci_init.c | 20 ++++++------- .../lib/libbsp/powerpc/beatnik/pci/motload_fixup.c | 34 +++++++++++----------- .../lib/libbsp/powerpc/beatnik/startup/bspreset.c | 3 +- 8 files changed, 50 insertions(+), 48 deletions(-) (limited to 'c/src/lib/libbsp/powerpc/beatnik') diff --git a/c/src/lib/libbsp/powerpc/beatnik/marvell/discovery.c b/c/src/lib/libbsp/powerpc/beatnik/marvell/discovery.c index 801d2c99d1..c6f647581f 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/marvell/discovery.c +++ b/c/src/lib/libbsp/powerpc/beatnik/marvell/discovery.c @@ -57,6 +57,7 @@ #include #include #include +#include #ifndef PCI_VENDOR_ID_MARVELL #define PCI_VENDOR_ID_MARVELL 0x11ab @@ -78,16 +79,16 @@ static unsigned long pci_early_config_read(int offset, int width) { - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(0<<8)|(PCI_DEVFN(0,0)<<16)|((offset&~3)<<24)); switch (width) { default: case 1: - return in_8((unsigned char*)pci.pci_config_data + (offset&3)); + return in_8((uint8_t*)pci.pci_config_data + (offset&3)); case 2: - return in_le16((unsigned short*)pci.pci_config_data + (offset&3)); + return in_le16((uint16_t*)pci.pci_config_data + (offset&3)); case 4: - return in_le32((unsigned long *)pci.pci_config_data + (offset&3)); + return in_le32((uint32_t *)pci.pci_config_data + (offset&3)); } } #endif diff --git a/c/src/lib/libbsp/powerpc/beatnik/marvell/gt_timer.c b/c/src/lib/libbsp/powerpc/beatnik/marvell/gt_timer.c index e53e8e10a1..b9a5cc8db0 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/marvell/gt_timer.c +++ b/c/src/lib/libbsp/powerpc/beatnik/marvell/gt_timer.c @@ -69,12 +69,12 @@ static inline uint32_t gt_rd(uint32_t off) { - return in_le32( (volatile unsigned *)(BSP_MV64x60_BASE+off) ); + return in_le32( (volatile uint32_t *)(BSP_MV64x60_BASE+off) ); } static inline void gt_wr(uint32_t off, uint32_t val) { - out_le32( (volatile unsigned *)(BSP_MV64x60_BASE+off), val); + out_le32( (volatile uint32_t *)(BSP_MV64x60_BASE+off), val); } static inline uint32_t gt_timer_bitmod(uint32_t off, uint32_t clr, uint32_t set) diff --git a/c/src/lib/libbsp/powerpc/beatnik/marvell/gti2c.c b/c/src/lib/libbsp/powerpc/beatnik/marvell/gti2c.c index 2cc67f3258..c602bac5eb 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/marvell/gti2c.c +++ b/c/src/lib/libbsp/powerpc/beatnik/marvell/gti2c.c @@ -113,13 +113,13 @@ static gti2c_desc_rec my_bus_tbl = { static inline uint32_t gt_read(uint32_t base, uint32_t off) { - return in_le32((volatile unsigned*)(base+off)); + return in_le32((volatile uint32_t*)(base+off)); } static inline void gt_write(uint32_t base, uint32_t off, uint32_t val) { - out_le32((volatile unsigned*)(base+off), val); + out_le32((volatile uint32_t*)(base+off), val); } @@ -206,7 +206,7 @@ struct gti2c_softc * const sc = &my_bus_tbl.pvt; */ {unsigned from,to; asm volatile("mftb %0":"=r"(from)); - while ( in_le32((volatile unsigned*)0xf100000c) & 0x20 ) + while ( in_le32((volatile uint32_t*)0xf100000c) & 0x20 ) ; asm volatile("mftb %0":"=r"(to)); printk("I2C IRQ remained asserted for %i TB ticks!\n",to-from); diff --git a/c/src/lib/libbsp/powerpc/beatnik/network/if_gfe/if_gfe.c b/c/src/lib/libbsp/powerpc/beatnik/network/if_gfe/if_gfe.c index b707fb8410..23fca30c46 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/network/if_gfe/if_gfe.c +++ b/c/src/lib/libbsp/powerpc/beatnik/network/if_gfe/if_gfe.c @@ -1758,7 +1758,7 @@ gfe_tx_enqueue(struct gfe_softc *sc, enum gfe_txprio txprio) */ d = NEXT_TXD(l); - out_be32((unsigned int*)&d->ed_cmdsts,0); + out_be32((uint32_t*)&d->ed_cmdsts,0); GE_TXDPRESYNC(sc, txq, d - txq->txq_descs); diff --git a/c/src/lib/libbsp/powerpc/beatnik/network/porting/rtemscompat.h b/c/src/lib/libbsp/powerpc/beatnik/network/porting/rtemscompat.h index ea1c251261..2451af76a9 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/network/porting/rtemscompat.h +++ b/c/src/lib/libbsp/powerpc/beatnik/network/porting/rtemscompat.h @@ -150,18 +150,18 @@ union { #ifdef __PPC__ -#define _out_byte(a,v) out_8((volatile unsigned char*)(a),(v)) -#define _inp_byte(a) in_8((volatile unsigned char*)(a)) +#define _out_byte(a,v) out_8((volatile uint8_t*)(a),(v)) +#define _inp_byte(a) in_8((volatile uint8_t*)(a)) #ifdef NET_CHIP_LE -#define _out_word(a,v) out_le16((volatile unsigned short*)(a),(v)) -#define _out_long(a,v) out_le32((volatile unsigned *)(a),(v)) -#define _inp_word(a) in_le16((volatile unsigned short*)(a)) -#define _inp_long(a) in_le32((volatile unsigned *)(a)) +#define _out_word(a,v) out_le16((volatile uint16_t*)(a),(v)) +#define _out_long(a,v) out_le32((volatile uint32_t *)(a),(v)) +#define _inp_word(a) in_le16((volatile uint16_t*)(a)) +#define _inp_long(a) in_le32((volatile uint32_t *)(a)) #elif defined(NET_CHIP_BE) -#define _out_word(a,v) out_be16((volatile unsigned short*)(a),(v)) -#define _out_long(a,v) out_be32((volatile unsigned *)(a),(v)) -#define _inp_word(a) in_be16((volatile unsigned short*)(a)) -#define _inp_long(a) in_be32((volatile unsigned *)(a)) +#define _out_word(a,v) out_be16((volatile uint16_t*)(a),(v)) +#define _out_long(a,v) out_be32((volatile uint32_t *)(a),(v)) +#define _inp_word(a) in_be16((volatile uint16_t*)(a)) +#define _inp_long(a) in_be32((volatile uint32_t *)(a)) #else #error rtemscompat_defs.h must define either NET_CHIP_LE or NET_CHIP_BE #endif diff --git a/c/src/lib/libbsp/powerpc/beatnik/pci/gt_pci_init.c b/c/src/lib/libbsp/powerpc/beatnik/pci/gt_pci_init.c index 0bd9db0940..82afd324c6 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/pci/gt_pci_init.c +++ b/c/src/lib/libbsp/powerpc/beatnik/pci/gt_pci_init.c @@ -83,7 +83,7 @@ indirect_pci_read_config_byte(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, uint8_t *val) { HOSE_PREAMBLE; - out_be32((volatile unsigned *) pci.pci_config_addr, + out_be32((volatile uint32_t *) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|((offset&~3)<<24)); *val = in_8(pci.pci_config_data + (offset&3)); return PCIBIOS_SUCCESSFUL; @@ -96,9 +96,9 @@ indirect_pci_read_config_word(unsigned char bus, unsigned char slot, HOSE_PREAMBLE; *val = 0xffff; if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|((offset&~3)<<24)); - *val = in_le16((volatile unsigned short *)(pci.pci_config_data + (offset&3))); + *val = in_le16((volatile uint16_t *)(pci.pci_config_data + (offset&3))); return PCIBIOS_SUCCESSFUL; } @@ -109,9 +109,9 @@ indirect_pci_read_config_dword(unsigned char bus, unsigned char slot, HOSE_PREAMBLE; *val = 0xffffffff; if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|(offset<<24)); - *val = in_le32((volatile unsigned *)pci.pci_config_data); + *val = in_le32((volatile uint32_t *)pci.pci_config_data); return PCIBIOS_SUCCESSFUL; } @@ -120,7 +120,7 @@ indirect_pci_write_config_byte(unsigned char bus, unsigned char slot, unsigned char function, unsigned char offset, uint8_t val) { HOSE_PREAMBLE; - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|((offset&~3)<<24)); out_8(pci.pci_config_data + (offset&3), val); return PCIBIOS_SUCCESSFUL; @@ -132,9 +132,9 @@ indirect_pci_write_config_word(unsigned char bus, unsigned char slot, unsigned char offset, uint16_t val) { HOSE_PREAMBLE; if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|((offset&~3)<<24)); - out_le16((volatile unsigned short *)(pci.pci_config_data + (offset&3)), val); + out_le16((volatile uint16_t *)(pci.pci_config_data + (offset&3)), val); return PCIBIOS_SUCCESSFUL; } @@ -144,9 +144,9 @@ indirect_pci_write_config_dword(unsigned char bus, unsigned char slot, unsigned char offset, uint32_t val) { HOSE_PREAMBLE; if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER; - out_be32((unsigned int*) pci.pci_config_addr, + out_be32((uint32_t*) pci.pci_config_addr, 0x80|(bus<<8)|(PCI_DEVFN(slot,function)<<16)|(offset<<24)); - out_le32((volatile unsigned *)pci.pci_config_data, val); + out_le32((volatile uint32_t *)pci.pci_config_data, val); return PCIBIOS_SUCCESSFUL; } diff --git a/c/src/lib/libbsp/powerpc/beatnik/pci/motload_fixup.c b/c/src/lib/libbsp/powerpc/beatnik/pci/motload_fixup.c index 91dc013c1f..f3bc120be8 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/pci/motload_fixup.c +++ b/c/src/lib/libbsp/powerpc/beatnik/pci/motload_fixup.c @@ -96,36 +96,36 @@ uint32_t b0,b1,r0,r1,lim,dis; * whereas the mvme6100 does it the other way round... */ - b0 = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_Low_Decode) ); - b1 = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_Low_Decode) ); + b0 = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_Low_Decode) ); + b1 = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_Low_Decode) ); - r0 = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap) ); - r1 = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap) ); + r0 = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap) ); + r1 = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap) ); switch ( BSP_getDiscoveryVersion(0) ) { case MV_64360: /* In case of the MV64360 the 'limit' is actually a 'size'! * Disable by setting special bits in the 'BAR disable reg'. */ - dis = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL) ); + dis = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL) ); /* disable PCI0 I/O and PCI1 I/O */ - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL), dis | (1<<9) | (1<<14) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL), dis | (1<<9) | (1<<14) ); /* remap busses on hose 0; if the remap register was already set, assume * that someone else [such as the bootloader] already performed the fixup */ if ( (b0 & 0xffff) && 0 == (r0 & 0xffff) ) { rtems_pci_io_remap( 0, BSP_pci_hose1_bus_base, (b0 & 0xffff)<<16 ); - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap), (b0 & 0xffff) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap), (b0 & 0xffff) ); } /* remap busses on hose 1 */ if ( (b1 & 0xffff) && 0 == (r1 & 0xffff) ) { rtems_pci_io_remap( BSP_pci_hose1_bus_base, pci_bus_count(), (b1 & 0xffff)<<16 ); - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap), (b1 & 0xffff) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap), (b1 & 0xffff) ); } /* re-enable */ - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL), dis ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + MV_64360_BASE_ADDR_DISBL), dis ); break; case GT_64260_A: @@ -133,32 +133,32 @@ uint32_t b0,b1,r0,r1,lim,dis; if ( (b0 & 0xfff) && 0 == (r0 & 0xfff) ) { /* base are only 12 bits */ /* switch window off by setting the limit < base */ - lim = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode) ); - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode), 0 ); + lim = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode), 0 ); /* remap busses on hose 0 */ rtems_pci_io_remap( 0, BSP_pci_hose1_bus_base, (b0 & 0xfff)<<20 ); /* BTW: it seems that writing the base register also copies the * value into the 'remap' register automatically (??) */ - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap), (b0 & 0xfff) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_Remap), (b0 & 0xfff) ); /* re-enable */ - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode), lim ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI0_IO_High_Decode), lim ); } if ( (b1 & 0xfff) && 0 == (r1 & 0xfff) ) { /* base are only 12 bits */ /* switch window off by setting the limit < base */ - lim = in_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode) ); - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode), 0 ); + lim = in_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode), 0 ); /* remap busses on hose 1 */ rtems_pci_io_remap( BSP_pci_hose1_bus_base, pci_bus_count(), (b1 & 0xfff)<<20 ); - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap), (b1 & 0xfff) ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_Remap), (b1 & 0xfff) ); /* re-enable */ - out_le32( (volatile unsigned*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode), lim ); + out_le32( (volatile uint32_t*)(BSP_MV64x60_BASE + GT_PCI1_IO_High_Decode), lim ); } break; diff --git a/c/src/lib/libbsp/powerpc/beatnik/startup/bspreset.c b/c/src/lib/libbsp/powerpc/beatnik/startup/bspreset.c index ecdc03404c..68540847ee 100644 --- a/c/src/lib/libbsp/powerpc/beatnik/startup/bspreset.c +++ b/c/src/lib/libbsp/powerpc/beatnik/startup/bspreset.c @@ -4,6 +4,7 @@ #include #include #include +#include void bsp_reset() { @@ -13,5 +14,5 @@ void bsp_reset() printk("RTEMS terminated; Rebooting ...\n"); /* Mvme5500 board reset : 2004 S. Kate Feng */ - out_8((volatile unsigned char*) (BSP_MV64x60_DEV1_BASE +2), 0x80); + out_8((volatile uint8_t*) (BSP_MV64x60_DEV1_BASE +2), 0x80); } -- cgit v1.2.3