Updates and Issues

2016-05-06 Thread Mudit Jain
Hi everyone,

GSOC Updates :
As per Gedare's mail I have set up the blog, calendar, wiki and have forked
the rtems-libbsd on github. I had set-up rtems for rpi following alan's
blog and now have built rtems libbsd for rpi. My first blog post is
regarding the same- Blog .

Issues faced :
Before building it for raspberry pi, I tried to build the latest master [
libbsd ] for arm/realview_pbx_a9_qemu however this failed with the
following error message

[802/849] Compiling testsuite/ping01/test_main.c
../../testsuite/ping01/test_main.c:40:43: fatal error:
rtems/bsd/test/network-config.h: No such file or directory
 #include 
 ^
compilation terminated.
--
I guess this is due to the recent change by chris. I did check out the
previous commit and it worked fine for that.

Thanks
Mudit
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: PWM driver tested in RTEMS with RGB

2016-05-06 Thread punit vara
On Fri, May 6, 2016 at 7:23 AM, Chris Johns  wrote:
> On 05/05/2016 22:25, punit vara wrote:
>>
>>
>> I have referred code from sourceforge.
>>
>> https://sourceforge.net/p/starterwarefree/code/ci/master/tree/
>>
>
> I am sorry but I am not comfortable with this repo at the moment and I would
> like to have origin of the code verified before any code from it enters
> RTEMS. The repo does not have a LICENSE file at the top and the
> AM335X_SoftwareManifest.pdf has "Ti Confidential" on every page yet it is
> public. If this code have been placed in a public repo after someone
> acknowledged an EULA then we need to be careful.
>
> Chris

Hi

Official TI wiki page.  http://processors.wiki.ti.com/index.php/StarterWare
leads me to same repo.

If you are saying here we need to be careful than I would like to have
a suggestion from my mentors that from where should I copy the code ?
I think few days back Martin and Marcos both discussed licence issue
with Gedare. I hope they can help me regarding this.

Regards,
Punit Vara
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: PWM driver tested in RTEMS with RGB

2016-05-06 Thread Chris Johns
On 6/05/2016 9:47 PM, punit vara wrote:
> 
> Official TI wiki page.  http://processors.wiki.ti.com/index.php/StarterWare
> leads me to same repo.
> 
> If you are saying here we need to be careful than I would like to have
> a suggestion from my mentors that from where should I copy the code ?
> I think few days back Martin and Marcos both discussed licence issue
> with Gedare. I hope they can help me regarding this.

This is what I was after. The link is on a TI domain and as you indicate
it does point to the SF site.

Thanks for providing this. The code looks fine to me.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Updates and Issues

2016-05-06 Thread Sebastian Huber

Should be fixed already.

On 06/05/16 12:11, Mudit Jain wrote:

Hi everyone,

GSOC Updates :
As per Gedare's mail I have set up the blog, calendar, wiki and have 
forked the rtems-libbsd on github. I had set-up rtems for rpi 
following alan's blog and now have built rtems libbsd for rpi. My 
first blog post is regarding the same- Blog 
.


Issues faced :
Before building it for raspberry pi, I tried to build the latest 
master [ libbsd ] for arm/realview_pbx_a9_qemu however this failed 
with the following error message


[802/849] Compiling testsuite/ping01/test_main.c
../../testsuite/ping01/test_main.c:40:43: fatal error: 
rtems/bsd/test/network-config.h: No such file or directory

 #include   ^
compilation terminated.
--
I guess this is due to the recent change by chris. I did check out the 
previous commit and it worked fine for that.


Thanks
Mudit


___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Advice Wanted on sonic.c Indentation Warning

2016-05-06 Thread Martin Galvan
Pinging this again. Is it ok to commit? I think the patch should still
apply since the file hasn't changed in a while.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Advice Wanted on sonic.c Indentation Warning

2016-05-06 Thread Gedare Bloom
Yes.

On Fri, May 6, 2016 at 9:41 AM, Martin Galvan
 wrote:
> Pinging this again. Is it ok to commit? I think the patch should still
> apply since the file hasn't changed in a while.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: Advice Wanted on sonic.c Indentation Warning

