Index: c/src/lib/libcpu/arm/ChangeLog
===================================================================
--- c/src/lib/libcpu/arm/ChangeLog	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/ChangeLog	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -1,2 +1,10 @@
+2007-05-01	Ray Xu <xr@trasin.net>
+
+	* lpc22xx/clock/clockdrv.c, lpc22xx/include/lpc22xx.h,
+	lpc22xx/irq/bsp_irq_asm.S, lpc22xx/irq/bsp_irq_init.c,
+	lpc22xx/irq/irq.c, lpc22xx/irq/irq.h, lpc22xx/timer/timer.c: Update
+	BSP to address changes between 4.7 and CVS head as well as to address
+	comments from Ralf and Joel.
+
 2007-04-25	Ralf CorsÃ©pius <ralf.corsepius@rtems.org>
 
Index: c/src/lib/libcpu/arm/lpc22xx/clock/clockdrv.c
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/clock/clockdrv.c	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/clock/clockdrv.c	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -1,5 +1,7 @@
 /*
- *  LPC22XX clock specific using the System Timer
- * set the Time0
+ *  LPC22XX/LPC21xx clock specific using the System Timer
+ * Copyright (c) 2006 by Ray <rayx.cn@gmail.com>
+ *  Set the Time0 to generate click for RTEMS
+ *
  *  This is hardware specific part of the clock driver. At the end of this
  *  file, the generic part of the driver is #included.
@@ -77,7 +79,7 @@
  */
  
-  /* set timer to generate interrupt every BSP_Configuration.microseconds_per_tick */
-  /* MR0/(LPC22xx_Fpclk/(PR0+1)) = 10/1000 = 0.01s */
-			
+  /* set timer to generate interrupt every BSP_Configuration.microseconds_per_tick
+   * MR0/(LPC22xx_Fpclk/(PR0+1)) = 10/1000 = 0.01s
+   */			
 	
 #define Clock_driver_support_initialize_hardware() \
@@ -104,4 +106,17 @@
 	BSP_remove_rtems_irq_handler(&clock_isr_data);                  \
      } while (0)
+
+uint32_t bsp_clock_nanoseconds_since_last_tick(void)
+{
+	uint32_t clicks;
+	
+	clicks = T0TC;  /*T0TC is the 32bit time counter 0*/
+	
+	return (uint32_t) (BSP_Configuration.microseconds_per_tick - clicks) * 1000;
+}
+	
+#define Clock_driver_nanoseconds_since_last_tick bsp_clock_nanoseconds_since_last_tick
+
+
 
 /**
Index: c/src/lib/libcpu/arm/lpc22xx/include/lpc22xx.h
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/include/lpc22xx.h	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/include/lpc22xx.h	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -1,7 +1,6 @@
 /*
- * Motorola LPC22XX Register definitions
+ * Philips LPC22XX/LPC21xx Register definitions
  *
- * Copyright (c) 2003 by Cogent Computer Systems
- * Written by Jay Monkman <jtm@lopingdog.com>
+ * Copyright (c) 2006 by Ray <rayx.cn@gmail.com>
  *	
  *  The license and distribution terms for this file may be
Index: c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_asm.S
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_asm.S	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_asm.S	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -1,8 +1,6 @@
 /*
- *  LPC22XX Intererrupt handler
+ *  LPC22XX/LPC21xx Intererrupt handler
  *
- *  Copyright (c) 2002 by Jay Monkman <jtm@lopingdog.com>
- *
- *  Modified by ray
+ *  Modified by Ray <rayx.cn@gmail.com> 2006 from Jay Monkman's code
  *
  *  The license and distribution terms for this file may be
Index: c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_init.c
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_init.c	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/irq/bsp_irq_init.c	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -1,7 +1,5 @@
 /*
- * Motorola LPC22XX Interrupt handler
- *
- * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
- *      
+ * Motorola LPC22XX/LPC21xx Interrupt handler
+ *  Modified by Ray 2006 <rayx.cn@gmail.com> to support LPC ARM     
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
@@ -25,8 +23,15 @@
 void BSP_rtems_irq_mngt_init()
 {
+  long *vectorTable;
+  int i;
 
     /* disable all interrupts */
   VICIntEnClr = 0xFFFFFFFF;
 
