1 |
/* |
/* |
2 |
* Copyright (C) 2003-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2006 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_bt459.c,v 1.59 2005/02/22 12:15:29 debug Exp $ |
* $Id: dev_bt459.c,v 1.63 2006/01/01 13:17:16 debug Exp $ |
29 |
* |
* |
30 |
* Brooktree 459 vdac, used by TURBOchannel graphics cards. |
* Brooktree 459 vdac, used by TURBOchannel graphics cards. |
31 |
*/ |
*/ |
101 |
|
|
102 |
|
|
103 |
/* |
/* |
|
* bt459_state(): |
|
|
*/ |
|
|
int bt459_state(struct cpu *cpu, struct memory *mem, void *extra, int wf, |
|
|
int nr, int *type, char **namep, void **data, size_t *len) |
|
|
{ |
|
|
struct bt459_data *d = (struct bt459_data *) extra; |
|
|
|
|
|
switch (nr) { |
|
|
case 0: if (wf) { |
|
|
memcpy(&d->cursor_on, *data, *len); |
|
|
} else { |
|
|
(*namep) = "cursor_on"; |
|
|
(*type) = DEVICE_STATE_TYPE_INT; |
|
|
*len = sizeof(d->cursor_on); |
|
|
*data = &d->cursor_on; |
|
|
} |
|
|
break; |
|
|
case 1: if (wf) { |
|
|
memcpy(&d->cursor_x, *data, *len); |
|
|
} else { |
|
|
(*namep) = "cursor_x"; |
|
|
(*type) = DEVICE_STATE_TYPE_INT; |
|
|
*len = sizeof(d->cursor_x); |
|
|
*data = &d->cursor_x; |
|
|
} |
|
|
break; |
|
|
case 2: if (wf) { |
|
|
memcpy(&d->cursor_y, *data, *len); |
|
|
} else { |
|
|
(*namep) = "cursor_y"; |
|
|
(*type) = DEVICE_STATE_TYPE_INT; |
|
|
*len = sizeof(d->cursor_y); |
|
|
*data = &d->cursor_y; |
|
|
} |
|
|
break; |
|
|
case 3: if (wf) { |
|
|
memcpy(&d->cursor_xsize, *data, *len); |
|
|
} else { |
|
|
(*namep) = "cursor_xsize"; |
|
|
(*type) = DEVICE_STATE_TYPE_INT; |
|
|
*len = sizeof(d->cursor_xsize); |
|
|
*data = &d->cursor_xsize; |
|
|
} |
|
|
break; |
|
|
case 4: if (wf) { |
|
|
memcpy(&d->cursor_ysize, *data, *len); |
|
|
} else { |
|
|
(*namep) = "cursor_ysize"; |
|
|
(*type) = DEVICE_STATE_TYPE_INT; |
|
|
*len = sizeof(d->cursor_ysize); |
|
|
*data = &d->cursor_ysize; |
|
|
} |
|
|
break; |
|
|
default: |
|
|
return 0; |
|
|
} |
|
|
|
|
|
return 1; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
104 |
* bt459_update_X_cursor(): |
* bt459_update_X_cursor(): |
105 |
* |
* |
106 |
* This routine takes the color values in the cursor RAM area, and put them |
* This routine takes the color values in the cursor RAM area, and put them |
288 |
/* |
/* |
289 |
* dev_bt459_irq_access(): |
* dev_bt459_irq_access(): |
290 |
*/ |
*/ |
291 |
int dev_bt459_irq_access(struct cpu *cpu, struct memory *mem, |
DEVICE_ACCESS(bt459_irq) |
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
292 |
{ |
{ |
293 |
struct bt459_data *d = (struct bt459_data *) extra; |
struct bt459_data *d = (struct bt459_data *) extra; |
294 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
295 |
|
|
296 |
idata = memory_readmax64(cpu, data, len); |
if (writeflag == MEM_WRITE) |
297 |
|
idata = memory_readmax64(cpu, data, len); |
298 |
|
|
299 |
#ifdef BT459_DEBUG |
#ifdef BT459_DEBUG |
300 |
fatal("[ bt459: IRQ ack ]\n"); |
fatal("[ bt459: IRQ ack ]\n"); |
314 |
/* |
/* |
315 |
* dev_bt459_access(): |
* dev_bt459_access(): |
316 |
*/ |
*/ |
317 |
int dev_bt459_access(struct cpu *cpu, struct memory *mem, |
DEVICE_ACCESS(bt459) |
|
uint64_t relative_addr, unsigned char *data, size_t len, |
|
|
int writeflag, void *extra) |
|
318 |
{ |
{ |
319 |
struct bt459_data *d = (struct bt459_data *) extra; |
struct bt459_data *d = (struct bt459_data *) extra; |
320 |
uint64_t idata = 0, odata = 0; |
uint64_t idata = 0, odata = 0; |
583 |
d->interrupt_time_reset_value = 500; |
d->interrupt_time_reset_value = 500; |
584 |
|
|
585 |
memory_device_register(mem, "bt459", baseaddr, DEV_BT459_LENGTH, |
memory_device_register(mem, "bt459", baseaddr, DEV_BT459_LENGTH, |
586 |
dev_bt459_access, (void *)d, MEM_DEFAULT, NULL); |
dev_bt459_access, (void *)d, DM_DEFAULT, NULL); |
587 |
|
|
588 |
if (baseaddr_irq != 0) |
if (baseaddr_irq != 0) |
589 |
memory_device_register(mem, "bt459_irq", baseaddr_irq, 0x10000, |
memory_device_register(mem, "bt459_irq", baseaddr_irq, 0x10000, |
590 |
dev_bt459_irq_access, (void *)d, MEM_DEFAULT, NULL); |
dev_bt459_irq_access, (void *)d, DM_DEFAULT, NULL); |
591 |
|
|
592 |
machine_add_tickfunction(machine, dev_bt459_tick, d, BT459_TICK_SHIFT); |
machine_add_tickfunction(machine, dev_bt459_tick, d, BT459_TICK_SHIFT); |
|
|
|
|
memory_device_register_statefunction(mem, d, bt459_state); |
|
593 |
} |
} |
594 |
|
|