2016-05-06 Thread Martin Galvan
Thanks. Here's what I committed:

https://git.rtems.org/rtems/commit/?id=b4d7d5d52e6459ed4fe490ca272fb6cb83e512aa

However, I got an error when I did the push. Here's the output:

$ git push
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 910 bytes | 0 bytes/s, done.
Total 7 (delta 6), reused 0 (delta 0)
remote: 1: mail v...@rtems.org
remote: 2: update github
remote: 3: update trac
remote: 4: IRC
remote: 5: Buildbot
remote: git_buildbot: ERROR: Could not connect to
buildbot.int.rtems.org:9899: Connection was refused by other side: 61:
Connection refused.
To ssh://mart...@dispatch.rtems.org/data/git/rtems.git
   f65f803..b4d7d5d  master -> master

I don't remember seeing that when I added myself to MAINTAINERS. Has
this happened to anybody else?
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 2/8] bsp/shared: Print the exception stack frame before the shut down message.

2016-05-06 Thread Chris Johns
This lets you see the exception otherwise the key press clears the screen
on the reboot on a PC BSP.

Also state there has been a fatal error.
---
 c/src/lib/libbsp/shared/bspclean.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/c/src/lib/libbsp/shared/bspclean.c 
b/c/src/lib/libbsp/shared/bspclean.c
index 2262c9d..4265f11 100644
--- a/c/src/lib/libbsp/shared/bspclean.c
+++ b/c/src/lib/libbsp/shared/bspclean.c
@@ -17,8 +17,14 @@ void bsp_fatal_extension(
   rtems_fatal_code code
 )
 {
+  #if (BSP_PRINT_EXCEPTION_CONTEXT)
+if ( source == RTEMS_FATAL_SOURCE_EXCEPTION ) {
+  rtems_exception_frame_print( (const rtems_exception_frame *) code );
+}
+  #endif
+
   #if (BSP_PRESS_KEY_FOR_RESET)
-printk( "\nEXECUTIVE SHUTDOWN! Any key to reboot..." );
+printk( "\nFATAL ERROR - Executive shutdown! Any key to reboot..." );
 
 /*
  * Wait for a key to be pressed
@@ -29,12 +35,6 @@ void bsp_fatal_extension(
 printk("\n");
   #endif
 
-  #if (BSP_PRINT_EXCEPTION_CONTEXT)
-if ( source == RTEMS_FATAL_SOURCE_EXCEPTION ) {
-  rtems_exception_frame_print( (const rtems_exception_frame *) code );
-}
-  #endif
-
   /*
*  Check both conditions -- if you want to ask for reboot, then
*  you must have meant to reset the board.
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 1/8] bsp/shared: Add bsp_interrupt_handler_is_empty.

2016-05-06 Thread Chris Johns
---
 c/src/lib/libbsp/shared/include/irq-generic.h | 15 ++-
 c/src/lib/libbsp/shared/src/irq-generic.c | 19 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/c/src/lib/libbsp/shared/include/irq-generic.h 
b/c/src/lib/libbsp/shared/include/irq-generic.h
index 389bd5a..4e89d74 100644
--- a/c/src/lib/libbsp/shared/include/irq-generic.h
+++ b/c/src/lib/libbsp/shared/include/irq-generic.h
@@ -17,6 +17,8 @@
  *  Germany
  *  
  *
+ * Copyright (c) 2016 Chris Johns 
+ *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
  * http://www.rtems.org/license/LICENSE.
@@ -106,7 +108,7 @@ static inline rtems_vector_number 
bsp_interrupt_handler_index(
  * @defgroup bsp_interrupt BSP Interrupt Support
  *
  * @ingroup bsp_shared
- * 
+ *
  * @brief Generic BSP Interrupt Support
  *
  * The BSP interrupt support manages a sequence of interrupt vector numbers
@@ -272,6 +274,17 @@ static inline void 
bsp_interrupt_handler_dispatch(rtems_vector_number vector)
   }
 }
 
+/**
+ * @brief Is interrupt handler empty.
+ *
+ * This routine returns true if the handler is empty and has not been
+ * initialised else false is returned. The interrupt lock is not used
+ * so this call can be used from within interrupts.
+ *
+ * @return If empty true shall be returned else false is returned.
+ */
+bool bsp_interrupt_handler_is_empty(rtems_vector_number vector);
+
 /** @} */
 
 /* For internal use only */
diff --git a/c/src/lib/libbsp/shared/src/irq-generic.c 
b/c/src/lib/libbsp/shared/src/irq-generic.c
index 19b52af..c62a756 100644
--- a/c/src/lib/libbsp/shared/src/irq-generic.c
+++ b/c/src/lib/libbsp/shared/src/irq-generic.c
@@ -566,3 +566,22 @@ rtems_status_code rtems_interrupt_handler_iterate(
 {
   return bsp_interrupt_handler_iterate(vector, routine, arg);
 }
+
+bool bsp_interrupt_handler_is_empty(rtems_vector_number vector)
+{
+  rtems_vector_number index = 0;
+  bsp_interrupt_handler_entry *head = NULL;
+  bool empty;
+
+  /* For use in interrupts so no lock. */
+
+  /* Get handler table index */
+  index = bsp_interrupt_handler_index(vector);
+
+  /* Get head entry of the handler list for the vector */
+  head = &bsp_interrupt_handler_table [index];
+
+  empty = bsp_interrupt_is_empty_handler_entry(head);
+
+  return empty;
+}
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


i386/pc386 interrupt and remote debug stub improvements.

2016-05-06 Thread Chris Johns
These patches improve the ATPIC handling removing the spurious interrupt
from PIC devices connected to the slave PIC.

The GDB stub now supports x86 debug registers so hardware break and
access point support works in gdb.

Add an IDE disable boot command line option.

Fix printk support on serial ports.
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 4/8] i386/pc386: Fix printk with the console changes.

2016-05-06 Thread Chris Johns
---
 .../lib/libbsp/i386/pc386/console/printk_support.c | 69 --
 1 file changed, 37 insertions(+), 32 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/console/printk_support.c 
b/c/src/lib/libbsp/i386/pc386/console/printk_support.c
index d4adf55..d6dd569 100644
--- a/c/src/lib/libbsp/i386/pc386/console/printk_support.c
+++ b/c/src/lib/libbsp/i386/pc386/console/printk_support.c
@@ -27,16 +27,7 @@
 #include 
 #include "../../../shared/console_private.h"
 
-rtems_device_minor_number BSPPrintkPort = 0;
-
-#if (BSP_IS_EDISON == 1)
-void edison_write_polled(int minor, char cChar); /* XXX */
-int edison_inbyte_nonblocking_polled(int minor);
-#endif
-
-#if BSP_ENABLE_COM1_COM4
-int ns16550_inbyte_nonblocking_polled( int minor );
-#endif
+rtems_device_minor_number BSPPrintkPort = 0;
 
 void BSP_outch(char ch);
 int BSP_inch(void);
@@ -44,41 +35,55 @@ int BSP_inch(void);
 void BSP_outch(char ch)
 {
   #if BSP_ENABLE_VGA
-if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
-  _IBMPC_outch( ch );
-  return;
-}
+bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
+  #else
+bool isVga = false;
   #endif
-  console_tbl *cptr;
 
-  cptr = &Console_Configuration_Ports[BSPPrintkPort];
-  cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
+  if ( !isVga ) {
+console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
+if (port->pDeviceFns && port->pDeviceFns->deviceWritePolled) {
+  port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
+  /*
+   * No termios so expand the LF to LF/CR.
+   */
+  if ( ch == '\n')
+port->pDeviceFns->deviceWritePolled( BSPPrintkPort, '\r' );
+}
+return;
+  }
+
+  #if BSP_ENABLE_VGA
+_IBMPC_outch( ch );
+  #endif
 }
 
