Index: pcmmio/original/ChangeLog
===================================================================
--- pcmmio/original/ChangeLog	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/ChangeLog	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,2 +1,8 @@
+2009-06-17	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* buffered.c, dacbuff.c, dacout.c, flash.c, getall.c, getvolt.c,
+	kbhit.c, mio_io.c, mio_io_linux.c, mio_io_rtems.c, pcmmio.c, poll.c,
+	repeat.c, rtems_config.c: Clean up. Worked on RTEMS IRQ support code.
+
 2009-06-10	Joel Sherrill <joel.sherrill@oarcorp.com>
 
Index: pcmmio/original/buffered.c
===================================================================
--- pcmmio/original/buffered.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/buffered.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -3,21 +3,15 @@
 /*
 *
-* $Header$
-*
 * $Id$
 *
-* $Log$
+* Compile for GNU/Linux with:
 *
-*	Compile with :
-*
-*		gcc buffered.c kbhit.c mio_io.o -o buffered -lpthread
+*   gcc buffered.c kbhit.c mio_io.o -o buffered -lpthread
 *
 *
-*	This program demonstrates the adc_buffered_channel_conversions function
-*	which allows for a programmed sequence of conversions to be accomplished
-*	with a single call.
-*
+*  This program demonstrates the adc_buffered_channel_conversions function
+*  which allows for a programmed sequence of conversions to be accomplished
+*  with a single call.
 */
-
 
 /* Our IOCTL definitions and all function prototypes */
Index: pcmmio/original/dacbuff.c
===================================================================
--- pcmmio/original/dacbuff.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/dacbuff.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -3,21 +3,16 @@
 /*
 *
-* $Header$
-*
 * $Id$
 *
-* $Log$
 *
-*	Compile with :
+* Compile for GNU/Linux with:
 *
-*		gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
+*     gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
 *
 *
-*	This program demonstrates the adc_buffered_channel_conversions function
-*	which allows for a programmed sequence of conversions to be accomplished
-*	with a single call.
-*
+* This program demonstrates the adc_buffered_channel_conversions function
+* which allows for a programmed sequence of conversions to be accomplished
+* with a single call.
 */
-
 
 #include "mio_io.h"    
Index: pcmmio/original/dacout.c
===================================================================
--- pcmmio/original/dacout.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/dacout.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,19 +1,13 @@
 /* dacout.c WinSystems PCM-MIO driver Demonstration Program
-*
-*  $Header$
 *
 *  $Id$
 *
-*  $Log$
+* Compile for GNU/Linux with:
+*
+*   gcc dacout.c mio_io.o -o dacout
 *
 *
-*  Compile with :
-*
-*
-*	gcc dacout.c mio_io.o -o dacout
-*
-*
-*	This extremely simple program uses the set_dac_voltage function to update
-*   the dac output to a specific voltage.
+* This extremely simple program uses the set_dac_voltage function to update
+*  the dac output to a specific voltage.
 */
 
Index: pcmmio/original/flash.c
===================================================================
--- pcmmio/original/flash.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/flash.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,21 +1,12 @@
 /* Flash.c WinSystems PCM-MIO driver Demonstration Program
-*
-*  $Header$
 *
 *  $Id$
 *
-*  $Log$
-*  Revision 1.1.1.1  2009/06/08 14:52:43  joel
-*  Initial import.
+*  Compile for GNU/Linux with:
 *
+*    gcc flash.c kbhit.c mio_io.o -o flash
 *
-*
-*  Compile with :
-*
-*
-*	gcc flash.c kbhit.c mio_io.o -o flash
-*
-*   This very simple program, toggles each of the 48  DIO lines in succession, holding it low
-*   for 250ms and then releasing it.
+*  This very simple program, toggles each of the 48  DIO lines in succession,
+*  holding it low for 250ms and then releasing it.
 * 
 */
Index: pcmmio/original/getall.c
===================================================================
--- pcmmio/original/getall.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/getall.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,14 +1,11 @@
-/* getall.c Demonstration program for use with the WinSystems PCM-MIO Linux driver
-*
-*	$Header$
-*
-*	$Id$
-*
-*	$Log$
-*
-*	Compile with :
-*
-*			gcc -static getall.c mio_io.o -o getall
-*/
+/* 
+ * Demonstration program for use with the WinSystems PCM-MIO driver
+ *
+ *	$Id$
+ *
+ * Compile for GNU/Linux with:
+ *
+ *    gcc -static getall.c mio_io.o -o getall
+ */
 
 #include <stdio.h>
