OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [arm9/] [innovator/] [v2_0/] [src/] [redboot_cmds.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#if 0
2
//==========================================================================
3
//
4
//      redboot_cmds.c
5
//
6
//      OMAP1510DC EVM [platform] specific RedBoot commands
7
//
8
//==========================================================================
9
//####ECOSGPLCOPYRIGHTBEGIN####
10
// -------------------------------------------
11
// This file is part of eCos, the Embedded Configurable Operating System.
12
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13
//
14
// eCos is free software; you can redistribute it and/or modify it under
15
// the terms of the GNU General Public License as published by the Free
16
// Software Foundation; either version 2 or (at your option) any later version.
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
// for more details.
22
//
23
// You should have received a copy of the GNU General Public License along
24
// with eCos; if not, write to the Free Software Foundation, Inc.,
25
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
//
27
// As a special exception, if other files instantiate templates or use macros
28
// or inline functions from this file, or you compile this file and link it
29
// with other works to produce a work based on this file, this file does not
30
// by itself cause the resulting work to be covered by the GNU General Public
31
// License. However the source code for this file must still be made available
32
// in accordance with section (3) of the GNU General Public License.
33
//
34
// This exception does not invalidate any other reasons why a work based on
35
// this file might be covered by the GNU General Public License.
36
//
37
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
// at http://sources.redhat.com/ecos/ecos-license/
39
// -------------------------------------------
40
//####ECOSGPLCOPYRIGHTEND####
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    Patrick Doyle <wpd@delcomsys.com>
45
// Contributors: Patrick Doyle <wpd@delcomsys.com>
46
// Date:         2002-11-27
47
// Purpose:      
48
// Description:  
49
//              
50
// This code is part of RedBoot (tm).  It was modified from "redboot_cmds"
51
// for the iPaq by wpd in order to add some platform specific commands to
52
// the OMAP1510DC EVM platform.
53
//
54
//####DESCRIPTIONEND####
55
//
56
//==========================================================================
57
 
58
#include <redboot.h>
59
 
60
#include <cyg/hal/hal_intr.h>
61
#include <cyg/hal/hal_cache.h>
62
#include <cyg/hal/hal_io.h>
63
#include <cyg/hal/hal_diag.h>
64
#include <cyg/hal/innovator.h>
65
 
66
static void do_mem(int argc, char *argv[]);
67
static void do_try_reset(int argc, char *argv[]);
68
static void do_testsdram(int argc, char *argv[]);
69
static void do_delay(int argc, char *argv[]);
70
 
71
RedBoot_cmd("mem",
72
            "Set a memory location",
73
            "[-h|-b] [-n] [-a <address>] <data>",
74
            do_mem
75
    );
76
 
77
RedBoot_cmd("try_reset",
78
            "try to reset the platform",
79
            "[-1|-2|-3|-4]",
80
            do_try_reset
81
    );
82
 
83
 
84
RedBoot_cmd("testsdram",
85
            "test SDRAM (very simply)",
86
            "[-l length]",
87
            do_testsdram
88
    );
89
 
90
RedBoot_cmd("delay",
91
            "delay specified number of usecs",
92
            "[-c count] amount",
93
            do_delay
94
    );
95
 
96
 
97
static void
98
do_mem(int argc,
99
       char *argv[])
100
{
101
  struct option_info opts[4];
102
  bool mem_half_word, mem_byte;
103
  bool no_verify = false;
104
  static int address = 0x00000000;
105
  int value;
106
  init_opts(&opts[0], 'b', false, OPTION_ARG_TYPE_FLG,
107
            (void**)&mem_byte, 0, "write a byte");
108
  init_opts(&opts[1], 'h', false, OPTION_ARG_TYPE_FLG,
109
            (void**)&mem_half_word, 0, "write a half-word");
110
  init_opts(&opts[2], 'a', true, OPTION_ARG_TYPE_NUM,
111
            (void**)&address, NULL, "address to write at");
112
  init_opts(&opts[3], 'n', false, OPTION_ARG_TYPE_FLG,
113
            (void**)&no_verify, 0, "noverify");
114
 
115
  if (!scan_opts(argc, argv,
116
                 1,
117
                 opts, sizeof(opts) / sizeof(opts[0]),
118
                 (void*)&value, OPTION_ARG_TYPE_NUM, "address to set")) {
119
    return;
120
  }
121
 
122
  if ( mem_byte && mem_half_word ) {
123
    diag_printf("*ERR: Should not specify both byte and half-word access\n");
124
  } else if ( mem_byte ) {
125
    *(cyg_uint8*)address = (cyg_uint8)(value & 255);
126
    if (no_verify) {
127
      diag_printf("  Set 0x%08X to 0x%02X\n",
128
                  address, value & 255);
129
    } else {
130
            diag_printf("  Set 0x%08X to 0x%02X (result 0x%02X)\n",
131
                  address, value & 255, (int)*(cyg_uint8*)address );
132
    }
133
  } else if ( mem_half_word ) {
134
    if ( address & 1 ) {
135
      diag_printf( "*ERR: Badly aligned address 0x%08X for half-word store\n",
136
                   address );
137
    } else {
138
      *(cyg_uint16*)address = (cyg_uint16)(value & 0xffff);
139
      if (no_verify) {
140
        diag_printf("  Set 0x%08X to 0x%04X\n",
141
                    address, value & 0xffff);
142
      } else {
143
        diag_printf("  Set 0x%08X to 0x%04X (result 0x%04X)\n",
144
                    address, value & 0xffff, (int)*(cyg_uint16*)address );
145
      }
146
    }
147
  } else {
148
    if ( address & 3 ) {
149
      diag_printf( "*ERR: Badly aligned address 0x%08X for word store\n",
150
                   address );
151
    } else {
152
      *(cyg_uint32*)address = (cyg_uint32)value;
153
      if (no_verify) {
154
        diag_printf("  Set 0x%08X to 0x%08X\n",
155
                    address, value);
156
      } else {
157
        diag_printf("  Set 0x%08X to 0x%08X (result 0x%08X)\n",
158
                    address, value, (int)*(cyg_uint32*)address );
159
      }
160
    }
161
  }
162
}
163
 
164
static void
165
do_try_reset(int argc,
166
             char *argv[])
167
{
168
  struct option_info opts[4];
169
  bool flag_1 = false;
170
  bool flag_2 = false;
171
  bool flag_3 = false;
172
  bool flag_4 = false;
173
 
174
  cyg_uint16 tmp = 0;
175
 
176
  init_opts(&opts[0], '1', false, OPTION_ARG_TYPE_FLG,
177
            (void**)&flag_1, 0, "only try phase 1");
178
  init_opts(&opts[1], '2', false, OPTION_ARG_TYPE_FLG,
179
            (void**)&flag_2, 0, "try phase 1 & phase 2");
180
  init_opts(&opts[2], '3', false, OPTION_ARG_TYPE_FLG,
181
            (void**)&flag_3, 0, "try phase 1 through phase 3");
182
  init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
183
            (void**)&flag_4, 0, "try phase 1 through phase 4");
184
 
185
  if (!scan_opts(argc, argv,
186
                 1,
187
                 opts, sizeof(opts) / sizeof(opts[0]),
188
                 0, 0, 0)) {
189
    return;
190
  }
191
  diag_printf("flag_4 = %d, flag_3 = %d, flag_2 = %d, flag_1 = %d\n",
192
              flag_4, flag_3, flag_2, flag_1);
193
  if (flag_4) {
194
    flag_3 = flag_2 = flag_1 = true;
195
  } else if (flag_3) {
196
    flag_2 = flag_1 = true;
197
  } else if (flag_2) {
198
    flag_1 = true;
199
  }
200
  diag_printf("flag_4 = %d, flag_3 = %d, flag_2 = %d, flag_1 = %d\n",
201
              flag_4, flag_3, flag_2, flag_1);
202
 
203
  if (flag_1) {
204
    HAL_READ_UINT16(CLKM_ARM_IDLECT2, tmp);
205
    diag_printf("tmp = %04X\n", tmp);
206
  }
207
 
208
  if (flag_2) {
209
    tmp |= 1;
210
    diag_printf("Writing %04X to %08X\n", tmp, CLKM_ARM_IDLECT2);
211
    HAL_WRITE_UINT16(CLKM_ARM_IDLECT2, tmp | 1);
212
  }
213
 
214
  if (flag_3) {
215
    diag_printf("Writing %04X to %08X\n", 0x80F5, WATCHDOG_TIMER_MODE);
216
    HAL_WRITE_UINT16(WATCHDOG_TIMER_MODE, 0x80F5); \
217
  }
218
 
219
  if (flag_4) {
220
    diag_printf("Writing %04X to %08X\n", 0x80F5, WATCHDOG_TIMER_MODE);
221
    HAL_WRITE_UINT16(WATCHDOG_TIMER_MODE, 0x80F5); \
222
  }
223
 
224
  diag_printf("try_reset: done\n");
225
}
226
 