-int BSP_inch(void) 
+int BSP_inch(void)
 {
-  int   result = -1;
-
   #if BSP_ENABLE_VGA
-if ( BSPPrintkPort == BSP_CONSOLE_VGA ) {
-  result = BSP_wait_polled_input();
-} else
+bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
+  #else
+bool isVga = false;
   #endif
-  #if BSP_ENABLE_COM1_COM4
-{
+
+  int result = -1;
+
+  if ( !isVga ) {
+console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
+if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
   do {
-result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort );
+result = port->pDeviceFns->deviceRead( BSPPrintkPort );
   } while (result == -1);
+  return result;
 }
+  }
+
+  #if BSP_ENABLE_VGA
+result = BSP_wait_polled_input();
   #endif
-  #if (BSP_IS_EDISON == 1)
-do {
-  result = edison_inbyte_nonblocking_polled( BSPPrintkPort );
-} while (result == -1);
-  #endif
+
   return result;
 }
 
 BSP_output_char_function_type BSP_output_char = BSP_outch;
 BSP_polling_getchar_function_type BSP_poll_char = BSP_inch;
-
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/8] bsp/pc386: Use irq-generic.

2016-05-06 Thread Chris Johns
---
 c/src/lib/libbsp/i386/pc386/clock/ckinit.c |  5 ++---
 c/src/lib/libbsp/i386/pc386/timer/timer.c  | 10 +-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c 
