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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [sh/] [arch/] [v2_0/] [src/] [redboot_linux_exec.c] - Blame information for rev 27

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

powered by: WebSVN 2.1.0

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