4 * Copyright (c) 2010 Edgar E. Iglesias, Axis Communications AB.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 #include "cris-boot.h"
30 static void main_cpu_reset(void *opaque
)
32 CPUCRISState
*env
= opaque
;
33 struct cris_load_info
*li
;
40 /* nothing more to do. */
46 if (li
->image_filename
) {
47 env
->regs
[8] = 0x56902387; /* RAM boot magic. */
48 env
->regs
[9] = 0x40004000 + li
->image_size
;
52 /* Let the kernel know we are modifying the cmdline. */
53 env
->regs
[10] = 0x87109563;
54 env
->regs
[11] = 0x40000000;
58 static uint64_t translate_kernel_address(void *opaque
, uint64_t addr
)
60 return addr
- 0x80000000LL
;
63 void cris_load_image(CPUCRISState
*env
, struct cris_load_info
*li
)
70 /* Boots a kernel elf binary, os/linux-2.6/vmlinux from the axis
72 image_size
= load_elf(li
->image_filename
, translate_kernel_address
, NULL
,
73 &entry
, NULL
, &high
, 0, ELF_MACHINE
, 0);
76 /* Takes a kimage from the axis devboard SDK. */
77 image_size
= load_image_targphys(li
->image_filename
, 0x40004000,
79 li
->entry
= 0x40004000;
83 fprintf(stderr
, "qemu: could not load kernel '%s'\n",
88 if (li
->cmdline
&& (kcmdline_len
= strlen(li
->cmdline
))) {
89 if (kcmdline_len
> 256) {
90 fprintf(stderr
, "Too long CRIS kernel cmdline (max 256)\n");
93 pstrcpy_targphys("cmdline", 0x40000000, 256, li
->cmdline
);
95 qemu_register_reset(main_cpu_reset
, env
);