[rtems commit] bsps/powerpc: Fix warnings

Sebastian Huber sebh at rtems.org
Wed Feb 15 12:06:25 UTC 2017


Module:    rtems
Branch:    master
Commit:    73f8d938474d04013d785f5918d75b9d82c80ca3
Changeset: http://git.rtems.org/rtems/commit/?id=73f8d938474d04013d785f5918d75b9d82c80ca3

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Feb 15 11:09:50 2017 +0100

bsps/powerpc: Fix warnings

---

 c/src/lib/libbsp/powerpc/psim/network/if_sim.c     | 10 +--
 c/src/lib/libbsp/powerpc/shared/openpic/openpic.c  | 11 +--
 c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c          | 20 ++---
 c/src/lib/libcpu/powerpc/mpc6xx/mmu/pte121.c       |  4 +-
 .../new-exceptions/bspsupport/ppc_exc_print.c      | 92 +++++++++++-----------
 c/src/lib/libcpu/powerpc/shared/src/stack.c        |  3 +-
 6 files changed, 72 insertions(+), 68 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/psim/network/if_sim.c b/c/src/lib/libbsp/powerpc/psim/network/if_sim.c
index 4314aad..240bf05 100644
--- a/c/src/lib/libbsp/powerpc/psim/network/if_sim.c
+++ b/c/src/lib/libbsp/powerpc/psim/network/if_sim.c
@@ -107,16 +107,16 @@ struct ifsim_softc theIfSims[IFSIM_SLOTS] = {{{{0}}} };
 
 rtems_id           ifsim_tid = 0;
 
-__inline__ uint32_t
+static __inline__ uint32_t
 ifsim_in(struct ifsim_softc *sc, unsigned regno)
 {
-	return in_be32( sc->pvt.base + regno );
+	return in_be32((volatile uint32_t *) (sc->pvt.base + regno));
 }
 
-__inline__ void
+static __inline__ void
 ifsim_out(struct ifsim_softc *sc, unsigned regno, uint32_t v)
 {
-	out_be32(sc->pvt.base + regno, v);
+	out_be32((volatile uint32_t *) (sc->pvt.base + regno), v);
 }
 
 static void *