@@ -16,9 +13,10 @@
 #include "mio_io.h"
 
-/* This program demonstrates usage of the adc_convert_all_channels function call.
-   This allows for all 16 channels to be quickly converted and the results passed
-   back in an 16 element array. Note that this function does not return voltage values,
-   it returns raw 16-bit data directly from the converter.
-*/
+/* This program demonstrates usage of the adc_convert_all_channels
+ * function call.  This allows for all 16 channels to be quickly converted
+ * and the results passed back in an 16 element array. Note that this
+ * function does not return voltage values, it returns raw 16-bit data
+ * directly from the converter.
+ */
 
 
Index: pcmmio/original/getvolt.c
===================================================================
--- pcmmio/original/getvolt.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/getvolt.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,22 +1,16 @@
 /* getvolt.c WinSystems PCM-MIO driver Demonstration Program
-*
-*  $Header$
-*
-*  $Id$
-*
-*  $Log$
-*
-*
-*  Compile with :
-*
-*
-*	gcc getvolt.c mio_io.o -o getvolt
-*
-*
-*	This program demonstrates the adc_auto_get_channel_voltage
-*	function. It reads the voltage on the channel specified
-*	prints the value and then exits.
-* 
-*/
+ *
+ *  $Id$
+ *
+ * Compile for GNU/Linux with:
+ *
+ *
+ *   gcc getvolt.c mio_io.o -o getvolt
+ *
+ *
+ * This program demonstrates the adc_auto_get_channel_voltage
+ * function. It reads the voltage on the channel specified
+ * prints the value and then exits.
+ */
 
 #include <stdio.h>
Index: pcmmio/original/kbhit.c
===================================================================
--- pcmmio/original/kbhit.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/kbhit.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,33 +1,18 @@
-/* $Header$
-*
-*
-*   Filename : $RCSfile$
-*
-*   $Id$
-*
-*   $Log$
-*   Revision 1.1.1.1  2009/06/08 14:52:43  joel
-*   Initial import.
-*
-*   Revision 1.1  2005/04/19 20:39:11  steve
-*   Initial revision
-*
-*
-*
-*/
+/*
+ * $Id$
+ */
 
 
 /* These functions are from the Wrox Press Book "Beginning Linux
-   Programming - Second Edition" by Richard Stones and Neil Matthew.
-   (C) 1996 & 1999 and are included here in compliance with the GNU
-   Public license.
-
-*/
+ * Programming - Second Edition" by Richard Stones and Neil Matthew.
+ * (C) 1996 & 1999 and are included here in compliance with the GNU
+ * Public license.
+ */
 
 #include <stdio.h>
 #include <termios.h>
 #if defined(__linux__)
-#include <term.h>
-#include <curses.h>
+  #include <term.h>
+  #include <curses.h>
 #endif
 #include <unistd.h>
Index: pcmmio/original/mio_io.c
===================================================================
--- pcmmio/original/mio_io.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/mio_io.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,23 +1,12 @@
-/* mio_io.c WinSystems support module file for the  PCM-MIO Linux driver */
-/*
-*  $Header$
-*
-*  $Id$
-*
-*  $Log$
-*  Revision 1.2  2009/06/08 18:21:56  joel
-*  2009-06-08	Joel Sherrill <joel.sherrill@oarcorp.com>
-*
-*  	* Makefile, kbhit.c, mio_io.c, mio_io.h: First successful compilation
-*  	under RTEMS. Added some Linux ifdef's.
-*  	* rtems_config.c: New file.
-*
-*  Revision 1.1.1.1  2009/06/08 14:52:43  joel
-*  Initial import.
-*
-*
-*  This file implements all of the supported 'C' language functions. Where necessary
-*  call are made into a porting layer to access the actual hardware.
-*/
+/* mio_io.c
+ * WinSystems support module file for the  PCM-MIO Linux driver
+ *
+ *  $Id$
+ *
+ *
+ *  This file implements all of the supported 'C' language functions.
+ *  Where necessary calls are made into a porting layer to access the
+ *  actual hardware.
+ */
 
 #define LIB_DEFINED
