Revision e62b5b13 hw/etraxfs.c
b/hw/etraxfs.c | ||
---|---|---|
25 | 25 |
#include <sys/time.h> |
26 | 26 |
#include "hw.h" |
27 | 27 |
#include "sysemu.h" |
28 |
#include "flash.h" |
|
28 | 29 |
#include "boards.h" |
29 | 30 |
|
30 |
extern FILE *logfile; |
|
31 |
|
|
32 | 31 |
static void main_cpu_reset(void *opaque) |
33 | 32 |
{ |
34 | 33 |
CPUState *env = opaque; |
35 | 34 |
cpu_reset(env); |
36 | 35 |
} |
37 | 36 |
|
38 |
static uint32_t fs_mmio_readb (void *opaque, target_phys_addr_t addr) |
|
39 |
{ |
|
40 |
CPUState *env = opaque; |
|
41 |
uint32_t r = 0; |
|
42 |
printf ("%s %x pc=%x\n", __func__, addr, env->pc); |
|
43 |
return r; |
|
44 |
} |
|
45 |
static uint32_t fs_mmio_readw (void *opaque, target_phys_addr_t addr) |
|
46 |
{ |
|
47 |
CPUState *env = opaque; |
|
48 |
uint32_t r = 0; |
|
49 |
printf ("%s %x pc=%x\n", __func__, addr, env->pc); |
|
50 |
return r; |
|
51 |
} |
|
52 |
|
|
53 |
static uint32_t fs_mmio_readl (void *opaque, target_phys_addr_t addr) |
|
54 |
{ |
|
55 |
CPUState *env = opaque; |
|
56 |
uint32_t r = 0; |
|
57 |
printf ("%s %x p=%x\n", __func__, addr, env->pc); |
|
58 |
return r; |
|
59 |
} |
|
60 |
|
|
61 |
static void |
|
62 |
fs_mmio_writeb (void *opaque, target_phys_addr_t addr, uint32_t value) |
|
63 |
{ |
|
64 |
CPUState *env = opaque; |
|
65 |
printf ("%s %x %x pc=%x\n", __func__, addr, value, env->pc); |
|
66 |
} |
|
67 |
static void |
|
68 |
fs_mmio_writew (void *opaque, target_phys_addr_t addr, uint32_t value) |
|
69 |
{ |
|
70 |
CPUState *env = opaque; |
|
71 |
printf ("%s %x %x pc=%x\n", __func__, addr, value, env->pc); |
|
72 |
} |
|
73 |
static void |
|
74 |
fs_mmio_writel (void *opaque, target_phys_addr_t addr, uint32_t value) |
|
75 |
{ |
|
76 |
CPUState *env = opaque; |
|
77 |
printf ("%s %x %x pc=%x\n", __func__, addr, value, env->pc); |
|
78 |
} |
|
79 |
|
|
80 |
static CPUReadMemoryFunc *fs_mmio_read[] = { |
|
81 |
&fs_mmio_readb, |
|
82 |
&fs_mmio_readw, |
|
83 |
&fs_mmio_readl, |
|
84 |
}; |
|
85 |
|
|
86 |
static CPUWriteMemoryFunc *fs_mmio_write[] = { |
|
87 |
&fs_mmio_writeb, |
|
88 |
&fs_mmio_writew, |
|
89 |
&fs_mmio_writel, |
|
90 |
}; |
|
91 |
|
|
92 |
|
|
93 | 37 |
/* Init functions for different blocks. */ |
38 |
extern qemu_irq *etraxfs_pic_init(CPUState *env, target_ulong base); |
|
39 |
/* TODO: Make these blocks relocate:able. */ |
|
94 | 40 |
extern void etraxfs_timer_init(CPUState *env, qemu_irq *irqs); |
95 | 41 |
extern void etraxfs_ser_init(CPUState *env, qemu_irq *irqs); |
96 | 42 |
|
97 |
void etrax_ack_irq(CPUState *env, uint32_t mask) |
|
98 |
{ |
|
99 |
env->pending_interrupts &= ~mask; |
|
100 |
} |
|
101 |
|
|
102 |
static void dummy_cpu_set_irq(void *opaque, int irq, int level) |
|
103 |
{ |
|
104 |
CPUState *env = opaque; |
|
105 |
|
|
106 |
/* Hmm, should this really be done here? */ |
|
107 |
env->pending_interrupts |= 1 << irq; |
|
108 |
cpu_interrupt(env, CPU_INTERRUPT_HARD); |
|
109 |
} |
|
110 |
|
|
111 | 43 |
static |
112 | 44 |
void bareetraxfs_init (int ram_size, int vga_ram_size, |
113 | 45 |
const char *boot_device, DisplayState *ds, |
... | ... | |
115 | 47 |
const char *initrd_filename, const char *cpu_model) |
116 | 48 |
{ |
117 | 49 |
CPUState *env; |
118 |
qemu_irq *irqs;
|
|
50 |
qemu_irq *pic;
|
|
119 | 51 |
int kernel_size; |
120 |
int internal_regs; |
|
52 |
int flash_size = 0x800000; |
|
53 |
int index; |
|
54 |
ram_addr_t phys_flash; |
|
55 |
ram_addr_t phys_ram; |
|
121 | 56 |
|
122 | 57 |
/* init CPUs */ |
123 | 58 |
if (cpu_model == NULL) { |
... | ... | |
126 | 61 |
env = cpu_init(cpu_model); |
127 | 62 |
/* register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */ |
128 | 63 |
qemu_register_reset(main_cpu_reset, env); |
129 |
irqs = qemu_allocate_irqs(dummy_cpu_set_irq, env, 32); |
|
130 | 64 |
|
131 |
internal_regs = cpu_register_io_memory(0, |
|
132 |
fs_mmio_read, fs_mmio_write, env); |
|
133 |
/* 0xb0050000 is the last reg. */ |
|
134 |
cpu_register_physical_memory (0xac000000, 0x4010000, internal_regs); |
|
135 | 65 |
/* allocate RAM */ |
136 |
cpu_register_physical_memory(0x40000000, ram_size, IO_MEM_RAM); |
|
137 |
|
|
138 |
etraxfs_timer_init(env, irqs); |
|
139 |
etraxfs_ser_init(env, irqs); |
|
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 |
etraxfs_timer_init(env, pic); |
|
88 |
etraxfs_ser_init(env, pic); |
|
140 | 89 |
|
141 | 90 |
kernel_size = load_image(kernel_filename, phys_ram_base + 0x4000); |
142 | 91 |
/* magic for boot. */ |
... | ... | |
165 | 114 |
{ |
166 | 115 |
} |
167 | 116 |
|
168 |
void pic_info() |
|
169 |
{ |
|
170 |
} |
|
171 |
|
|
172 |
void irq_info() |
|
173 |
{ |
|
174 |
} |
|
175 |
|
|
176 | 117 |
QEMUMachine bareetraxfs_machine = { |
177 | 118 |
"bareetraxfs", |
178 | 119 |
"Bare ETRAX FS board", |
Also available in: Unified diff