/[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 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  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.59 2005/02/22 12:15:29 debug Exp $   *  $Id: dev_bt459.c,v 1.67 2006/12/30 13:30:57 debug Exp $
29   *     *  
30   *  Brooktree 459 vdac, used by TURBOchannel graphics cards.   *  Brooktree 459 vdac, used by TURBOchannel graphics cards.
31   */   */
# 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 101  struct bt459_data { Line 101  struct bt459_data {
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
# Line 306  static void bt459_update_cursor_position Line 244  static void bt459_update_cursor_position
244  }  }
245    
246    
247  /*  DEVICE_TICK(bt459)
  *  dev_bt459_tick():  
  */  
 void dev_bt459_tick(struct cpu *cpu, void *extra)  
248  {  {
249          struct bt459_data *d = extra;          struct bt459_data *d = extra;
250          int old_cursor_on = d->cursor_on;          int old_cursor_on = d->cursor_on;
# Line 336  void dev_bt459_tick(struct cpu *cpu, voi Line 271  void dev_bt459_tick(struct cpu *cpu, voi
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    
285  /*  DEVICE_ACCESS(bt459_irq)
  *  dev_bt459_irq_access():  
  */  
 int dev_bt459_irq_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
286  {  {
287          struct bt459_data *d = (struct bt459_data *) extra;          struct bt459_data *d = (struct bt459_data *) extra;
288          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
289    
290          idata = memory_readmax64(cpu, data, len);          if (writeflag == MEM_WRITE)
291                    idata = memory_readmax64(cpu, data, len);
292    
293  #ifdef BT459_DEBUG  #ifdef BT459_DEBUG
294          fatal("[ bt459: IRQ ack ]\n");          fatal("[ bt459: IRQ ack ]\n");
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 377  int dev_bt459_irq_access(struct cpu *cpu Line 308  int dev_bt459_irq_access(struct cpu *cpu
308  /*  /*
309   *  dev_bt459_access():   *  dev_bt459_access():
310   */   */
311  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)  
312  {  {
313          struct bt459_data *d = (struct bt459_data *) extra;          struct bt459_data *d = (struct bt459_data *) extra;
314          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 398  int dev_bt459_access(struct cpu *cpu, st Line 327  int dev_bt459_access(struct cpu *cpu, st
327           *  accessing a normal BT459 register, or the irq register,           *  accessing a normal BT459 register, or the irq register,
328           *  or by simply "missing" it.           *  or by simply "missing" it.
329           */           */
330          if (d->irq_nr > 0)          INTERRUPT_DEASSERT(d->irq);
                 cpu_interrupt_ack(cpu, d->irq_nr);  
331    
332          /*  ID register is read-only, should always be 0x4a or 0x4a4a4a:  */          /*  ID register is read-only, should always be 0x4a or 0x4a4a4a:  */
333          if (d->planes == 24)          if (d->planes == 24)
# Line 598  int dev_bt459_access(struct cpu *cpu, st Line 526  int dev_bt459_access(struct cpu *cpu, st
526   */   */
527  void dev_bt459_init(struct machine *machine, struct memory *mem,  void dev_bt459_init(struct machine *machine, struct memory *mem,
528          uint64_t baseaddr, uint64_t baseaddr_irq, struct vfb_data *vfb_data,          uint64_t baseaddr, uint64_t baseaddr_irq, struct vfb_data *vfb_data,
529          int planes, int irq_nr, int type)          int planes, char *irq_path, int type)
530  {  {
531          struct bt459_data *d = malloc(sizeof(struct bt459_data));          struct bt459_data *d = malloc(sizeof(struct bt459_data));
532          if (d == NULL) {          if (d == NULL) {
# Line 608  void dev_bt459_init(struct machine *mach Line 536  void dev_bt459_init(struct machine *mach
536    
537          memset(d, 0, sizeof(struct bt459_data));          memset(d, 0, sizeof(struct bt459_data));
538    
539            INTERRUPT_CONNECT(irq_path, d->irq);
540    
541          d->vfb_data     = vfb_data;          d->vfb_data     = vfb_data;
542          d->rgb_palette  = vfb_data->rgb_palette;          d->rgb_palette  = vfb_data->rgb_palette;
543          d->planes       = planes;          d->planes       = planes;
         d->irq_nr       = irq_nr;  
544          d->type         = type;          d->type         = type;
545          d->cursor_x     = -1;          d->cursor_x     = -1;
546          d->cursor_y     = -1;          d->cursor_y     = -1;
# Line 648  void dev_bt459_init(struct machine *mach Line 577  void dev_bt459_init(struct machine *mach
577          d->interrupt_time_reset_value = 500;          d->interrupt_time_reset_value = 500;
578    
579          memory_device_register(mem, "bt459", baseaddr, DEV_BT459_LENGTH,          memory_device_register(mem, "bt459", baseaddr, DEV_BT459_LENGTH,
580              dev_bt459_access, (void *)d, MEM_DEFAULT, NULL);              dev_bt459_access, (void *)d, DM_DEFAULT, NULL);
581    
582          if (baseaddr_irq != 0)          if (baseaddr_irq != 0)
583                  memory_device_register(mem, "bt459_irq", baseaddr_irq, 0x10000,                  memory_device_register(mem, "bt459_irq", baseaddr_irq, 0x10000,
584                      dev_bt459_irq_access, (void *)d, MEM_DEFAULT, NULL);                      dev_bt459_irq_access, (void *)d, DM_DEFAULT, NULL);
   
         machine_add_tickfunction(machine, dev_bt459_tick, d, BT459_TICK_SHIFT);  
585    
586          memory_device_register_statefunction(mem, d, bt459_state);          machine_add_tickfunction(machine, dev_bt459_tick, d,
587                BT459_TICK_SHIFT, 0.0);
588  }  }
589    

Legend:
Removed from v.4  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26