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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sh/] [arch/] [current/] [src/] [redboot_linux_exec.c] - Blame information for rev 817

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

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      redboot_linux_exec.c
4
//
5
//      RedBoot exec command for Linux booting
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):    t@keshi.org
43
// Contributors: t@keshi.org, jskov
44
// Date:         2001-06-19
45
// Purpose:      RedBoot exec command for Linux booting
46
//
47
//####DESCRIPTIONEND####
48
//
49
//===========================================================================
50
 
51
#include <redboot.h>
52
 
53
#include <cyg/infra/cyg_type.h>
54
#include <cyg/hal/hal_intr.h>
55
#include <cyg/hal/hal_cache.h>
56
 
57
#ifdef CYGPKG_IO_ETH_DRIVERS
58
#include <cyg/io/eth/eth_drv.h>            // Logical driver interfaces
59
#endif
60
 
61
#define xstr(s) str(s)
62
#define str(s...) #s
63
 
64
struct parmblock {
65
    cyg_uint32 mount_rdonly;
66
    cyg_uint32 ramdisk_flags;
67
    cyg_uint32 orig_root_dev;
68
    cyg_uint32 loader_type;
69
    cyg_uint32 initrd_start;
70
    cyg_uint32 initrd_size;
71
};
72
 
73
static void do_exec(int argc, char *argv[]);
74
RedBoot_cmd("exec",
75
            "Execute an image",
76
            "[-b <parameter block addr>] [-m <mount rdonly flags>]\n"
77
            "        [-f <ramdisk flags>] [-r <root device>] [-l <loader type>]\n"
78
            "        [-i <initrd start addr>] [-j <initrd size>] [-c \"kernel command line\"]\n"
79
            "        [<entry point>]",
80
            do_exec
81
    );
82
 
83
static void
84
do_exec(int argc, char *argv[])
85
{
86
    cyg_uint32 entry = CYGDAT_REDBOOT_SH_LINUX_BOOT_ENTRY;
87
    cyg_uint32 base_addr = CYGDAT_REDBOOT_SH_LINUX_BOOT_BASE_ADDR;
88
    cyg_uint32 mount_rdonly = CYGDAT_REDBOOT_SH_LINUX_BOOT_MOUNT_RDONLY;
89
    cyg_uint32 ramdisk_flags = CYGDAT_REDBOOT_SH_LINUX_BOOT_RAMDISK_FLAGS;
90
    cyg_uint32 orig_root_dev = CYGDAT_REDBOOT_SH_LINUX_BOOT_ORIG_ROOT_DEV;
91
    cyg_uint32 loader_type = CYGDAT_REDBOOT_SH_LINUX_BOOT_LOADER_TYPE;
92
    cyg_uint32 initrd_start = CYGDAT_REDBOOT_SH_LINUX_BOOT_INITRD_START;
93
    cyg_uint32 initrd_size = CYGDAT_REDBOOT_SH_LINUX_BOOT_INITRD_SIZE;
94
    char *cmd_line = xstr(CYGDAT_REDBOOT_SH_LINUX_BOOT_COMMAND_LINE);
95
 
96
    bool base_addr_set, mount_rdonly_set, ramdisk_flags_set;
97
    bool orig_root_dev_set, loader_type_set;
98
    bool initrd_start_set, initrd_size_set, cmd_line_set;
99
 
100
    struct option_info opts[8];
101
    struct parmblock *pb;
102
    char *pcmd;
103
    int oldints;
104
 
105
    init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
106
              (void **)&base_addr, &base_addr_set, "base address");
107
    init_opts(&opts[1], 'm', true, OPTION_ARG_TYPE_NUM,
108
              (void **)&mount_rdonly, &mount_rdonly_set, "mount_rdonly");
109
    init_opts(&opts[2], 'f', true, OPTION_ARG_TYPE_NUM,
110
              (void **)&ramdisk_flags, &ramdisk_flags_set, "ramdisk_flags");
111
    init_opts(&opts[3], 'r', true, OPTION_ARG_TYPE_NUM,
112
              (void **)&orig_root_dev, &orig_root_dev_set, "orig_root_dev");
113
    init_opts(&opts[4], 'l', true, OPTION_ARG_TYPE_NUM,
114
              (void **)&loader_type, &loader_type_set, "loader_type");
115
    init_opts(&opts[5], 'i', true, OPTION_ARG_TYPE_NUM,
116
              (void **)&initrd_start, &initrd_start_set, "initrd_start");
117
    init_opts(&opts[6], 'j', true, OPTION_ARG_TYPE_NUM,
118
              (void **)&initrd_size, &initrd_size_set, "initrd_size");
119
    init_opts(&opts[7], 'c', true, OPTION_ARG_TYPE_STR,
120
              (void **)&cmd_line, &cmd_line_set, "kernel command line");
121
 
122
    if (!scan_opts(argc, argv, 1, opts, 8, (void *)&entry,
123
                   OPTION_ARG_TYPE_NUM, "entry address"))
124
        return;
125
    if (entry == (unsigned long)NO_MEMORY) {
126
        diag_printf("Can't execute Linux - invalid entry address\n");
127
        return;
128
    }
129
 
130
    diag_printf("Now booting linux kernel:\n");
131
    diag_printf(" Base address 0x%08x Entry 0x%08x\n", base_addr, entry);
132
    diag_printf(" Cmdline : %s\n", cmd_line);
133
 
134
#ifdef CYGPKG_IO_ETH_DRIVERS
135
    eth_drv_stop();
136
#endif
137
 
138
    HAL_DISABLE_INTERRUPTS(oldints);
139
    HAL_DCACHE_SYNC();
140
    HAL_ICACHE_DISABLE();
141
    HAL_DCACHE_DISABLE();
142
    HAL_DCACHE_SYNC();
143
    HAL_ICACHE_INVALIDATE_ALL();
144
    HAL_DCACHE_INVALIDATE_ALL();
145
 
146
    pb = (struct parmblock *)base_addr;
147
    if (mount_rdonly_set) {
148
        pb->mount_rdonly = mount_rdonly;
149
        diag_printf(" MOUNT_RDONLY  : 0x%08x\n", mount_rdonly);
150
    }
151
    if (ramdisk_flags_set) {
152
        pb->ramdisk_flags = ramdisk_flags;
153
        diag_printf(" RAMDISK_FLAGS : 0x%08x\n", ramdisk_flags);
154
    }
155
    if (orig_root_dev_set) {
156
        pb->orig_root_dev = orig_root_dev;
157
        diag_printf(" ORIG_ROOT_DEV : 0x%08x\n", orig_root_dev);
158
    }
159
    if (loader_type_set) {
160
        pb->loader_type = loader_type;
161
        diag_printf(" LOADER_TYPE   : 0x%08x\n", loader_type);
162
    }
163
    if (initrd_start_set) {
164
        pb->initrd_start = initrd_start;
165
        pb->initrd_size = initrd_size;
166
        diag_printf(" INITRD_START  : 0x%08x\n", initrd_start);
167
        diag_printf(" INITRD_SIZE   : 0x%08x\n", initrd_size);
168
    }
169
 
170
    pcmd = (char *)(base_addr + 0x100);
171
    while ((*pcmd++ = *cmd_line++));
172
 
173
    asm ("jmp @%0\n\tnop" : : "r" (entry));
174
}

powered by: WebSVN 2.1.0

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