b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
index 2291839..67f4bf7 100644
--- a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
+++ b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c
@@ -24,7 +24,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -150,7 +150,7 @@ static void clockOn(void)
   }
   pc386_clock_click_count = US_TO_TICK(pc386_microseconds_per_isr);
 
-  BSP_irq_enable_at_i8259s( BSP_PERIODIC_TIMER - BSP_IRQ_VECTOR_BASE );
+  bsp_interrupt_vector_enable( BSP_PERIODIC_TIMER - BSP_IRQ_VECTOR_BASE );
 
   #if 0
 printk( "configured usecs per tick=%d \n",
@@ -256,4 +256,3 @@ void Clock_driver_support_initialize_hardware(void)
   } while (0)
 
 #include "../../../shared/clockdrv_shell.h"
-
diff --git a/c/src/lib/libbsp/i386/pc386/timer/timer.c 
b/c/src/lib/libbsp/i386/pc386/timer/timer.c
index 541d2e3..0e4d6a9 100644
--- a/c/src/lib/libbsp/i386/pc386/timer/timer.c
+++ b/c/src/lib/libbsp/i386/pc386/timer/timer.c
@@ -16,7 +16,7 @@
  *  This file is provided "AS IS" without warranty of any kind, either
  *  expressed or implied.
  *
- *  Based upon code by 
+ *  Based upon code by
  *  COPYRIGHT (c) 1989-1999.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 /*
@@ -118,7 +118,7 @@ static void timerOff(const rtems_raw_irq_connect_data* used)
   /*
* disable interrrupt at i8259 level
*/
-   BSP_irq_disable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+   bsp_interrupt_vector_disable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
/* reset timer mode to standard (DOS) value */
outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
outport_byte(TIMER_CNTR0, 0);
@@ -135,12 +135,12 @@ static void timerOn(const rtems_raw_irq_connect_data* 
used)
   /*
* enable interrrupt at i8259 level
*/
-  BSP_irq_enable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+  bsp_interrupt_vector_enable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
 }
 
 static int timerIsOn(const rtems_raw_irq_connect_data *used)
 {
-  return BSP_irq_enabled_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+  return bsp_interrupt_vector_enable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
 }
 
 static rtems_raw_irq_connect_data timer_raw_irq_data = {
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 5/8] i386/pc386: Fix interrupt support.

2016-05-06 Thread Chris Johns
Fix the interrupt and stop the spurious interrupt from happening.

The fix moves the EOI to C code and cleans that functionality out
of the asm part of the ISR handler.

The code checks the ISR and IRR registers on the enable.

