SOCIS16: RTEMS Fault Tolerance

2016-03-09 Thread Saeed Ehteshamifar
Hello,

During SOCIS15, I adapted two fault injection tools to RTEMS: one tool to
generate and compile code (in Python), one tool to execute the binary on
(virtual) machine and store injection result (in Java).
Interestingly, bunch of test cases (POSIX function calls with corner
arguments) led to RTEMS crash (out of approximately 600 test cases).

Future works for current state of the project are listed under final
report's

TOC. This year (hopefully I get admitted!), I'm very interested to
integrate the two in one tool (in Python) and automate the whole
generation-execution-store results process.

FYI, the proposed framework tests RTEMS' POSIX API via data-type based
fault injection.

Any and all ideas, suggestions, comments are highly welcomed!

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

Re: x86_64 BSP as GSOC2016 project

2016-03-09 Thread Joel Sherrill
On Tue, Mar 8, 2016 at 8:46 PM, Saket Sinha  wrote:

> Hi Joel,
>
>
> On Tue, Mar 1, 2016 at 5:40 AM, Joel Sherrill  wrote:
> >
> >
> > On Mon, Feb 29, 2016 at 2:00 PM, Saket Sinha 
> > wrote:
> >>
> >> On Tue, Mar 1, 2016 at 1:14 AM, Saket Sinha 
> >> wrote:
> >> > Hi,
> >> >
> >> > Congratulations to the coreboot team for selection in GSOC 2016.
> >>
> >> Sorry for the typo. I meant the RTEMS team. I worked for Coreboot last
> >> year so still relate to  with GSOC everytime mistakenly.
> >>
> >> >
> >> > I am interested in working on x86_64 BSP as GSOC2016 project with
> >> > RTEMS and with initial guidance from Joel as to how to get started, I
> >> > am working on the same.
> >>
> >
> > Great! This is a nice project we need.
> >
> > Have you done the RTEMS GSoC hello world project?
> >
>
> Yes. I am done with that.
>
> > The x86_64 now has tools for 4.12. It needs a port and a BSP. The BSP can
> > share
> > with the pc386 but we likely have to address the dependency on legacy
> > hardware.
> > Some of those issues are captured in the pc386 project page. I have
> started
> > to try
> > to fix the dependency on legacy PCI BIOS but there is more like APIC
> support
> > and
> > device probes.
> >
>
> I have tried building x86_64 with RTEMS source builder just to verify
> where we are.
> Now my question in how to test it?
> Do you want me to run it on a real  x86_64 hardware or qemu-x86_64
> would be enough to test it ?
>

For all the initial work, qemu-system-x86_64 will be sufficient. Once it is
functional enough, it will need to be periodically tested on real HW.

As a starting point, you will need to add score/cpu/x86_64 and get a
stub compiling with no BSP. Then you need a simple x86_64 BSP.
Initially I would recommend focusing on the minimum required to
run hello world.

But a lot of the regular pc386 BSP should be sharable and reusable with
an x86_64 BSP. I see that as a real challenge in this effort. We need
to decide where to move shared code. Since it is shared between two
architectures, it is something like libbsp/shared/PC but that is open
for discussion. For sure, you want to share as much code as possible
and ensure the pc386 BSP continues to work.

FWIW I have a series of patches that remove the need for legacy
PCI BIOS and allow the use of PCI UARTs as the console. But
there are other general issues impacting both 32 and 64 bit BSPs.

+ we need APIC support
+ probe for what's available using ACPI
   - probe for legacy IDE/ATA when not there hangs
   - need to probe for legacy COM ports

But you have to get by hello world on x86_64 first.

Work on your proposal so we can fine tune the plan.

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

[PATCH 00/17] pc386 non-legacy enhancements

2016-03-09 Thread Joel Sherrill
First, there are only 15 patches in this series. The last two
are additions of commands directly to fileio. Both may be of
interest but should be discussed separately.

This series started with the need to get the pc386 BSP working
on an embedded PC without legacy PCI BIOS and with a COM1 port
on the PCI and not in I/O space. This target board does not have
an IDE/ATA controller. The probe hangs so the build disables that.

The first patches eliminate the need for the pc386 specific pcibios.h
and add dynamic detection of using PCI BIOS or I/O space accesses for
PCI Configuration Space. It also added a shared implementation of
pci_find_device() and later patches use this to eliminate copies
in other BSPs. A ticket will be filed for the last case.

There are patches to add boot command line arguments for --printk=XXX
to specify printk output go somewhere besides the --console=XXX device.
There is also a --disable-com1-com4 boot command line argument to
disable those at run-time. The BSP is booted with these arguments:

The PCI UART is added as /dev/pcicom1. It uses a UART PCI table from
FreeBSD and probes for all PCI UARTs. These are dynamically installed.
The dynamic registration support in the shared console was enhanced
to be able to be called multiple times.

kernel tftp://192.168.1.92/fileio.exe --console=pcicom1 --printk=vgacons 
--disable-com1-com4
boot fileio.exe

Along the way, there is also miscellaneous clean up to comments, a warning
in bsp_fatal_halt.c, etc.

I hope the description helps.

--joel

Joel Sherrill (17):
  pc386: Eliminate pcibios.h and begin removal obsolete PCI BIOS API
uses
  i386/shared/pci/pcibios.c: Remove unused pcib_special_cycle()
  i386/shared/pci/pcibios.c: Remove unused pcib_find_by_class()
  pc386/configure.ac: Delete incorrect and unused AM_CONDITIONAL
  Add shared PCI support and enhance pc386 to support non-legacy PCI
configuration space
  pc386: Improve boot command arguments for console/printk device
selection
  console_private.h: Remove prototypes for non-existent methods
bsp_com_inch() and bsp_com_outch()
  console_private.h: Improve comment for vt_ioctl()
  pc386: Add PCI UART support
  pc386/startup/bspstart.c: Reformat and cleanup file header
  pc386/startup/bsp_fatal_halt.c: Fix noreturn does return warning
  libbsp/shared/console.c: Clean up memory allocation for per device
data
  pc386: Add --disable-com1-com4 boot argument
  mips/malta: Use shared pci_find_device() and removed unused
pci_list_devices()
  powerpc/mvme5500: Use shared pci_find_device()
  fileio: lspci candidate command
  fileio: Add command "com" to write to files

 c/src/lib/libbsp/Makefile.am   |   3 +
 c/src/lib/libbsp/i386/Makefile.am  |   2 +-
 c/src/lib/libbsp/i386/pc386/Makefile.am|   8 +-
 c/src/lib/libbsp/i386/pc386/configure.ac   |   1 -
 c/src/lib/libbsp/i386/pc386/console/conscfg.c  |  29 +-
 .../lib/libbsp/i386/pc386/console/console_select.c | 217 +--
 c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c | 398 +
 c/src/lib/libbsp/i386/pc386/include/bsp.h  |  10 +
 c/src/lib/libbsp/i386/pc386/preinstall.am  |   4 -
 .../lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c |   3 +
 c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 102 --
 c/src/lib/libbsp/i386/shared/pci/pci_io.c  | 200 +++
 c/src/lib/libbsp/i386/shared/pci/pcibios.c | 246 ++---
 c/src/lib/libbsp/i386/shared/pci/pcibios.h |  62 
 c/src/lib/libbsp/mips/malta/Makefile.am|   3 +-
 c/src/lib/libbsp/mips/malta/include/pci.h  |  32 --
 c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c| 277 --
 c/src/lib/libbsp/mips/malta/pci/pcilistdevices.c   | 102 --
 c/src/lib/libbsp/powerpc/mvme5500/Makefile.am  |   6 +-
 .../libbsp/powerpc/mvme5500/pci/pcifinddevice.c|  62 
 c/src/lib/libbsp/shared/console.c  |  57 ++-
 c/src/lib/libbsp/shared/console_private.h  |  35 +-
 c/src/lib/libbsp/shared/pci/pci_bus_count.c|  67 
 c/src/lib/libbsp/shared/pci/pci_find_device.c  | 274 ++
 c/src/libchip/network/if_fxp.c |  43 ++-
 testsuites/samples/fileio/Makefile.am  |   2 +-
 testsuites/samples/fileio/init.c   |   7 +-
 testsuites/samples/fileio/main_com.c   | 129 +++
 testsuites/samples/fileio/main_lspci.c |  43 +++
 29 files changed, 1540 insertions(+), 884 deletions(-)
 create mode 100644 c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c
 create mode 100644 c/src/lib/libbsp/i386/shared/pci/pci_io.c
 delete mode 100644 c/src/lib/libbsp/i386/shared/pci/pcibios.h
 delete mode 100644 c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c
 delete mode 100644 c/src/lib/libbsp/mips/malta/pci/pcilistdevices.c
 delete mode 100644 c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
 create mode 100644 c/src/l

[PATCH 13/17] pc386: Add --disable-com1-com4 boot argument

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/pc386/console/conscfg.c  | 29 +
 .../lib/libbsp/i386/pc386/console/console_select.c | 37 ++
 c/src/lib/libbsp/shared/console.c  |  4 +--
 3 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/console/conscfg.c 
b/c/src/lib/libbsp/i386/pc386/console/conscfg.c
index d5586d7..e59498b 100644
--- a/c/src/lib/libbsp/i386/pc386/console/conscfg.c
+++ b/c/src/lib/libbsp/i386/pc386/console/conscfg.c
@@ -1,11 +1,13 @@
-/*
- *  This file contains the libchip configuration information
- *  to instantiate the libchip driver for the VGA console
- *  and serial ports on a PC.
+/**
+ * @file
+ *
+ * This file contains the libchip configuration information
+ * to instantiate the libchip driver for the VGA console
+ * and serial ports on a PC.
  */
 
 /*
- *  COPYRIGHT (c) 1989-2014.
+ *  COPYRIGHT (c) 1989-2014, 2016.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -13,8 +15,6 @@
  *  http://www.rtems.org/license/LICENSE.
  */
 
