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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [redboot/] [v2_0/] [src/] [main.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
//==========================================================================
2
//
3
//      main.c
4
//
5
//      RedBoot main routine
6
//
7
//==========================================================================
8
//####ECOSGPLCOPYRIGHTBEGIN####
9
// -------------------------------------------
10
// This file is part of eCos, the Embedded Configurable Operating System.
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
12
// Copyright (C) 2002 Gary Thomas
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):    gthomas
45
// Contributors: gthomas, tkoeller
46
// Date:         2000-07-14
47
// Purpose:      
48
// Description:  
49
//              
50
// This code is part of RedBoot (tm).
51
//
52
//####DESCRIPTIONEND####
53
//
54
//==========================================================================
55
 
56
#define  DEFINE_VARS
57
#include <redboot.h>
58
#include <cyg/hal/hal_arch.h>
59
#include <cyg/hal/hal_intr.h>
60
#include <cyg/hal/hal_if.h>
61
#include <cyg/hal/hal_cache.h>
62
#include CYGHWR_MEMORY_LAYOUT_H
63
 
64
#include <cyg/hal/hal_tables.h>
65
 
66
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
67
#ifdef CYGBLD_HAL_PLATFORM_STUB_H
68
#include CYGBLD_HAL_PLATFORM_STUB_H
69
#else
70
#include <cyg/hal/plf_stub.h>
71
#endif
72
// GDB interfaces
73
extern void breakpoint(void);
74
#endif
75
 
76
// Builtin Self Test (BIST)
77
externC void bist(void);
78
 
79
// Return path for code run from a go command
80
static void return_to_redboot(int status);
81
 
82
 
83
// CLI command processing (defined in this file)
84
RedBoot_cmd("version",
85
            "Display RedBoot version information",
86
            "",
87
            do_version
88
    );
89
RedBoot_cmd("help",
90
            "Help about help?",
91
            "[<topic>]",
92
            do_help
93
    );
94
RedBoot_cmd("go",
95
            "Execute code at a location",
96
            "[-w <timeout>] [entry]",
97
            do_go
98
    );
99
#ifdef HAL_PLATFORM_RESET
100
RedBoot_cmd("reset",
101
            "Reset the system",
102
            "",
103
            do_reset
104
    );
105
#endif
106
#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
107
RedBoot_cmd("baudrate",
108
            "Set/Query the system console baud rate",
109
            "[-b <rate>]",
110
            do_baud_rate
111
    );
112
#endif
113
 
114
// Define table boundaries
115
CYG_HAL_TABLE_BEGIN( __RedBoot_INIT_TAB__, RedBoot_inits );
116
CYG_HAL_TABLE_END( __RedBoot_INIT_TAB_END__, RedBoot_inits );
117
extern struct init_tab_entry __RedBoot_INIT_TAB__[], __RedBoot_INIT_TAB_END__;
118
 
119
CYG_HAL_TABLE_BEGIN( __RedBoot_CMD_TAB__, RedBoot_commands );
120
CYG_HAL_TABLE_END( __RedBoot_CMD_TAB_END__, RedBoot_commands );
121
extern struct cmd __RedBoot_CMD_TAB__[], __RedBoot_CMD_TAB_END__;
122
 
123
CYG_HAL_TABLE_BEGIN( __RedBoot_IDLE_TAB__, RedBoot_idle );
124
CYG_HAL_TABLE_END( __RedBoot_IDLE_TAB_END__, RedBoot_idle );
125
extern struct idle_tab_entry __RedBoot_IDLE_TAB__[], __RedBoot_IDLE_TAB_END__;
126
 
127
#ifdef HAL_ARCH_PROGRAM_NEW_STACK
128
extern void HAL_ARCH_PROGRAM_NEW_STACK(void *fun);
129
#endif
130
 
131
 
132
void
133
do_version(int argc, char *argv[])
134
{
135
#ifdef CYGPKG_IO_FLASH
136
    externC void _flash_info(void);
137
#endif
138
    char *version = CYGACC_CALL_IF_MONITOR_VERSION();
139
 
140
    diag_printf(version);
141
#ifdef HAL_PLATFORM_CPU
142
    diag_printf("Platform: %s (%s) %s\n", HAL_PLATFORM_BOARD, HAL_PLATFORM_CPU, HAL_PLATFORM_EXTRA);
143
#endif
144
    diag_printf("Copyright (C) 2000, 2001, 2002, Red Hat, Inc.\n\n");
145
    diag_printf("RAM: %p-%p, %p-%p available\n",
146
                (void*)ram_start, (void*)ram_end,
147
                (void*)user_ram_start, (void *)user_ram_end);
148
#ifdef CYGPKG_IO_FLASH
149
    _flash_info();
150
#endif
151
}
152
 
