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

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

revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC revision 44 by dpavlin, Mon Oct 8 16:22:56 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_malta_lcd.c,v 1.11 2007/06/15 19:11:15 debug Exp $   *  $Id: dev_malta_lcd.c,v 1.12 2007/06/17 02:05:51 debug Exp $
29   *   *
30   *  COMMENT: Malta (evbmips) LCD display   *  COMMENT: Malta (evbmips) LCD display
31   *   *
32   *  TODO. This is mostly a dummy device.   *  TODO: Write output to somewhere else, not just as a debug message.
33   */   */
34    
35  #include <stdio.h>  #include <stdio.h>
# Line 43  Line 43 
43  #include "memory.h"  #include "memory.h"
44  #include "misc.h"  #include "misc.h"
45    
46    #include "maltareg.h"
47    
48    
49  #define DEV_MALTA_LCD_LENGTH            0x80  #define DEV_MALTA_LCD_LENGTH            0x80
50  #define MALTA_LCD_TICK_SHIFT            15  #define MALTA_LCD_TICK_SHIFT            16
51  #define LCD_LEN                         8  #define LCD_LEN                         8
52    
53  struct malta_lcd_data {  struct malta_lcd_data {
54            uint64_t        base_addr;
55    
56          int             display_modified;          int             display_modified;
57          unsigned char   display[LCD_LEN];          unsigned char   display[LCD_LEN];
58  };  };
# Line 66  DEVICE_TICK(malta_lcd) Line 70  DEVICE_TICK(malta_lcd)
70                  return;                  return;
71          }          }
72    
73          debug("[ malta_lcd:  ");          debug("[ malta_lcd: \"");
74          for (i=0; i<LCD_LEN; i++)          for (i=0; i<LCD_LEN; i++)
75                  if (d->display[i] >= ' ')                  if (d->display[i] >= ' ')
76                          debug("%c", d->display[i]);                          debug("%c", d->display[i]);
77          debug("  ]\n");                  else
78                            debug("?");
79            debug("\" ]\n");
80    
81          d->display_modified = 0;          d->display_modified = 0;
82  }  }
# Line 80  DEVICE_ACCESS(malta_lcd) Line 86  DEVICE_ACCESS(malta_lcd)
86  {  {
87          struct malta_lcd_data *d = extra;          struct malta_lcd_data *d = extra;
88          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
89          int i;          int pos;
90    
91          if (writeflag == MEM_WRITE)          if (writeflag == MEM_WRITE)
92                  idata = memory_readmax64(cpu, data, len);                  idata = memory_readmax64(cpu, data, len);
93    
94            relative_addr += d->base_addr;
95    
96          switch (relative_addr) {          switch (relative_addr) {
97    
98          case 0x18:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS0:
99          case 0x20:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS1:
100          case 0x28:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS2:
101          case 0x30:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS3:
102          case 0x38:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS4:
103          case 0x40:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS5:
104          case 0x48:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS6:
105          case 0x50:          case MALTA_ASCII_BASE + MALTA_ASCIIPOS7:
106                  i = (relative_addr - 0x18) / 8;                  pos = (relative_addr - MALTA_ASCII_BASE) / 8;
107                  if (writeflag == MEM_WRITE) {                  if (writeflag == MEM_WRITE) {
108                          d->display[i] = idata;                          d->display[pos] = idata;
109                          d->display_modified = 1;                          d->display_modified = 1;
110                  } else                  } else {
111                          odata = d->display[i];                          odata = d->display[pos];
112                    }
113                  break;                  break;
114    
115          default:if (writeflag == MEM_WRITE) {          default:
116                    if (writeflag == MEM_WRITE) {
117                          fatal("[ malta_lcd: unimplemented write to "                          fatal("[ malta_lcd: unimplemented write to "
118                              "offset 0x%x: data=0x%02x ]\n", (int)                              "offset 0x%x: data=0x%02x ]\n", (int)
119                              relative_addr, (int)idata);                              relative_addr, (int)idata);
# Line 127  DEVINIT(malta_lcd) Line 137  DEVINIT(malta_lcd)
137          CHECK_ALLOCATION(d = malloc(sizeof(struct malta_lcd_data)));          CHECK_ALLOCATION(d = malloc(sizeof(struct malta_lcd_data)));
138          memset(d, 0, sizeof(struct malta_lcd_data));          memset(d, 0, sizeof(struct malta_lcd_data));
139    
140            d->base_addr = devinit->addr;
141    
142          memory_device_register(devinit->machine->memory, devinit->name,          memory_device_register(devinit->machine->memory, devinit->name,
143              devinit->addr, DEV_MALTA_LCD_LENGTH,              devinit->addr, DEV_MALTA_LCD_LENGTH,
144              dev_malta_lcd_access, (void *)d, DM_DEFAULT, NULL);              dev_malta_lcd_access, (void *)d, DM_DEFAULT, NULL);

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

  ViewVC Help
Powered by ViewVC 1.1.26