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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [arm9/] [innovator/] [current/] [src/] [redboot_cmds.c] - Blame information for rev 853

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

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

powered by: WebSVN 2.1.0

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