153
void
154
do_idle(bool is_idle)
155
{
156
    struct idle_tab_entry *idle_entry;
157
 
158
    for (idle_entry = __RedBoot_IDLE_TAB__;
159
         idle_entry != &__RedBoot_IDLE_TAB_END__;  idle_entry++) {
160
        (*idle_entry->fun)(is_idle);
161
    }
162
}
163
 
164
// Wrapper used by diag_printf()
165
static void
166
_mon_write_char(char c, void **param)
167
{
168
    if (c == '\n') {
169
        mon_write_char('\r');
170
    }
171
    mon_write_char(c);
172
}
173
 
174
//
175
// This is the main entry point for RedBoot
176
//
177
void
178
cyg_start(void)
179
{
180
    int res = 0;
181
    bool prompt = true;
182
    static char line[CYGPKG_REDBOOT_MAX_CMD_LINE];
183
    char *command;
184
    struct cmd *cmd;
185
    int cur;
186
    struct init_tab_entry *init_entry;
187
    extern char RedBoot_version[];
188
 
189
    // Export version information
190
    CYGACC_CALL_IF_MONITOR_VERSION_SET(RedBoot_version);
191
 
192
    CYGACC_CALL_IF_MONITOR_RETURN_SET(return_to_redboot);
193
 
194
    // Make sure the channels are properly initialized.
195
    diag_init_putc(_mon_write_char);
196
    hal_if_diag_init();
197
 
198
    // Force console to output raw text - but remember the old setting
199
    // so it can be restored if interaction with a debugger is
200
    // required.
201
    cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
202
    CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_HAL_VIRTUAL_VECTOR_DEBUG_CHANNEL);
203
#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
204
    console_selected = false;
205
#endif
206
    console_echo = true;
207
    CYGACC_CALL_IF_DELAY_US((cyg_int32)2*100000);
208
 
209
    ram_start = (unsigned char *)CYGMEM_REGION_ram;
210
    ram_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
211
#ifdef HAL_MEM_REAL_REGION_TOP
212
    {
213
        unsigned char *ram_end_tmp = ram_end;
214
        ram_end = HAL_MEM_REAL_REGION_TOP( ram_end_tmp );
215
    }
216
#endif
217
#ifdef CYGMEM_SECTION_heap1
218
    workspace_start = (unsigned char *)CYGMEM_SECTION_heap1;
219
    workspace_end = (unsigned char *)(CYGMEM_SECTION_heap1+CYGMEM_SECTION_heap1_SIZE);
220
    workspace_size = CYGMEM_SECTION_heap1_SIZE;
221
#else
222
    workspace_start = (unsigned char *)CYGMEM_REGION_ram;
223
    workspace_end = (unsigned char *)(CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE);
224
    workspace_size = CYGMEM_REGION_ram_SIZE;
225
#endif
226
 
227
    if ( ram_end < workspace_end ) {
228
        // when *less* SDRAM is installed than the possible maximum,
229
        // but the heap1 region remains greater...
230
        workspace_end = ram_end;
231
        workspace_size = workspace_end - workspace_start;
232
    }
233
 
234
    bist();
235
 
236
#ifdef CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER
237
    fis_zlib_common_buffer =
238
    workspace_end -= CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE;
239
#endif
240
 
241
    for (init_entry = __RedBoot_INIT_TAB__; init_entry != &__RedBoot_INIT_TAB_END__;  init_entry++) {
242
        (*init_entry->fun)();
243
    }
244
 
245
    user_ram_start = workspace_start;
246
    user_ram_end = workspace_end;
247
 
248
    do_version(0,0);
249
 
250
#ifdef CYGFUN_REDBOOT_BOOT_SCRIPT
251
# ifdef CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT
252
    if (!script) {
253
      script = CYGDAT_REDBOOT_DEFAULT_BOOT_SCRIPT;
254
#  ifndef CYGSEM_REDBOOT_FLASH_CONFIG
255
      script_timeout = CYGNUM_REDBOOT_BOOT_SCRIPT_DEFAULT_TIMEOUT;
256
#  endif
257
    }
