[GSOC2009] Clean code of gumstix bsp and skyeye shut down support added

xi yang hiyangxi at gmail.com
Sun Jun 28 07:23:29 UTC 2009


Hi, joel please delete pxa255/include/bits.h. This patch contains
performance counter support. Also, I add changes to ChangeLog.
Regards



Here is the patch:

Index: c/src/lib/libbsp/arm/gumstix/ChangeLog
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/arm/gumstix/ChangeLog,v
retrieving revision 1.3
diff -u -p -r1.3 ChangeLog
--- c/src/lib/libbsp/arm/gumstix/ChangeLog	11 Jun 2009 13:12:42 -0000	1.3
+++ c/src/lib/libbsp/arm/gumstix/ChangeLog	28 Jun 2009 07:21:03 -0000
@@ -1,3 +1,7 @@
+2009-06-11	Xi Yang <hiyangxi at gmail.com>
+	* startup/bspstart.c: Shutdown skyeye simulator in bsp_reset
+	* Makefile.am: Clean code and add PMC
+	
 2009-06-11	Joel Sherrill <joel.sherrill at oarcorp.com>

 	* startup/linkcmds: Fix spacing.
Index: c/src/lib/libbsp/arm/gumstix/Makefile.am
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/arm/gumstix/Makefile.am,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile.am
--- c/src/lib/libbsp/arm/gumstix/Makefile.am	4 Jun 2009 16:23:11 -0000	1.1
+++ c/src/lib/libbsp/arm/gumstix/Makefile.am	28 Jun 2009 07:21:03 -0000
@@ -21,42 +21,33 @@ noinst_PROGRAMS =

 nodist_include_HEADERS += ../../shared/include/coverhd.h

-EXTRA_DIST = start/start.S
-start.$(OBJEXT): start/start.S
-	$(CPPASCOMPILE) -o $@ -c $<
+noinst_LIBRARIES = libbspstart.a
+libbspstart_a_SOURCES = ./start/start.S
 project_lib_DATA = start.$(OBJEXT)

 dist_project_lib_DATA += startup/linkcmds

-noinst_PROGRAMS += startup.rel
-startup_rel_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c \
+noinst_LIBRARIES += libbsp.a
+libbsp_a_SOURCES =
+#startup
+libbsp_a_SOURCES += ../../shared/bsplibc.c ../../shared/bsppost.c \
 	../../shared/bsppredriverhook.c ../../shared/bspgetworkarea.c \
 	../../shared/bootcard.c ../../shared/sbrk.c \
-    	../../shared/gnatinstallhandler.c ../../shared/bsppretaskinghook.c \
-	../../shared/bspclean.c ../../shared/bspreset.c \
-    	startup/bspstart.c startup/memmap.c
-
-startup_rel_CPPFLAGS = $(AM_CPPFLAGS)
-startup_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
-
-noinst_PROGRAMS += console.rel
-console_rel_SOURCES = console/uarts.c ../../shared/console.c
-console_rel_CPPFLAGS = $(AM_CPPFLAGS)
-console_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+	../../shared/gnatinstallhandler.c ../../shared/bsppretaskinghook.c \
+	../../shared/bspclean.c \
+	startup/bspstart.c startup/memmap.c
+
+#console
+libbsp_a_SOURCES += console/uarts.c ../../shared/console.c
+#abort
+libbsp_a_SOURCES += ../shared/abort/abort.c

-noinst_PROGRAMS += abort.rel
-abort_rel_SOURCES = ../shared/abort/abort.c
-abort_rel_CPPFLAGS = $(AM_CPPFLAGS)
-abort_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
-
-noinst_LIBRARIES = libbsp.a
-libbsp_a_SOURCES =
-libbsp_a_LIBADD = startup.rel console.rel abort.rel
-libbsp_a_LIBADD += ../../../libcpu/@RTEMS_CPU@/shared/arm920.rel \
+libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/shared/arm920.rel \
     ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/clock.rel \
     ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/timer.rel \
     ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/ffuart.rel \
-    ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/irq.rel
+    ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/irq.rel \
+    ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/pmc.rel

 include $(srcdir)/preinstall.am
 include $(top_srcdir)/../../../../automake/local.am
Index: c/src/lib/libbsp/arm/gumstix/bsp_specs
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/arm/gumstix/bsp_specs,v
retrieving revision 1.1
diff -u -p -r1.1 bsp_specs
--- c/src/lib/libbsp/arm/gumstix/bsp_specs	4 Jun 2009 16:23:11 -0000	1.1
+++ c/src/lib/libbsp/arm/gumstix/bsp_specs	28 Jun 2009 07:21:03 -0000
@@ -4,10 +4,10 @@

 *startfile:
 %{!qrtems: %(old_startfile)} \