Index: pcmmio/original/mio_io_linux.c
===================================================================
--- pcmmio/original/mio_io_linux.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/mio_io_linux.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,23 +1,13 @@
-/* mio_io.c WinSystems support module file for the  PCM-MIO Linux driver */
-/*
-*  $Header$
-*
-*  $Id$
-*
-*  $Log$
-*  Revision 1.2  2009/06/08 18:21:56  joel
-*  2009-06-08	Joel Sherrill <joel.sherrill@oarcorp.com>
-*
-*  	* Makefile, kbhit.c, mio_io.c, mio_io.h: First successful compilation
-*  	under RTEMS. Added some Linux ifdef's.
-*  	* rtems_config.c: New file.
-*
-*  Revision 1.1.1.1  2009/06/08 14:52:43  joel
-*  Initial import.
-*
-*
-*  This file implements all of the supported 'C' language functions. Where necessary
-*  ioctl call are made into the kernel driver to access the actual hardware.
-*/
+/* mio_io.c
+ * WinSystems support module file for the  PCM-MIO Linux driver
+ *
+ *
+ *  $Id$
+ *
+ *
+ *  This file implements all of the supported 'C' language functions.
+ *  Where necessary ioctl calls are made into the kernel driver to access
+ *  the actual hardware.
+ */
 
 /* #define DEBUG 1 */
Index: pcmmio/original/mio_io_rtems.c
===================================================================
--- pcmmio/original/mio_io_rtems.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/mio_io_rtems.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,4 +1,4 @@
-/* mio_io.c WinSystems support module file for the  PCM-MIO RTEMS driver */
-/*
+/* mio_io.c WinSystems support module file for the  PCM-MIO RTEMS driver
+ *
  *  $Id$
  *
@@ -460,17 +460,32 @@
 void common_handler(void);
 
-void pcmmio_interrupt_handler(
+void pcmmio_irq_handler(
   rtems_irq_hdl_param param
 )
 {
+  common_handler();
+}
+
+static void pcmmio_irq_disable(const rtems_irq_connect_data *irq)
+{
+  BSP_irq_disable_at_i8259s(irq->name - BSP_IRQ_VECTOR_BASE);
+}
+static void pcmmio_irq_enable(const rtems_irq_connect_data *irq)
+{
+  BSP_irq_enable_at_i8259s(irq->name - BSP_IRQ_VECTOR_BASE);
+}
+
+static int pcmmio_irq_is_on(const rtems_irq_connect_data *irq)
+{
+  return BSP_irq_enabled_at_i8259s( irq->name );
 }
 
 rtems_irq_connect_data pcmmio_irq = {
   0,                            // name
-  pcmmio_interrupt_handler,     // handler
+  pcmmio_irq_handler,           // handler
   NULL,                         // parameter
-  NULL,                         // enable IRQ
-  NULL,                         // disable IRQ
-  NULL,                         // is IRQ enabled
+  pcmmio_irq_enable,            // enable IRQ
+  pcmmio_irq_disable,           // disable IRQ
+  pcmmio_irq_is_on,             // is IRQ enabled
 };
 
@@ -495,4 +510,5 @@
   /* install IRQ handler */
   if ( irq ) {
+    int status = 0;
     pcmmio_irq.name = irq;
     #if defined(BSP_SHARED_HANDLER_SUPPORT)
@@ -502,4 +518,8 @@
       BSP_install_rtems_irq_handler( &pcmmio_irq );
     #endif
+    if ( !status ) {
+      printk("Error installing PCMMIO interrupt handler!\n" );
+      rtems_fatal_error_occurred( status );
+    }
   }
 }
@@ -525,6 +545,6 @@
 
 static DIO_Int_t int_buffer[MAX_INTS];
-static int inptr = 0;
-static int outptr = 0;
+static int       inptr = 0;
+static int       outptr = 0;
 
 /* real copy is in mio_io.c */
@@ -579,5 +599,10 @@
       #endif
 
-      /* Buffer the interrupt */
+      /*
+       * Buffer the interrupt
+       *
+       * NOTE: No need to worry about disabling interrupts,
+       *       we are in interrupts.
+       */
 
       int_buffer[inptr].timestamp = rdtsc();
