1 |
/* |
2 |
* Copyright (C) 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 |
* $Id: dev_lca.c,v 1.1 2006/05/30 19:49:39 debug Exp $ |
29 |
* |
30 |
* LCA bus (for Alpha machines). |
31 |
*/ |
32 |
|
33 |
#include <stdio.h> |
34 |
#include <stdlib.h> |
35 |
#include <string.h> |
36 |
|
37 |
#include "bus_isa.h" |
38 |
#include "cpu.h" |
39 |
#include "device.h" |
40 |
#include "emul.h" |
41 |
#include "machine.h" |
42 |
#include "memory.h" |
43 |
#include "misc.h" |
44 |
|
45 |
|
46 |
#include "alpha_lcareg.h" |
47 |
|
48 |
#define LCA_ISA_BASE (LCA_PCI_SIO + 0x10000000) |
49 |
#define LCA_ISA_MEMBASE (LCA_PCI_SIO + 0x18000000) |
50 |
|
51 |
|
52 |
struct lca_data { |
53 |
int dummy; |
54 |
}; |
55 |
|
56 |
|
57 |
DEVICE_ACCESS(lca_isa) |
58 |
{ |
59 |
int ofs, i; |
60 |
uint8_t byte; |
61 |
|
62 |
relative_addr >>= 5; |
63 |
|
64 |
ofs = relative_addr & 3; |
65 |
if (ofs > len) { |
66 |
fatal("[ ofs=%i len=%i in lca_isa access function. " |
67 |
"aborting ]\n", ofs, len); |
68 |
exit(1); |
69 |
} |
70 |
|
71 |
if (writeflag == MEM_WRITE) { |
72 |
byte = data[ofs % len]; |
73 |
return cpu->memory_rw(cpu, cpu->mem, LCA_ISA_BASE + |
74 |
relative_addr, &byte, 1, writeflag, CACHE_NONE); |
75 |
} |
76 |
|
77 |
cpu->memory_rw(cpu, cpu->mem, LCA_ISA_BASE + relative_addr, |
78 |
&byte, 1, MEM_READ, CACHE_NONE); |
79 |
|
80 |
for (i=0; i<len; i++) |
81 |
data[i] = i == ofs? byte : 0x00; |
82 |
|
83 |
return 1; |
84 |
} |
85 |
|
86 |
|
87 |
DEVINIT(lca) |
88 |
{ |
89 |
struct lca_data *d = malloc(sizeof(struct lca_data)); |
90 |
if (d == NULL) { |
91 |
fprintf(stderr, "out of memory\n"); |
92 |
exit(1); |
93 |
} |
94 |
memset(d, 0, sizeof(struct lca_data)); |
95 |
|
96 |
memory_device_register(devinit->machine->memory, "lca_isa", |
97 |
LCA_PCI_SIO, 0x10000 << 5, dev_lca_isa_access, (void *)d, |
98 |
DM_DEFAULT, NULL); |
99 |
|
100 |
/* TODO: IRQs etc. */ |
101 |
bus_isa_init(devinit->machine, BUS_ISA_IDE0 | BUS_ISA_IDE1, |
102 |
LCA_ISA_BASE, LCA_ISA_MEMBASE, 32, 48); |
103 |
|
104 |
return 1; |
105 |
} |
106 |
|