This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: redboot peek and poke commands for prodding I/O ports


On Tue, 2004-11-09 at 12:07 +0100, Andrew Lunn wrote:
> On Fri, Oct 29, 2004 at 03:16:06PM +0100, Ian Campbell wrote:
> > Hi,
> > 
> > The patch adds command peek and poke to RedBoot which can be used to
> > access I/O mapped regions in the same way mfill and dump can be used on
> > memory mapped regions. By default they are only enabled on i386
> > platforms since it is the only one I know of that has a separate I/O
> > bus.
> 
> I don't like the naming of these commands. From the Jargon File:
>   
> The definition is that it access memory locations, not IO
> locations. So i would prefer different names. iopeek and iopoke might
> be possible, or "in" and "out" as you said in the cdl file.

I went with iopeek and iopoke -- in and out are a little generic (in one
sense, and i386 specific in another)...

> Please could you include this as part of the patch itself. The less
> work i have to do, the more likely a patch will get accepted quickly.

done. our local ChangeLog includes the entire history of the feature so
I have constructed a single entry against the main eCos CVS tree.

> Also the HAL_READ_ and HAL_WRITE_ macros should exist on all
> platforms, so i don't see a need to make these commands conditional on
> x86. It should not really make a difference if the IO is memory mapped
> into the normal memory address space or in a different address
> space. The commands are still valid.

The first time I submitted the patch I was asked to disable it by
default, then recently I decided that enabling by default on x86 made
sense. In any case -- I've enabled it by default now.

New patch attached.

Thanks!
Ian.

-- 
Ian Campbell, Senior Design Engineer
                                        Web: http://www.arcom.com
Arcom, Clifton Road,                    Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom       Phone:  +44 (0)1223 411 200


_____________________________________________________________________
The message in this transmission is sent in confidence for the attention of the addressee only and should not be disclosed to any other party. Unauthorised recipients are requested to preserve this confidentiality. Please advise the sender if the addressee is not resident at the receiving end.  Email to and from Arcom is automatically monitored for operational and lawful business reasons.

This message has been virus scanned by MessageLabs.
Index: packages/redboot/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/ChangeLog,v
retrieving revision 1.213
diff -u -p -r1.213 ChangeLog
--- packages/redboot/current/ChangeLog	13 Oct 2004 21:22:53 -0000	1.213
+++ packages/redboot/current/ChangeLog	9 Nov 2004 11:44:36 -0000
@@ -1,3 +1,9 @@
+2004-11-09  Ian Campbell  <icampbell@arcom.com>
+
+	* cdl/redboot.cdl, doc/redboot_cmds.sgml, src/iomem.c:
+	Add support for'iopeek' and 'iopoke' commands to bit-bash 
+	the I/O regions.
+
 2004-10-10	Iztok Zupet	 <iz@elsis.si>
 
 	* cdl/redboot.cdl: added CYGSEM_REDBOOT_DISK_IDE_VMWARE option.
Index: packages/redboot/current/cdl/redboot.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.68
diff -u -p -r1.68 redboot.cdl
--- packages/redboot/current/cdl/redboot.cdl	13 Oct 2004 21:22:53 -0000	1.68
+++ packages/redboot/current/cdl/redboot.cdl	9 Nov 2004 11:44:41 -0000
@@ -263,6 +263,12 @@ cdl_package CYGPKG_REDBOOT {
             # Implemented within the platform HAL
         }
 
+	cdl_option CYGBLD_BUILD_REDBOOT_WITH_IOMEM {
+	    display       "Include I/O Memory commands 'iopeek' and 'iopoke'"
+	    default_value 1
+	    compile -library=libextras.a iomem.c
+	}
+
         no_define
         description "This option enables the building of the Redboot ELF image.
                      The image may require further relocation or symbol
Index: packages/redboot/current/doc/redboot_cmds.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/doc/redboot_cmds.sgml,v
retrieving revision 1.10
diff -u -p -r1.10 redboot_cmds.sgml
--- packages/redboot/current/doc/redboot_cmds.sgml	2 Sep 2004 16:31:26 -0000	1.10
+++ packages/redboot/current/doc/redboot_cmds.sgml	9 Nov 2004 11:44:42 -0000
@@ -865,6 +865,10 @@ Execute code at a location
    go [-w &lt;timeout&gt;] [entry]
 Help about help?
    help [&lt;topic&gt;]
+Read I/O location
+   iopeek [-b &lt;location&gt;] [-1|2|4]
+Write I/O location
+   iopoke [-b &lt;location&gt;] [-1|2|4] -v &lt;value&gt;
 Set/change IP addresses
    ip_address [-l &lt;local_ip_address&gt;[/&lt;mask_length&gt;]] [-h &lt;server_address&gt;]
 Load a file