@@ -719,5 +744,6 @@
 )
 {
-  int                line;
+  rtems_interrupt_level level;
+  int                   line;
 
   if (irq == 0) {
@@ -728,14 +754,17 @@
   }
 
-  if (outptr != inptr) {
-    if ( timestamp )
-      *timestamp = int_buffer[outptr].timestamp;
-    line = int_buffer[outptr].line;
-    outptr++;
-    if (outptr == MAX_INTS)
-      outptr = 0;
-    return line;
-  }
-
-  return 0;
-}
+  line = 0;
+
+  rtems_interrupt_disable( level );
+    if (outptr != inptr) {
+      if ( timestamp )
+        *timestamp = int_buffer[outptr].timestamp;
+      line = int_buffer[outptr].line;
+      outptr++;
+      if (outptr == MAX_INTS)
+        outptr = 0;
+    }
+  rtems_interrupt_enable( level );
+  
+  return line;
+}
Index: pcmmio/original/pcmmio.c
===================================================================
--- pcmmio/original/pcmmio.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/pcmmio.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,14 +1,6 @@
-/* PCMMIO.C    WinSystems PCM-MIO Linux Driver */
-
-/* 
- * $Header$
+/*
+ * WinSystems PCM-MIO Linux Device Driver
+ * 
  * $Id$
- *
- * Filename : $RCSfile$
- * 
- * $Log$
- *
- *
- * WinSystems PCM-MIO Linux Device Driver
  */
 
@@ -1025,3 +1017,2 @@
 }
 
-	
Index: pcmmio/original/poll.c
===================================================================
--- pcmmio/original/poll.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/poll.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,19 +1,12 @@
-/* Poll.c Demonstration program for WinSystems PCM-MIO Driver */
-
-/*
-*
-* $Header$
-*
-* $Id$
-*
-* $Log$
-*
-*/
-
-/* This program demonstrates one manner in which an unprivledged 
-   application running in user space can sychronize to hardware events 
-   handled by a device driver running in Kernel space.
-*/
-
+/* poll.c
+ * Demonstration program for WinSystems PCM-MIO Driver
+ *
+ * $Id$
+ */
+
+/* This program demonstrates one manner in which an unprivileged 
+ * application running in user space can synchronize to hardware events 
+ * handled by a device driver running in Kernel space.
+ */
 
 #include "mio_io.h"    
@@ -27,5 +20,5 @@
 
 
-/* This function will be a sub-processe using the Posix threads 
+/* This function will be a sub-processes using the Posix threads 
    capability of Linux. This thread will simulate a type of 
    Interrupt service routine in that it will start up and then suspend 
Index: pcmmio/original/repeat.c
===================================================================
--- pcmmio/original/repeat.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/repeat.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,22 +1,15 @@
-/* repeat.c Demonstration program for WinSystems PCM-MIO Driver */
-
-/*
-*
-* $Header$
-*
-* $Id$
-*
-* $Log$
-*
-*	Compile with :
-*
-*		gcc repeat.c kbhit.c mio_io.o -o repeat
-*
-*
-*	This program demonstrates the adc_convert_single_repeated function
-*	which allows for a sequence of conversions to be accomplished
-*	with a single call on the same channel.
-*
-*/
+/* repeat.c
+ * Demonstration program for WinSystems PCM-MIO Driver
+ *
+ * $Id$
+ *
+ * Compile for GNU/Linux with:
+ *
+ *    gcc repeat.c kbhit.c mio_io.o -o repeat
+ *
+ * This program demonstrates the adc_convert_single_repeated function
+ * which allows for a sequence of conversions to be accomplished
+ * with a single call on the same channel.
+ */
 
 #include "mio_io.h"    
Index: pcmmio/original/rtems_config.c
===================================================================
--- pcmmio/original/rtems_config.c	(revision 758418e4963c8e2ed803bba1bb23fe978d57f711)
+++ pcmmio/original/rtems_config.c	(revision 1cbabbedf98cdf57fe284603c379ff8168867d3c)
@@ -1,3 +1,5 @@
 /*
+ *  RTEMS Configuration and Initialization for PCMMIO Demonstration Programs	
+ *
  *  $Id$
  */
@@ -14,5 +16,4 @@
 )
 {
-    
   pcmmio_initialize(0, 0);
   main(0,NULL);