227
#define SDRAM_BASE 0x10000000
228
#define SDRAM_LEN  (32*1024*1024)       /* 32 Mbytes */
229
static void
230
do_testsdram(int argc,
231
             char *argv[])
232
{
233
  cyg_uint32 *mem_addr = (cyg_uint32 *)SDRAM_BASE;
234
  unsigned    len;
235
  bool        len_set;
236
 
237
  register int i;
238
  struct option_info opts[1];
239
 
240
  init_opts(&opts[0], 'l', true, OPTION_ARG_TYPE_NUM,
241
            (void**)&len, &len_set, "length");
242
 
243
  if (!scan_opts(argc, argv,
244
                 1,
245
                 opts, 1,
246
                 0, 0, 0)) {
247
    return;
248
  }
249
  if (!len_set) {
250
    len = SDRAM_LEN / 4;
251
  }
252
 
253
  diag_printf("Length = 0x%08X\n", len);
254
 
255
  diag_printf("Writing data-equals-address pattern to SDRAM\n");
256
  for (i = 0; i < len; i++) {
257
    mem_addr[i] = ~(cyg_uint32)(mem_addr + i);
258
  }
259
  diag_printf("Reading back pattern\n");
260
  for (i = 0; i < len; i++) {
261
    if (mem_addr[i] != ~(cyg_uint32)(mem_addr + i)) {
262
      diag_printf("Error: mismatch at address %p, read back 0x%08x\n",
263
                  mem_addr + i,
264
                  mem_addr[i]);
265
      break;
266
    }
267
  }
268
  diag_printf("Done\n");
269
}
270
 
271
static void
272
do_delay(int argc,
273
         char *argv[])
274
{
275
  struct option_info opts[1];
276
  int count = 0x00000000;
277
  bool count_set;
278
  int value;
279
  register int i;
280
 
281
  init_opts(&opts[0], 'c', true, OPTION_ARG_TYPE_NUM,
282
            (void**)&count, &count_set, "Number of times to delay");
283
 
284
  if (!scan_opts(argc, argv,
285
                 1,
286
                 opts, sizeof(opts) / sizeof(opts[0]),
287
                 (void*)&value, OPTION_ARG_TYPE_NUM, "amount of time to delay (usec)")) {
288
    return;
289
  }
290
 
291
  if (!count_set) {
292
    count = 1;
293
  }
294
  for (i = 0; i < count; i++) {
295
    diag_printf("Delaying %d useconds...", value);
296
    HAL_DELAY_US(value);
297
    diag_printf("Done\n");
298
  }
299
}
300
 
301
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.