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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mn10300/] [am33/] [v2_0/] [src/] [redboot_linux_exec.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
//      redboot_linux_exec.c
4
//
5
//      AM33 Linux specific RedBoot exec command
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 Red Hat, Inc.
12
//
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.
16
//
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
20
// for more details.
21
//
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.
25
//
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.
32
//
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.
35
//
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####
42
//
43
// Author(s):    dhowells
44
// Contributors: gthomas, jskov, msalter
45
// Date:         2001-07-19
46
// Purpose:      
47
// Description:  
48
//              
49
// This code is part of RedBoot (tm).
50
//
51
//####DESCRIPTIONEND####
52
//
53
//==========================================================================
54
 
55
#include <redboot.h>
56
 
57
#include <cyg/hal/hal_intr.h>
58
#include <cyg/hal/hal_cache.h>
59
 
60
// Exported CLI function(s)
61
 
62
// The exec command works like the go command in YAMON - that is,
63
// providing callee with argc, argv, and env. In addition to the
64
// information provided by the user, 
65
 
66
static void do_exec(int argc, char *argv[]);
67
 
68
static char exec_usage[] =
69
            "[-w timeout] [-c \"kernel command line\"] [<entry_point>]";
70
 
71
RedBoot_cmd("exec",
72
            "Execute an image - with MMU off",
73
            exec_usage,
74
            do_exec
75
            );
76
 
77
typedef void (*code_fun)(void) __attribute__((noreturn));
78
 
79
static void
80
do_exec(int argc, char *argv[])
81
{
82
    unsigned long oldints;
83
    bool wait_time_set;
84
    int  wait_time, res;
85
    bool cmd_line_set;
86
    struct option_info opts[4];
87
    code_fun entry;
88
    char line[8];
89
    char *cmd_line;
90
    int num_options;
91
 
92
    entry = (code_fun)entry_address;  // Default from last 'load' operation
93
    init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
94
              (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
95
    init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR,
96
              (void **)&cmd_line, (bool *)&cmd_line_set, "kernel command line");
97
    num_options = 2;
98
 
99
    if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry,
100
                   OPTION_ARG_TYPE_NUM, "starting address"))
101
    {
102
        return;
103
    }
104
    if (cmd_line_set) {
105
        memcpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS,"cmdline:",8);
106
        strncpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8,cmd_line,256);
107
        *(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8+256) = 0;
108
    }
109
    else {
110
        *(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+256) = 0;
111
    }
112
 
113
    if (wait_time_set) {
114
        diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
115
                    (void *)entry, wait_time);
116
        res = _rb_gets(line, sizeof(line), wait_time*1000);
117
        if (res == _GETS_CTRLC) {
118
            return;
119
        }
120
    }
121
 
122
    HAL_DISABLE_INTERRUPTS(oldints);
123
    HAL_DCACHE_SYNC();
124
    HAL_ICACHE_DISABLE();
125
    HAL_DCACHE_DISABLE();
126
    HAL_DCACHE_SYNC();
127
    HAL_ICACHE_INVALIDATE_ALL();
128
    HAL_DCACHE_INVALIDATE_ALL();
129
    (*entry)();
130
}
131
 
132
// EOF redboot_linux_exec.c

powered by: WebSVN 2.1.0

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