258
# endif
259
    if (script) {
260
        // Give the guy a chance to abort any boot script
261
        unsigned char *hold_script = script;
262
        int script_timeout_ms = script_timeout * CYGNUM_REDBOOT_BOOT_SCRIPT_TIMEOUT_RESOLUTION;
263
        diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
264
                    script_timeout_ms/1000, script_timeout_ms%1000);
265
        script = (unsigned char *)0;
266
        res = _GETS_CTRLC;  // Treat 0 timeout as ^C
267
        while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
268
            res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
269
            if (res >= _GETS_OK) {
270
                diag_printf("== Executing boot script in %d.%03d seconds - enter ^C to abort\n",
271
                            script_timeout_ms/1000, script_timeout_ms%1000);
272
                continue;  // Ignore anything but ^C
273
            }
274
            if (res != _GETS_TIMEOUT) break;
275
            script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
276
        }
277
        if (res == _GETS_CTRLC) {
278
            script = (unsigned char *)0;  // Disable script
279
        } else {
280
            script = hold_script;  // Re-enable script
281
        }
282
    }
283
#endif
284
 
285
    while (true) {
286
        if (prompt) {
287
            diag_printf("RedBoot> ");
288
            prompt = false;
289
        }
290
#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
291
        cmd_history = true;  // Enable history collection
292
#endif
293
        res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
294
#if CYGNUM_REDBOOT_CMD_LINE_EDITING != 0
295
        cmd_history = false;  // Enable history collection
296
#endif
297
        if (res == _GETS_TIMEOUT) {
298
            // No input arrived
299
        } else {
300
#ifdef CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
301
            if (res == _GETS_GDB) {
302
                int dbgchan;
303
                hal_virtual_comm_table_t *__chan;
304
                int i;
305
                // Special case of '$' - need to start GDB protocol
306
                gdb_active = true;
307
                // Mask interrupts on all channels
308
                for (i = 0;  i < CYGNUM_HAL_VIRTUAL_VECTOR_NUM_CHANNELS;  i++) {
309
                    CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
310
                    __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
311
                    CYGACC_COMM_IF_CONTROL( *__chan, __COMMCTL_IRQ_DISABLE );
312
                }
313
 
314
                CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
315
#ifdef HAL_ARCH_PROGRAM_NEW_STACK
316
                HAL_ARCH_PROGRAM_NEW_STACK(breakpoint);
317
#else
318
                breakpoint();  // Get GDB stubs started, with a proper environment, etc.
319
#endif
320
                dbgchan = CYGACC_CALL_IF_SET_DEBUG_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
321
                CYGACC_CALL_IF_SET_CONSOLE_COMM(dbgchan);
322
            } else
323
#endif // CYGDBG_HAL_DEBUG_GDB_INCLUDE_STUBS
324
            {
325
                expand_aliases(line, sizeof(line));
326
                command = (char *)&line;
327
                if ((*command == '#') || (*command == '=')) {
328
                    // Special cases
329
                    if (*command == '=') {
330
                        // Print line on console
331
                        diag_printf("%s\n", &line[2]);
332
                    }
333
                } else {
334
                    while (strlen(command) > 0) {
335
                        if ((cmd = parse(&command, &argc, &argv[0])) != (struct cmd *)0) {
336
                            (cmd->fun)(argc, argv);
337
                        } else {
338
                            diag_printf("** Error: Illegal command: \"%s\"\n", argv[0]);
339
                        }
340
                    }
341
                }
342
                prompt = true;
343
            }
344
        }
345
    }
346
}
347
 
348
void
349
show_help(struct cmd *cmd, struct cmd *cmd_end, char *which, char *pre)
350
{
351
    bool show;
352
    int len = 0;
353
 
354
    if (which) {
355
        len = strlen(which);
356
    }
357
    while (cmd != cmd_end) {
358
        show = true;
359
        if (which && (strncasecmp(which, cmd->str, len) != 0)) {
360
            show = false;
361
        }
362
        if (show) {
363
            diag_printf("%s\n  %s %s %s\n", cmd->help, pre, cmd->str, cmd->usage);
364
            if ((cmd->sub_cmds != (struct cmd *)0) && (which != (char *)0)) {
365
                show_help(cmd->sub_cmds, cmd->sub_cmds_end, 0, cmd->str);
366
            }
367
        }
368
        cmd++;
369
    }
370
}
371
 