-#include  /* write */
-
 #include 
 #include 
 #include 
@@ -23,7 +23,6 @@
 #endif
 #include 
 #include 
-#include 
 
 #if BSP_ENABLE_VGA
 #define VGA_CONSOLE_FUNCTIONS  &vgacons_fns
@@ -49,7 +48,7 @@
   static uint8_t com_get_register(uint32_t addr, uint8_t i)
   {
 register uint8_t val;
-  
+
 inport_byte( (addr + i),val );
 return val;
   }
@@ -58,6 +57,8 @@
   {
 outport_byte( (addr + i),val );
   }
+
+  extern bool pc386_com1_com4_enabled(int);
 #endif
 
 #if (BSP_IS_EDISON == 1 )
@@ -68,7 +69,7 @@ console_tbl Console_Configuration_Ports[] = {
 #if (BSP_IS_EDISON == 1)
   {
 "/dev/vgacons",/* sDeviceName */
--1, /* deviceType */
+-1,/* deviceType */
 &edison_fns,   /* pDeviceFns */
 NULL,  /* deviceProbe */
 NULL,  /* pDeviceFlow */
@@ -112,7 +113,7 @@ console_tbl Console_Configuration_Ports[] = {
 "/dev/com1",   /* sDeviceName */
 SERIAL_NS16550,/* deviceType */
 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
-NULL,  /* deviceProbe, assume it is there 
*/
+pc386_com1_com4_enabled,   /* deviceProbe */
 NULL,  /* pDeviceFlow */
 16,/* ulMargin */
 8, /* ulHysteresis */
@@ -131,7 +132,7 @@ console_tbl Console_Configuration_Ports[] = {
 "/dev/com2",   /* sDeviceName */
 SERIAL_NS16550,/* deviceType */
 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
-NULL,  /* deviceProbe, assume it is there 
*/
+pc386_com1_com4_enabled,   /* deviceProbe */
 NULL,  /* pDeviceFlow */
 16,/* ulMargin */
 8, /* ulHysteresis */
@@ -151,7 +152,7 @@ console_tbl Console_Configuration_Ports[] = {
 "/dev/com3",   /* sDeviceName */
 SERIAL_NS16550,/* deviceType */
 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
-NULL,  /* deviceProbe, assume it is there 
*/
+pc386_com1_com4_enabled,   /* deviceProbe */
 NULL,  /* pDeviceFlow */
 16,/* ulMargin */
 8, /* ulHysteresis */
@@ -171,7 +172,7 @@ console_tbl Console_Configuration_Ports[] = {
 "/dev/com4",   /* sDeviceName */
 SERIAL_NS16550,/* deviceType */
 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */
-NULL,  /* deviceProbe, assume it is there 
*/
+pc386_com1_com4_enabled,   /* deviceProbe */
 NULL,  /* pDeviceFlow */
 16,/* ulMargin */
 8, /* ulHysteresis */
diff --git a/c/src/lib/libbsp/i386/pc386/console/console_select.c 
b/c/src/lib/libbsp/i386/pc386/console/console_select.c
index c78b4b8..1d938a1 100644
--- a/c/src/lib/libbsp/i386/pc386/console/console_select.c
+++ b/c/src/lib/libbsp/i386/pc386/console/console_select.c
@@ -32,6 +32,22 @@
 #endif
 
 /*
+ * Forward prototype
+ */
+extern bool pc386_com1_com4_enabled(int);
+
+/*
+ * This method is used to determine if COM1-COM4 are enabled based upon
+ * boot command line arguments.
+ */
+static bool are_com1_com4_enabled;
+
+bool pc386_com1_com4_enabled(int minor)

[PATCH 05/17] Add shared PCI support and enhance pc386 to support non-legacy PCI configuration space

2016-03-09 Thread Joel Sherrill
This patch fundamentally results from enhancements to the pc386 BSP
to support systems which do **NOT** have the legacy PCI BIOS. The
patch adds support for detecting when legacy PCI BIOS is not
present and then using IO space to access to PCI Configuration Space.
This resulted in dynamically selected between two implementations
of PCI and refactoring out the shared methods.

This patch adds shared implementations of pci_bus_count() and
pci_find_device(). Subsequent patches will remove implementations
of these methods in other BSPs where possible.
---
 c/src/lib/libbsp/Makefile.am   |   3 +
 c/src/lib/libbsp/i386/Makefile.am  |   1 +
 c/src/lib/libbsp/i386/pc386/Makefile.am|   3 +
 c/src/lib/libbsp/i386/pc386/startup/bspstart.c |  31 ++-
 c/src/lib/libbsp/i386/shared/pci/pci_io.c  | 200 ++
 c/src/lib/libbsp/i386/shared/pci/pcibios.c | 149 ++
 c/src/lib/libbsp/shared/pci/pci_bus_count.c|  67 ++
 c/src/lib/libbsp/shared/pci/pci_find_device.c  | 274 +
 8 files changed, 594 insertions(+), 134 deletions(-)
 create mode 100644 c/src/lib/libbsp/i386/shared/pci/pci_io.c
 create mode 100644 c/src/lib/libbsp/shared/pci/pci_bus_count.c
 create mode 100644 c/src/lib/libbsp/shared/pci/pci_find_device.c

diff --git a/c/src/lib/libbsp/Makefile.am b/c/src/lib/libbsp/Makefile.am
index 16c276f..c54fdcb 100644
--- a/c/src/lib/libbsp/Makefile.am
+++ b/c/src/lib/libbsp/Makefile.am
@@ -29,6 +29,9 @@ EXTRA_DIST += shared/include/coverhd.h
 EXTRA_DIST += shared/gdbstub/rtems-stub-glue.c
 EXTRA_DIST += shared/include/bootcard.h
 
+EXTRA_DIST += shared/pci/pci_bus_count.c
+EXTRA_DIST += shared/pci/pci_find_device.c
+
 include_bspdir = $(includedir)/bsp
 
 include_bsp_HEADERS =
diff --git a/c/src/lib/libbsp/i386/Makefile.am 
b/c/src/lib/libbsp/i386/Makefile.am
index f10b764..3b6df65 100644
--- a/c/src/lib/libbsp/i386/Makefile.am
+++ b/c/src/lib/libbsp/i386/Makefile.am
@@ -22,6 +22,7 @@ EXTRA_DIST += shared/irq/irq_init.c
 
 # shared/pci
 EXTRA_DIST += shared/pci/pcibios.c
+EXTRA_DIST += shared/pci/pci_io.c
 
 include $(top_srcdir)/../../../automake/subdirs.am
 include $(top_srcdir)/../../../automake/local.am
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am 
b/c/src/lib/libbsp/i386/pc386/Makefile.am
index a9c645b..fc73afd 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -141,6 +141,9 @@ libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 
 # pci
 libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c
+libbsp_a_SOURCES += ../../i386/shared/pci/pci_io.c
+libbsp_a_SOURCES += ../../shared/pci/pci_bus_count.c
+libbsp_a_SOURCES += ../../shared/pci/pci_find_device.c
 
 include_HEADERS += ../../i386/shared/comm/uart.h
 # startup
diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c 
b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
index ac871f0..a0bbf66 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
+++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
@@ -34,17 +34,40 @@
 #include 
 
 /*
+ * PCI Bus Configuration
+ */
+rtems_pci_config_t BSP_pci_configuration = {
+  (volatile unsigned char*)0,
+  (volatile unsigned char*)0,
+  NULL
+};
+
+const pci_config_access_functions *pci_bios_initialize(void);
+const pci_config_access_functions *pci_io_initialize(void);
+
+/*
  * Helper to initialize the PCI Bus
  */
 static void bsp_pci_initialize_helper(void)
 {
 #if (BSP_IS_EDISON == 0)
-  int pci_init_retval;
+  const pci_config_access_functions *pci_accessors;
 
-  pci_init_retval = pci_initialize();
-  if (pci_init_retval != PCIB_ERR_SUCCESS) {
-  printk("PCI bus: could not initialize PCI BIOS interface\n");
+  pci_accessors = pci_bios_initialize();
+  if (pci_accessors != NULL) {
+printk("PCI bus: using PCI BIOS interface\n");
+BSP_pci_configuration.pci_functions = pci_accessors;
+return;
   }
+
+  pci_accessors = pci_io_initialize();
+  if (pci_accessors != NULL) {
+printk("PCI bus: using PCI I/O interface\n");
+BSP_pci_configuration.pci_functions = pci_accessors;
+return;
+  }
+
+  printk("PCI bus: could not initialize PCI BIOS interface\n");
 #endif
 }
 
diff --git a/c/src/lib/libbsp/i386/shared/pci/pci_io.c 
b/c/src/lib/libbsp/i386/shared/pci/pci_io.c
new file mode 100644
index 000..9103b5c
--- /dev/null
+++ b/c/src/lib/libbsp/i386/shared/pci/pci_io.c
@@ -0,0 +1,200 @@
+#include 
+#include 
+#include 
+
+static int pci_io_initialized = 0;
+
+/*
+ * Forward reference. Initialized at bottom.
+ */
+static const pci_config_access_functions pci_io_indirect_functions;
+
+/* prototype before defining */
+const pci_config_access_functions *pci_io_initialize(void);
+
+/*
+ * Detects presense of PCI Configuration is in I/O space. If so, return 
pointer to
+ * accessor methods.
+ *
+ * NOTE: TBD to determine if (a) PCI Bus exists and (b) this is the access 
method.
+ */
+const pci_config_access_functions *pci_io_initialize(void)
+{
+  pci_io_in

[PATCH 04/17] pc386/configure.ac: Delete incorrect and unused AM_CONDITIONAL

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/pc386/configure.ac | 1 -
 1 file changed, 1 deletion(-)

diff --git a/c/src/lib/libbsp/i386/pc386/configure.ac 
b/c/src/lib/libbsp/i386/pc386/configure.ac
index 469d5f5..17b7d02 100644
--- a/c/src/lib/libbsp/i386/pc386/configure.ac
+++ b/c/src/lib/libbsp/i386/pc386/configure.ac
@@ -34,7 +34,6 @@ AM_CONDITIONAL(RTEMS_VGA,[test "$BSP_ENABLE_VGA" = "1"])
 RTEMS_BSPOPTS_SET([BSP_ENABLE_COM1_COM4],[*],[1])
 RTEMS_BSPOPTS_HELP([BSP_ENABLE_COM1_COM4],
 [Set if COM1..COM4 support is enabled.])
-AM_CONDITIONAL(RTEMS_VGA,[test "$BSP_ENABLE_COM1_COM4" = "1"])
 
 RTEMS_BSPOPTS_SET([BSP_ENABLE_IDE],[edison],[0])
 RTEMS_BSPOPTS_SET([BSP_ENABLE_IDE],[*],[1])
-- 
1.8.3.1

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


[PATCH 09/17] pc386: Add PCI UART support

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/pc386/Makefile.am|   1 +
 c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c | 398 +
 c/src/lib/libbsp/i386/pc386/include/bsp.h  |   4 +
 c/src/lib/libbsp/i386/pc386/startup/bspstart.c |   5 +
 4 files changed, 408 insertions(+)
 create mode 100644 c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c

diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am 
b/c/src/lib/libbsp/i386/pc386/Makefile.am
index fc73afd..c54307f 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -130,6 +130,7 @@ libbsp_a_SOURCES += console/conscfg.c
 libbsp_a_SOURCES += console/printk_support.c
 libbsp_a_SOURCES += console/exar17d15x.c
 libbsp_a_SOURCES += console/rtd316.c
+libbsp_a_SOURCES += console/uart_bus_pci.c
 
 # gdb
 libbsp_a_SOURCES += ../../i386/shared/comm/i386-stub.c
diff --git a/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c 
b/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c
new file mode 100644
index 000..36afb73
--- /dev/null
+++ b/c/src/lib/libbsp/i386/pc386/console/uart_bus_pci.c
@@ -0,0 +1,398 @@
+/*
+ * This file was brought over from FreeBSD for the PCI device table.
+ * The code for using the table is RTEMS specific is also under the
+ * FreeBSD license.
+ *
+ * COPYRIGHT (c) 1989-2012.
+ * On-Line Applications Research Corporation (OAR).
+ */
+
+/*-
+ * Copyright (c) 2006 Marcel Moolenaar
+ * Copyright (c) 2001 M. Warner Losh
+ * 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 ``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 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.
+ */
+
+#ifdef __rtems__
+#include 
+#include 
+#else
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#endif
+
+#defineDEFAULT_RCLK1843200
+
+#ifndef __rtems__
+static int uart_pci_probe(device_t dev);
+
+static device_method_t uart_pci_methods[] = {
+   /* Device interface */
+   DEVMETHOD(device_probe, uart_pci_probe),
+   DEVMETHOD(device_attach,uart_bus_attach),
+   DEVMETHOD(device_detach,uart_bus_detach),
+   DEVMETHOD(device_resume,uart_bus_resume),
+   DEVMETHOD_END
+};
+
+static driver_t uart_pci_driver = {
+   uart_driver_name,
+   uart_pci_methods,
+   sizeof(struct uart_softc),
+};
+#endif
+
+struct pci_id {
+   uint16_tvendor;
+   uint16_tdevice;
+   uint16_tsubven;
+   uint16_tsubdev;
+   const char  *desc;
+   int rid;
+   int rclk;
+   int regshft;
+};
+
+static const struct pci_id pci_ns8250_ids[] = {
+{ 0x1028, 0x0008, 0x, 0, "Dell Remote Access Card III", 0x14,
+   128 * DEFAULT_RCLK },
+{ 0x1028, 0x0012, 0x, 0, "Dell RAC 4 Daughter Card Virtual UART", 0x14,
+   128 * DEFAULT_RCLK },
+{ 0x1033, 0x0074, 0x1033, 0x8014, "NEC RCV56ACF 56k Voice Modem", 0x10 },
+{ 0x1033, 0x007d, 0x1033, 0x8012, "NEC RS232C", 0x10 },
+{ 0x103c, 0x1048, 0x103c, 0x1227, "HP Diva Serial [GSP] UART - Powerbar SP2",
+   0x10 },
+{ 0x103c, 0x1048, 0x103c, 0x1301, "HP Diva RMP3", 0x14 },
+{ 0x103c, 0x1290, 0x, 0, "HP Auxiliary Diva Serial Port", 0x18 },
+{ 0x103c, 0x3301, 0x, 0, "HP iLO serial port", 0x10 },
+{ 0x11c1, 0x0480, 0x, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 
},
+{ 0x115d, 0x0103, 0x, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 },
+{ 0x1282, 0x6585, 0x, 0, "Davicom 56PDV PCI Modem", 0x10 },
+{ 0x12b9, 0x1008, 0x, 0, "3Com 56K FaxModem Model 5610", 0x10 },
+{ 0x131f, 0x1000, 0x, 0, "Siig CyberSerial (1-port) 16550", 0x18 },
+{ 0x131f, 0x1001, 0x, 0, "Siig CyberSerial (1-port) 16650", 0x18 },
+{ 0x131f, 0x1002, 0x, 0

[PATCH 06/17] pc386: Improve boot command arguments for console/printk device selection

2016-03-09 Thread Joel Sherrill
This patch adds the "--printk=" boot command line argument to specify
the printk() device. It also enhances the "--console=" boot command
line argument to match any device configured in the console device
table. The arguments are parsed as early as possible so they take
effect early. Currently, this is immediately after PCI initialization.
This will allow dynamically discovered and registers devices on the
PCI bus to be selected as the console.
---
 .../lib/libbsp/i386/pc386/console/console_select.c | 180 -
 c/src/lib/libbsp/i386/pc386/include/bsp.h  |   6 +
 c/src/lib/libbsp/i386/pc386/startup/bspstart.c |  10 +-
 c/src/lib/libbsp/shared/console.c  |   8 +-
 c/src/lib/libbsp/shared/console_private.h  |  12 +-
 5 files changed, 171 insertions(+), 45 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/console/console_select.c 
b/c/src/lib/libbsp/i386/pc386/console/console_select.c
index 3a756b4..c78b4b8 100644
--- a/c/src/lib/libbsp/i386/pc386/console/console_select.c
+++ b/c/src/lib/libbsp/i386/pc386/console/console_select.c
@@ -3,14 +3,14 @@
  *
  * @ingroup Console
  *
- * @brief Generic libchip console select
+ * @brief pc397 console select
  *
  * This file contains a routine to select the console based upon a number
  * of criteria.
  */
 
 /*
- *  COPYRIGHT (c) 2011-2012.
+ *  COPYRIGHT (c) 2011-2012, 2016.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -77,52 +77,154 @@ static rtems_device_minor_number 
bsp_First_Available_Device( void )
   rtems_fatal_error_occurred(RTEMS_IO_ERROR);
 }
 
-void bsp_console_select(void)
+static bool bsp_find_console_entry(
+  const char*match,
+  size_t length,
+  rtems_device_minor_number *match_minor
+)
 {
-  static const char* opt;
+  rtems_device_minor_number  minor;
+  const char*name;
+
+  for (minor=0; minor < Console_Port_Count ; minor++) {
+console_tbl  *cptr = Console_Port_Tbl[minor];
+
+/*
+ * Console table entries include /dev/ prefix, device names passed
+ * in on command line do not.
+ */
+name = cptr->sDeviceName  + sizeof("/dev");
+if ( !strncmp( name, match, length ) ) {
+  *match_minor = minor;
+  return true;
+}
+  }
+
+  return false;
+}
+
+static bool parse_printk_or_console(
+  const char*param,
+  rtems_device_minor_number *minor_out
+)
+{
+  static const char *opt;
+  char   working[64] = "";
+  char  *p;
 
   /*
* Check the command line for the type of mode the console is.
*/
-  opt = bsp_cmdline_arg ("--console=");
+  opt = bsp_cmdline_arg(param);
+  if ( !opt ) {
+return false;
+  }
+
+  /*
+   * bsp_cmdline_arg() returns pointer to a string. It may not be the
+   * last string on the command line.
+   */
+  strncpy( working, opt, sizeof(working) );
+  p = strchr( working, ' ' );
+  if ( p ) {
+*p = '\0';
+  }
 
-  if (opt) {
-const char* comma;
+  const char*comma;
+  size_t length = NAME_MAX;
+  rtems_device_minor_number  minor;
+  char  *option = working;
 
-opt += sizeof ("--console=") - 1;
-if (strncmp (opt, "console", sizeof ("console") - 1) == 0) {
-  Console_Port_Minor = BSP_CONSOLE_VGA;
-  BSPPrintkPort  = BSP_CONSOLE_VGA;
-} else if (strncmp (opt, "com1", sizeof ("com1") - 1) == 0) {
-  Console_Port_Minor = BSP_CONSOLE_COM1;
-  BSPPrintkPort  = BSP_CONSOLE_COM1;
-} else if (strncmp (opt, "com2", sizeof ("com2") - 1) == 0) {
-  Console_Port_Minor = BSP_CONSOLE_COM2;
-  BSPPrintkPort  = BSP_CONSOLE_COM2;
-}
+  /*
+   * Only match up to a comma or NULL
+   */
+  comma = strchr (option, ',');
 
-comma = strchr (opt, ',');
-
-if (comma) {
-  console_tbl *conscfg;
-
-  comma += 1;
-  conscfg = &Console_Configuration_Ports[Console_Port_Minor];
-  if (strncmp (opt, "115200", sizeof ("115200") - 1) == 0)
-conscfg->pDeviceParams = (void *)115200;
-  else if (strncmp (opt, "57600", sizeof ("57600") - 1) == 0)
-conscfg->pDeviceParams = (void *)57600;
-  else if (strncmp (opt, "38400", sizeof ("38400") - 1) == 0)
-conscfg->pDeviceParams = (void *)38400;
-  else if (strncmp (opt, "19200", sizeof ("19200") - 1) == 0)
-conscfg->pDeviceParams = (void *)19200;
-  else if (strncmp (opt, "9600", sizeof ("9600") - 1) == 0)
-conscfg->pDeviceParams = (void *)9600;
-  else if (strncmp (opt, "4800", sizeof ("4800") - 1) == 0)
-conscfg->pDeviceParams = (void *)4800;
-}
+  if ( comma ) {
+length = comma - option;
+  }
+
+  option += strnlen(param, 32);
+
+  if ( !bsp_find_console_entry( option, length, &minor ) ) {
+return false;
+  }
+
+  *minor_out = minor;
+  if (comma) {
+console_tbl *conscfg;
+
+comma += 1;
+conscfg = &Console_Configuration_Ports[m

[PATCH 10/17] pc386/startup/bspstart.c: Reformat and cleanup file header

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 56 +-
 1 file changed, 27 insertions(+), 29 deletions(-)

diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c 
b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
index 50afe18..5671a4b 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
+++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
@@ -1,32 +1,30 @@
-/*-+
-| This file contains the PC386 BSP startup package. It includes application,
-| board, and monitor specific initialization and configuration. The generic CPU
-| dependent initialization has been performed before this routine is invoked.
-+--+
-| (C) Copyright 1997 -
-| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
-|
-| http://pandora.ist.utl.pt
-|
-| Instituto Superior Tecnico * Lisboa * PORTUGAL
-+--+
-| Disclaimer:
-|
-| This file is provided "AS IS" without warranty of any kind, either
-| expressed or implied.
-+--+
-| This code is based on:
-|   bspstart.c,v 1.8 1996/05/28 13:12:40 joel Exp - go32 BSP
-| With the following copyright notice:
-| **
-| *  COPYRIGHT (c) 1989-2008.
-| *  On-Line Applications Research Corporation (OAR).
-| *
-| *  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.
-| **
-+--*/
+/**
+ * @file
+ *
+ * This file contains the PC386 BSP startup package. It includes application,
+ * board, and monitor specific initialization and configuration.
+ */
+
+/*
+ * This file was initially written by Joel Sherrill as part of the go32 BSP.
+ * It was subsequently adapted as part of the pc386 BSP by developers from
+ * the NavIST Group in 1997.
+ *
+ * COPYRIGHT (c) 1989-2008, 2016.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ *
+ * (C) Copyright 1997 -
+ * - NavIST Group - Real-Time Distributed Systems and Industrial Automation
+ * Instituto Superior Tecnico * Lisboa * PORTUGAL (http://pandora.ist.utl.pt)
+ *
+ * NavISY Disclaimer:
+ * This file is provided "AS IS" without warranty of any kind, either
+ * expressed or implied.
+ */
 
 #include 
 #include 
-- 
1.8.3.1

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


[PATCH 07/17] console_private.h: Remove prototypes for non-existent methods bsp_com_inch() and bsp_com_outch()

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/shared/console_private.h | 20 
 1 file changed, 20 deletions(-)

diff --git a/c/src/lib/libbsp/shared/console_private.h 
b/c/src/lib/libbsp/shared/console_private.h
index ee89eb2..2af5326 100644
--- a/c/src/lib/libbsp/shared/console_private.h
+++ b/c/src/lib/libbsp/shared/console_private.h
@@ -29,26 +29,6 @@ extern "C" {
 extern rtems_device_minor_number  BSPPrintkPort;
 
 /**
- *  @brief bsp_com_outch
- *
- *  This function puts a character out of the console port.
- *
- *  @param[in] ch specifies the character to write
- */
-extern void bsp_com_outch(char ch);
-
-/**
- *  @brief bsp_com_inch
- *
- *  This function gets a character from the console
- *  port.
- *
- *  @return This method returns the character that
- *was retrieved from the console port.
- */
-extern int bsp_com_inch(void);
-
-/**
  *  @brief
  *
  *  This function
-- 
1.8.3.1

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


[PATCH 17/17] fileio: Add command "com" to write to files

2016-03-09 Thread Joel Sherrill
This was used to open, write, and close the VGA console and
/dev/pcicom1 for testing purposes.
---
 testsuites/samples/fileio/Makefile.am |   2 +-
 testsuites/samples/fileio/init.c  |   2 +
 testsuites/samples/fileio/main_com.c  | 129 ++
 3 files changed, 132 insertions(+), 1 deletion(-)
 create mode 100644 testsuites/samples/fileio/main_com.c

diff --git a/testsuites/samples/fileio/Makefile.am 
b/testsuites/samples/fileio/Makefile.am
index 6e67e42..060fca8 100644
--- a/testsuites/samples/fileio/Makefile.am
+++ b/testsuites/samples/fileio/Makefile.am
@@ -1,5 +1,5 @@
 rtems_tests_PROGRAMS = fileio
-fileio_SOURCES = init.c system.h main_lspci.c
+fileio_SOURCES = init.c system.h main_com.c main_lspci.c
 
 dist_rtems_tests_DATA = fileio.doc
 
diff --git a/testsuites/samples/fileio/init.c b/testsuites/samples/fileio/init.c
index ca3527d..05a7157 100644
--- a/testsuites/samples/fileio/init.c
+++ b/testsuites/samples/fileio/init.c
@@ -1291,10 +1291,12 @@ static rtems_shell_alias_t Shell_USERECHO_Alias = {
   "userecho" /* alias */
 };
 
+extern rtems_shell_cmd_t Shell_COM_Command;
 extern rtems_shell_cmd_t Shell_LSPCI_Command;
 
 #define CONFIGURE_SHELL_USER_COMMANDS \
 &Shell_USERCMD_Command, \
+&Shell_COM_Command, \
 &Shell_LSPCI_Command
 #define CONFIGURE_SHELL_USER_ALIASES &Shell_USERECHO_Alias
 #define CONFIGURE_SHELL_COMMANDS_INIT
diff --git a/testsuites/samples/fileio/main_com.c 
b/testsuites/samples/fileio/main_com.c
new file mode 100644
index 000..fda482d
--- /dev/null
+++ b/testsuites/samples/fileio/main_com.c
@@ -0,0 +1,129 @@
+/**
+ * @brief com command
+ *
+ * This file contains a command to perform individual system call operations
+ * on a specified file.
+ */
+
+/*  COPYRIGHT (c) 2016.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  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.
+ */
+
+#define __need_getopt_newlib
+#include 
+#include 
+
+#include  /* for getopt */
+#include 
+
+#include   /* for open() */
+#include 
+#include 
+
+#include 
+
+
+int main_com(
+  intargc,
+  char **argv
+);
+
+int main_com(
+  intargc,
+  char **argv
+)
+{
+  int opt;
+  struct getopt_data getopt_reent;
+  #define optarg getopt_reent.optarg
+  #define optind getopt_reent.optind
+  #define opterr getopt.reent.opterr
+  #define optopt getopt.reent.optopt
+  static int fd = -1;
+  int action_taken = 0;
+
+  memset(&getopt_reent, 0, sizeof(getopt_reent));
+  while ((opt = getopt_r(argc, argv, "o:r:w:c", &getopt_reent )) != -1 ) {
+switch (opt) {
+  /* o - Open */
+  case 'o':  {
+char *filename;
+
+filename = optarg;
+fd = open( filename, O_RDWR );
+if ( fd == -1 ) {
+  fprintf( stderr, "Unable to open %s: %s\n", filename, strerror( 
errno ) );
+  return -1;
+}
+
+fprintf( stderr, "Opened %s: fd=%d\n", filename, fd );
+action_taken = 1;
+break;
+  }
+  /* r - Read */
+  case 'r':  {
+fprintf( stderr, "Read is not yet supported\n" );
+return -1;
+break;
+  }
+  /* w - Write */
+  case 'w': {
+char*p;
+ssize_t  rc;
+
+for ( p = optarg ; *p ; p++ ) {
+  rc = write( fd, p, 1 );
+  if ( rc != 1 ) {
+fprintf( stderr, "write() returned %s\n", strerror( errno ) );
+return -1;
+  }
+}
+fprintf( stderr, "\nwrite() OK\n" );
+action_taken = 1;
+break;
+  }
+  /* c - Close */
+  case 'c':  {
+int rc;
+
+rc = close( fd );
+if ( rc == -1 ) {
+  fprintf( stderr, "Unable to close: %s\n", strerror( errno ) );
+  return -1;
+}
+
+fprintf( stderr, "Closed\n" );
+fd = -1;
+action_taken = 1;
+break;
+  }
+  default:
+fprintf( stderr, "%c is not a valid options\n", opt );
+break;
+}
+  }
+
+  if (optind < argc) {
+fprintf( stderr, "Unparsed arguments remain\n" );
+return -1;
+  }
+
+  if ( action_taken == 0 ) {
+fprintf( stderr, "No action(s) specified\n" );
+return -1;
+  }
+  return 0;
+}
+
+rtems_shell_cmd_t Shell_COM_Command = {
+  "com", /* name */
+  "com [-o file] [-rc] [-w string]", /* usage */
+  "user",/* topic */
+  main_com,  /* command */
+  NULL,  /* alias */
+  NULL   /* next */
+};
-- 
1.8.3.1

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


[PATCH 16/17] fileio: lspci candidate command

2016-03-09 Thread Joel Sherrill
From: Joel Sherrill 

---
 testsuites/samples/fileio/Makefile.am  |  2 +-
 testsuites/samples/fileio/init.c   |  5 +++-
 testsuites/samples/fileio/main_lspci.c | 43 ++
 3 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 testsuites/samples/fileio/main_lspci.c

diff --git a/testsuites/samples/fileio/Makefile.am 
b/testsuites/samples/fileio/Makefile.am
index bf88273..6e67e42 100644
--- a/testsuites/samples/fileio/Makefile.am
+++ b/testsuites/samples/fileio/Makefile.am
@@ -1,5 +1,5 @@
 rtems_tests_PROGRAMS = fileio
-fileio_SOURCES = init.c system.h
+fileio_SOURCES = init.c system.h main_lspci.c
 
 dist_rtems_tests_DATA = fileio.doc
 
diff --git a/testsuites/samples/fileio/init.c b/testsuites/samples/fileio/init.c
index 07ec2c6..ca3527d 100644
--- a/testsuites/samples/fileio/init.c
+++ b/testsuites/samples/fileio/init.c
@@ -1291,8 +1291,11 @@ static rtems_shell_alias_t Shell_USERECHO_Alias = {
   "userecho" /* alias */
 };
 
+extern rtems_shell_cmd_t Shell_LSPCI_Command;
 
-#define CONFIGURE_SHELL_USER_COMMANDS &Shell_USERCMD_Command
+#define CONFIGURE_SHELL_USER_COMMANDS \
+&Shell_USERCMD_Command, \
+&Shell_LSPCI_Command
 #define CONFIGURE_SHELL_USER_ALIASES &Shell_USERECHO_Alias
 #define CONFIGURE_SHELL_COMMANDS_INIT
 #define CONFIGURE_SHELL_COMMANDS_ALL
diff --git a/testsuites/samples/fileio/main_lspci.c 
b/testsuites/samples/fileio/main_lspci.c
new file mode 100644
index 000..564b701
--- /dev/null
+++ b/testsuites/samples/fileio/main_lspci.c
@@ -0,0 +1,43 @@
+/**
+ * @brief lspci command
+ *
+ * This file is a simple wrapper for the pci_dump() method and provides
+ * a simple lspci command.
+ */
+
+/*  COPYRIGHT (c) 2016.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  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.
+ */
+
+#include 
+#include 
+
+extern void pci_dump(FILE *f);
+
+int main_lspci(
+  intargc,
+  char **argv
+);
+
+int main_lspci(
+  intargc,
+  char **argv
+)
+{
+  pci_dump( NULL );
+
+  return 0;
+}
+
+rtems_shell_cmd_t Shell_LSPCI_Command = {
+  "lspci", /* name */
+  "lspci", /* usage */
+  "user",  /* topic */
+  main_lspci,  /* command */
+  NULL,/* alias */
+  NULL /* next */
+};
-- 
1.8.3.1

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


[PATCH 02/17] i386/shared/pci/pcibios.c: Remove unused pcib_special_cycle()

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/shared/pci/pcibios.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c 
b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index ec19bb3..48c2c60 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -288,36 +288,6 @@ pci_bus_count(void)
 }
 
 /*
- * Generate Special Cycle
- */
-int
-pcib_special_cycle(int busNo, int data)
-{
-  if (!pcibInitialized) {
-return PCIB_ERR_UNINITIALIZED;
-  }
-
-  pcibExchg[0] = pcibEntry;
-  pcibExchg[1] = busNo << 8;
-  pcibExchg[2] = data;
-
-  __asm__ ("pusha");
-  __asm__ ("movl pcibExchg, %edi");
-  __asm__ ("movb $0xb1, %ah");
-  __asm__ ("movb $0x06, %al");
-  __asm__ ("movl pcibExchg+4, %ebx");
-  __asm__ ("movl pcibExchg+8, %edx");
-  __asm__ ("pushl %cs");
-  __asm__ ("call *%edi");
-  __asm__ ("movl %eax, pcibExchg");
-  __asm__ ("movl %ebx, pcibExchg+4");
-  __asm__ ("popa");
-
-  return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
-}
-
-
-/*
  * Read byte from config space
  */
 static int
-- 
1.8.3.1

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


[PATCH 12/17] libbsp/shared/console.c: Clean up memory allocation for per device data

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/shared/console.c | 49 ---
 1 file changed, 36 insertions(+), 13 deletions(-)

diff --git a/c/src/lib/libbsp/shared/console.c 
b/c/src/lib/libbsp/shared/console.c
index 81a70b1..d030065 100644
--- a/c/src/lib/libbsp/shared/console.c
+++ b/c/src/lib/libbsp/shared/console.c
@@ -7,7 +7,7 @@
  */
 
 /*
- *  COPYRIGHT (c) 1989-2011.
+ *  COPYRIGHT (c) 1989-2011, 2016.
  *  On-Line Applications Research Corporation (OAR).
  *
  *  The license and distribution terms for this file may be
@@ -46,13 +46,28 @@ void console_initialize_data(void)
   if ( Console_Port_Tbl )
 return;
 
+  /*
+   * Allocate memory for the table of device pointers.
+   */
   Console_Port_Count = Console_Configuration_Count;
   Console_Port_Tbl   = malloc( Console_Port_Count * sizeof( console_tbl * ) );
   if (Console_Port_Tbl == NULL)
 bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_0 );
 
-  for (i=0 ; i < Console_Port_Count ; i++)
+  /*
+   * Allocate memory for the table of device specific data pointers.
+   */
+  Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) );
+  if ( Console_Port_Data == NULL ) {
+bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_3 );
+  }
+
+  /*
+   * Fill in the Console Table
+   */
+  for (i=0 ; i < Console_Port_Count ; i++) {
 Console_Port_Tbl[i] = &Console_Configuration_Ports[i];
+  }
 }
 
 /*
@@ -69,10 +84,13 @@ void console_register_devices(
   int  old_number_of_ports;
   int  i;
 
+  /*
+   * Initialize the console data elements
+   */
   console_initialize_data();
 
   /*
-   *  console_initialize has been invoked so it is now too late to
+   *  console_initialize() has been invoked so it is now too late to
*  register devices.
*/
   if ( console_initialized ) {
@@ -86,23 +104,31 @@ void console_register_devices(
   Console_Port_Count += number_of_ports;
   Console_Port_Tbl = realloc(
 Console_Port_Tbl,
-Console_Port_Count * sizeof( console_tbl * )
+Console_Port_Count * sizeof(console_tbl *)
   );
   if ( Console_Port_Tbl == NULL ) {
 bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_1 );
   }
 
-  Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) );
+  /*
+   * Since we can only add devices before console_initialize(),
+   * the data area will contain no information and must be zero
+   * before it is used. So extend the area and zero it out.
+   */
+  Console_Port_Data = realloc(
+Console_Port_Data,
+Console_Port_Count * sizeof(console_tbl *)
+  );
   if ( Console_Port_Data == NULL ) {
 bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_2 );
   }
+  memset(&Console_Port_Data, '\0', Console_Port_Count * sizeof(console_tbl *));
 
   /*
*  Now add the new devices at the end.
*/
-
   for (i=0 ; i < number_of_ports ; i++) {
-Console_Port_Tbl[old_number_of_ports + i] = &new_ports[i];
+Console_Port_Tbl[old_number_of_ports + i]  = &new_ports[i];
   }
 }
 
@@ -249,14 +275,11 @@ rtems_device_driver console_initialize(
 
   /*
* If we have no devices which were registered earlier then we
-   * must still initialize pointers and set Console_Port_Data.
+   * must still initialize pointers for Console_Port_Tbl and
+   * Console_Port_Data.
*/
-  if ( ! Console_Port_Tbl ) {
+  if ( !Console_Port_Tbl ) {
 console_initialize_data();
-Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) );
-if ( Console_Port_Data == NULL ) {
-  bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_3 );
-}
   }
 
   /*
-- 
1.8.3.1

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


[PATCH 11/17] pc386/startup/bsp_fatal_halt.c: Fix noreturn does return warning

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/c/src/lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c 
b/c/src/lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c
index 3e4f263..07bbd79 100644
--- a/c/src/lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c
+++ b/c/src/lib/libbsp/i386/pc386/startup/bsp_fatal_halt.c
@@ -18,4 +18,7 @@ void _CPU_Fatal_halt(uint32_t source, uint32_t error)
  : "=r" ((error))
  : "0" ((error))
   );
+  #ifdef __GNUC__
+__builtin_unreachable();
+  #endif
 }
-- 
1.8.3.1

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


[PATCH 14/17] mips/malta: Use shared pci_find_device() and removed unused pci_list_devices()

2016-03-09 Thread Joel Sherrill
Also includes .h file cleanup.
---
 c/src/lib/libbsp/mips/malta/Makefile.am  |   3 +-
 c/src/lib/libbsp/mips/malta/include/pci.h|  32 ---
 c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c  | 277 ---
 c/src/lib/libbsp/mips/malta/pci/pcilistdevices.c | 102 -
 4 files changed, 1 insertion(+), 413 deletions(-)
 delete mode 100644 c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c
 delete mode 100644 c/src/lib/libbsp/mips/malta/pci/pcilistdevices.c

diff --git a/c/src/lib/libbsp/mips/malta/Makefile.am 
b/c/src/lib/libbsp/mips/malta/Makefile.am
index 15aa898..5d4b5f5 100644
--- a/c/src/lib/libbsp/mips/malta/Makefile.am
+++ b/c/src/lib/libbsp/mips/malta/Makefile.am
@@ -68,8 +68,7 @@ libbsp_a_LIBADD += 
../../../libcpu/@RTEMS_CPU@/shared/interrupts.rel
 
 # pci
 libbsp_a_SOURCES += pci/pci.c
-libbsp_a_SOURCES += pci/pcifinddevice.c
-libbsp_a_SOURCES += pci/pcilistdevices.c
+libbsp_a_SOURCES += ../../shared/pci/pci_find_device.c
 
 #isr
 libbsp_a_SOURCES += ../../shared/src/irq-generic.c
diff --git a/c/src/lib/libbsp/mips/malta/include/pci.h 
b/c/src/lib/libbsp/mips/malta/include/pci.h
index ad69e3a..c5944da 100644
--- a/c/src/lib/libbsp/mips/malta/include/pci.h
+++ b/c/src/lib/libbsp/mips/malta/include/pci.h
@@ -59,37 +59,6 @@ void FixupPCI( const struct _int_map *, int 
(*swizzler)(int,int) );
 /* FIXME: This probably belongs into rtems/pci.h */
 extern unsigned char pci_bus_count();
 
-/* FIXME: This also is generic and could go into rtems/pci.h */
-
-/* Scan pci config space and run a user callback on each
- * device present; the user callback may return 0 to
- * continue the scan or a value > 0 to abort the scan.
- * Return values < 0 are reserved and must not be used.
- *
- * RETURNS: a (opaque) handle pointing to the bus/slot/fn-triple
- *  just after where the scan was aborted by a callback
- *  returning 1 (see above) or NULL if all devices were
- *  scanned.
- *  The handle may be passed to this routine to resume the
- *  scan continuing with the device after the one causing the
- *  abort.
- *  Pass a NULL 'handle' argument to start scanning from
- *  the beginning (bus/slot/fn = 0/0/0).
- */
-typedef void *BSP_PciScanHandle;
-typedef int (*BSP_PciScannerCb)(int bus, int slot, int fun, void *uarg);
-
-
-BSP_PciScanHandle
-BSP_pciScan(BSP_PciScanHandle handle, BSP_PciScannerCb cb, void *uarg);
-
-/* Dump basic config. space info to a file. The argument may
- * be NULL in which case 'stdout' is used.
- * NOTE: the C-library must be functional before you can use
- *   this routine.
- */
-void BSP_pciConfigDump(FILE *fp);
-
 int indirect_pci_read_config_byte(
   unsigned char bus,
   unsigned char slot,
@@ -140,7 +109,6 @@ int indirect_pci_write_config_dword(
 
 /* Can these be moved to the rtems pci.h? */
 int FindPCIbridge( int mybus, struct pcibridge *pb );
-void pci_list_devices( void );
 
 const pci_config_access_functions pci_indirect_functions;
 
diff --git a/c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c 
b/c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c
deleted file mode 100644
index 43ae261..000
--- a/c/src/lib/libbsp/mips/malta/pci/pcifinddevice.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- *  @file
- *
- *  This file was copied from the powerpc and modified slightly.
- *  I think this file could be made generic and put in a general pci
- *  area.
- */
-
-/*
- *  COPYRIGHT (c) 1989-2012.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  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.
- */
-/* find a particular PCI device
- * (we assume, the firmware configured the PCI bus[es] for us)
- */
-
-/*
- * Authorship
- * --
- * This software was created by
- * Till Straumann , 2001,
- *  Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * --
- * This software was produced by
- * the Stanford Linear Accelerator Center, Stanford University,
- *  under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * --
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * 
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * 
- * Stanford University, o

[PATCH 08/17] console_private.h: Improve comment for vt_ioctl()

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/shared/console_private.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/c/src/lib/libbsp/shared/console_private.h 
b/c/src/lib/libbsp/shared/console_private.h
index 2af5326..42a8ee9 100644
--- a/c/src/lib/libbsp/shared/console_private.h
+++ b/c/src/lib/libbsp/shared/console_private.h
@@ -31,11 +31,14 @@ extern rtems_device_minor_number  BSPPrintkPort;
 /**
  *  @brief
  *
- *  This function
+ *  This function is the ioctl() support for a VGA buffer driver.
  *
- *  @return This method returns
+ *  @return This method returns 0 on success.
  */
-int vt_ioctl( unsigned int cmd, unsigned long arg);
+int vt_ioctl(
+  unsigned int cmd,
+  unsigned long arg
+);
 
 /**
  *  @brief console_initialize_data
-- 
1.8.3.1

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


[PATCH 01/17] pc386: Eliminate pcibios.h and begin removal obsolete PCI BIOS API uses

2016-03-09 Thread Joel Sherrill
This first step eliminates the following as public APIs for the pc386
BSP:

  + pcib_conf_read8
  + pcib_conf_read16
  + pcib_conf_read32
  + pcib_conf_write8
  + pcib_conf_write16
  + pcib_conf_write32

The if_fxp.c driver uses these enough where I provided local macros
to allow the code to be mostly unmodified. On other architectures
these names have been used privately. It will take multiple patches
to completely eliminate these symbols from the RTEMS source tree.

The focus of the first effort is just to eliminate these as a public
pc386 API so support can be added for systems without legacy PCI BIOS.
---
 c/src/lib/libbsp/i386/Makefile.am  |  1 -
 c/src/lib/libbsp/i386/pc386/Makefile.am|  4 +-
 c/src/lib/libbsp/i386/pc386/preinstall.am  |  4 --
 c/src/lib/libbsp/i386/shared/pci/pcibios.c | 41 
 c/src/lib/libbsp/i386/shared/pci/pcibios.h | 62 --
 c/src/libchip/network/if_fxp.c | 43 -
 6 files changed, 67 insertions(+), 88 deletions(-)
 delete mode 100644 c/src/lib/libbsp/i386/shared/pci/pcibios.h

diff --git a/c/src/lib/libbsp/i386/Makefile.am 
b/c/src/lib/libbsp/i386/Makefile.am
index 397e8e6..f10b764 100644
--- a/c/src/lib/libbsp/i386/Makefile.am
+++ b/c/src/lib/libbsp/i386/Makefile.am
@@ -21,7 +21,6 @@ EXTRA_DIST += shared/irq/idt.c
 EXTRA_DIST += shared/irq/irq_init.c
 
 # shared/pci
-EXTRA_DIST += shared/pci/pcibios.h
 EXTRA_DIST += shared/pci/pcibios.c
 
 include $(top_srcdir)/../../../automake/subdirs.am
diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am 
b/c/src/lib/libbsp/i386/pc386/Makefile.am
index 1d52cf4..a9c645b 100644
--- a/c/src/lib/libbsp/i386/pc386/Makefile.am
+++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
@@ -139,10 +139,8 @@ libbsp_a_SOURCES += ../../i386/shared/comm/gdb_glue.c
 # gnat
 libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
 
-include_HEADERS += ../../i386/shared/pci/pcibios.h
 # pci
-libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c \
-../../i386/shared/pci/pcibios.h
+libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c
 
 include_HEADERS += ../../i386/shared/comm/uart.h
 # startup
diff --git a/c/src/lib/libbsp/i386/pc386/preinstall.am 
b/c/src/lib/libbsp/i386/pc386/preinstall.am
index 1b9f862..46b6467 100644
--- a/c/src/lib/libbsp/i386/pc386/preinstall.am
+++ b/c/src/lib/libbsp/i386/pc386/preinstall.am
@@ -166,10 +166,6 @@ $(PROJECT_INCLUDE)/rtems/console_private.h: 
../../shared/console_private.h $(PRO
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console_private.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/console_private.h
 
-$(PROJECT_INCLUDE)/pcibios.h: ../../i386/shared/pci/pcibios.h 
$(PROJECT_INCLUDE)/$(dirstamp)
-   $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pcibios.h
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/pcibios.h
-
 $(PROJECT_INCLUDE)/uart.h: ../../i386/shared/comm/uart.h 
$(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uart.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/uart.h
diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c 
b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index 870721f..ec19bb3 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -7,7 +7,7 @@
 
 #include 
 #include 
-#include 
+#include 
 
 #include   /* memcpy */
 
@@ -15,8 +15,6 @@
  * This is simpliest possible PCI BIOS, it assumes that addressing
  * is flat and that stack is big enough
  */
-
-
 static int pcibInitialized = 0;
 static unsigned int pcibEntry;
 
@@ -30,6 +28,18 @@ static volatile unsigned int pcibExchg[5];
 
 static int pcib_convert_err(int err);
 
+/** @brief
+ * Make device signature from bus number, device numebr and function
+ * number
+ */
+#define PCIB_DEVSIG_MAKE(b,d,f) ((b<<8)|(d<<3)|(f))
+
+/** @brief
+ * Extract valrous part from device signature
+ */
+#define PCIB_DEVSIG_BUS(x) (((x)>>8) &0xff)
+#define PCIB_DEVSIG_DEV(x) (((x)>>3) & 0x1f)
+#define PCIB_DEVSIG_FUNC(x) ((x) & 0x7)
 /*
  * Detects presense of PCI BIOS, returns
  * error code
@@ -232,33 +242,30 @@ pci_bus_count(void)
 unsigned char nfn;
 unsigned char hd = 0;
 uint32_t d = 0;
-int sig;
 
 ucBusCount = 0;
 
 for (bus=0; bus< 0xff; bus++) {
   for (dev=0; dev> 16) == PCI_CLASS_BRIDGE_PCI ) {
-pcib_conf_read8(sig, PCI_SUBORDINATE_BUS, &hd);
+pci_read_config_byte(bus, dev, fun, PCI_SUBORDINATE_BUS, &hd);
 
 if ( hd > ucBusCount )
   ucBusCount = hd;
@@ -313,7 +320,7 @@ pcib_special_cycle(int busNo, int data)
 /*
  * Read byte from config space
  */
-int
+static int
 pcib_conf_read8(int sig, int off, uint8_t *data)
 {
   if (!pcibInitialized) {
@@ -349,7 +356,7 @@ pcib_conf_read8(int sig, int off, uint8_t *data)
 /*
  * Read word from config space
  */
-int
+static int
 pcib_conf_read16(int sig, int off, uint16_t *data)
 {
   if (!pcibInitialized) {
@@ -385,7 +392,7 @@ pcib_conf_read16(int sig, int off, uint16_t *data)
 /*
  * Read dw

[PATCH 03/17] i386/shared/pci/pcibios.c: Remove unused pcib_find_by_class()

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/i386/shared/pci/pcibios.c | 36 --
 1 file changed, 36 deletions(-)

diff --git a/c/src/lib/libbsp/i386/shared/pci/pcibios.c 
b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
index 48c2c60..7dc53a1 100644
--- a/c/src/lib/libbsp/i386/shared/pci/pcibios.c
+++ b/c/src/lib/libbsp/i386/shared/pci/pcibios.c
@@ -194,42 +194,6 @@ pci_find_device(
   return status ? -1 : 0;
 }
 
-/*
- * Find specified class code return device signature: combination
- * of bus number, device number and function number
- */
-int
-pcib_find_by_class(int classCode, int idx, int *sig)
-{
-  if (!pcibInitialized) {
-return PCIB_ERR_UNINITIALIZED;
-  }
-
-  pcibExchg[0] = pcibEntry;
-  pcibExchg[1] = classCode;
-  pcibExchg[2] = idx;
-
-  __asm__ ("pusha");
-  __asm__ ("movl pcibExchg, %edi");
-  __asm__ ("movb $0xb1, %ah");
-  __asm__ ("movb $0x03, %al");
-  __asm__ ("movl pcibExchg+4, %ecx");
-  __asm__ ("movl pcibExchg+8, %esi");
-  __asm__ ("pushl %cs");
-  __asm__ ("call *%edi");
-  __asm__ ("movl %eax, pcibExchg");
-  __asm__ ("movl %ebx, pcibExchg+4");
-  __asm__ ("popa");
-
-  if ((pcibExchg[0] & 0xff00) != 0) {
-return pcib_convert_err((pcibExchg[0] >> 8) & 0xff);
-  }
-
-  *sig = pcibExchg[1] & 0x;
-
-  return PCIB_ERR_SUCCESS;
-}
-
 static uint8_t ucBusCount = 0xff;
 
 unsigned char
-- 
1.8.3.1

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


[PATCH 15/17] powerpc/mvme5500: Use shared pci_find_device()

2016-03-09 Thread Joel Sherrill
---
 c/src/lib/libbsp/powerpc/mvme5500/Makefile.am  |  6 ++-
 .../libbsp/powerpc/mvme5500/pci/pcifinddevice.c| 62 --
 2 files changed, 4 insertions(+), 64 deletions(-)
 delete mode 100644 c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c

diff --git a/c/src/lib/libbsp/powerpc/mvme5500/Makefile.am 
b/c/src/lib/libbsp/powerpc/mvme5500/Makefile.am
index c8cb229..8794f5f 100644
--- a/c/src/lib/libbsp/powerpc/mvme5500/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/mvme5500/Makefile.am
@@ -49,8 +49,10 @@ libbsp_a_SOURCES += ../../powerpc/shared/console/uart.c \
 include_bsp_HEADERS += pci/gtpcireg.h
 include_bsp_HEADERS += ../../powerpc/shared/pci/pci.h
 # pci
-libbsp_a_SOURCES += pci/pci.c pci/pci_interface.c pci/detect_host_bridge.c \
-pci/pcifinddevice.c
+libbsp_a_SOURCES += pci/pci.c
+libbsp_a_SOURCES += pci/pci_interface.c
+libbsp_a_SOURCES += pci/detect_host_bridge.c
+libbsp_a_SOURCES += ../../shared/pci/pci_find_device.c
 
 include_bsp_HEADERS += irq/irq.h
 # irq
diff --git a/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c 
b/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
deleted file mode 100644
index 9f3acee..000
--- a/c/src/lib/libbsp/powerpc/mvme5500/pci/pcifinddevice.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * find a particular PCI device
- * (we assume, the firmware configured the PCI bus[es] for us)
- */
-
-/*
- * Copyright 2001,  Till Straumann 
- *
- * Kate Feng , modified it to support the mvme5500 board.
- */
-
-#include 
-#include 
-#include 
-
-static int BSP_pciDebug=0;
-
-int pci_find_device( unsigned short vendorid, unsigned short deviceid,
-   int instance, int *pbus, int *pdev, int *pfun )
-{
-  uint32_t d;
-  unsigned short s;
-  unsigned char bus,dev,fun,hd;
-
-  for (bus=0; bus= BSP_MAX_PCI_BUS_ON_PCI0)? 1:0,
- (bus>= BSP_MAX_PCI_BUS_ON_PCI0)? bus-BSP_MAX_PCI_BUS_ON_PCI0:bus,
- dev, fun);
-}
-
-(void)pci_read_config_word(bus,dev,fun,PCI_VENDOR_ID,&s);
-if (vendorid != s)
-  continue;
-  (void)pci_read_config_word(bus,dev,fun,PCI_DEVICE_ID,&s);
-  if (deviceid == s) {
-if (instance--) continue;
-  *pbus=bus; *pdev=dev; *pfun=fun;
-  return 0;
-}
-  }
-}
-  }  /* end for bus */
-  return -1;
-}
-
-/* eof */
-- 
1.8.3.1

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


Re: [PATCH 16/17] fileio: lspci candidate command

2016-03-09 Thread Joel Sherrill
Ignore this one. It is just a wrapper command for debug. There is
discussion before to consider this.

--joel

On Wed, Mar 9, 2016 at 4:25 PM, Joel Sherrill  wrote:

> From: Joel Sherrill 
>
> ---
>  testsuites/samples/fileio/Makefile.am  |  2 +-
>  testsuites/samples/fileio/init.c   |  5 +++-
>  testsuites/samples/fileio/main_lspci.c | 43
> ++
>  3 files changed, 48 insertions(+), 2 deletions(-)
>  create mode 100644 testsuites/samples/fileio/main_lspci.c
>
> diff --git a/testsuites/samples/fileio/Makefile.am
> b/testsuites/samples/fileio/Makefile.am
> index bf88273..6e67e42 100644
> --- a/testsuites/samples/fileio/Makefile.am
> +++ b/testsuites/samples/fileio/Makefile.am
> @@ -1,5 +1,5 @@
>  rtems_tests_PROGRAMS = fileio
> -fileio_SOURCES = init.c system.h
> +fileio_SOURCES = init.c system.h main_lspci.c
>
>  dist_rtems_tests_DATA = fileio.doc
>
> diff --git a/testsuites/samples/fileio/init.c
> b/testsuites/samples/fileio/init.c
> index 07ec2c6..ca3527d 100644
> --- a/testsuites/samples/fileio/init.c
> +++ b/testsuites/samples/fileio/init.c
> @@ -1291,8 +1291,11 @@ static rtems_shell_alias_t Shell_USERECHO_Alias = {
>"userecho" /* alias */
>  };
>
> +extern rtems_shell_cmd_t Shell_LSPCI_Command;
>
> -#define CONFIGURE_SHELL_USER_COMMANDS &Shell_USERCMD_Command
> +#define CONFIGURE_SHELL_USER_COMMANDS \
> +&Shell_USERCMD_Command, \
> +&Shell_LSPCI_Command
>  #define CONFIGURE_SHELL_USER_ALIASES &Shell_USERECHO_Alias
>  #define CONFIGURE_SHELL_COMMANDS_INIT
>  #define CONFIGURE_SHELL_COMMANDS_ALL
> diff --git a/testsuites/samples/fileio/main_lspci.c
> b/testsuites/samples/fileio/main_lspci.c
> new file mode 100644
> index 000..564b701
> --- /dev/null
> +++ b/testsuites/samples/fileio/main_lspci.c
> @@ -0,0 +1,43 @@
> +/**
> + * @brief lspci command
> + *
> + * This file is a simple wrapper for the pci_dump() method and provides
> + * a simple lspci command.
> + */
> +
> +/*  COPYRIGHT (c) 2016.
> + *  On-Line Applications Research Corporation (OAR).
> + *
> + *  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.
> + */
> +
> +#include 
> +#include 
> +
> +extern void pci_dump(FILE *f);
> +
> +int main_lspci(
> +  intargc,
> +  char **argv
> +);
> +
> +int main_lspci(
> +  intargc,
> +  char **argv
> +)
> +{
> +  pci_dump( NULL );
> +
> +  return 0;
> +}
> +
> +rtems_shell_cmd_t Shell_LSPCI_Command = {
> +  "lspci", /* name */
> +  "lspci", /* usage */
> +  "user",  /* topic */
> +  main_lspci,  /* command */
> +  NULL,/* alias */
> +  NULL /* next */
> +};
> --
> 1.8.3.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH 12/17] libbsp/shared/console.c: Clean up memory allocation for per device data

2016-03-09 Thread Gedare Bloom
On Wed, Mar 9, 2016 at 5:24 PM, Joel Sherrill  wrote:
> ---
>  c/src/lib/libbsp/shared/console.c | 49 
> ---
>  1 file changed, 36 insertions(+), 13 deletions(-)
>
> diff --git a/c/src/lib/libbsp/shared/console.c 
> b/c/src/lib/libbsp/shared/console.c
> index 81a70b1..d030065 100644
> --- a/c/src/lib/libbsp/shared/console.c
> +++ b/c/src/lib/libbsp/shared/console.c
> @@ -7,7 +7,7 @@
>   */
>
>  /*
> - *  COPYRIGHT (c) 1989-2011.
> + *  COPYRIGHT (c) 1989-2011, 2016.
>   *  On-Line Applications Research Corporation (OAR).
>   *
>   *  The license and distribution terms for this file may be
> @@ -46,13 +46,28 @@ void console_initialize_data(void)
>if ( Console_Port_Tbl )
>  return;
>
> +  /*
> +   * Allocate memory for the table of device pointers.
> +   */
>Console_Port_Count = Console_Configuration_Count;
>Console_Port_Tbl   = malloc( Console_Port_Count * sizeof( console_tbl * ) 
> );
>if (Console_Port_Tbl == NULL)
>  bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_0 );
>
> -  for (i=0 ; i < Console_Port_Count ; i++)
> +  /*
> +   * Allocate memory for the table of device specific data pointers.
> +   */
> +  Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) );
why calloc ...