Only ack the master for a slave IRQ if the slave has no other pending
requests.
---
 c/src/lib/libbsp/i386/Makefile.am   |   1 +
 c/src/lib/libbsp/i386/pc386/Makefile.am |   1 +
 c/src/lib/libbsp/i386/shared/irq/elcr.c | 170 +
 c/src/lib/libbsp/i386/shared/irq/elcr.h |  37 
 c/src/lib/libbsp/i386/shared/irq/irq.c  | 278 
 c/src/lib/libbsp/i386/shared/irq/irq.h  |  55 +++---
 c/src/lib/libbsp/i386/shared/irq/irq_asm.S  |  81 +---
 c/src/lib/libbsp/i386/shared/irq/irq_asm.h  |  16 +-
 c/src/lib/libbsp/i386/shared/irq/irq_init.c |   4 +-
 9 files changed, 471 insertions(+), 172 deletions(-)
 create mode 100644 c/src/lib/libbsp/i386/shared/irq/elcr.c
 create mode 100644 c/src/lib/libbsp/i386/shared/irq/elcr.h

diff --git a/c/src/lib/libbsp/i386/Makefile.am 
b/c/src/lib/libbsp/i386/Makefile.am
index 3b6df65..567f75f 100644
--- a/c/src/lib/libbsp/i386/Makefile.am
+++ b/c/src/lib/libbsp/i386/Makefile.am
@@ -19,6 +19,7 @@ EXTRA_DIST += shared/irq/irq.h shared/irq/irq.c
 EXTRA_DIST += shared/irq/irq_asm.h shared/irq/irq_asm.S
 EXTRA_DIST += shared/irq/idt.c
 EXTRA_DIST += shared/irq/irq_init.c
+EXTRA_DIST += shared/irq/elcr.c
 
 # shared/pci
 EXTRA_DIST += shared/pci/pcibios.c
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am 
b/c/src/lib/libbsp/i386/pc386/Makefile.am
index 22d4bf1..d051da8 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -161,6 +161,7 @@ libbsp_a_SOURCES += startup/bspreset.c
 libbsp_a_SOURCES += ../../i386/shared/irq/idt.c
 libbsp_a_SOURCES += ../../i386/shared/irq/irq.c
 libbsp_a_SOURCES += ../../i386/shared/irq/irq_init.c
+libbsp_a_SOURCES += ../../i386/shared/irq/elcr.c
 libbsp_a_SOURCES += ../../shared/bootcard.c
 libbsp_a_SOURCES += ../../shared/sbrk.c
 libbsp_a_SOURCES += startup/ldsegs.S
diff --git a/c/src/lib/libbsp/i386/shared/irq/elcr.c 
b/c/src/lib/libbsp/i386/shared/irq/elcr.c
new file mode 100644
index 000..f72e36c
--- /dev/null
+++ b/c/src/lib/libbsp/i386/shared/irq/elcr.c
@@ -0,0 +1,170 @@
+/*-
+ * Copyright (c) 2004 John Baldwin 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+#ifndef __rtems__
+__FBSDID("$FreeBSD$");
+#endif /* __rtems__ */
+
+/*
+ * The ELCR is a register that controls the trigger mode and polarity of
+ * EISA and ISA interrupts.  In FreeBSD 3.x and 4.x, the ELCR was only
+ * consulted for determining the appropriate trigger mode of EISA
+ * interrupts when using an APIC.  However, it seems that almost all
+ * systems that include PCI also include an ELCR that manages the ISA
+ * IRQs 0 through 15.  Thus, we check for the presence of an ELCR on
+ * every machine by checking to see if the values found at bootup are
+ * sane.  Note that the polarity of ISA and EISA IRQs are linked to the
+ * trigger mode.  All edge triggered IRQs use active-hi polarity, and
+ * all level triggered interrupts use active-lo polarity.
+ *
+ * The format of the ELCR is simple: it is a 16-bit bitmap where bit 0
+ * controls IRQ 0, bit 1 controls IRQ 1, etc.  If the bit is zero, the
+ * associated IRQ is edge triggered.  If the bit is one, the IRQ is
+ * level triggered.
+ */
+
+#ifndef __rtems__
+#include 
+#include 
+#include 
+#include 
+#endif /* __rtems__ */
+
+#ifdef __rtems__
+#include 
+#include "i386_io.h"
+#include 
+#include "elcr.h"
+#endif /* __rtems__ */
+
+#defineELCR_PORT   0x4d0
+#defineELCR_MASK(irq)  (1 << (i

