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 Fri, 2004-10-29 at 15:16, Ian Campbell wrote:
> The patch adds command peek and poke to RedBoot

My colleague David pointed out that the CDL file says the commands are
called 'in' and 'out' when they are actually 'peek' and 'poke'.

I also managed to nob up the paths in the patch, they  are missing the
'current' bit -- that's what I get for manually fixing up the patch
paths.

In any case, here is the ChangeLog again and a corrected patch.

Ian.

packages/redboot/current/ChangeLog:

2004-10-29  Ian Campbell  <icampbell@arcom.com>

        * cdl/redboot.cdl, doc/redboot_cmds.sgml, src/iomem.c: 
        Add support for 'peek' and 'poke' commands to bit-bash 
        the I/O regions.

-- 
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/cdl/redboot.cdl
===================================================================
RCS file: /var/cvs/ecos/packages/redboot/current/cdl/redboot.cdl,v
retrieving revision 1.1.1.8
diff -u -p -r1.1.1.8 redboot.cdl
--- packages/redboot/current/cdl/redboot.cdl	14 Oct 2004 10:54:33 -0000	1.1.1.8
+++ packages/redboot/current/cdl/redboot.cdl	1 Nov 2004 09:54:46 -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 'peek' and 'poke'"
+	    default_value CYGPKG_HAL_I386
+	    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: /var/cvs/ecos/packages/redboot/current/doc/redboot_cmds.sgml,v
retrieving revision 1.1.1.3
retrieving revision 1.5
diff -u -p -r1.1.1.3 -r1.5
--- packages/redboot/current/doc/redboot_cmds.sgml	14 Oct 2004 10:54:33 -0000	1.1.1.3
+++ packages/redboot/current/doc/redboot_cmds.sgml	14 Oct 2004 13:23:45 -0000	1.5
@@ -873,10 +873,15 @@ 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]
+Read I/O location
+   peek [-b &lt;location&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;
+Write I/O location
+   poke [-b &lt;location&gt;] [-1|2|4] -v &lt;value&gt;
 Reset the system
    reset 
 Display RedBoot version information
@@ -1512,6 +1517,91 @@ RedBoot> <userinput>x -b 0x100000 -l 0x2
     </refsect1>
   </refentry>
 
+<!-- ******** peek *************************************************** -->
+  <refentry id="peek-command">
+  <refnamediv>
+    <refname>peek</refname>
+    <refpurpose>Read I/O location</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>peek</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>peek -b 0x3f8</userinput>
+0x03f8 = 0x30
+</screen> 
+</para>
+     <para>
+Examine 32 bit value at I/O location 0x3f8.
+<screen> 
+RedBoot> <userinput>peek -b 0x3f8 -4</userinput>
+0x03f8 = 0x03c10065
+</screen>
+</para>
+    </refsect1>
+  </refentry>
+
 <!-- ******** ping *************************************************** -->
   <refentry id="ping-command">
     <refnamediv>
@@ -1635,6 +1725,86 @@ PING: Cannot reach server '192.168.1.109
     </refsect1>
   </refentry>
 
+<!-- ******** poke *************************************************** -->
+  <refentry id="poke-command">
+  <refnamediv>
+    <refname>poke</refname>
+    <refpurpose>Write I/O location</refpurpose>
+  </refnamediv>
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>poke</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>poke -b 0x200 -v 0x123 -2</userinput>
+</screen> 
+</para>
+    </refsect1>
+  </refentry>
+
 <!-- ******** reset *************************************************** -->
   <refentry id="reset-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	1 Oct 2003 08:47:32 -0000	1.2
@@ -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("peek",
+	    "Read I/O location",
+	    "[-b <location>] [-1|2|4]",
+	    do_peek
+    );
+RedBoot_cmd("poke",
+	    "Write I/O location",
+	    "[-b <location>] [-1|2|4] -v <value>",
+	    do_poke
+    );
+
+
+
+void
+do_poke(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_peek(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]