1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
/*
* $Id: chip_intel_8237A.c,v 1.25 2009-06-03 11:34:04 vrsieh Exp $
*
* Copyright (C) 2003-2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include "fixme.h"
#include "glue-log.h"
#include "chip_intel_8237A.h"
struct cpssp {
/*
* Config
*/
/*
* Signals
*/
struct sig_cs *port_cs;
struct sig_isa_bus_main *port_bus;
struct sig_isa_bus_dma *port_dma0;
struct sig_isa_bus_dma *port_dma1;
struct sig_isa_bus_dma *port_dma2;
struct sig_isa_bus_dma *port_dma3;
/*
* State
*/
unsigned int state_power;
#define STATE
#define NAME dma
#define NAME_(x) dma_ ## x
#define SNAME "dma"
#include "arch_dma.c"
#undef SNAME
#undef NAME_
#undef NAME
#undef STATE
};
/* Write transfer. */
static void
dma_ack_in(
struct cpssp *cpssp,
unsigned short offset,
unsigned char chan,
unsigned int tc
)
{
struct sig_isa_bus_dma *port_dma;
assert(/* 0 <= chan && */ chan < 4);
switch (chan) {
case 0:
port_dma = cpssp->port_dma0;
break;
case 1:
port_dma = cpssp->port_dma1;
break;
case 2:
port_dma = cpssp->port_dma2;
break;
case 3:
port_dma = cpssp->port_dma3;
break;
default:
assert(0); /* Cannot happen. */
}
sig_isa_bus_dma_ack_in(port_dma, cpssp, offset, tc);
}
/* Read transfer. */
static void
dma_ack_out(
struct cpssp *cpssp,
unsigned short offset,
unsigned char chan,
unsigned int tc
)
{
struct sig_isa_bus_dma *port_dma;
assert(/* 0 <= chan && */ chan < 4);
switch (chan) {
case 0:
port_dma = cpssp->port_dma0;
break;
case 1:
port_dma = cpssp->port_dma1;
break;
case 2:
port_dma = cpssp->port_dma2;
break;
case 3:
port_dma = cpssp->port_dma3;
break;
default:
assert(0); /* Cannot happen. */
}
sig_isa_bus_dma_ack_out(port_dma, cpssp, offset, tc);
}
/* Verify transfer. */
static void
dma_ack_verify(
struct cpssp *cpssp,
unsigned char chan,
unsigned int tc
)
{
struct sig_isa_bus_dma *port_dma;
assert(/* 0 <= chan && */ chan < 4);
switch (chan) {
case 0:
port_dma = cpssp->port_dma0;
break;
case 1:
port_dma = cpssp->port_dma1;
break;
case 2:
port_dma = cpssp->port_dma2;
break;
case 3:
port_dma = cpssp->port_dma3;
break;
default:
assert(0); /* Cannot happen. */
}
sig_isa_bus_dma_ack_verify(port_dma, cpssp, tc);
}
#define BEHAVIOR
#define NAME dma
#define NAME_(x) dma_ ## x
#define SNAME "dma"
#include "arch_dma.c"
#undef SNAME
#undef NAME_
#undef NAME
#undef BEHAVIOR
static void
chip_intel_8237A_power_set(void *_css, unsigned int val)
{
struct cpssp *cpssp = (struct cpssp *) _css;
cpssp->state_power = val;
}
static void
chip_intel_8237A_n_reset_set(void *_css, unsigned int val)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_reset(cpssp);
}
static int
chip_intel_8237A_req0(void *_css)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_req(cpssp, 0);
return 0;
}
static int
chip_intel_8237A_req1(void *_css)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_req(cpssp, 1);
return 0;
}
static int
chip_intel_8237A_req2(void *_css)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_req(cpssp, 2);
return 0;
}
static int
chip_intel_8237A_req3(void *_css)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_req(cpssp, 3);
return 0;
}
static int
chip_intel_8237A_inb(void *_css, uint8_t *valp, unsigned long port)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_inb(cpssp, valp, port);
return 0;
}
static int
chip_intel_8237A_outb(void *_css, uint8_t value, unsigned long port)
{
struct cpssp *cpssp = (struct cpssp *) _css;
dma_outb(cpssp, value, port);
return 0;
}
void *
chip_intel_8237A_create(
const char *name,
struct sig_manage *port_manage,
struct sig_boolean *port_power,
struct sig_boolean *port_reset_hash_,
struct sig_cs *port_cs,
struct sig_isa_bus_main *port_bus,
struct sig_isa_bus_dma *port_dma0,
struct sig_isa_bus_dma *port_dma1,
struct sig_isa_bus_dma *port_dma2,
struct sig_isa_bus_dma *port_dma3
)
{
static const struct sig_boolean_funcs power_funcs = {
.set = chip_intel_8237A_power_set,
};
static const struct sig_boolean_funcs reset_hash__funcs = {
.set = chip_intel_8237A_n_reset_set,
};
static const struct sig_cs_funcs cs_funcs = {
.readb = chip_intel_8237A_inb,
.writeb = chip_intel_8237A_outb,
};
static const struct sig_isa_bus_dma_funcs dma0_funcs = {
.req = chip_intel_8237A_req0,
};
static const struct sig_isa_bus_dma_funcs dma1_funcs = {
.req = chip_intel_8237A_req1,
};
static const struct sig_isa_bus_dma_funcs dma2_funcs = {
.req = chip_intel_8237A_req2,
};
static const struct sig_isa_bus_dma_funcs dma3_funcs = {
.req = chip_intel_8237A_req3,
};
struct cpssp *cpssp;
cpssp = malloc(sizeof(*cpssp));
assert(cpssp);
dma_init(cpssp);
/* Out */
/* Call */
cpssp->port_cs = port_cs;
sig_cs_connect(port_cs, cpssp, &cs_funcs);
cpssp->port_dma0 = port_dma0;
sig_isa_bus_dma_connect(port_dma0, cpssp, &dma0_funcs);
cpssp->port_dma1 = port_dma1;
sig_isa_bus_dma_connect(port_dma1, cpssp, &dma1_funcs);
cpssp->port_dma2 = port_dma2;
sig_isa_bus_dma_connect(port_dma2, cpssp, &dma2_funcs);
cpssp->port_dma3 = port_dma3;
sig_isa_bus_dma_connect(port_dma3, cpssp, &dma3_funcs);
/* In */
cpssp->state_power = 0;
sig_boolean_connect_in(port_power, cpssp, &power_funcs);
sig_boolean_connect_in(port_reset_hash_, cpssp, &reset_hash__funcs);
return cpssp;
}
void
chip_intel_8237A_destroy(void *_cpssp)
{
struct cpssp *cpssp = _cpssp;
free(cpssp);
}
|