[PATCH 6/8] i386/pc386: Add --ide-disable boot command line option.

2016-05-06 Thread Chris Johns
---
 c/src/lib/libbsp/i386/pc386/ide/idecfg.c | 108 ---
 1 file changed, 57 insertions(+), 51 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/ide/idecfg.c 
b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c
index f0f5bfe..371a6ee 100644
--- a/c/src/lib/libbsp/i386/pc386/ide/idecfg.c
+++ b/c/src/lib/libbsp/i386/pc386/ide/idecfg.c
@@ -74,66 +74,72 @@ unsigned long IDE_Controller_Count;
 
 void bsp_ide_cmdline_init(void)
 {
-  bool ide1 = IDE1_DEFAULT;
-  bool ide2 = IDE2_DEFAULT;
-  const char* ide;
-
-  /*
-   * Can have:
-   *  --ide=0,1
-   */
-  ide = bsp_cmdline_arg ("--ide=");
-
-  if (ide)
-  {
-int i;
+  const char* ide_disable;
+
+  ide_disable = bsp_cmdline_arg ("--ide-disable");
+
+  if (ide_disable == NULL) {
+bool ide1 = IDE1_DEFAULT;
+bool ide2 = IDE2_DEFAULT;
+const char* ide;
+
 /*
- * If a command line option exists remove the defaults.
+ * Can have:
+ *  --ide=0,1
  */
-ide1 = ide2 = false;
+ide = bsp_cmdline_arg ("--ide=");
 
-ide += sizeof ("--ide=") - 1;
-
-for (i = 0; i < 3; i++)
+if (ide)
 {
-  switch (ide[i])
+  int i;
+  /*
+   * If a command line option exists remove the defaults.
+   */
+  ide1 = ide2 = false;
+
+  ide += sizeof ("--ide=") - 1;
+
+  for (i = 0; i < 3; i++)
   {
-case '0':
-  ide1 = true;
-  break;
-case '1':
-  ide2 = true;
-  break;
-case '2':
-case '3':
-case '4':
-case '5':
-case '6':
-case '7':
-case '8':
-case '9':
-case ',':
-  break;
-default:
-  break;
+switch (ide[i])
+{
+  case '0':
+ide1 = true;
+break;
+  case '1':
+ide2 = true;
+break;
+  case '2':
+  case '3':
+  case '4':
+  case '5':
+  case '6':
+  case '7':
+  case '8':
+  case '9':
+  case ',':
+break;
+  default:
+break;
+}
   }
 }
-  }
 
-  if (ide2 && !ide1)
-IDE_Controller_Table[0] = IDE_Controller_Table[1];
+if (ide2 && !ide1)
+  IDE_Controller_Table[0] = IDE_Controller_Table[1];
 
-  if (ide1)
-IDE_Controller_Count++;
-  if (ide2)
-IDE_Controller_Count++;
+if (ide1)
+  IDE_Controller_Count++;
+if (ide2)
+  IDE_Controller_Count++;
 
-  /*
-   * Allow the user to get the initialise to print probing
-   * type information.
-   */
-  ide = bsp_cmdline_arg ("--ide-show");
+/*
+ * Allow the user to get the initialise to print probing
+ * type information.
+ */
+ide = bsp_cmdline_arg ("--ide-show");
 
-  if (ide)
-pc386_ide_show = true;
+if (ide)
+  pc386_ide_show = true;
+  }
 }
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 7/8] i386/pc386: EOI the master and slave for slave IRQ signals.

2016-05-06 Thread Chris Johns
---
 c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c | 39 ++
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c 
b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
index 25a153f..7802270 100644
--- a/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
+++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub-glue.c
@@ -9,7 +9,7 @@
  */
 
 #include 
-#include 
+#include 
 #include 
 
 #include "../../../shared/console_private.h"
@@ -31,6 +31,7 @@ extern int remote_debug;
 
 /* Current uart and port used by the gdb stub */
 static int  uart_current;