-%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s}}
+%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}

 *link:
-%{!qrtems: %(old_link)} %{qrtems: -Qy -dp -Bstatic -N -e _start}
+%{!qrtems: %(old_link)} %{qrtems: -dp -Bstatic -N}

 *endfile:
 %{!qrtems: *(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
Index: c/src/lib/libbsp/arm/gumstix/start/start.S
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/arm/gumstix/start/start.S,v
retrieving revision 1.1
diff -u -p -r1.1 start.S
--- c/src/lib/libbsp/arm/gumstix/start/start.S	4 Jun 2009 16:23:11 -0000	1.1
+++ c/src/lib/libbsp/arm/gumstix/start/start.S	28 Jun 2009 07:21:03 -0000
@@ -1,6 +1,6 @@
 /*
  *  By Yang Xi <hiyangxi at gmail.com>.
- *  Based upon CSB336
+ *  Based upon CSB337
  *
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
Index: c/src/lib/libbsp/arm/gumstix/startup/bspstart.c
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/arm/gumstix/startup/bspstart.c,v
retrieving revision 1.1
diff -u -p -r1.1 bspstart.c
--- c/src/lib/libbsp/arm/gumstix/startup/bspstart.c	4 Jun 2009
16:23:11 -0000	1.1
+++ c/src/lib/libbsp/arm/gumstix/startup/bspstart.c	28 Jun 2009 07:21:03 -0000
@@ -43,3 +43,11 @@ void bsp_start_default( void )
  *  can override the actual bsp_start routine used.
  */
 void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
+
+
+void bsp_reset( void )
+{
+#if ON_SKYEYE == 1
+  SKYEYE_MAGIC_ADDRESS = 0xff;
+#endif
+}
Index: c/src/lib/libcpu/arm/ChangeLog
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/arm/ChangeLog,v
retrieving revision 1.58
diff -u -p -r1.58 ChangeLog
--- c/src/lib/libcpu/arm/ChangeLog	5 Jun 2009 22:10:42 -0000	1.58
+++ c/src/lib/libcpu/arm/ChangeLog	28 Jun 2009 07:21:04 -0000
@@ -1,3 +1,7 @@
+2009-06-28	Xi Yang <hiyangxi at gmail.com>
+	* pxa255/ffuart/ffuart.c: Just output '\n' on skyeye
+	* Makefile.am, pxa255/include/pxa255.h, pxa255/pmc/pmc.c: Add
performance counter support to pxa255
+	
 2009-06-05	Joel Sherrill <joel.sherrill at OARcorp.com>

 	* preinstall.am, pxa255/clock/clock.c, pxa255/ffuart/ffuart.c,
Index: c/src/lib/libcpu/arm/Makefile.am
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/arm/Makefile.am,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.am
--- c/src/lib/libcpu/arm/Makefile.am	4 Jun 2009 16:33:31 -0000	1.13
+++ c/src/lib/libcpu/arm/Makefile.am	28 Jun 2009 07:21:04 -0000
@@ -43,6 +43,13 @@ noinst_PROGRAMS += pxa255/ffuart.rel
 pxa255_ffuart_rel_SOURCES = pxa255/ffuart/ffuart.c
 pxa255_ffuart_rel_CPPFLAGS = $(AM_CPPFLAGS)
 pxa255_ffuart_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+## pxa255/pmc
+noinst_PROGRAMS += pxa255/pmc.rel
+pxa255_pmc_rel_SOURCES = pxa255/pmc/pmc.c
+pxa255_pmc_rel_CPPFLAGS = $(AM_CPPFLAGS)
+pxa255_pmc_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
 ## pxa255/interrupt
 include_HEADERS += pxa255/irq/irq.h
 noinst_PROGRAMS += pxa255/irq.rel
Index: c/src/lib/libcpu/arm/pxa255/ffuart/ffuart.c
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/arm/pxa255/ffuart/ffuart.c,v
retrieving revision 1.2
diff -u -p -r1.2 ffuart.c
--- c/src/lib/libcpu/arm/pxa255/ffuart/ffuart.c	5 Jun 2009 22:10:42 -0000	1.2
+++ c/src/lib/libcpu/arm/pxa255/ffuart/ffuart.c	28 Jun 2009 07:21:04 -0000
@@ -20,6 +20,7 @@
 #include <libchip/sersupp.h>

 volatile int dbg_dly;
+void _start(void);

 /* static function prototypes */
 static int     ffuart_first_open(int major, int minor, void *arg);
@@ -126,6 +127,7 @@ static int ffuart_write(int minor, const
         }

         c = (char) buf[i];
+#if ON_SKYEYE != 1
 	if(c=='\n'){
 	  ffuart->rbr = '\r';
 	  for (x = 0; x < 100; x++) {
@@ -136,8 +138,8 @@ static int ffuart_write(int minor, const
 	      break;
 	    }
 	  }
-	  ffuart->rbr = c;
 	}
+#endif
         ffuart->rbr = c;

         /* the TXRDY flag does not seem to update right away (is this true?) */
Index: c/src/lib/libcpu/arm/pxa255/include/pxa255.h
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/arm/pxa255/include/pxa255.h,v
retrieving revision 1.1
diff -u -p -r1.1 pxa255.h
--- c/src/lib/libcpu/arm/pxa255/include/pxa255.h	4 Jun 2009 16:33:31 -0000	1.1
+++ c/src/lib/libcpu/arm/pxa255/include/pxa255.h	28 Jun 2009 07:21:04 -0000
@@ -86,17 +86,26 @@ typedef unsigned int word_t;
 #define FFUART_BASE   0x40100000


-/*Write the MAGIC_NUMBER to the MAGIC_ADDRESS then the Skyeye will exit,
-  we can use this function to automatic test the RTEMS bsp */
+/*Write to KSYEYE_MAGIC_ADDRESS makes SKYEYE to exits*/

 #define SKYEYE_MAGIC_ADDRESS (*(volatile word_t *)(0xb0000000))
 #define SKYEYE_MAGIC_NUMBER  (0xf0f0f0f0)

 /*PMC*/
-/*Clock counter overflow flag*/
-#define CCOF (0x01<<10)
-#define ENABLE_CC_INT (0x01<<6)
-#define ENABLE_PMC_CC (0x01)
-#define RESET_CC (0x01<<2)
+#define PMC_PMNC 0
+#define PMC_CCNT 1
+#define PMC_INTEN 2
+#define PMC_FLAG 3
+#define PMC_EVTSEL 4
+#define PMC_PMN0 5
+#define PMC_PMN1 6
+#define PMC_PMN2 7
+#define PMC_PMN3 8
+
+#define PMC_PMNC_E (0x01)
+#define PMC_PMNC_PCR (0x01 << 1)
+#define PMC_PMNC_CCR (0x01 << 2)
+#define PMC_PMNC_CCD (0x01 << 3)
+#define PMC_PMNC_PCD (0x01 << 4)

 #endif
Index: c/src/lib/libcpu/arm/pxa255/pmc/pmc.c
===================================================================
RCS file: /usr1/CVS/rtems/c/src/lib/libcpu/arm/pxa255/pmc/pmc.c,v
retrieving revision 1.1
diff -u -p -r1.1 pmc.c
--- c/src/lib/libcpu/arm/pxa255/pmc/pmc.c	4 Jun 2009 16:33:31 -0000	1.1
+++ c/src/lib/libcpu/arm/pxa255/pmc/pmc.c	28 Jun 2009 07:21:04 -0000
@@ -12,34 +12,117 @@
 #include <bsp.h>
 #include <pxa255.h>

-unsigned int int_latency;
+unsigned int xscale_read_pmc(int reg)
+{
+  unsigned int val = 0;
+  switch(reg){
+  case PMC_PMNC:
+    asm volatile("mrc p14,0,%0,c0,c1,0\n":"=r"(val):);
+    break;
+  case PMC_CCNT:
+    asm volatile("mrc p14,0,%0,c1,c1,0\n":"=r"(val):);
+    break;
+  case PMC_INTEN:
+    asm volatile("mrc p14,0,%0,c4,c1,0\n":"=r"(val):);
+    break;
+  case PMC_FLAG:
+    asm volatile("mrc p14,0,%0,c5,c1,0\n":"=r"(val):);
+    break;
+  case PMC_EVTSEL:
+    asm volatile("mrc p14,0,%0,c8,c1,0\n":"=r"(val):);
+    break;
+  case PMC_PMN0:
+    asm volatile("mrc p14,0,%0,c0,c2,0\n":"=r"(val):);
+    break;
+  case PMC_PMN1:
+    asm volatile("mrc p14,0,%0,c1,c2,0\n":"=r"(val):);
+    break;
+  case PMC_PMN2:
+    asm volatile("mrc p14,0,%0,c2,c2,0\n":"=r"(val):);
+    break;
+  case PMC_PMN3:
+    asm volatile("mrc p14,0,%0,c3,c2,0\n":"=r"(val):);
+    break;
+  default:
+    val = 0;
+    break;
+  }
+  return val;
+}
+
+void xscale_write_pmc(int reg, unsigned int val)
+{
+  switch(reg){
+  case PMC_PMNC:
+    asm volatile("mcr p14,0,%0,c0,c1,0\n"::"r"(val));
+    break;
+  case PMC_CCNT:
+    asm volatile("mcr p14,0,%0,c1,c1,0\n"::"r"(val));
+    break;
+  case PMC_INTEN:
+    asm volatile("mcr p14,0,%0,c4,c1,0\n"::"r"(val));
+    break;
+  case PMC_FLAG:
+    asm volatile("mcr p14,0,%0,c5,c1,0\n"::"r"(val));
+    break;
+  case PMC_EVTSEL:
+    asm volatile("mcr p14,0,%0,c8,c1,0\n"::"r"(val));
+    break;
+  case PMC_PMN0:
+    asm volatile("mcr p14,0,%0,c0,c2,0\n"::"r"(val));
+    break;
+  case PMC_PMN1:
+    asm volatile("mcr p14,0,%0,c1,c2,0\n"::"r"(val));
+    break;
+  case PMC_PMN2:
+    asm volatile("mcr p14,0,%0,c2,c2,0\n"::"r"(val));
+    break;
+  case PMC_PMN3:
+    asm volatile("mcr p14,0,%0,c3,c2,0\n"::"r"(val));
+    break;
+  default:
+    break;
+  }
+}
+
+void xscale_pmc_enable_pmc(void)
+{
+  unsigned int val;
+  val = xscale_read_pmc(PMC_PMNC);
+  val = (val | PMC_PMNC_E)&(~PMC_PMNC_PCD);
+  xscale_write_pmc(PMC_PMNC,val);
+}
+void xscale_pmc_disable_pmc(void)
+{
+  unsigned int val;
+  val = xscale_read_pmc(PMC_PMNC);
+  val = val & (~PMC_PMNC_E);
+  xscale_write_pmc(PMC_PMNC,val);
+}

-static void pmc_isr_on(const rtems_irq_connect_data *unused)
+void xscale_pmc_reset_pmc(void)
 {
-  unsigned int operand;
-  /*clean CC*/
-  operand = 0x0;
-  asm volatile("mcr p14,0,%0,c1,c0,0 \n"::"r"(operand));
-   /*clean the Clock counter flag and enable the interrupt of CC*/
-  operand = 0x0|RESET_CCOF|ENABLE_CC_INT|RESET_CC|ENABLE_PMC_CC;
-  asm volatile("mcr p14,0,%0,c0,c0,0 \n"::"r"(operand));
-  /*Set to the 4kHZ*/
-  operand = (unsigned int)0xffffffff-(unsigned int)100000;
-  asm volatile("mcr p14,0,%0,c1,c0,0 \n"::"r"(operand));
+  unsigned int val;
+  val = xscale_read_pmc(PMC_PMNC);
+  val = val | PMC_PMNC_PCR;
+  xscale_write_pmc(PMC_PMNC,val);
 }

-static void pmc_isr_off(const rtems_irq_connect_data *unused)
+void xscale_pmc_reset_ccnt(void)
 {
-  unsigned int operand;
-  operand = 0x0|RESET_CCOF;
-  asm volatile("mcr p14,0,%0,c0,c0,0 \n"::"r"(operand));
+  unsigned int val;
+  val = xscale_read_pmc(PMC_PMNC);
+  val = val | PMC_PMNC_CCR;
+  xscale_write_pmc(PMC_PMNC,val);
 }

-static int pmc_isr_is_on(const rtems_irq_connect_data *unused)
+void xscale_pmc_setevent(int reg, unsigned char evt)
 {
-  unsigned int operand;
-  asm volatile("mrc p14,0,%0,c0,c0,0 \n":"=r"(operand):);
-  if((operand & ENABLE_PMC_CC ) && (operand & ENABLE_CC_INT))
-    return 1;
-  return 0;
+  unsigned int val;
+  val = xscale_read_pmc(PMC_EVTSEL);
+  if((reg >= PMC_PMN0) && (reg <= PMC_PMN3)){
+    val &= ~(0xff<<(reg-PMC_PMN0)*8);
+    val |= evt << (reg-PMC_PMN0)*8;
+    xscale_write_pmc(PMC_EVTSEL,val);
+  }
 }



More information about the users mailing list