1 //==========================================================================
5 // RedBoot I/O memory peek and poke
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 2004 eCosCentric Ltd
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
43 // Author(s): icampbell
44 // Contributors: icampbell
49 // This code is part of RedBoot (tm).
51 //####DESCRIPTIONEND####
53 //==========================================================================
56 #include <cyg/hal/hal_io.h>
60 "[-b <location>] [-1|2|4]",
65 "[-b <location>] [-1|2|4] -v <value>",
70 do_iopoke(int argc, char *argv[])
72 struct option_info opts[5];
74 bool base_set, value_set;
75 bool set_32bit = false;
76 bool set_16bit = false;
77 bool set_8bit = false;
81 init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
82 &base, &base_set, "base address");
83 init_opts(&opts[1], 'v', true, OPTION_ARG_TYPE_NUM,
84 &value, &value_set, "valuex");
85 init_opts(&opts[2], '4', false, OPTION_ARG_TYPE_FLG,
86 &set_32bit, 0, "output 32 bit units");
87 init_opts(&opts[3], '2', false, OPTION_ARG_TYPE_FLG,
88 &set_16bit, 0, "output 16 bit units");
89 init_opts(&opts[4], '1', false, OPTION_ARG_TYPE_FLG,
90 &set_8bit, 0, "output 8 bit units");
91 if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) {
95 diag_printf("iopoke what <location>?\n");
99 diag_printf("iopoke what <value>?\n");
104 } else if (set_16bit) {
106 } else if (set_8bit) {
112 HAL_WRITE_UINT32 ( base, value );
115 HAL_WRITE_UINT16 ( base, value );
118 HAL_WRITE_UINT8 ( base, value );
124 do_iopeek(int argc, char *argv[])
126 struct option_info opts[4];
129 bool set_32bit = false;
130 bool set_16bit = false;
131 bool set_8bit = false;
134 init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
135 &base, &base_set, "base address");
136 init_opts(&opts[1], '4', false, OPTION_ARG_TYPE_FLG,
137 &set_32bit, 0, "output 32 bit units");
138 init_opts(&opts[2], '2', false, OPTION_ARG_TYPE_FLG,
139 &set_16bit, 0, "output 16 bit units");
140 init_opts(&opts[3], '1', false, OPTION_ARG_TYPE_FLG,
141 &set_8bit, 0, "output 8 bit units");
142 if (!scan_opts(argc, argv, 1, opts, 4, 0, 0, "")) {
146 diag_printf("iopeek what <location>?\n");
151 } else if (set_16bit) {
153 } else if (set_8bit) {
159 HAL_READ_UINT32 ( base, value );
160 diag_printf("0x%04lx = 0x%08x\n", base, value );
163 HAL_READ_UINT16 ( base, value );
164 diag_printf("0x%04lx = 0x%04x\n", base, value );
167 HAL_READ_UINT8 ( base, value );
168 diag_printf("0x%04lx = 0x%02x\n", base, value );