+static int  uart_vector;
 static console_tbl* port_current;
 
 /*
@@ -66,16 +67,41 @@ __asm__ ("pushl %ebx"); 
 /* Push eip */
 __asm__ ("movl  i386_gdb_uart_isr_regsav + 4, %ebx");/* Restore ebx */
 __asm__ ("movl  i386_gdb_uart_isr_regsav + 8, %edx");/* Restore edx */
 __asm__ ("i386_gdb_uart_isr_1:");
-__asm__ ("movb  $0x20, %al");
-__asm__ ("outb  %al, $0x20");
 __asm__ ("movl  i386_gdb_uart_isr_regsav, %eax");/* Restore eax */
 __asm__ ("iret");/* Done */
 
 static int gdb_hello_index;
 static const char const* gdb_hello = "+";
 
+static inline uint8_t BSP_i8259a_irq_in_service_reg(uint32_t ioport)
+{
+  uint8_t isr;
+  outport_byte(ioport, PIC_OCW3_SEL | PIC_OCW3_RR | PIC_OCW3_RIS);
+  inport_byte(ioport, isr);
+  outport_byte(ioport, PIC_OCW3_SEL | PIC_OCW3_RR);
+  return isr;
+}
+
+static inline void BSP_irq_ack_at_i8259a(const int irqLine)
+{
+  uint8_t slave_isr = 0;
+  if (irqLine >= 8) {
+   outport_byte(PIC_SLAVE_COMMAND_IO_PORT, PIC_EOI);
+   slave_isr = BSP_i8259a_irq_in_service_reg(PIC_SLAVE_COMMAND_IO_PORT);
+  }
+
+  /*
+   * Only issue the EOI to the master if there are no more interrupts in
+   * service for the slave. i8259a data sheet page 18, The Special Fully Nested
+   * Mode, b.
+   */
+  if (slave_isr == 0)
+outport_byte(PIC_MASTER_COMMAND_IO_PORT, PIC_EOI);
+}
+
 int i386_gdb_uart_ctrl_c_check(void)
 {
+  BSP_irq_ack_at_i8259a(uart_vector);
   if (port_current) {
 int c = 0;
 while (c >= 0) {
@@ -139,17 +165,17 @@ i386_stub_glue_init(int uart)
 
 static void BSP_uart_on(const rtems_raw_irq_connect_data* used)
 {
-  BSP_irq_enable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+  bsp_interrupt_vector_enable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
 }
 
 static void BSP_uart_off(const rtems_raw_irq_connect_data* used)
 {
-  BSP_irq_disable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+  bsp_interrupt_vector_disable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
 }
 
 static int BSP_uart_isOn(const rtems_raw_irq_connect_data* used)
 {
-  return BSP_irq_enabled_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+  return bsp_interrupt_vector_enable(used->idtIndex - BSP_IRQ_VECTOR_BASE);
 }
 
 /*
@@ -169,6 +195,7 @@ void i386_stub_glue_init_breakin(void)
 printk("GDB: no UART interrupt support\n");
   }
   else {
+uart_vector = port_current->ulIntVector;
 uart_raw_irq_data.idtIndex = port_current->ulIntVector + 
BSP_IRQ_VECTOR_BASE;
 
 if (!i386_get_current_idt_entry(&uart_raw_irq_data)) {
-- 
2.4.6

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 8/8] i386/pc386: Add x86 debug register support for hardware break points.

2016-05-06 Thread Chris Johns
---
 c/src/lib/libbsp/i386/shared/comm/i386-stub.c | 158 +-
 1 file changed, 157 insertions(+), 1 deletion(-)

diff --git a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c 
b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
index b3630ee..d28a431 100644
--- a/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
+++ b/c/src/lib/libbsp/i386/shared/comm/i386-stub.c
@@ -102,8 +102,14 @@
 #include 
 
 /*
+ * Number of debug registers.
+ */
+#define NUM_DEBUG_REGISTERS 4
+
+/*
  * Prototypes we need to avoid warnings but not going into public space.
  */
+void bsp_reset(void);
 void breakpoint (void);
 void set_debug_traps(void);
 void set_mem_err(void);
@@ -159,7 +165,6 @@ int i386_gdb_registers[NUMREGS];
 int i386_gdb_remcomStack[STACKSIZE / sizeof (int)];
 int *i386_gdb_stackPtr = &i386_gdb_remcomStack[STACKSIZE / sizeof (int) - 1];
 
-
 static int gdb_connected;
 
 /***  ASSEMBLY CODE MACROS */
@@ -771,6 +776,65 @@ hexToInt (char **ptr, int *intValue)
 }
 
 /*
+ * Get/Set the DR registers.
+ */
+static uint32_t getDR7(void)
+{
+  uint32_t value = 0;
+  asm volatile (" movl %%dr7, %0;" : "=r" (value) : : );
+  return value;
+}
+
+static void setDR7(uint32_t value)
+{
+  asm volatile (" movl %0, %%dr7;" : : "r" (value) : );
+}
+
+static uint32_t getDR(int reg)
+{
+  uint32_t value = 0;
+  switch (reg)
+{
+case 0:
+  asm volatile (" movl %%dr0, %0;" : "=r" (value) : : );
+  break;
+case 1:
+  asm volatile (" movl %%dr1, %0;" : "=r" (value) : : );
+  break;
+case 2:
+  asm volatile (" movl %%dr2, %0;" : "=r" (value) : : );
+  break;
+case 3:
+  asm volatile (" movl %%dr3, %0;" : "=r" (value) : : );
+  break;
+default:
+  break;
+}
+  return value;
+}
+
+static void setDR(int reg, uint32_t addr)
+{
+  switch (reg)
+{
+case 0:
+  asm volatile (" movl %0, %%dr0;" : : "r" (addr) : );
+  break;
+case 1:
+  asm volatile (" movl %0, %%dr1;" : : "r" (addr) : );
+  break;
+case 2:
+  asm volatile (" movl %0, %%dr2;" : : "r" (addr) : );
+  break;
+case 3:
+  asm volatile (" movl %0, %%dr3;" : : "r" (addr) : );
+  break;
+default:
+  break;
+}
+}
+
+/*
  * This function does all command procesing for interfacing to gdb.
  *
  * NOTE: This method is called from assembly code so must be marked
@@ -939,6 +1003,98 @@ handle_exception (int exceptionVector)
  _returnFromException ();  /* this is a jump */
  break;
 
+   case 'Z':
+   case 'z':
+ /*
+  * Z1 = execute (00b)
+  * Z2 = write (01b)
+  * Z3 = read (??, need to use 11b))
+  * Z4 = read/write (11b)
+  */
+ ptr = &remcomInBuffer[1];
+ reg = *(ptr++);
+ if (reg == '0')
+   break;
+ printk("hbreak\n");
+ switch ((char) reg)
+   {
+   case '1':
+ reg = 0;
+ break;
+   case '2':
+ reg = 1;
+   case '3':
+   case '4':
+   default:
+ reg = 3;
+ break;
+   }
+ if (*(ptr++) == ',')
+   {
+ bool insert = remcomInBuffer[0] == 'Z';
+ printk("hbreak type\n", insert);
+ if (hexToInt (&ptr, &addr))
+   {
+ if (*(ptr++) == ',')
+   {
+ uint32_t dr7;
+ int i;
+ hexToInt(&ptr, &length);
+ dr7 = getDR7();
+ for (i = 0; i < NUM_DEBUG_REGISTERS; ++i)
+   {
+ if ((dr7 & (2 << (i * 2))) == 0)
+   {
+ if (insert)
+   {
+ setDR(i, addr);
+ dr7 |=
+   ((length - 1) << ((i * 2) + 18)) |
+   (reg << ((i * 2) + 16)) |
+   (2 << (i * 2));
+ setDR7(dr7);
+ printk("set DR%i to %08x\n", i, addr);
+ break;
+   }
+   }
+ else if (!insert)
+   {
+ uint32_t dra = getDR(i);
+ if (dra == addr)
+   {
+ dr7 &= ~(2 << (i * 2));
+ setDR7(dr7);
+ printk("clear DR%i\n", i);
+ break;
+   }
+   }
+   }
+ if (insert && (i == NUM_DEBUG_REGISTERS))
+   {
+ ptr = 0;
+   }
+