RAM usage information in machine definition.
[qemu] / hw / etraxfs.c
1 /*
2  * QEMU ETRAX System Emulator
3  *
4  * Copyright (c) 2007 Edgar E. Iglesias, Axis Communications AB.
5  *
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:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
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
22  * THE SOFTWARE.
23  */
24 #include <time.h>
25 #include <sys/time.h>
26 #include "hw.h"
27 #include "sysemu.h"
28 #include "flash.h"
29 #include "boards.h"
30
31 static void main_cpu_reset(void *opaque)
32 {
33     CPUState *env = opaque;
34     cpu_reset(env);
35 }
36
37 /* Init functions for different blocks.  */
38 extern qemu_irq *etraxfs_pic_init(CPUState *env, target_phys_addr_t base);
39 void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, 
40                         target_phys_addr_t base);
41 void etraxfs_ser_init(CPUState *env, qemu_irq *irqs, target_phys_addr_t base);
42
43 static
44 void bareetraxfs_init (int ram_size, int vga_ram_size,
45                        const char *boot_device, DisplayState *ds,
46                        const char *kernel_filename, const char *kernel_cmdline,
47                        const char *initrd_filename, const char *cpu_model)
48 {
49     CPUState *env;
50     qemu_irq *pic;
51     int kernel_size;
52     int flash_size = 0x800000;
53     int index;
54     ram_addr_t phys_flash;
55     ram_addr_t phys_ram;
56
57     /* init CPUs */
58     if (cpu_model == NULL) {
59         cpu_model = "crisv32";
60     }
61     env = cpu_init(cpu_model);
62 /*    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */
63     qemu_register_reset(main_cpu_reset, env);
64
65     /* allocate RAM */
66     phys_ram = qemu_ram_alloc(ram_size);
67     cpu_register_physical_memory(0x40000000, ram_size, phys_ram | IO_MEM_RAM);
68     /* Unached mapping.  */
69     cpu_register_physical_memory(0xc0000000, ram_size, phys_ram | IO_MEM_RAM);
70
71     phys_flash = qemu_ram_alloc(flash_size);
72     cpu_register_physical_memory(0,flash_size, IO_MEM_ROM);
73     cpu_register_physical_memory(0x80000000, flash_size, IO_MEM_ROM);
74     cpu_register_physical_memory(0x04000000, flash_size, IO_MEM_ROM);
75     cpu_register_physical_memory(0x84000000, flash_size, 
76                                  0x04000000 | IO_MEM_ROM);
77     index = drive_get_index(IF_PFLASH, 0, 0);
78     pflash_cfi01_register(0x80000000, flash_size,
79                           drives_table[index].bdrv, 65536, flash_size >> 16,
80                           4, 0x0000, 0x0000, 0x0000, 0x0000);
81     index = drive_get_index(IF_PFLASH, 0, 1);
82     pflash_cfi01_register(0x84000000, flash_size,
83                           drives_table[index].bdrv, 65536, flash_size >> 16,
84                           4, 0x0000, 0x0000, 0x0000, 0x0000);
85
86     pic = etraxfs_pic_init(env, 0xb001c000);
87     /* 2 timers.  */
88     etraxfs_timer_init(env, pic, 0xb001e000);
89     etraxfs_timer_init(env, pic, 0xb005e000);
90     /* 4 serial ports.  */
91     etraxfs_ser_init(env, pic, 0xb0026000);
92     etraxfs_ser_init(env, pic, 0xb0028000);
93     etraxfs_ser_init(env, pic, 0xb002a000);
94     etraxfs_ser_init(env, pic, 0xb002c000);
95
96     kernel_size = load_image(kernel_filename, phys_ram_base + 0x4000);
97     /* magic for boot.  */
98     env->regs[8] = 0x56902387;
99     env->regs[9] = 0x40004000 + kernel_size;
100     env->pc = 0x40004000;
101
102     {
103        unsigned char *ptr = phys_ram_base + 0x4000;
104        int i;
105        for (i = 0; i < 8; i++)
106        {
107                 printf ("%2.2x ", ptr[i]);
108        }
109         printf("\n");
110     }
111
112     printf ("pc =%x\n", env->pc);
113     printf ("ram size =%d\n", ram_size);
114     printf ("kernel name =%s\n", kernel_filename);
115     printf ("kernel size =%d\n", kernel_size);
116     printf ("cpu haltd =%d\n", env->halted);
117 }
118
119 void DMA_run(void)
120 {
121 }
122
123 QEMUMachine bareetraxfs_machine = {
124     "bareetraxfs",
125     "Bare ETRAX FS board",
126     bareetraxfs_init,
127     0x800000,
128 };