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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mn10300/] [am33/] [current/] [src/] [redboot_linux_exec.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
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, 2003, 2004 Free Software Foundation, 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      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY 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        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    dhowells
43
// Contributors: gthomas, jskov, msalter
44
// Date:         2001-07-19
45
// Purpose:      
46
// Description:  
47
//              
48
// This code is part of RedBoot (tm).
49
//
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
#include <redboot.h>
55
 
56
#include <cyg/hal/hal_intr.h>
57
#include <cyg/hal/hal_cache.h>
58
 
59
#ifdef CYGPKG_IO_ETH_DRIVERS
60
#include <cyg/io/eth/eth_drv.h>            // Logical driver interfaces
61
#endif
62
 
63
// Exported CLI function(s)
64
 
65
// The exec command works like the go command in YAMON - that is,
66
// providing callee with argc, argv, and env. In addition to the
67
// information provided by the user, 
68
 
69
static void do_exec(int argc, char *argv[]);
70
 
71
static char exec_usage[] =
72
            "[-w timeout] [-c \"kernel command line\"] [<entry_point>]";
73
 
74
RedBoot_cmd("exec",
75
            "Execute an image - with MMU off",
76
            exec_usage,
77
            do_exec
78
            );
79
 
80
typedef void (*code_fun)(void) __attribute__((noreturn));
81
 
82
static void
83
do_exec(int argc, char *argv[])
84
{
85
    unsigned long oldints;
86
    bool wait_time_set;
87
    int  wait_time, res;
88
    bool cmd_line_set;
89
    struct option_info opts[4];
90
    code_fun entry;
91
    char line[8];
92
    char *cmd_line;
93
    int num_options;
94
 
95
    entry = (code_fun)entry_address;  // Default from last 'load' operation
96
    init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
97
              (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
98
    init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR,
99
              (void **)&cmd_line, (bool *)&cmd_line_set, "kernel command line");
100
    num_options = 2;
101
 
102
    if (!scan_opts(argc, argv, 1, opts, num_options, (void *)&entry,
103
                   OPTION_ARG_TYPE_NUM, "starting address"))
104
    {
105
        return;
106
    }
107
    if (entry == (unsigned long)NO_MEMORY) {
108
        diag_printf("Can't execute Linux - invalid entry address\n");
109
        return;
110
    }
111
    if (cmd_line_set) {
112
        memcpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS,"cmdline:",8);
113
        strncpy((char*)CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8,cmd_line,256);
114
        *(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+8+256) = 0;
115
    }
116
    else {
117
        *(char*)(CYGHWR_REDBOOT_AM33_LINUX_CMD_ADDRESS+256) = 0;
118
    }
119
 
120
    if (wait_time_set) {
121
        diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
122
                    (void *)entry, wait_time);
123
        res = _rb_gets(line, sizeof(line), wait_time*1000);
124
        if (res == _GETS_CTRLC) {
125
            return;
126
        }
127
    }
128
 
129
#ifdef CYGPKG_IO_ETH_DRIVERS
130
    eth_drv_stop();
131
#endif
132
 
133
    HAL_DISABLE_INTERRUPTS(oldints);
134
    HAL_DCACHE_SYNC();
135
    HAL_ICACHE_DISABLE();
136
    HAL_DCACHE_DISABLE();
137
    HAL_DCACHE_SYNC();
138
    HAL_ICACHE_INVALIDATE_ALL();
139
    HAL_DCACHE_INVALIDATE_ALL();
140
    (*entry)();
141
}
142
 
143
// EOF redboot_linux_exec.c

powered by: WebSVN 2.1.0

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