machine_algor.cc Source File

Back to the index.

machine_algor.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: Algorithmic P4032 and P5064 evaluation boards
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 
44 
46 {
47  struct pci_data *pci_bus;
48  char tmpstr[300];
49 
50  machine->emulated_hz = 166560000;
51 
52  switch (machine->machine_subtype) {
54  machine->machine_name = strdup("Algor P4032");
55  break;
57  machine->machine_name = strdup("Algor P5064");
58  break;
59  default:fatal("Unimplemented Algor machine.\n");
60  exit(1);
61  }
62 
63  /*
64  * Algor CPU interrupts:
65  *
66  * 7 = CPU count/compare
67  * 4 = Local
68  * 3 = PCI
69  * 2 = ISA
70  */
71 
72  pci_bus = (struct pci_data *) device_add(machine, "v3");
73 
74  device_add(machine, "algor addr=0x1ff00000");
75 
76  snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].v3",
79  0x1d000000, 0x10000000);
80 
81  /* bus_pci_add(machine, pci_bus, machine->memory, 0, 0, 0,
82  "dec21143"); */
83 
84  if (!machine->prom_emulation)
85  return;
86 
87  /* NetBSD/algor wants these: */
88 
89  /* a0 = argc */
90  cpu->cd.mips.gpr[MIPS_GPR_A0] = 2;
91 
92  /* a1 = argv */
93  cpu->cd.mips.gpr[MIPS_GPR_A1] = (int32_t)0x9fc01000;
94  store_32bit_word(cpu, (int32_t)0x9fc01000, 0x9fc01040);
95  store_32bit_word(cpu, (int32_t)0x9fc01004, 0x9fc01200);
96  store_32bit_word(cpu, (int32_t)0x9fc01008, 0);
97 
100  store_string(cpu, (int32_t)0x9fc01040, machine->bootstr);
101  store_string(cpu, (int32_t)0x9fc01200, machine->bootarg);
102 
103  /* a2 = pointer to environment strings */
104  cpu->cd.mips.gpr[MIPS_GPR_A2] = (int32_t)0x9fc01800;
105  {
106  char tmps[50];
107  store_32bit_word(cpu, (int32_t)0x9fc01800, 0x9fc01900);
108  store_32bit_word(cpu, (int32_t)0x9fc01804, 0x9fc01a00);
109  store_32bit_word(cpu, (int32_t)0x9fc01808, 0);
110 
111  snprintf(tmps, sizeof(tmps), "memsize=0x%08x",
112  machine->physical_ram_in_mb * 1048576);
113  store_string(cpu, (int)0x9fc01900, tmps);
114  store_string(cpu, (int)0x9fc01a00,
115  "ethaddr=10:20:30:30:20:10");
116  }
117 }
118 
119 
121 {
122  machine->cpu_name = strdup("RM5200");
123 }
124 
125 
127 {
128  MR_DEFAULT(algor, "Algor evaluation board", ARCH_MIPS, MACHINE_ALGOR);
129 
130  machine_entry_add_alias(me, "algor");
131 
133  "p4032", NULL);
134 
136  "p5064", NULL);
137 }
138 
void fatal(const char *fmt,...)
Definition: main.cc:152
int emulated_hz
Definition: machine.h:165
int prom_emulation
Definition: machine.h:149
char * cpu_name
Definition: machine.h:133
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
#define MACHINE_ALGOR
Definition: machine.h:220
#define MIPS_GPR_A0
union cpu::@1 cd
void store_string(struct cpu *cpu, uint64_t addr, const char *s)
Definition: memory.cc:695
#define MIPS_GPR_A2
void * device_add(struct machine *machine, const char *name_and_params)
Definition: device.cc:252
int physical_ram_in_mb
Definition: machine.h:147
char * boot_string_argument
Definition: machine.h:171
char * boot_kernel_filename
Definition: machine.h:170
char * path
Definition: machine.h:108
int bootstrap_cpu
Definition: machine.h:136
#define BUS_ISA_FDC
Definition: bus_isa.h:60
#define MACHINE_ALGOR_P5064
Definition: machine.h:307
#define MIPS_GPR_A1
void machine_entry_add_subtype(struct machine_entry *me, const char *name, int oldstyle_subtype,...)
Definition: machine.cc:717
void machine_entry_add_alias(struct machine_entry *me, const char *name)
Definition: machine.cc:697
MACHINE_REGISTER(algor)
char * bootstr
Definition: machine.h:155
Definition: cpu.h:326
#define BUS_ISA_EXTERNAL_PIC
Definition: bus_isa.h:67
struct bus_isa_data * bus_isa_init(struct machine *machine, char *interrupt_base_path, uint32_t bus_isa_flags, uint64_t isa_portbase, uint64_t isa_membase)
Definition: bus_isa.cc:174
uint64_t gpr[N_MIPS_GPRS]
Definition: cpu_mips.h:209
MACHINE_SETUP(algor)
struct mips_cpu mips
Definition: cpu.h:443
MACHINE_DEFAULT_CPU(algor)
int machine_subtype
Definition: machine.h:112
#define MACHINE_ALGOR_P4032
Definition: machine.h:306
#define MR_DEFAULT(x, name, arch, type)
Definition: machine.h:370
const char * machine_name
Definition: machine.h:115
#define ARCH_MIPS
Definition: machine.h:203
char * bootarg
Definition: machine.h:156

Generated on Fri Dec 7 2018 19:52:23 for GXemul by doxygen 1.8.13