56 #define DEV_8253_LENGTH 4 77 static void timer0_tick(
struct timer *
t,
void *
extra)
103 uint64_t idata = 0, odata = 0;
110 switch (relative_addr) {
119 d->
counter[relative_addr] &= 0xff00;
120 d->
counter[relative_addr] |= (idata & 0xff);
123 d->
counter[relative_addr] &= 0x00ff;
124 d->
counter[relative_addr] |= ((idata&0xff)<<8);
125 if (d->
counter[relative_addr] != 0)
126 d->
hz[relative_addr] = (int) (
128 d->
counter[relative_addr] + 0.5);
130 d->
hz[relative_addr] = 0;
131 debug(
"[ 8253: counter %i set to %i (%i Hz) " 132 "]\n", relative_addr, d->
counter[
133 relative_addr], d->
hz[relative_addr]);
134 switch (relative_addr) {
135 case 0:
if (d->
timer0 == NULL)
137 d->
hz[0], timer0_tick, d);
142 case 1:
fatal(
"TODO: DMA refresh?\n");
144 case 2:
fatal(
"TODO: 8253 tone generation?\n");
148 default:
fatal(
"[ 8253: huh? writing to counter" 149 " %i but neither from msb nor lsb? ]\n",
157 odata = d->
counter[relative_addr] & 0xff;
160 odata = (d->
counter[relative_addr] >> 8) & 0xff;
162 default:
fatal(
"[ 8253: huh? reading from counter" 163 " %i but neither from msb nor lsb? ]\n",
181 debug(
"[ 8253: attempt to select counter 3," 182 " which doesn't exist. ]\n");
188 debug(
"[ 8253: select=%i mode=0x%x ",
191 switch (idata & 0x30) {
204 fatal(
"[ 8253: BCD not yet implemented ]\n");
208 debug(
"[ 8253: read; can this actually happen? ]\n");
214 fatal(
"[ 8253: unimplemented write to address 0x%x" 215 " data=0x%02x ]\n", (
int)relative_addr, (
int)idata);
217 fatal(
"[ 8253: unimplemented read from address 0x%x " 218 "]\n", (
int)relative_addr);
uint64_t memory_readmax64(struct cpu *cpu, unsigned char *buf, int len)
void fatal(const char *fmt,...)
int * pending_timer_interrupts
int pending_interrupts_timer0
#define I8253_TIMER_RATEGEN
#define I8253_TIMER_CNTR0
struct isa_pic_data isa_pic_data
#define CHECK_ALLOCATION(ptr)
void timer_update_frequency(struct timer *t, double new_freq)
struct timer * timer_add(double freq, void(*timer_tick)(struct timer *timer, void *extra), void *extra)
#define INTERRUPT_ASSERT(istruct)
#define I8253_TIMER_CNTR2
#define I8253_TIMER_16BIT
#define INTERRUPT_CONNECT(name, istruct)
void memory_writemax64(struct cpu *cpu, unsigned char *buf, int len, uint64_t data)
void memory_device_register(struct memory *mem, const char *, uint64_t baseaddr, uint64_t len, int(*f)(struct cpu *, struct memory *, uint64_t, unsigned char *, size_t, int, void *), void *extra, int flags, unsigned char *dyntrans_data)
void machine_add_tickfunction(struct machine *machine, void(*func)(struct cpu *, void *), void *extra, int clockshift)
#define I8253_TIMER_CNTR1