Statistics
| Branch: | Revision:

root / hw / shix.c @ 9c17d615

History | View | Annotate | Download (3.4 kB)

1 27c7ca7e bellard
/*
2 27c7ca7e bellard
 * SHIX 2.0 board description
3 5fafdf24 ths
 *
4 27c7ca7e bellard
 * Copyright (c) 2005 Samuel Tardieu
5 5fafdf24 ths
 *
6 27c7ca7e bellard
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 27c7ca7e bellard
 * of this software and associated documentation files (the "Software"), to deal
8 27c7ca7e bellard
 * in the Software without restriction, including without limitation the rights
9 27c7ca7e bellard
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 27c7ca7e bellard
 * copies of the Software, and to permit persons to whom the Software is
11 27c7ca7e bellard
 * furnished to do so, subject to the following conditions:
12 27c7ca7e bellard
 *
13 27c7ca7e bellard
 * The above copyright notice and this permission notice shall be included in
14 27c7ca7e bellard
 * all copies or substantial portions of the Software.
15 27c7ca7e bellard
 *
16 27c7ca7e bellard
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 27c7ca7e bellard
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 27c7ca7e bellard
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 27c7ca7e bellard
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 27c7ca7e bellard
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 27c7ca7e bellard
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 27c7ca7e bellard
 * THE SOFTWARE.
23 27c7ca7e bellard
 */
24 5fafdf24 ths
/*
25 27c7ca7e bellard
   Shix 2.0 board by Alexis Polti, described at
26 27c7ca7e bellard
   http://perso.enst.fr/~polti/realisations/shix20/
27 27c7ca7e bellard

28 27c7ca7e bellard
   More information in target-sh4/README.sh4
29 27c7ca7e bellard
*/
30 87ecb68b pbrook
#include "hw.h"
31 87ecb68b pbrook
#include "sh.h"
32 9c17d615 Paolo Bonzini
#include "sysemu/sysemu.h"
33 87ecb68b pbrook
#include "boards.h"
34 ca20cf32 Blue Swirl
#include "loader.h"
35 022c62cb Paolo Bonzini
#include "exec/address-spaces.h"
36 27c7ca7e bellard
37 27c7ca7e bellard
#define BIOS_FILENAME "shix_bios.bin"
38 27c7ca7e bellard
#define BIOS_ADDRESS 0xA0000000
39 27c7ca7e bellard
40 5f072e1f Eduardo Habkost
static void shix_init(QEMUMachineInitArgs *args)
41 27c7ca7e bellard
{
42 5f072e1f Eduardo Habkost
    const char *cpu_model = args->cpu_model;
43 27c7ca7e bellard
    int ret;
44 0b7ade1d Andreas Färber
    CPUSH4State *env;
45 27c7ca7e bellard
    struct SH7750State *s;
46 0af58e58 Avi Kivity
    MemoryRegion *sysmem = get_system_memory();
47 0af58e58 Avi Kivity
    MemoryRegion *rom = g_new(MemoryRegion, 1);
48 0af58e58 Avi Kivity
    MemoryRegion *sdram = g_new(MemoryRegion, 2);
49 aaed909a bellard
    
50 aaed909a bellard
    if (!cpu_model)
51 aaed909a bellard
        cpu_model = "any";
52 27c7ca7e bellard
53 27c7ca7e bellard
    printf("Initializing CPU\n");
54 aaed909a bellard
    env = cpu_init(cpu_model);
55 27c7ca7e bellard
56 27c7ca7e bellard
    /* Allocate memory space */
57 27c7ca7e bellard
    printf("Allocating ROM\n");
58 c5705a77 Avi Kivity
    memory_region_init_ram(rom, "shix.rom", 0x4000);
59 c5705a77 Avi Kivity
    vmstate_register_ram_global(rom);
60 0af58e58 Avi Kivity
    memory_region_set_readonly(rom, true);
61 0af58e58 Avi Kivity
    memory_region_add_subregion(sysmem, 0x00000000, rom);
62 27c7ca7e bellard
    printf("Allocating SDRAM 1\n");
63 c5705a77 Avi Kivity
    memory_region_init_ram(&sdram[0], "shix.sdram1", 0x01000000);
64 c5705a77 Avi Kivity
    vmstate_register_ram_global(&sdram[0]);
65 0af58e58 Avi Kivity
    memory_region_add_subregion(sysmem, 0x08000000, &sdram[0]);
66 27c7ca7e bellard
    printf("Allocating SDRAM 2\n");
67 c5705a77 Avi Kivity
    memory_region_init_ram(&sdram[1], "shix.sdram2", 0x01000000);
68 c5705a77 Avi Kivity
    vmstate_register_ram_global(&sdram[1]);
69 0af58e58 Avi Kivity
    memory_region_add_subregion(sysmem, 0x0c000000, &sdram[1]);
70 27c7ca7e bellard
71 27c7ca7e bellard
    /* Load BIOS in 0 (and access it through P2, 0xA0000000) */
72 1192dad8 j_mayer
    if (bios_name == NULL)
73 1192dad8 j_mayer
        bios_name = BIOS_FILENAME;
74 1192dad8 j_mayer
    printf("%s: load BIOS '%s'\n", __func__, bios_name);
75 dcac9679 pbrook
    ret = load_image_targphys(bios_name, 0, 0x4000);
76 27c7ca7e bellard
    if (ret < 0) {                /* Check bios size */
77 27c7ca7e bellard
        fprintf(stderr, "ret=%d\n", ret);
78 27c7ca7e bellard
        fprintf(stderr, "qemu: could not load SHIX bios '%s'\n",
79 1192dad8 j_mayer
                bios_name);
80 27c7ca7e bellard
        exit(1);
81 27c7ca7e bellard
    }
82 27c7ca7e bellard
83 27c7ca7e bellard
    /* Register peripherals */
84 382863e2 Benoît Canet
    s = sh7750_init(env, sysmem);
85 27c7ca7e bellard
    /* XXXXX Check success */
86 27c7ca7e bellard
    tc58128_init(s, "shix_linux_nand.bin", NULL);
87 27c7ca7e bellard
    fprintf(stderr, "initialization terminated\n");
88 27c7ca7e bellard
}
89 27c7ca7e bellard
90 f80f9ec9 Anthony Liguori
static QEMUMachine shix_machine = {
91 4b32e168 aliguori
    .name = "shix",
92 4b32e168 aliguori
    .desc = "shix card",
93 4b32e168 aliguori
    .init = shix_init,
94 0c257437 Anthony Liguori
    .is_default = 1,
95 27c7ca7e bellard
};
96 f80f9ec9 Anthony Liguori
97 f80f9ec9 Anthony Liguori
static void shix_machine_init(void)
98 f80f9ec9 Anthony Liguori
{
99 f80f9ec9 Anthony Liguori
    qemu_register_machine(&shix_machine);
100 f80f9ec9 Anthony Liguori
}
101 f80f9ec9 Anthony Liguori
102 f80f9ec9 Anthony Liguori
machine_init(shix_machine_init);