1 |
/* |
/* |
2 |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: dev_adb.c,v 1.10 2006/07/21 16:55:41 debug Exp $ |
* $Id: dev_adb.c,v 1.12 2007/01/28 11:29:52 debug Exp $ |
29 |
* |
* |
30 |
* ADB (Apple Desktop Bus) controller. |
* ADB (Apple Desktop Bus) controller. |
31 |
* |
* |
48 |
#include "console.h" |
#include "console.h" |
49 |
#include "cpu.h" |
#include "cpu.h" |
50 |
#include "device.h" |
#include "device.h" |
51 |
|
#include "interrupt.h" |
52 |
#include "machine.h" |
#include "machine.h" |
53 |
#include "memory.h" |
#include "memory.h" |
54 |
#include "misc.h" |
#include "misc.h" |
76 |
"vPCR", "vIFR", "vIER", "(unknown)" }; |
"vPCR", "vIFR", "vIER", "(unknown)" }; |
77 |
|
|
78 |
struct adb_data { |
struct adb_data { |
79 |
int irq_nr; |
struct interrupt irq; |
80 |
int int_asserted; |
int int_asserted; |
81 |
|
|
82 |
int kbd_dev; |
int kbd_dev; |
113 |
DEVICE_TICK(adb) |
DEVICE_TICK(adb) |
114 |
{ |
{ |
115 |
struct adb_data *d = extra; |
struct adb_data *d = extra; |
116 |
int a; |
int assert; |
117 |
|
|
118 |
a = d->reg[vIFR >> VIA_REG_SHIFT] & IFR_ANY; |
assert = d->reg[vIFR >> VIA_REG_SHIFT] & IFR_ANY; |
119 |
if (a == IFR_ANY && d->int_enable) |
if (assert == IFR_ANY && d->int_enable) |
120 |
a = 1; |
assert = 1; |
121 |
|
|
122 |
if (a) |
if (assert) |
123 |
cpu_interrupt(cpu, d->irq_nr); |
INTERRUPT_ASSERT(d->irq); |
124 |
else if (d->int_asserted) |
else if (d->int_asserted) |
125 |
cpu_interrupt_ack(cpu, d->irq_nr); |
INTERRUPT_DEASSERT(d->irq); |
126 |
|
|
127 |
d->int_asserted = a; |
d->int_asserted = assert; |
128 |
} |
} |
129 |
|
|
130 |
|
|
445 |
exit(1); |
exit(1); |
446 |
} |
} |
447 |
memset(d, 0, sizeof(struct adb_data)); |
memset(d, 0, sizeof(struct adb_data)); |
448 |
d->irq_nr = devinit->irq_nr; |
|
449 |
|
INTERRUPT_CONNECT(devinit->interrupt_path, d->irq); |
450 |
|
|
451 |
adb_reset(d); |
adb_reset(d); |
452 |
|
|