> +  if ( Console_Port_Data == NULL ) {
> +bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_3 );
> +  }
> +
> +  /*
> +   * Fill in the Console Table
> +   */
> +  for (i=0 ; i < Console_Port_Count ; i++) {
>  Console_Port_Tbl[i] = &Console_Configuration_Ports[i];
> +  }
... if you will immediately initialize it

>  }
>
>  /*
> @@ -69,10 +84,13 @@ void console_register_devices(
>int  old_number_of_ports;
>int  i;
>
> +  /*
> +   * Initialize the console data elements
> +   */
>console_initialize_data();
>
>/*
> -   *  console_initialize has been invoked so it is now too late to
> +   *  console_initialize() has been invoked so it is now too late to
> *  register devices.
> */
>if ( console_initialized ) {
> @@ -86,23 +104,31 @@ void console_register_devices(
>Console_Port_Count += number_of_ports;
>Console_Port_Tbl = realloc(
>  Console_Port_Tbl,
> -Console_Port_Count * sizeof( console_tbl * )
> +Console_Port_Count * sizeof(console_tbl *)
>);
>if ( Console_Port_Tbl == NULL ) {
>  bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_1 );
>}
>
> -  Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) );
> +  /*
> +   * Since we can only add devices before console_initialize(),
> +   * the data area will contain no information and must be zero
> +   * before it is used. So extend the area and zero it out.
> +   */
> +  Console_Port_Data = realloc(
> +Console_Port_Data,
> +Console_Port_Count * sizeof(console_tbl *)
> +  );
>if ( Console_Port_Data == NULL ) {
>  bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_2 );
>}
> +  memset(&Console_Port_Data, '\0', Console_Port_Count * sizeof(console_tbl 
> *));
>
>/*
> *  Now add the new devices at the end.
> */
> -
>for (i=0 ; i < number_of_ports ; i++) {
> -Console_Port_Tbl[old_number_of_ports + i] = &new_ports[i];
> +Console_Port_Tbl[old_number_of_ports + i]  = &new_ports[i];
>}
>  }
>
> @@ -249,14 +275,11 @@ rtems_device_driver console_initialize(
>
>/*
> * If we have no devices which were registered earlier then we
> -   * must still initialize pointers and set Console_Port_Data.
> +   * must still initialize pointers for Console_Port_Tbl and
> +   * Console_Port_Data.
> */
> -  if ( ! Console_Port_Tbl ) {
> +  if ( !Console_Port_Tbl ) {
>  console_initialize_data();
> -Console_Port_Data  = calloc( Console_Port_Count, sizeof( console_data ) 
> );
> -if ( Console_Port_Data == NULL ) {
> -  bsp_fatal( BSP_FATAL_CONSOLE_NO_MEMORY_3 );
> -}
>}
>
>/*
> --
> 1.8.3.1
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH 05/17] Add shared PCI support and enhance pc386 to support non-legacy PCI configuration space

2016-03-09 Thread Gedare Bloom
On Wed, Mar 9, 2016 at 5:24 PM, Joel Sherrill  wrote:
> This patch fundamentally results from enhancements to the pc386 BSP
> to support systems which do **NOT** have the legacy PCI BIOS. The
> patch adds support for detecting when legacy PCI BIOS is not
> present and then using IO space to access to PCI Configuration Space.
> This resulted in dynamically selected between two implementations
> of PCI and refactoring out the shared methods.
>
> This patch adds shared implementations of pci_bus_count() and
> pci_find_device(). Subsequent patches will remove implementations
> of these methods in other BSPs where possible.
> ---
>  c/src/lib/libbsp/Makefile.am   |   3 +
>  c/src/lib/libbsp/i386/Makefile.am  |   1 +
>  c/src/lib/libbsp/i386/pc386/Makefile.am|   3 +
>  c/src/lib/libbsp/i386/pc386/startup/bspstart.c |  31 ++-
>  c/src/lib/libbsp/i386/shared/pci/pci_io.c  | 200 ++
>  c/src/lib/libbsp/i386/shared/pci/pcibios.c | 149 ++
>  c/src/lib/libbsp/shared/pci/pci_bus_count.c|  67 ++
>  c/src/lib/libbsp/shared/pci/pci_find_device.c  | 274 
> +
>  8 files changed, 594 insertions(+), 134 deletions(-)
>  create mode 100644 c/src/lib/libbsp/i386/shared/pci/pci_io.c
>  create mode 100644 c/src/lib/libbsp/shared/pci/pci_bus_count.c
>  create mode 100644 c/src/lib/libbsp/shared/pci/pci_find_device.c
>
> diff --git a/c/src/lib/libbsp/Makefile.am b/c/src/lib/libbsp/Makefile.am
> index 16c276f..c54fdcb 100644
> --- a/c/src/lib/libbsp/Makefile.am
> +++ b/c/src/lib/libbsp/Makefile.am
> @@ -29,6 +29,9 @@ EXTRA_DIST += shared/include/coverhd.h
>  EXTRA_DIST += shared/gdbstub/rtems-stub-glue.c
>  EXTRA_DIST += shared/include/bootcard.h
>
> +EXTRA_DIST += shared/pci/pci_bus_count.c
> +EXTRA_DIST += shared/pci/pci_find_device.c
> +
>  include_bspdir = $(includedir)/bsp
>
>  include_bsp_HEADERS =
> diff --git a/c/src/lib/libbsp/i386/Makefile.am 
> b/c/src/lib/libbsp/i386/Makefile.am
> index f10b764..3b6df65 100644
> --- a/c/src/lib/libbsp/i386/Makefile.am
> +++ b/c/src/lib/libbsp/i386/Makefile.am
> @@ -22,6 +22,7 @@ EXTRA_DIST += shared/irq/irq_init.c
>
>  # shared/pci
>  EXTRA_DIST += shared/pci/pcibios.c
> +EXTRA_DIST += shared/pci/pci_io.c
>
>  include $(top_srcdir)/../../../automake/subdirs.am
>  include $(top_srcdir)/../../../automake/local.am
> diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am 
> b/c/src/lib/libbsp/i386/pc386/Makefile.am
> index a9c645b..fc73afd 100644
> --- a/c/src/lib/libbsp/i386/pc386/Makefile.am
> +++ b/c/src/lib/libbsp/i386/pc386/Makefile.am
> @@ -141,6 +141,9 @@ libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
>
>  # pci
>  libbsp_a_SOURCES += ../../i386/shared/pci/pcibios.c
> +libbsp_a_SOURCES += ../../i386/shared/pci/pci_io.c
> +libbsp_a_SOURCES += ../../shared/pci/pci_bus_count.c
> +libbsp_a_SOURCES += ../../shared/pci/pci_find_device.c
>
>  include_HEADERS += ../../i386/shared/comm/uart.h
>  # startup
> diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c 
> b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> index ac871f0..a0bbf66 100644
> --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c
> @@ -34,17 +34,40 @@
>  #include 
>
>  /*
> + * PCI Bus Configuration
> + */
> +rtems_pci_config_t BSP_pci_configuration = {
> +  (volatile unsigned char*)0,
> +  (volatile unsigned char*)0,
> +  NULL
> +};
> +
> +const pci_config_access_functions *pci_bios_initialize(void);
> +const pci_config_access_functions *pci_io_initialize(void);
> +
> +/*
>   * Helper to initialize the PCI Bus
>   */
>  static void bsp_pci_initialize_helper(void)
>  {
>  #if (BSP_IS_EDISON == 0)
> -  int pci_init_retval;
> +  const pci_config_access_functions *pci_accessors;
>
> -  pci_init_retval = pci_initialize();
> -  if (pci_init_retval != PCIB_ERR_SUCCESS) {
> -  printk("PCI bus: could not initialize PCI BIOS interface\n");
> +  pci_accessors = pci_bios_initialize();
> +  if (pci_accessors != NULL) {
> +printk("PCI bus: using PCI BIOS interface\n");
> +BSP_pci_configuration.pci_functions = pci_accessors;
> +return;
>}
> +
> +  pci_accessors = pci_io_initialize();
> +  if (pci_accessors != NULL) {
> +printk("PCI bus: using PCI I/O interface\n");
> +BSP_pci_configuration.pci_functions = pci_accessors;
> +return;
> +  }
> +
> +  printk("PCI bus: could not initialize PCI BIOS interface\n");
>  #endif
>  }
>
> diff --git a/c/src/lib/libbsp/i386/shared/pci/pci_io.c 
> b/c/src/lib/libbsp/i386/shared/pci/pci_io.c
> new file mode 100644
> index 000..9103b5c
> --- /dev/null
> +++ b/c/src/lib/libbsp/i386/shared/pci/pci_io.c
> @@ -0,0 +1,200 @@
> +#include 
> +#include 
> +#include 
> +
> +static int pci_io_initialized = 0;
> +
> +/*
> + * Forward reference. Initialized at bottom.
> + */
> +static const pci_config_access_functions pci_io_indirect_functions;
> +
> +/* prototype before defining */
> +const pci_config_access_functions