+  vectorTable = (long *) VECTOR_TABLE;
+  /* Initialize the vector table contents with default handler */
+  for (i=0; i<BSP_MAX_INT; i++) {
+      *(vectorTable + i) = (long)(default_int_handler);
+  }
    
   /*
@@ -63,5 +68,4 @@
   VICIntSelect = 0;
   
-
 }
 
Index: c/src/lib/libcpu/arm/lpc22xx/irq/irq.c
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/irq/irq.c	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/irq/irq.c	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -2,6 +2,5 @@
  * Philps LPC22XX Interrupt handler
  * 
- * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
- * Modified by ray     
+ * Copyright (c)  2006 by Ray<rayx.cn@gmail.com>  to support LPC ARM      
  *  The license and distribution terms for this file may be
  *  found in the file LICENSE in this distribution or at
Index: c/src/lib/libcpu/arm/lpc22xx/irq/irq.h
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/irq/irq.h	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/irq/irq.h	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -2,5 +2,5 @@
  * Interrupt handler Header file
  *
- * Copyright (c) 2004 by Jay Monkman <jtm@lopingdog.com>
+ * Copyright (c) 2006 by Ray <rayx.cn@gmail.com> to support LPC ARM  
  *	
  *  The license and distribution terms for this file may be
Index: c/src/lib/libcpu/arm/lpc22xx/timer/timer.c
===================================================================
--- c/src/lib/libcpu/arm/lpc22xx/timer/timer.c	(revision 9e0e37c1ed5a34e6ebbbb3e58c3bcdef350b5225)
+++ c/src/lib/libcpu/arm/lpc22xx/timer/timer.c	(revision 716f6bede98614f69a223f9eac9acd14efbbf563)
@@ -4,5 +4,5 @@
  * This uses Timer1 for timing measurments.
  *  
- *  By Ray xu, modify form Mc9328mxl	RTEMS DSP
+ *  By Ray xu<rayx.cn@gmail.com>, modify form Mc9328mxl	RTEMS DSP
  *
  *  The license and distribution terms for this file may be
@@ -45,10 +45,4 @@
 void Timer_initialize( void )
 {
-	T1TCR &= 0; 	 /* disable and clear timer 0  */ 
-       g_start = (T1TC/(LPC22xx_Fpclk/1000000));
-       T1PC  = 0;            /* TC is incrementet on every pclk.*/ 
-	T1MR0 = ((LPC22xx_Fpclk/1000* BSP_Configuration.microseconds_per_tick) / 1000); /* initialize the timer period and prescaler */  
-       T1EMR = 0;  /*No external match*/ 
-	T1TCR = 1; /*enable timer1*/ 
        g_freq = LPC22xx_Fpclk / 1000;
 }
@@ -74,25 +68,10 @@
   unsigned long long total;
   
-  t = (T1TC/(LPC22xx_Fpclk/1000000));
+  return (T0TC/(LPC22xx_Fpclk/1000000));
   /*
    *  Total is calculated by taking into account the number of timer overflow
    *  interrupts since the timer was initialized and clicks since the last
-   *  interrupts. currently it is not supported
+   *  interrupts.
    */
-
-  total = (t - g_start);
-
-  /* convert to nanoseconds */
-
-  if ( Timer_driver_Find_average_overhead == 1 ) {
-    return (int) total; 
-  } else if ( total < LEAST_VALID ) {
-      return 0;       
-  }
-  /*
-   *  Somehow convert total into microseconds
-   */
-
-  return (total - AVG_OVERHEAD);
 }
 