@@ -378,7 +378,7 @@ rtems_event_set    evs;
 							if ( crc_len
 								 && (memcpy(&crc_net, (char*)eh + len, crc_len),
 							        (crc = (ether_crc32_le((uint8_t *)eh, len) ^ 0xffffffff)) != crc_net) ) {
-								printk("CSUM: me 0x%08X, them 0x%08x\n", crc, crc_net);
+								printk("CSUM: me 0x%08" PRIx32 ", them 0x%08" PRIx32 "\n", crc, crc_net);
 								sc->pvt.rx_cserrs++;
 							} else {
 
diff --git a/c/src/lib/libbsp/powerpc/shared/openpic/openpic.c b/c/src/lib/libbsp/powerpc/shared/openpic/openpic.c
index 39abcd9..15a37d1 100644
--- a/c/src/lib/libbsp/powerpc/shared/openpic/openpic.c
+++ b/c/src/lib/libbsp/powerpc/shared/openpic/openpic.c
@@ -25,6 +25,7 @@
 #include <libcpu/io.h>
 #include <libcpu/byteorder.h>
 #include <rtems/bspIo.h>
+#include <inttypes.h>
 
 #ifndef NULL
 #define NULL 0
@@ -72,9 +73,9 @@ static          int openpic_src_offst = 0;
 	printk("openpic.c:%d: illegal priority %d\n", __LINE__, pri);
 #define check_arg_irq(irq) \
     if (irq < 0 || irq >= NumSources) \
-	printk("openpic.c:%d: illegal irq %d from 0x%08x,[0x%08x],[[0x%08x]]\n", \
-	       __LINE__, irq, __builtin_return_address(0), \
-	       __builtin_return_address(1), __builtin_return_address(2) \
+	printk("openpic.c:%d: illegal irq %d from 0x%08" PRIxPTR ",[0x%08" PRIxPTR "],[[0x%08" PRIxPTR "]]\n", \
+	       __LINE__, irq, (uintptr_t) __builtin_return_address(0), \
+	       (uintptr_t) __builtin_return_address(1), (uintptr_t) __builtin_return_address(2) \
 	       );
 #define check_arg_cpu(cpu) \
     if (cpu < 0 || cpu >= NumProcessors) \
@@ -234,8 +235,8 @@ void openpic_init(int main_pic, unsigned char *polarities, unsigned char *senses
 		break;
 	}
     }
-    printk("OpenPIC Version %s (%d CPUs and %d IRQ sources) at 0x%08x\n", version,
-	   NumProcessors, NumSources, OpenPIC);
+    printk("OpenPIC Version %s (%d CPUs and %d IRQ sources) at 0x%08" PRIuPTR "\n", version,
+	   NumProcessors, NumSources, (uintptr_t) OpenPIC);
 
     printk("OpenPIC Vendor %d (%s), Device %d (%s), Stepping %d\n", vendorid,
 	   vendor, devid, device, stepping);
diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c b/c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c
index c848f4c..7a9487b 100644
--- a/c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c
+++ b/c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c
@@ -335,29 +335,29 @@ setbat (int typ, int bat_index, unsigned long virt, unsigned long phys,
   ubat bat;
 
   if (check_bat_index (bat_index)) {
-    printk ("Invalid BAT index\n", bat_index);
+    printk ("Invalid BAT index %d\n", bat_index);
     return -1;
   }
 
   if ((int) (bl = check_bat_size (size)) < 0) {
-    printk ("Invalid BAT size\n", size);
+    printk ("Invalid BAT size %u\n", size);
     return -1;
   }
 
   if (virt & (size - 1)) {
-    printk ("BAT effective address 0x%08x misaligned (size is 0x%08x)\n",
+    printk ("BAT effective address 0x%08lx misaligned (size is 0x%08x)\n",
             virt, size);
     return -1;
   }
 
   if (phys & (size - 1)) {
-    printk ("BAT physical address 0x%08x misaligned (size is 0x%08x)\n", phys,
+    printk ("BAT physical address 0x%08lx misaligned (size is 0x%08x)\n", phys,
             size);
     return -1;
   }
 
   if (virt + size - 1 < virt) {
-    printk ("BAT range invalid: wraps around zero 0x%08x..0x%08x\n", virt,
+    printk ("BAT range invalid: wraps around zero 0x%08lx..0x%08lx\n", virt,
             virt + size - 1);
     return -1;
   }
@@ -383,7 +383,7 @@ setbat (int typ, int bat_index, unsigned long virt, unsigned long phys,
   err = check_overlap (typ, virt, size);
   if ((size >= (1 << 17)) && (err >= 0) && (err != bat_index)) {
     rtems_interrupt_enable (level);
-    printk ("BATs must not overlap; area 0x%08x..0x%08x hits %cBAT %i\n",
+    printk ("BATs must not overlap; area 0x%08lx..0x%08lx hits %cBAT %i\n",
             virt, virt + size, (TYP_I == typ ? 'I' : 'D'), err);
     return -1;
   }
@@ -495,13 +495,13 @@ getbat (int typ, int idx, unsigned long *pu, unsigned long *pl)
     ubat b;
     b.words.u = u;
     b.words.l = l;
-    printk ("Raw %cBAT %i contents; UPPER: (0x%08x)", (TYP_I == typ ? 'I' : 'D'), idx, u);
+    printk ("Raw %cBAT %i contents; UPPER: (0x%08lx)", (TYP_I == typ ? 'I' : 'D'), idx, u);
     printk (" BEPI: 0x%08x", b.bat.batu.bepi);
-    printk (" BL: 0x%08x", (u >> 2) & ((1 << 15) - 1));
+    printk (" BL: 0x%08lx", (u >> 2) & ((1 << 15) - 1));
     printk (" VS: 0b%i", b.bat.batu.vs);
     printk (" VP: 0b%i", b.bat.batu.vp);
     printk ("\n");
-    printk ("                     LOWER: (0x%08x)", l);
+    printk ("                     LOWER: (0x%08lx)", l);
     printk ("  RPN: 0x%08x", b.bat.batl.brpn);
     printk (" wimg:   0b%1i%1i%1i%1i", b.bat.batl.w, b.bat.batl.i,
             b.bat.batl.m, b.bat.batl.g);
@@ -509,7 +509,7 @@ getbat (int typ, int idx, unsigned long *pu, unsigned long *pl)
     printk ("\n");
     printk ("Covering EA Range: ");
     if (bat_in_use[typ] & (1 << idx))
-      printk ("0x%08x .. 0x%08x\n", bat_addrs[typ][idx].start,
+      printk ("0x%08lx .. 0x%08lx\n", bat_addrs[typ][idx].start,
               bat_addrs[typ][idx].limit);
     else
       printk ("<none> (BAT off)\n");
diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/mmu/pte121.c b/c/src/lib/libcpu/powerpc/mpc6xx/mmu/pte121.c
index f6e9f42..fb346ea 100644
--- a/c/src/lib/libcpu/powerpc/mpc6xx/mmu/pte121.c
+++ b/c/src/lib/libcpu/powerpc/mpc6xx/mmu/pte121.c
@@ -182,11 +182,11 @@ seg2vsid (uint32_t ea)
 /* Horrible Macros */
 #ifdef __rtems__
 /* must not use printf until multitasking is up */
-typedef void (*PrintF) (const char *, ...);
+typedef int (*PrintF) (const char *, ...);
 static PrintF
 whatPrintf (void)
 {
-  return _Thread_Executing ? (PrintF) printf : printk;
+  return _Thread_Executing ? printf : printk;
 }
 
 #define PRINTF(args...) ((void)(whatPrintf())(args))
diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_print.c b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_print.c
index 27b76a1..f745713 100644
--- a/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_print.c
+++ b/c/src/lib/libcpu/powerpc/new-exceptions/bspsupport/ppc_exc_print.c
@@ -21,6 +21,8 @@
 
 #include <rtems/score/threaddispatch.h>
 
+#include <inttypes.h>
+
 #ifndef __SPE__
   #define GET_GPR(gpr) (gpr)
 #else
@@ -65,7 +67,7 @@ void BSP_printStackTrace(const BSP_Exception_frame *excPtr)
 
   printk("Stack Trace: \n  ");
   if (excPtr) {
-    printk("IP: 0x%08x, ", excPtr->EXC_SRR0);
+    printk("IP: 0x%08" PRIu32 ", ", excPtr->EXC_SRR0);
     sp = (LRFrame) GET_GPR(excPtr->GPR1);
     lr = (void *) excPtr->EXC_LR;
   } else {
@@ -73,9 +75,9 @@ void BSP_printStackTrace(const BSP_Exception_frame *excPtr)
     __asm__ __volatile__("mr %0, 1":"=r"(sp));
     lr = (LRFrame) ppc_link_register();
   }
-  printk("LR: 0x%08x\n", lr);
+  printk("LR: 0x%08" PRIuPTR "\n", (uintptr_t) lr);
   for (f = (LRFrame) sp, i = 0; f->frameLink && i < STACK_CLAMP; f = f->frameLink) {
-    printk("--^ 0x%08x", (long) (f->frameLink->lr));
+    printk("--^ 0x%08" PRIuPTR "", (uintptr_t) (f->frameLink->lr));
     if (!(++i % 5))
       printk("\n");
   }
@@ -94,67 +96,67 @@ void _CPU_Exception_frame_print(const CPU_Exception_frame *excPtr)
   unsigned n = excPtr->_EXC_number & 0x7fff;
 
   printk("exception vector %d (0x%x)\n", n, n);
-  printk("  next PC or address of fault = 0x%08x\n", excPtr->EXC_SRR0);
-  printk("  saved MSR = 0x%08x\n", excPtr->EXC_SRR1);
+  printk("  next PC or address of fault = 0x%08" PRIu32 "\n", excPtr->EXC_SRR0);
+  printk("  saved MSR = 0x%08" PRIu32 "\n", excPtr->EXC_SRR1);
 
   /* Try to find out more about the context where this happened */
   printk(
-    "  context = %s, ISR nest level = %u\n",
+    "  context = %s, ISR nest level = %" PRIu32 "\n",
     _ISR_Nest_level == 0 ? "task" : "interrupt",
     _ISR_Nest_level
   );
   printk(
-    "  thread dispatch disable level = %u\n",
+    "  thread dispatch disable level = %" PRIu32 "\n",
     _Thread_Dispatch_disable_level
   );
 
   /* Dump registers */
 
-  printk("  R0  = 0x%08x", GET_GPR(excPtr->GPR0));
+  printk("  R0  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR0));
   if (synch) {
-    printk(" R1  = 0x%08x", GET_GPR(excPtr->GPR1));
-    printk(" R2  = 0x%08x", GET_GPR(excPtr->GPR2));
+    printk(" R1  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR1));
+    printk(" R2  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR2));
   } else {
     printk("               ");
     printk("               ");
   }
-  printk(" R3  = 0x%08x\n", GET_GPR(excPtr->GPR3));
-  printk("  R4  = 0x%08x", GET_GPR(excPtr->GPR4));
-  printk(" R5  = 0x%08x", GET_GPR(excPtr->GPR5));
-  printk(" R6  = 0x%08x", GET_GPR(excPtr->GPR6));
-  printk(" R7  = 0x%08x\n", GET_GPR(excPtr->GPR7));
-  printk("  R8  = 0x%08x", GET_GPR(excPtr->GPR8));
-  printk(" R9  = 0x%08x", GET_GPR(excPtr->GPR9));
-  printk(" R10 = 0x%08x", GET_GPR(excPtr->GPR10));
-  printk(" R11 = 0x%08x\n", GET_GPR(excPtr->GPR11));
-  printk("  R12 = 0x%08x", GET_GPR(excPtr->GPR12));
+  printk(" R3  = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR3));
+  printk("  R4  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR4));
+  printk(" R5  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR5));
+  printk(" R6  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR6));
+  printk(" R7  = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR7));
+  printk("  R8  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR8));
+  printk(" R9  = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR9));
+  printk(" R10 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR10));
+  printk(" R11 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR11));
+  printk("  R12 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR12));
   if (synch) {
-    printk(" R13 = 0x%08x", GET_GPR(excPtr->GPR13));
-    printk(" R14 = 0x%08x", GET_GPR(excPtr->GPR14));
-    printk(" R15 = 0x%08x\n", GET_GPR(excPtr->GPR15));
-    printk("  R16 = 0x%08x", GET_GPR(excPtr->GPR16));
-    printk(" R17 = 0x%08x", GET_GPR(excPtr->GPR17));
-    printk(" R18 = 0x%08x", GET_GPR(excPtr->GPR18));
-    printk(" R19 = 0x%08x\n", GET_GPR(excPtr->GPR19));
-    printk("  R20 = 0x%08x", GET_GPR(excPtr->GPR20));
-    printk(" R21 = 0x%08x", GET_GPR(excPtr->GPR21));
-    printk(" R22 = 0x%08x", GET_GPR(excPtr->GPR22));
-    printk(" R23 = 0x%08x\n", GET_GPR(excPtr->GPR23));
-    printk("  R24 = 0x%08x", GET_GPR(excPtr->GPR24));
-    printk(" R25 = 0x%08x", GET_GPR(excPtr->GPR25));
-    printk(" R26 = 0x%08x", GET_GPR(excPtr->GPR26));
-    printk(" R27 = 0x%08x\n", GET_GPR(excPtr->GPR27));
-    printk("  R28 = 0x%08x", GET_GPR(excPtr->GPR28));
-    printk(" R29 = 0x%08x", GET_GPR(excPtr->GPR29));
-    printk(" R30 = 0x%08x", GET_GPR(excPtr->GPR30));
-    printk(" R31 = 0x%08x\n", GET_GPR(excPtr->GPR31));
+    printk(" R13 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR13));
+    printk(" R14 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR14));
+    printk(" R15 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR15));
+    printk("  R16 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR16));
+    printk(" R17 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR17));
+    printk(" R18 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR18));
+    printk(" R19 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR19));
+    printk("  R20 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR20));
+    printk(" R21 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR21));
+    printk(" R22 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR22));
+    printk(" R23 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR23));
+    printk("  R24 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR24));
+    printk(" R25 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR25));
+    printk(" R26 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR26));
+    printk(" R27 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR27));
+    printk("  R28 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR28));
+    printk(" R29 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR29));
+    printk(" R30 = 0x%08" PRIu32 "", GET_GPR(excPtr->GPR30));
+    printk(" R31 = 0x%08" PRIu32 "\n", GET_GPR(excPtr->GPR31));
   } else {
     printk("\n");
   }
-  printk("  CR  = 0x%08x\n", excPtr->EXC_CR);
-  printk("  CTR = 0x%08x\n", excPtr->EXC_CTR);
-  printk("  XER = 0x%08x\n", excPtr->EXC_XER);
-  printk("  LR  = 0x%08x\n", excPtr->EXC_LR);
+  printk("  CR  = 0x%08" PRIu32 "\n", excPtr->EXC_CR);
+  printk("  CTR = 0x%08" PRIu32 "\n", excPtr->EXC_CTR);
+  printk("  XER = 0x%08" PRIu32 "\n", excPtr->EXC_XER);
+  printk("  LR  = 0x%08" PRIu32 "\n", excPtr->EXC_LR);
 
   /* Would be great to print DAR but unfortunately,
    * that is not portable across different CPUs.
@@ -164,7 +166,7 @@ void _CPU_Exception_frame_print(const CPU_Exception_frame *excPtr)
    */
   if (ppc_exc_get_DAR != NULL) {
     char* reg = ppc_cpu_is_60x() ? " DAR" : "DEAR";
-    printk(" %s = 0x%08x\n", reg, ppc_exc_get_DAR());
+    printk(" %s = 0x%08" PRIu32 "\n", reg, ppc_exc_get_DAR());
   }
   if (ppc_cpu_is_bookE()) {
     unsigned esr, mcsr;
@@ -219,7 +221,7 @@ void _CPU_Exception_frame_print(const CPU_Exception_frame *excPtr)
     const char *name = (const char *) &executing->Object.name;
 
     printk(
-      "  executing thread ID = 0x%08x, name = %c%c%c%c\n",
+      "  executing thread ID = 0x%08" PRIx32 ", name = %c%c%c%c\n",
       executing->Object.id,
       name [0],
       name [1],
diff --git a/c/src/lib/libcpu/powerpc/shared/src/stack.c b/c/src/lib/libcpu/powerpc/shared/src/stack.c
index 657ae2f..f19cecd 100644
--- a/c/src/lib/libcpu/powerpc/shared/src/stack.c
+++ b/c/src/lib/libcpu/powerpc/shared/src/stack.c
@@ -1,6 +1,7 @@
 #include "stackTrace.h"
 #include <rtems/bspIo.h>
 #include <libcpu/spr.h>
+#include <inttypes.h>
 
 SPR_RO(PPC_LR)
 
@@ -36,7 +37,7 @@ void CPU_print_stack(void)
         for (i=0; stck[i]; i++) {
                 if (i%5) printk("--> ");
                 else     printk("\n");
-                printk("0x%08x",stck[i]);
+                printk("0x%08" PRIuPTR, (uintptr_t)stck[i]);
 	}
 	printk("\n");
 }




More information about the vc mailing list