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

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

revision 21 by dpavlin, Mon Oct 8 16:19:23 2007 UTC revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2004-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:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_jazz.c,v 1.20 2005/11/13 00:14:09 debug Exp $   *  $Id: dev_jazz.c,v 1.23 2006/02/09 20:02:59 debug Exp $
29   *     *  
30   *  Microsoft Jazz-related stuff (Acer PICA-61, etc).   *  Microsoft Jazz-related stuff (Acer PICA-61, etc).
31     *
32     *  TODO/NOTE: This is mostly a quick hack, it doesn't really implement
33     *  much of the Jazz architecture.  Also, the a0/20 isa-like stuff is
34     *  not supposed to be here.
35   */   */
36    
37  #include <stdio.h>  #include <stdio.h>
# Line 91  size_t dev_jazz_dma_controller(void *dma Line 95  size_t dev_jazz_dma_controller(void *dma
95    
96          dma_addr = d->dma0_addr;          dma_addr = d->dma0_addr;
97          i = 0;          i = 0;
98          while (dma_addr < d->dma0_addr + d->dma0_count && i < len) {          while (dma_addr < d->dma0_addr + d->dma0_count && i < (int32_t)len) {
99    
100                  res = cpu->memory_rw(cpu, cpu->mem,                  res = cpu->memory_rw(cpu, cpu->mem,
101                      d->dma_translation_table_base + (dma_addr >> 12) * 8,                      d->dma_translation_table_base + (dma_addr >> 12) * 8,
# Line 111  size_t dev_jazz_dma_controller(void *dma Line 115  size_t dev_jazz_dma_controller(void *dma
115    
116                  /*  Speed up the copying by copying 16 or 256 bytes:  */                  /*  Speed up the copying by copying 16 or 256 bytes:  */
117                  ncpy = 1;                  ncpy = 1;
118                  if ((phys_addr & 15) == 0 && i + 15 <= len)                  if ((phys_addr & 15) == 0 && i + 15 <= (int32_t)len)
119                          ncpy = 15;                          ncpy = 15;
120                  if ((phys_addr & 255) == 0 && i + 255 <= len)                  if ((phys_addr & 255) == 0 && i + 255 <= (int32_t)len)
121                          ncpy = 255;                          ncpy = 255;
122    
123                  res = cpu->memory_rw(cpu, cpu->mem, phys_addr,                  res = cpu->memory_rw(cpu, cpu->mem, phys_addr,
# Line 161  void dev_jazz_tick(struct cpu *cpu, void Line 165  void dev_jazz_tick(struct cpu *cpu, void
165  /*  /*
166   *  dev_jazz_access():   *  dev_jazz_access():
167   */   */
168  int dev_jazz_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(jazz)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
169  {  {
170          struct jazz_data *d = (struct jazz_data *) extra;          struct jazz_data *d = (struct jazz_data *) extra;
171          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 298  printf("R4030_SYS_ISA_VECTOR: w=%i\n", w Line 300  printf("R4030_SYS_ISA_VECTOR: w=%i\n", w
300  /*  /*
301   *  dev_jazz_led_access():   *  dev_jazz_led_access():
302   */   */
303  int dev_jazz_led_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(jazz_led)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
304  {  {
305          struct jazz_data *d = (struct jazz_data *) extra;          struct jazz_data *d = (struct jazz_data *) extra;
306          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 340  int dev_jazz_led_access(struct cpu *cpu, Line 340  int dev_jazz_led_access(struct cpu *cpu,
340    
341    
342  /*  /*
343   *  dev_jazz_access_a0():   *  dev_jazz_a0_access():
344   *   *
345   *  ISA interrupt stuff, high 8 interrupts.   *  ISA interrupt stuff, high 8 interrupts.
346     *
347     *  TODO: use isa8 stuff instead!
348   */   */
349  int dev_jazz_access_a0(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(jazz_a0)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
350  {  {
351          struct jazz_data *d = (struct jazz_data *) extra;          struct jazz_data *d = (struct jazz_data *) extra;
352          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 393  int dev_jazz_access_a0(struct cpu *cpu, Line 393  int dev_jazz_access_a0(struct cpu *cpu,
393    
394    
395  /*  /*
396   *  dev_jazz_access_20():   *  dev_jazz_20_access():
397   *   *
398   *  ISA interrupt stuff, low 8 interrupts.   *  ISA interrupt stuff, low 8 interrupts.
399   */   */
400  int dev_jazz_access_20(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(jazz_20)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
401  {  {
402          struct jazz_data *d = (struct jazz_data *) extra;          struct jazz_data *d = (struct jazz_data *) extra;
403          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 446  int dev_jazz_access_20(struct cpu *cpu, Line 444  int dev_jazz_access_20(struct cpu *cpu,
444    
445    
446  /*  /*
447   *  dev_jazz_access_jazzio():   *  dev_jazz_jazzio_access():
448   *   *
449   *  See jazzio_intr() in NetBSD's   *  See jazzio_intr() in NetBSD's
450   *  /usr/src/sys/arch/arc/jazz/jazzio.c for more info.   *  /usr/src/sys/arch/arc/jazz/jazzio.c for more info.
451   */   */
452  int dev_jazz_access_jazzio(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(jazz_jazzio)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
453  {  {
454          struct jazz_data *d = (struct jazz_data *) extra;          struct jazz_data *d = (struct jazz_data *) extra;
455          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
# Line 502  int dev_jazz_access_jazzio(struct cpu *c Line 498  int dev_jazz_access_jazzio(struct cpu *c
498  }  }
499    
500    
501  /*  DEVINIT(jazz)
  *  devinit_jazz():  
  */  
 int devinit_jazz(struct devinit *devinit)  
502  {  {
503          struct jazz_data *d = malloc(sizeof(struct jazz_data));          struct jazz_data *d = malloc(sizeof(struct jazz_data));
504          if (d == NULL) {          if (d == NULL) {
# Line 528  int devinit_jazz(struct devinit *devinit Line 521  int devinit_jazz(struct devinit *devinit
521              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
522    
523          memory_device_register(devinit->machine->memory, "jazz_isa_20",          memory_device_register(devinit->machine->memory, "jazz_isa_20",
524              0x90000020ULL, 2, dev_jazz_access_20, (void *)d, DM_DEFAULT, NULL);              0x90000020ULL, 2, dev_jazz_20_access, (void *)d, DM_DEFAULT, NULL);
525    
526          memory_device_register(devinit->machine->memory, "jazz_isa_a0",          memory_device_register(devinit->machine->memory, "jazz_isa_a0",
527              0x900000a0ULL, 2, dev_jazz_access_a0, (void *)d, DM_DEFAULT, NULL);              0x900000a0ULL, 2, dev_jazz_a0_access, (void *)d, DM_DEFAULT, NULL);
528    
529          memory_device_register(devinit->machine->memory, "pica_jazzio",          memory_device_register(devinit->machine->memory, "pica_jazzio",
530              0xf0000000ULL, 4, dev_jazz_access_jazzio, (void *)d,              0xf0000000ULL, 4, dev_jazz_jazzio_access, (void *)d,
531              DM_DEFAULT, NULL);              DM_DEFAULT, NULL);
532    
533          machine_add_tickfunction(devinit->machine, dev_jazz_tick,          machine_add_tickfunction(devinit->machine, dev_jazz_tick,

Legend:
Removed from v.21  
changed lines
  Added in v.22

  ViewVC Help
Powered by ViewVC 1.1.26