1 |
/* |
2 |
* Copyright (C) 2003-2007 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 |
* $Id: machine_cobalt.c,v 1.10 2007/04/29 13:44:14 debug Exp $ |
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 |
|
45 |
MACHINE_SETUP(cobalt) |
46 |
{ |
47 |
char tmpstr[500], tmpstr2[500]; |
48 |
struct pci_data *pci_data; |
49 |
struct memory *mem = machine->memory; |
50 |
|
51 |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
52 |
machine->machine_name = "Cobalt"; |
53 |
machine->stable = 1; |
54 |
|
55 |
/* |
56 |
* Interrupts seem to be the following: |
57 |
* (according to http://www.funet.fi/pub/Linux/PEOPLE/Linus/v2.4/ |
58 |
* patch-html/patch-2.4.19/linux-2.4.19_arch_mips_cobalt_irq.c.html) |
59 |
* |
60 |
* 2 Galileo chip (timer) |
61 |
* 3 Tulip 0 + NCR SCSI |
62 |
* 4 Tulip 1 |
63 |
* 5 16550 UART (serial console) |
64 |
* 6 VIA southbridge PIC |
65 |
* 7 PCI (Note: Not used. The PCI controller |
66 |
* interrupts at ISA interrupt 9.) |
67 |
*/ |
68 |
|
69 |
/* ISA bus at MIPS irq 6: */ |
70 |
snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].6", |
71 |
machine->path, machine->bootstrap_cpu); |
72 |
bus_isa_init(machine, tmpstr, 0, 0x10000000, 0x14000000 /* TODO */); |
73 |
|
74 |
snprintf(tmpstr, sizeof(tmpstr), "ns16550 irq=%s.cpu[%i].5" |
75 |
" addr=0x1c800000 name2=tty0 in_use=1", |
76 |
machine->path, machine->bootstrap_cpu); |
77 |
machine->main_console_handle = (size_t) device_add(machine, tmpstr); |
78 |
|
79 |
|
80 |
/* |
81 |
* According to NetBSD/cobalt: |
82 |
* |
83 |
* pchb0 at pci0 dev 0 function 0: Galileo GT-64111 System Controller, |
84 |
* rev 1 (NOTE: added by dev_gt_init()) |
85 |
* tlp0 at pci0 dev 7 function 0: DECchip 21143 Ethernet, pass 4.1 |
86 |
* Symbios Logic 53c860 (SCSI mass storage, revision 0x02) at pci0 |
87 |
* dev 8 |
88 |
* pcib0 at pci0 dev 9 function 0, VIA Technologies VT82C586 (Apollo |
89 |
* VP) PCI-ISA Bridge, rev 37 |
90 |
* pciide0 at pci0 dev 9 function 1: VIA Technologies VT82C586 (Apollo |
91 |
* VP) ATA33 cr |
92 |
* tlp1 at pci0 dev 12 function 0: DECchip 21143 Ethernet, pass 4.1 |
93 |
* |
94 |
* The PCI controller interrupts at ISA interrupt 9. (TODO?) |
95 |
*/ |
96 |
snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2", |
97 |
machine->path, machine->bootstrap_cpu); |
98 |
snprintf(tmpstr2, sizeof(tmpstr2), "%s.cpu[%i].6", |
99 |
machine->path, machine->bootstrap_cpu); |
100 |
pci_data = dev_gt_init(machine, mem, 0x14000000, tmpstr, |
101 |
tmpstr2, 11); |
102 |
/* bus_pci_add(machine, pci_data, mem, 0, 7, 0, "dec21143"); */ |
103 |
/* bus_pci_add(machine, pci_data, mem, 0, 8, 0, "symbios_860"); |
104 |
PCI_VENDOR_SYMBIOS, PCI_PRODUCT_SYMBIOS_860 */ |
105 |
bus_pci_add(machine, pci_data, mem, 0, 9, 0, "vt82c586_isa"); |
106 |
bus_pci_add(machine, pci_data, mem, 0, 9, 1, "vt82c586_ide"); |
107 |
/* bus_pci_add(machine, pci_data, mem, 0, 12, 0, "dec21143"); */ |
108 |
|
109 |
if (!machine->prom_emulation) |
110 |
return; |
111 |
|
112 |
|
113 |
/* |
114 |
* NetBSD/cobalt expects memsize in a0, but it seems that what |
115 |
* it really wants is the end of memory + 0x80000000. |
116 |
* |
117 |
* The bootstring is stored 512 bytes before the end of |
118 |
* physical ram. |
119 |
*/ |
120 |
cpu->cd.mips.gpr[MIPS_GPR_A0] = |
121 |
machine->physical_ram_in_mb * 1048576 + 0xffffffff80000000ULL; |
122 |
machine->bootstr = "root=/dev/hda1 ro"; |
123 |
/* bootstr = "nfsroot=/usr/cobalt/"; */ |
124 |
/* TODO: bootarg, and/or automagic boot device detection */ |
125 |
store_string(cpu, cpu->cd.mips.gpr[MIPS_GPR_A0] - 512, |
126 |
machine->bootstr); |
127 |
} |
128 |
|
129 |
|
130 |
MACHINE_DEFAULT_CPU(cobalt) |
131 |
{ |
132 |
machine->cpu_name = strdup("RM5200"); |
133 |
} |
134 |
|
135 |
|
136 |
MACHINE_DEFAULT_RAM(cobalt) |
137 |
{ |
138 |
machine->physical_ram_in_mb = 64; |
139 |
} |
140 |
|
141 |
|
142 |
MACHINE_REGISTER(cobalt) |
143 |
{ |
144 |
MR_DEFAULT(cobalt, "Cobalt", ARCH_MIPS, MACHINE_COBALT); |
145 |
|
146 |
machine_entry_add_alias(me, "cobalt"); |
147 |
} |
148 |
|