@@ -873,7 +877,8 @@ Load a file
 Compare two blocks of memory
    mcmp -s &lt;location&gt; -d &lt;location&gt; -l &lt;length&gt; [-1|-2|-4]
 Fill a block of memory with a pattern
-   mfill -b &lt;location&gt; -l &lt;length&gt; -p &lt;pattern&gt; [-1|-2|-4]
+   mfill -b &lt;location&gt; -l &lt;length&gt; -p &lt;pattern&gt;
+  [-1|-2|-4]
 Network connectivity test
    ping [-v] [-n &lt;count&gt;] [-l &lt;length&gt;] [-t &lt;timeout&gt;] [-r &lt;rate&gt;]
         [-i &lt;IP_addr&gt;] -h &lt;IP_addr&gt;
@@ -913,6 +918,171 @@ Write raw data directly to FLASH
     </refsect1>
   </refentry>
 
+<!-- ******** iopeek *************************************************** -->
+  <refentry id="iopeek-command">
+  <refnamediv>
+    <refname>iopeek</refname>
+    <refpurpose>Read I/O location</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>iopeek</command>
+      <arg>-b <replaceable> location</replaceable></arg>
+      <group>
+        <arg>-1</arg>
+        <arg>-2</arg>
+        <arg>-4</arg>
+      </group>
+    </cmdsynopsis>
+  </refsynopsisdiv>      
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>-b <replaceable>location</replaceable></entry>             
+            <entry>I/O address</entry>
+            <entry>I/O Location.</entry>             
+            <entry><emphasis>none</emphasis></entry>             
+          </row>
+          <row>
+            <entry>-1</entry>             
+            <entry></entry>
+            <entry>Access a one byte (8 bit) I/O location.</entry>             
+            <entry>-1</entry>             
+          </row>
+          <row>
+            <entry>-2</entry>             
+            <entry></entry>
+            <entry>Access a two byte (16 bit) I/O location.</entry>             
+            <entry>-1</entry>             
+          </row>
+          <row>
+            <entry>-4</entry>             
+            <entry></entry>
+            <entry>Access a one word (32 bit) I/O location.</entry>             
+            <entry>-1</entry>             
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+      <para>Reads a value from the I/O address space.</para>
+  </refsect1>
+  <refsect1>
+    <title>Examples</title>
+    <para>
+Examine 8 bit value at I/O location 0x3F8.
+<screen> 
+RedBoot> <userinput>iopeek -b 0x3f8</userinput>
+0x03f8 = 0x30
+</screen> 
+</para>
+     <para>
+Examine 32 bit value at I/O location 0x3f8.
+<screen> 
+RedBoot> <userinput>iopeek -b 0x3f8 -4</userinput>
+0x03f8 = 0x03c10065
+</screen>
+</para>
+    </refsect1>
+  </refentry>
+
+<!-- ******** iopoke *************************************************** -->
+  <refentry id="iopoke-command">
+  <refnamediv>
+    <refname>iopoke</refname>
+    <refpurpose>Write I/O location</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>iopoke</command>
+      <arg>-b <replaceable> location</replaceable></arg>
+      <group>
+        <arg>-1</arg>
+        <arg>-2</arg>
+        <arg>-4</arg>
+      </group>
+      <arg>-v <replaceable> value</replaceable></arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>      
+  <refsect1>
+    <title>Arguments</title>
+    <informaltable frame="all">
+      <tgroup cols="4" colsep="1" rowsep="1" align="left">
+        <colspec colname="c1">
+        <colspec colname="c2">
+        <colspec colname="c3">
+        <colspec colname="c4">
+        <thead>
+          <row>
+            <entry>Name</entry>
+            <entry>Type</entry>
+            <entry>Description</entry>
+            <entry>Default</entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>-b <replaceable>location</replaceable></entry>             
+            <entry>I/O address</entry>
+            <entry>I/O Location.</entry>             
+            <entry><emphasis>none</emphasis></entry>             
+          </row>
+          <row>
+            <entry>-1</entry>             
+            <entry></entry>
+            <entry>Access a one byte (8 bit) I/O location. 
+Only the 8 least significant bits of value will be used</entry>             
+            <entry>-1</entry>             
+          </row>
+          <row>
+            <entry>-2</entry>             
+            <entry></entry>
+            <entry>Access a two byte (16 bit) I/O location.
+Only the 16 least significant bits of value will be used</entry>             
+            <entry>-1</entry>             
+          </row>
+          <row>
+            <entry>-4</entry>             
+            <entry></entry>
+            <entry>Access a one word (32 bit) I/O location.</entry>             
+            <entry>-1</entry>             
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </refsect1>
+  <refsect1>
+    <title>Description</title>
+      <para>Writes a value to the I/O address space.</para>
+  </refsect1>
+  <refsect1>
+    <title>Examples</title>
+    <para>
+Write 0x0123 to 16 bit I/O location 0x200.
+<screen> 
+RedBoot> <userinput>iopoke -b 0x200 -v 0x123 -2</userinput>
+</screen> 
+</para>
+    </refsect1>
+  </refentry>
+
 <!-- ******** ip_address *************************************************** -->
   <refentry id="ip-address-command">
     <refnamediv>
