machine_cats.cc Source File

Back to the index.

machine_cats.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2009 Anders Gavare. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. The name of the author may not be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  *
28  * COMMENT: Simtec Electronics' CATS board
29  */
30 
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <string.h>
34 
35 #include "bus_isa.h"
36 #include "bus_pci.h"
37 #include "cpu.h"
38 #include "device.h"
39 #include "devices.h"
40 #include "machine.h"
41 #include "memory.h"
42 #include "misc.h"
43 
45 
46 
48 {
49  struct ebsaboot ebsaboot;
50  struct pci_data *pci_bus;
51  char bs[300], tmpstr[400];
52  int boot_id = machine->bootdev_id >= 0? machine->bootdev_id : 0;
53 
54  machine->machine_name = strdup("CATS evaluation board");
55 
56  if (machine->emulated_hz == 0)
57  machine->emulated_hz = 50000000;
58 
59  if (machine->physical_ram_in_mb > 256)
60  fprintf(stderr, "WARNING! Real CATS machines cannot"
61  " have more than 256 MB RAM. Continuing anyway.\n");
62 
63  snprintf(tmpstr, sizeof(tmpstr), "footbridge irq=%s.cpu[%i].irq"
64  " addr=0x42000000", machine->path, machine->bootstrap_cpu);
65  pci_bus = (struct pci_data *) device_add(machine, tmpstr);
66 
67  /* DC21285_ROM_BASE (256 KB at 0x41000000) */
68  dev_ram_init(machine, 0x41000000, 256 * 1024, DEV_RAM_RAM, 0);
69 
70  /* NetBSD, OpenBSD, and Linux (?) clean their caches here: */
71  dev_ram_init(machine, 0x50000000, 0x10000, DEV_RAM_RAM, 0);
72 
73  /* Interrupt ack space? */
74  dev_ram_init(machine, 0x80000000, 0x1000, DEV_RAM_RAM, 0);
75 
76  /* Linux uses 0xc0000000 as phys.: */
77  dev_ram_init(machine, 0xc0000000, 0x20000000, DEV_RAM_MIRROR, 0x0);
78 
79  /* OpenBSD reboot needs 0xf??????? to be mapped to phys.: */
80  dev_ram_init(machine, 0xf0000000, 0x1000000, DEV_RAM_MIRROR, 0x0);
81 
82  bus_pci_add(machine, pci_bus, machine->memory, 0xc0, 8, 0, "s3_virge");
83 
84  if (!machine->prom_emulation)
85  return;
86 
87  /* See cyclone_boot.h for details. */
88 
89  /* DC21285_ROM_BASE "reboot" code: (works with NetBSD) */
90  store_32bit_word(cpu, 0x41000008ULL, 0xef8c64ebUL);
91 
92  cpu->cd.arm.r[0] = /* machine->physical_ram_in_mb */
93  7 * 1048576 - 0x1000;
94 
95  memset(&ebsaboot, 0, sizeof(struct ebsaboot));
96  store_32bit_word_in_host(cpu, (unsigned char *)
98  store_32bit_word_in_host(cpu, (unsigned char *)
99  &(ebsaboot.bt_vargp), 0);
100  store_32bit_word_in_host(cpu, (unsigned char *)
101  &(ebsaboot.bt_pargp), 0);
102  store_32bit_word_in_host(cpu, (unsigned char *)
103  &(ebsaboot.bt_args), cpu->cd.arm.r[0]
104  + sizeof(struct ebsaboot));
105  store_32bit_word_in_host(cpu, (unsigned char *)
106  &(ebsaboot.bt_l1), 7 * 1048576 - 32768);
107  store_32bit_word_in_host(cpu, (unsigned char *)
108  &(ebsaboot.bt_memstart), 0);
109  store_32bit_word_in_host(cpu, (unsigned char *)
110  &(ebsaboot.bt_memend),
111  machine->physical_ram_in_mb * 1048576);
112  store_32bit_word_in_host(cpu, (unsigned char *)
113  &(ebsaboot.bt_memavail), 7 * 1048576);
114  store_32bit_word_in_host(cpu, (unsigned char *)
115  &(ebsaboot.bt_fclk), 50 * 1000000);
116  store_32bit_word_in_host(cpu, (unsigned char *)
117  &(ebsaboot.bt_pciclk), 66 * 1000000);
118  /* TODO: bt_vers */
119  /* TODO: bt_features */
120 
121  store_buf(cpu, cpu->cd.arm.r[0],
122  (char *)&ebsaboot, sizeof(struct ebsaboot));
123 
124  snprintf(bs, sizeof(bs), "(hd%i)%s root=/dev/wd%i%s%s",
125  boot_id, machine->boot_kernel_filename, boot_id,
126  (machine->boot_string_argument[0])? " " : "",
128 
129  store_string(cpu, cpu->cd.arm.r[0]+sizeof(struct ebsaboot), bs);
130 
131  arm_setup_initial_translation_table(cpu, 7 * 1048576 - 32768);
132 }
133 
134 
136 {
137  machine->cpu_name = strdup("SA110");
138 }
139 
140 
142 {
144 }
145 
146 
148 {
149  MR_DEFAULT(cats, "CATS evaluation board", ARCH_ARM,
150  MACHINE_CATS);
151 
152  machine_entry_add_alias(me, "cats");
153 
154  me->set_default_ram = machine_default_ram_cats;
155 }
156 
machine::bootstrap_cpu
int bootstrap_cpu
Definition: machine.h:136
store_buf
void store_buf(struct cpu *cpu, uint64_t addr, const char *s, size_t len)
Definition: memory.cc:826
ebsaboot::bt_vargp
u_int32_t bt_vargp
Definition: cyclone_boot.h:51
MACHINE_REGISTER
MACHINE_REGISTER(cats)
Definition: machine_cats.cc:147
BT_MAGIC_NUMBER_CATS
#define BT_MAGIC_NUMBER_CATS
Definition: cyclone_boot.h:67
MACHINE_CATS
#define MACHINE_CATS
Definition: machine.h:239
MACHINE_DEFAULT_RAM
MACHINE_DEFAULT_RAM(cats)
Definition: machine_cats.cc:141
bus_isa.h
cyclone_boot.h
DEV_RAM_MIRROR
#define DEV_RAM_MIRROR
Definition: devices.h:365
ebsaboot::bt_pciclk
u_int32_t bt_pciclk
Definition: cyclone_boot.h:61
ebsaboot::bt_memstart
u_int32_t bt_memstart
Definition: cyclone_boot.h:57
arm_setup_initial_translation_table
void arm_setup_initial_translation_table(struct cpu *cpu, uint32_t ttb_addr)
Definition: cpu_arm.cc:220
ebsaboot::bt_memavail
u_int32_t bt_memavail
Definition: cyclone_boot.h:59
machine::prom_emulation
int prom_emulation
Definition: machine.h:149
DEV_RAM_RAM
#define DEV_RAM_RAM
Definition: devices.h:364
device.h
machine::boot_string_argument
char * boot_string_argument
Definition: machine.h:171
machine::cpu_name
char * cpu_name
Definition: machine.h:133
ebsaboot::bt_l1
uint32_t bt_l1
Definition: cyclone_boot.h:55
misc.h
ebsaboot::bt_args
u_int32_t bt_args
Definition: cyclone_boot.h:53
cpu::cd
union cpu::@1 cd
device_add
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
machine.h
machine
Definition: machine.h:97
MR_DEFAULT
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:373
arm_cpu::r
uint32_t r[N_ARM_REGS]
Definition: cpu_arm.h:155
store_string
void store_string(struct cpu *cpu, uint64_t addr, const char *s)
Definition: memory.cc:695
cpu.h
machine::path
char * path
Definition: machine.h:108
machine::bootdev_id
int bootdev_id
Definition: machine.h:154
machine::memory
struct memory * memory
Definition: machine.h:126
bus_pci.h
machine::physical_ram_in_mb
uint32_t physical_ram_in_mb
Definition: machine.h:147
machine::boot_kernel_filename
char * boot_kernel_filename
Definition: machine.h:170
ebsaboot
Definition: cyclone_boot.h:49
ebsaboot::bt_fclk
u_int32_t bt_fclk
Definition: cyclone_boot.h:60
cpu::arm
struct arm_cpu arm
Definition: cpu.h:444
store_32bit_word
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
MACHINE_DEFAULT_CPU
MACHINE_DEFAULT_CPU(cats)
Definition: machine_cats.cc:135
store_32bit_word_in_host
void store_32bit_word_in_host(struct cpu *cpu, unsigned char *data, uint64_t data32)
Definition: memory.cc:973
ebsaboot::bt_magic
u_int32_t bt_magic
Definition: cyclone_boot.h:50
machine::emulated_hz
int emulated_hz
Definition: machine.h:165
ARCH_ARM
#define ARCH_ARM
Definition: machine.h:206
ebsaboot::bt_pargp
u_int32_t bt_pargp
Definition: cyclone_boot.h:52
MACHINE_SETUP
MACHINE_SETUP(cats)
Definition: machine_cats.cc:47
devices.h
machine::machine_name
const char * machine_name
Definition: machine.h:115
cpu
Definition: cpu.h:326
machine_entry_add_alias
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
ebsaboot::bt_memend
u_int32_t bt_memend
Definition: cyclone_boot.h:58
bus_pci_add
void bus_pci_add(struct machine *machine, struct pci_data *pci_data, struct memory *mem, int bus, int device, int function, const char *name)
Definition: bus_pci.cc:216
dev_ram_init
void dev_ram_init(struct machine *machine, uint64_t baseaddr, uint64_t length, int mode, uint64_t otheraddress, const char *name)
Definition: dev_ram.cc:146
memory.h

Generated on Tue Aug 25 2020 19:25:06 for GXemul by doxygen 1.8.18