1 |
dpavlin |
22 |
/* |
2 |
|
|
* Copyright (C) 2005-2006 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 |
dpavlin |
30 |
* $Id: machine_algor.c,v 1.8 2006/08/14 18:03:12 debug Exp $ |
29 |
dpavlin |
22 |
*/ |
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 "machine_interrupts.h" |
42 |
|
|
#include "memory.h" |
43 |
|
|
#include "misc.h" |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
MACHINE_SETUP(algor) |
47 |
|
|
{ |
48 |
|
|
switch (machine->machine_subtype) { |
49 |
|
|
case MACHINE_ALGOR_P4032: |
50 |
|
|
machine->machine_name = "Algor P4032"; |
51 |
|
|
break; |
52 |
|
|
case MACHINE_ALGOR_P5064: |
53 |
|
|
machine->machine_name = "Algor P5064"; |
54 |
|
|
break; |
55 |
|
|
default:fatal("Unimplemented Algor machine.\n"); |
56 |
|
|
exit(1); |
57 |
|
|
} |
58 |
|
|
|
59 |
dpavlin |
30 |
/* |
60 |
|
|
* Algor CPU interrupts: |
61 |
|
|
* |
62 |
|
|
* 7 = CPU count/compare |
63 |
|
|
* 4 = Local |
64 |
|
|
* 3 = PCI |
65 |
|
|
* 2 = ISA |
66 |
|
|
*/ |
67 |
|
|
|
68 |
dpavlin |
22 |
machine->md_int.v3_data = dev_v3_init(machine, machine->memory); |
69 |
|
|
machine->md_interrupt = isa8_interrupt; |
70 |
dpavlin |
30 |
machine->isa_pic_data.native_irq = 2; /* Primary: ISA */ |
71 |
|
|
machine->isa_pic_data.secondary_mask1 = 0x18; |
72 |
|
|
machine->isa_pic_data.native_secondary_irq = 4; /* Secondary: Local */ |
73 |
dpavlin |
22 |
|
74 |
|
|
device_add(machine, "algor addr=0x1ff00000"); |
75 |
|
|
|
76 |
|
|
bus_isa_init(machine, BUS_ISA_FDC, 0x1d000000, 0x10000000, 8, 24); |
77 |
|
|
|
78 |
|
|
bus_pci_add(machine, machine->md_int.v3_data->pci_data, |
79 |
|
|
machine->memory, 0, 0, 0, "dec21143"); |
80 |
|
|
|
81 |
|
|
if (!machine->prom_emulation) |
82 |
|
|
return; |
83 |
|
|
|
84 |
dpavlin |
30 |
/* Magic "reboot" instruction at 0xbfc00000: */ |
85 |
|
|
store_32bit_word(cpu, 0xffffffff9fc00000ULL, 0x00c0de0d); |
86 |
|
|
|
87 |
dpavlin |
22 |
/* 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 |
|
|
|
98 |
|
|
machine->bootstr = strdup(machine->boot_kernel_filename); |
99 |
|
|
machine->bootarg = strdup(machine->boot_string_argument); |
100 |
|
|
store_string(cpu, (int32_t)0x9fc01040, machine->bootstr); |
101 |
|
|
store_string(cpu, (int32_t)0x9fc01200, machine->bootarg); |
102 |
|
|
|
103 |
|
|
/* a2 = (yamon_env_var *)envp */ |
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 |
|
|
|
120 |
|
|
MACHINE_DEFAULT_CPU(algor) |
121 |
|
|
{ |
122 |
|
|
machine->cpu_name = strdup("RM5200"); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
|
126 |
|
|
MACHINE_REGISTER(algor) |
127 |
|
|
{ |
128 |
dpavlin |
26 |
MR_DEFAULT(algor, "Algor evaluation board", ARCH_MIPS, MACHINE_ALGOR); |
129 |
|
|
|
130 |
|
|
machine_entry_add_alias(me, "algor"); |
131 |
|
|
|
132 |
|
|
machine_entry_add_subtype(me, "P4032", MACHINE_ALGOR_P4032, |
133 |
|
|
"p4032", NULL); |
134 |
|
|
|
135 |
|
|
machine_entry_add_subtype(me, "P5064", MACHINE_ALGOR_P5064, |
136 |
|
|
"p5064", NULL); |
137 |
dpavlin |
22 |
} |
138 |
|
|
|