/[gxemul]/trunk/src/devices/dev_bt459.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_bt459.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Mon Oct 8 16:20:40 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-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:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_bt459.c,v 1.65 2006/07/23 14:37:34 debug Exp $   *  $Id: dev_bt459.c,v 1.70 2007/06/15 18:44:19 debug Exp $
29   *     *  
30   *  Brooktree 459 vdac, used by TURBOchannel graphics cards.   *  COMMENT: Brooktree BT459, used by TURBOchannel graphics cards
31   */   */
32    
33  #include <stdio.h>  #include <stdio.h>
# Line 65  struct bt459_data { Line 65  struct bt459_data {
65          int             planes;          int             planes;
66          int             type;          int             type;
67    
68          int             irq_nr;          struct interrupt irq;
69          int             interrupts_enable;          int             interrupts_enable;
70          int             interrupt_time;          int             interrupt_time;
71          int             interrupt_time_reset_value;          int             interrupt_time_reset_value;
# Line 145  static void bt459_update_X_cursor(struct Line 145  static void bt459_update_X_cursor(struct
145           */           */
146    
147  #ifdef WITH_X11  #ifdef WITH_X11
148          if (cpu->machine->use_x11 && d->vfb_data->fb_window != NULL) {          if (cpu->machine->x11_md.in_use && d->vfb_data->fb_window != NULL) {
149                  for (y=0; y<=ymax; y++) {                  for (y=0; y<=ymax; y++) {
150                          for (x=0; x<=xmax; x+=4) {                          for (x=0; x<=xmax; x+=4) {
151                                  struct fb_window *win = d->vfb_data->fb_window;                                  struct fb_window *win = d->vfb_data->fb_window;
# Line 271  DEVICE_TICK(bt459) Line 271  DEVICE_TICK(bt459)
271           *  or after another tick has passed.  (This is to prevent           *  or after another tick has passed.  (This is to prevent
272           *  lockups from unhandled interrupts.)           *  lockups from unhandled interrupts.)
273           */           */
274          if (d->type != BT459_PX && d->interrupts_enable && d->irq_nr > 0) {          if (d->type != BT459_PX && d->interrupts_enable) {
275                  d->interrupt_time --;                  d->interrupt_time --;
276                  if (d->interrupt_time < 0) {                  if (d->interrupt_time < 0) {
277                          d->interrupt_time = d->interrupt_time_reset_value;                          d->interrupt_time = d->interrupt_time_reset_value;
278                          cpu_interrupt(cpu, d->irq_nr);                          INTERRUPT_ASSERT(d->irq);
279                  } else                  } else
280                          cpu_interrupt_ack(cpu, d->irq_nr);                          INTERRUPT_DEASSERT(d->irq);
281          }          }
282  }  }
283    
284    
 /*  
  *  dev_bt459_irq_access():  
  */  
285  DEVICE_ACCESS(bt459_irq)  DEVICE_ACCESS(bt459_irq)
286  {  {
287          struct bt459_data *d = (struct bt459_data *) extra;          struct bt459_data *d = extra;
288          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
289    
290          if (writeflag == MEM_WRITE)          if (writeflag == MEM_WRITE)
# Line 298  DEVICE_ACCESS(bt459_irq) Line 295  DEVICE_ACCESS(bt459_irq)
295  #endif  #endif
296    
297          d->interrupts_enable = 1;          d->interrupts_enable = 1;
298          if (d->irq_nr > 0)  
299                  cpu_interrupt_ack(cpu, d->irq_nr);          INTERRUPT_DEASSERT(d->irq);
300    
301          if (writeflag == MEM_READ)          if (writeflag == MEM_READ)
302                  memory_writemax64(cpu, data, len, odata);                  memory_writemax64(cpu, data, len, odata);
# Line 308  DEVICE_ACCESS(bt459_irq) Line 305  DEVICE_ACCESS(bt459_irq)
305  }  }
306    
307    
 /*  
  *  dev_bt459_access():  
  */  
308  DEVICE_ACCESS(bt459)  DEVICE_ACCESS(bt459)
309  {  {
310          struct bt459_data *d = (struct bt459_data *) extra;          struct bt459_data *d = extra;
311          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
312          int btaddr, old_cursor_on = d->cursor_on, modified;          int btaddr, old_cursor_on = d->cursor_on, modified;
313    
# Line 330  DEVICE_ACCESS(bt459) Line 324  DEVICE_ACCESS(bt459)
324           *  accessing a normal BT459 register, or the irq register,           *  accessing a normal BT459 register, or the irq register,
325           *  or by simply "missing" it.           *  or by simply "missing" it.
326           */           */
327          if (d->irq_nr > 0)          INTERRUPT_DEASSERT(d->irq);
                 cpu_interrupt_ack(cpu, d->irq_nr);  
328    
329          /*  ID register is read-only, should always be 0x4a or 0x4a4a4a:  */          /*  ID register is read-only, should always be 0x4a or 0x4a4a4a:  */
330          if (d->planes == 24)          if (d->planes == 24)
# Line 530  DEVICE_ACCESS(bt459) Line 523  DEVICE_ACCESS(bt459)
523   */   */
524  void dev_bt459_init(struct machine *machine, struct memory *mem,  void dev_bt459_init(struct machine *machine, struct memory *mem,
525          uint64_t baseaddr, uint64_t baseaddr_irq, struct vfb_data *vfb_data,          uint64_t baseaddr, uint64_t baseaddr_irq, struct vfb_data *vfb_data,
526          int planes, int irq_nr, int type)          int planes, char *irq_path, int type)
527  {  {
528          struct bt459_data *d = malloc(sizeof(struct bt459_data));          struct bt459_data *d;
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
529    
530            CHECK_ALLOCATION(d = malloc(sizeof(struct bt459_data)));
531          memset(d, 0, sizeof(struct bt459_data));          memset(d, 0, sizeof(struct bt459_data));
532    
533            INTERRUPT_CONNECT(irq_path, d->irq);
534    
535          d->vfb_data     = vfb_data;          d->vfb_data     = vfb_data;
536          d->rgb_palette  = vfb_data->rgb_palette;          d->rgb_palette  = vfb_data->rgb_palette;
537          d->planes       = planes;          d->planes       = planes;
         d->irq_nr       = irq_nr;  
538          d->type         = type;          d->type         = type;
539          d->cursor_x     = -1;          d->cursor_x     = -1;
540          d->cursor_y     = -1;          d->cursor_y     = -1;
# Line 587  void dev_bt459_init(struct machine *mach Line 578  void dev_bt459_init(struct machine *mach
578                      dev_bt459_irq_access, (void *)d, DM_DEFAULT, NULL);                      dev_bt459_irq_access, (void *)d, DM_DEFAULT, NULL);
579    
580          machine_add_tickfunction(machine, dev_bt459_tick, d,          machine_add_tickfunction(machine, dev_bt459_tick, d,
581              BT459_TICK_SHIFT, 0.0);              BT459_TICK_SHIFT);
582  }  }
583    

Legend:
Removed from v.30  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26