/[gxemul]/trunk/src/devices/dev_pmagja.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_pmagja.c

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

revision 12 by dpavlin, Mon Oct 8 16:18:38 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-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_pmagja.c,v 1.15 2005/07/19 10:48:06 debug Exp $   *  $Id: dev_pmagja.c,v 1.22 2007/06/15 19:57:33 debug Exp $
29   *     *  
30   *  TURBOchannel PMAG-JA graphics device.   *  COMMENT: TURBOchannel PMAG-JA graphics card
31   *   *
32   *  TODO   *  TODO
33   */   */
# Line 50  Line 50 
50  /*  #define JA_DEBUG  */  /*  #define JA_DEBUG  */
51    
52  struct pmagja_data {  struct pmagja_data {
53          int             irq_nr;          struct interrupt        irq;
54          struct memory   *fb_mem;          struct memory           *fb_mem;
55          struct vfb_data *vfb_data;          struct vfb_data         *vfb_data;
56    
57          unsigned char   pixeldata[XSIZE * YSIZE];          unsigned char           pixeldata[XSIZE * YSIZE];
58    
59          int             current_r;          int                     current_r;
60          int             current_g;          int                     current_g;
61          int             current_b;          int                     current_b;
62    
63          int             pip_offset;          int                     pip_offset;
64  };  };
65    
66    
67  /*  DEVICE_ACCESS(pmagja)
  *  dev_pmagja_access():  
  */  
 int dev_pmagja_access(struct cpu *cpu, struct memory *mem,  
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
68  {  {
         uint64_t idata = 0, odata = 0;  
69          struct pmagja_data *d = extra;          struct pmagja_data *d = extra;
70          int i, res = 1;          uint64_t idata = 0, odata = 0;
71            size_t i, res = 1;
72    
73          relative_addr += PMAGJA_FIRSTOFFSET;          if (writeflag == MEM_WRITE)
74                    idata = memory_readmax64(cpu, data, len);
75    
76          idata = memory_readmax64(cpu, data, len);          relative_addr += PMAGJA_FIRSTOFFSET;
77    
78  #ifdef JA_DEBUG  #ifdef JA_DEBUG
79  {  {
80  int i;  size_t i;
81  for (i=0; i<len; i++)  for (i=0; i<len; i++)
82    if (data[i] != 0 && data[i] != 1 && data[i]!=0xff)    if (data[i] != 0 && data[i] != 1 && data[i]!=0xff)
83          if (writeflag)          if (writeflag)
# Line 199  for (i=0; i<len; i++) Line 195  for (i=0; i<len; i++)
195  }  }
196    
197    
 /*  
  *  dev_pmagja_init():  
  */  
198  void dev_pmagja_init(struct machine *machine, struct memory *mem,  void dev_pmagja_init(struct machine *machine, struct memory *mem,
199          uint64_t baseaddr, int irq_nr)          uint64_t baseaddr, char *irq_path)
200  {  {
201          struct pmagja_data *d;          struct pmagja_data *d;
202    
203          d = malloc(sizeof(struct pmagja_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct pmagja_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
204          memset(d, 0, sizeof(struct pmagja_data));          memset(d, 0, sizeof(struct pmagja_data));
205    
206          d->irq_nr = irq_nr;          INTERRUPT_CONNECT(irq_path, d->irq);
207    
208          d->fb_mem = memory_new(XSIZE * YSIZE * 3, machine->arch);          d->fb_mem = memory_new(XSIZE * YSIZE * 3, machine->arch);
209          if (d->fb_mem == NULL) {          if (d->fb_mem == NULL) {
# Line 230  void dev_pmagja_init(struct machine *mac Line 219  void dev_pmagja_init(struct machine *mac
219    
220          /*  TODO: not bt459, but a bt463:  */          /*  TODO: not bt459, but a bt463:  */
221          dev_bt459_init(machine, mem, baseaddr + 0x40000, 0, d->vfb_data, 8,          dev_bt459_init(machine, mem, baseaddr + 0x40000, 0, d->vfb_data, 8,
222              irq_nr, 0); /*  palette  (TODO: type)  */              irq_path, 0);       /*  palette  (TODO: type)  */
223          dev_bt431_init(mem, baseaddr + 0x40010, d->vfb_data, 8);  /*  cursor  */          dev_bt431_init(mem, baseaddr + 0x40010, d->vfb_data, 8);  /*  cursor  */
224    
225          memory_device_register(mem, "pmagja", baseaddr + PMAGJA_FIRSTOFFSET,          memory_device_register(mem, "pmagja", baseaddr + PMAGJA_FIRSTOFFSET,
226              DEV_PMAGJA_LENGTH - PMAGJA_FIRSTOFFSET, dev_pmagja_access, d,              DEV_PMAGJA_LENGTH - PMAGJA_FIRSTOFFSET, dev_pmagja_access, d,
227              MEM_DEFAULT, NULL);              DM_DEFAULT, NULL);
228  }  }
229    

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

  ViewVC Help
Powered by ViewVC 1.1.26