Index: packages/redboot/current/src/iomem.c
===================================================================
RCS file: packages/redboot/current/src/iomem.c
diff -N packages/redboot/current/src/iomem.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ packages/redboot/current/src/iomem.c	9 Nov 2004 11:46:37 -0000	1.3
@@ -0,0 +1,173 @@
+//==========================================================================
+//
+//      iomem.c
+//
+//      RedBoot I/O memory peek and poke
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2002 Arcom Control Systems Ltd.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    icampbell
+// Contributors: 
+// Date:         2002-10-28
+// Purpose:      
+// Description:  
+//              
+// This code is part of RedBoot (tm).
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <redboot.h>
+#include <cyg/hal/hal_io.h>
+
+RedBoot_cmd("iopeek",
+	    "Read I/O location",
+	    "[-b <location>] [-1|2|4]",
+	    do_iopeek
+    );
+RedBoot_cmd("iopoke",
+	    "Write I/O location",
+	    "[-b <location>] [-1|2|4] -v <value>",
+	    do_iopoke
+    );
+
+
+
+void
+do_iopoke(int argc, char *argv[])
+{
+    struct option_info opts[5];
+    unsigned long base;
+    bool base_set, value_set;
+    bool set_32bit = false;
+    bool set_16bit = false;
+    bool set_8bit = false;
+    cyg_uint32 value;
+    int size = 1;
+
+    init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, 
+              &base, &base_set, "base address");
+    init_opts(&opts[1], 'v', true, OPTION_ARG_TYPE_NUM, 
+              &value, &value_set, "valuex");
+    init_opts(&opts[2], '4', false, OPTION_ARG_TYPE_FLG,
+              &set_32bit, 0, "output 32 bit units");
+    init_opts(&opts[3], '2', false, OPTION_ARG_TYPE_FLG,
+              &set_16bit, 0, "output 16 bit units");
+    init_opts(&opts[4], '1', false, OPTION_ARG_TYPE_FLG,
+              &set_8bit, 0, "output 8 bit units");
+    if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) {
+        return;
+    }
+    if (!base_set) {
+        diag_printf("Fill what <location>?\n");
+        return;
+    }
+    if (!value_set) { 
+        diag_printf("Fill what <value>?\n");
+        return;
+    }
+    if (set_32bit) {
+        size = 4;
+    } else if (set_16bit) {
+        size = 2;
+    } else if (set_8bit) {
+        size = 1;
+    }
+
+    switch (size) {
+    case 4:
+        HAL_WRITE_UINT32 ( base, value );
+        break;
+    case 2:
+        HAL_WRITE_UINT16 ( base, value );
+        break;
+    case 1: 
+        HAL_WRITE_UINT8 ( base, value );
+        break;
+    }
+}
+
+void
+do_iopeek(int argc, char *argv[])
+{
+    struct option_info opts[4];
+    unsigned long base;
+    bool base_set;
+    bool set_32bit = false;
+    bool set_16bit = false;
+    bool set_8bit = false;
+    int size = 1, value;
+
+    init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, 
+              &base, &base_set, "base address");
+    init_opts(&opts[1], '4', false, OPTION_ARG_TYPE_FLG,
+              &set_32bit, 0, "output 32 bit units");
+    init_opts(&opts[2], '2', false, OPTION_ARG_TYPE_FLG,
+              &set_16bit, 0, "output 16 bit units");
+    init_opts(&opts[3], '1', false, OPTION_ARG_TYPE_FLG,
+              &set_8bit, 0, "output 8 bit units");
+    if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) {
+        return;
+    }
+    if (!base_set) {
+        diag_printf("Read what <location>?\n");
+        return;
+    }
+    if (set_32bit) {
+      size = 4;
+    } else if (set_16bit) {
+        size = 2;
+    } else if (set_8bit) {
+        size = 1;
+    }
+
+    switch (size) {
+    case 4:
+        HAL_READ_UINT32 ( base, value );
+        diag_printf("0x%04x = 0x%08x\n", base, value );
+        break;
+    case 2:
+        HAL_READ_UINT16 ( base, value );
+        diag_printf("0x%04x = 0x%04x\n", base, value );
+        break;
+    case 1: 
+        HAL_READ_UINT8 ( base, value );
+        diag_printf("0x%04x = 0x%02x\n", base, value );
+        break;
+    }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]