372
void
373
do_help(int argc, char *argv[])
374
{
375
    struct cmd *cmd;
376
    char *which = (char *)0;
377
 
378
    if (!scan_opts(argc, argv, 1, 0, 0, (void **)&which, OPTION_ARG_TYPE_STR, "<topic>")) {
379
        diag_printf("Invalid argument\n");
380
        return;
381
    }
382
    cmd = __RedBoot_CMD_TAB__;
383
    show_help(cmd, &__RedBoot_CMD_TAB_END__, which, "");
384
    return;
385
}
386
 
387
static void * go_saved_context;
388
static int go_return_status;
389
 
390
static void
391
go_trampoline(unsigned long entry)
392
{
393
    typedef void code_fun(void);
394
    code_fun *fun = (code_fun *)entry;
395
    unsigned long oldints;
396
 
397
    HAL_DISABLE_INTERRUPTS(oldints);
398
 
399
#ifdef HAL_ARCH_PROGRAM_NEW_STACK
400
    HAL_ARCH_PROGRAM_NEW_STACK(fun);
401
#else
402
    (*fun)();
403
#endif
404
}
405
 
406
static void
407
return_to_redboot(int status)
408
{
409
    CYGARC_HAL_SAVE_GP();
410
 
411
    go_return_status = status;
412
    HAL_THREAD_LOAD_CONTEXT(&go_saved_context);
413
    // never returns
414
 
415
    // need this to balance above CYGARC_HAL_SAVE_GP on
416
    // some platforms. It will never run, though.
417
    CYGARC_HAL_RESTORE_GP();
418
}
419
 
420
void
421
do_go(int argc, char *argv[])
422
{
423
    unsigned long entry;
424
    unsigned long oldints;
425
    bool wait_time_set;
426
    int  wait_time, res;
427
    bool cache_enabled = false;
428
    struct option_info opts[2];
429
    char line[8];
430
    hal_virtual_comm_table_t *__chan = CYGACC_CALL_IF_CONSOLE_PROCS();
431
 
432
    entry = entry_address;  // Default from last 'load' operation
433
    init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
434
              (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
435
    init_opts(&opts[1], 'c', false, OPTION_ARG_TYPE_FLG,
436
              (void **)&cache_enabled, (bool *)0, "go with caches enabled");
437
    if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry, OPTION_ARG_TYPE_NUM, "starting address"))
438
    {
439
        return;
440
    }
441
    if (wait_time_set) {
442
        int script_timeout_ms = wait_time * 1000;
443
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
444
        unsigned char *hold_script = script;
445
        script = (unsigned char *)0;
446
#endif
447
        diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
448
                    (void *)entry, wait_time);
449
        while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) {
450
            res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT);
451
            if (res == _GETS_CTRLC) {
452
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
453
                script = hold_script;  // Re-enable script
454
#endif
455
                return;
456
            }
457
            script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT;
458
        }
459
    }
460
    CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_ENABLE_LINE_FLUSH);
461
 
462
    HAL_DISABLE_INTERRUPTS(oldints);
463
    HAL_DCACHE_SYNC();
464
    if (!cache_enabled) {
465
        HAL_ICACHE_DISABLE();
466
        HAL_DCACHE_DISABLE();
467
        HAL_DCACHE_SYNC();
468
    }
469
    HAL_ICACHE_INVALIDATE_ALL();
470
    HAL_DCACHE_INVALIDATE_ALL();
471
 
472
    // set up a temporary context that will take us to the trampoline
473
    HAL_THREAD_INIT_CONTEXT((CYG_ADDRESS)workspace_end, entry, go_trampoline, 0);
474
 
475
    // switch context to trampoline
476
    HAL_THREAD_SWITCH_CONTEXT(&go_saved_context, &workspace_end);
477
 
478
    // we get back here by way of return_to_redboot()
479
 
480
    // undo the changes we made before switching context
481
    if (!cache_enabled) {
482
        HAL_ICACHE_ENABLE();
483
        HAL_DCACHE_ENABLE();
484
    }
485
 
486
    CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_DISABLE_LINE_FLUSH);
487
 
488
    HAL_RESTORE_INTERRUPTS(oldints);
489
 
490
    diag_printf("\nProgram completed with status %d\n", go_return_status);
491
}
492
 
493
#ifdef HAL_PLATFORM_RESET
494
void
495
do_reset(int argc, char *argv[])
496
{
497
    diag_printf("... Resetting.");
498
    CYGACC_CALL_IF_DELAY_US(2*100000);
499
    diag_printf("\n");
500
    CYGACC_CALL_IF_RESET();
501
    diag_printf("!! oops, RESET not working on this platform\n");
502
}
503
#endif
504
 
505
#ifdef CYGSEM_REDBOOT_VARIABLE_BAUD_RATE
506
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
507
#include <flash_config.h>
508
#endif
509
 
510
static int
511
set_comm_baud_rate(hal_virtual_comm_table_t *chan, int rate)
512
{
513
    int current_rate;
514
 
515
    current_rate = CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_SETBAUD, rate);
516
    if (rate != current_rate)
517
        return CYGACC_COMM_IF_CONTROL(*chan, __COMMCTL_SETBAUD, rate);
518
 
519
    return 0;
520
}
521
 
522
int
523
set_console_baud_rate(int rate)
524
{
525
    int ret;
526
#ifdef CYGPKG_REDBOOT_ANY_CONSOLE
527
    if (!console_selected) {
528
        int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
529
        int i;
530
        // Set baud for all channels
531
        for (i = 0;  i < CYGNUM_HAL_VIRTUAL_VECTOR_COMM_CHANNELS;  i++) {
532
            CYGACC_CALL_IF_SET_CONSOLE_COMM(i);
533
            ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
534
            if (ret < 0)
535
                break;
536
        }
537
        CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
538
    } else
539
#endif
540
    ret = set_comm_baud_rate(CYGACC_CALL_IF_CONSOLE_PROCS(), rate);
541
 
542
    if (ret < 0)
543
        diag_printf("Setting console baud rate to %d failed\n", rate);
544
 
545
    return ret;
546
}
547
 
548
static void
549
_sleep(int ms)
550
{
551
    int i;
552
    for (i = 0;  i < ms;  i++) {
553
        CYGACC_CALL_IF_DELAY_US((cyg_int32)1000);
554
    }
555
}
556
 
557
void
558
do_baud_rate(int argc, char *argv[])
559
{
560
    int new_rate, ret, old_rate;
561
    bool new_rate_set;
562
    hal_virtual_comm_table_t *__chan;
563
    struct option_info opts[1];
564
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
565
    struct config_option opt;
566
#endif
567
 
568
    init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
569
              (void **)&new_rate, (bool *)&new_rate_set, "new baud rate");
570
    if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, "")) {
571
        return;
572
    }
573
    __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
574
    if (new_rate_set) {
575
        diag_printf("Baud rate will be changed to %d - update your settings\n", new_rate);
576
        _sleep(500);  // Give serial time to flush
577
        old_rate = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
578
        ret = set_console_baud_rate(new_rate);
579
        if (ret < 0) {
580
            if (old_rate > 0) {
581
                // Try to restore
582
                set_console_baud_rate(old_rate);
583
                _sleep(500);  // Give serial time to flush
584
                diag_printf("\nret = %d\n", ret);
585
            }
586
            return;  // Couldn't set the desired rate
587
        }
588
        old_rate = ret;
589
        // Make sure this new rate works or back off to previous value
590
        // Sleep for a few seconds, then prompt to see if it works
591
        _sleep(3000);  // Give serial time to flush
592
        if (!verify_action_with_timeout(5000, "Baud rate changed to %d", new_rate)) {
593
            _sleep(500);  // Give serial time to flush
594
            set_console_baud_rate(old_rate);
595
            _sleep(500);  // Give serial time to flush
596
            return;
597
        }
598
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
599
        opt.type = CONFIG_INT;
600
        opt.enable = (char *)0;
601
        opt.enable_sense = 1;
602
        opt.key = "console_baud_rate";
603
        opt.dflt = new_rate;
604
        flash_add_config(&opt, true);
605
#endif
606
    } else {
607
        ret = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
608
        diag_printf("Baud rate = ");
609
        if (ret <= 0) {
610
            diag_printf("unknown\n");
611
        } else {
612
            diag_printf("%d\n", ret);
613
        }
614
    }
615
}
616
#endif
617
 
618
// 
619
// [Null] Builtin [Power On] Self Test
620
//
621
void bist(void) CYGBLD_ATTRIB_WEAK;
622
 
623
void
624
bist(void)
625
{
626
}

powered by: WebSVN 2.1.0

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