/[gxemul]/trunk/src/devices/dev_vr41xx.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_vr41xx.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 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_vr41xx.c,v 1.29 2005/04/09 12:11:46 debug Exp $   *  $Id: dev_vr41xx.c,v 1.35 2006/01/01 13:17:18 debug Exp $
29   *     *  
30   *  VR41xx (actually, VR4122 and VR4131) misc functions.   *  VR41xx (actually, VR4122 and VR4131) misc functions.
31   *   *
# Line 389  static uint64_t vr41xx_kiu(struct cpu *c Line 389  static uint64_t vr41xx_kiu(struct cpu *c
389  /*  /*
390   *  dev_vr41xx_access():   *  dev_vr41xx_access():
391   */   */
392  int dev_vr41xx_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(vr41xx)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
393  {  {
394          struct vr41xx_data *d = (struct vr41xx_data *) extra;          struct vr41xx_data *d = (struct vr41xx_data *) extra;
395          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
396          int regnr;          int regnr;
397          int revision = 0;          int revision = 0;
398    
399          idata = memory_readmax64(cpu, data, len);          if (writeflag == MEM_WRITE)
400                    idata = memory_readmax64(cpu, data, len);
401    
402          regnr = relative_addr / sizeof(uint64_t);          regnr = relative_addr / sizeof(uint64_t);
403    
404          /*  KIU ("Keyboard Interface Unit") is handled separately.  */          /*  KIU ("Keyboard Interface Unit") is handled separately.  */
# Line 544  struct vr41xx_data *dev_vr41xx_init(stru Line 544  struct vr41xx_data *dev_vr41xx_init(stru
544          struct memory *mem, int cpumodel)          struct memory *mem, int cpumodel)
545  {  {
546          uint64_t baseaddr = 0;          uint64_t baseaddr = 0;
547            char tmps[100];
548          struct vr41xx_data *d = malloc(sizeof(struct vr41xx_data));          struct vr41xx_data *d = malloc(sizeof(struct vr41xx_data));
549    
550          if (d == NULL) {          if (d == NULL) {
551                  fprintf(stderr, "out of memory\n");                  fprintf(stderr, "out of memory\n");
552                  exit(1);                  exit(1);
# Line 555  struct vr41xx_data *dev_vr41xx_init(stru Line 557  struct vr41xx_data *dev_vr41xx_init(stru
557    
558          /*  TODO: VRC4173 has the KIU at offset 0x100?  */          /*  TODO: VRC4173 has the KIU at offset 0x100?  */
559          d->kiu_offset = 0x180;          d->kiu_offset = 0x180;
560          d->kiu_console_handle = console_start_slave_inputonly(machine, "kiu");          d->kiu_console_handle = console_start_slave_inputonly(
561                machine, "kiu", 1);
562          d->kiu_irq_nr = VRIP_INTR_KIU;          d->kiu_irq_nr = VRIP_INTR_KIU;
563    
564          switch (cpumodel) {          switch (cpumodel) {
# Line 567  struct vr41xx_data *dev_vr41xx_init(stru Line 570  struct vr41xx_data *dev_vr41xx_init(stru
570                  break;                  break;
571          case 4181:          case 4181:
572                  baseaddr = 0xa000000;                  baseaddr = 0xa000000;
573                  dev_ram_init(mem, 0xb000000, 0x1000000, DEV_RAM_MIRROR,                  dev_ram_init(machine, 0xb000000, 0x1000000, DEV_RAM_MIRROR,
574                      0xa000000);                      0xa000000);
575                  break;                  break;
576          case 4122:          case 4122:
# Line 580  struct vr41xx_data *dev_vr41xx_init(stru Line 583  struct vr41xx_data *dev_vr41xx_init(stru
583          }          }
584    
585          memory_device_register(mem, "vr41xx", baseaddr, DEV_VR41XX_LENGTH,          memory_device_register(mem, "vr41xx", baseaddr, DEV_VR41XX_LENGTH,
586              dev_vr41xx_access, (void *)d, MEM_DEFAULT, NULL);              dev_vr41xx_access, (void *)d, DM_DEFAULT, NULL);
587    
588          /*          /*
589           *  TODO: Find out which controllers are at which addresses on           *  TODO: Find out which controllers are at which addresses on
590           *  which chips.           *  which chips.
591           */           */
592          if (cpumodel == 4131) {          if (cpumodel == 4131) {
593                  dev_ns16550_init(machine, mem, baseaddr + 0x800,                  snprintf(tmps, sizeof(tmps), "ns16550 irq=%i addr=0x%llx "
594                      8 + VRIP_INTR_SIU, 1, 1, "vr41xx siu");                      "name2=siu", 8+VRIP_INTR_SIU, (long long)(baseaddr+0x800));
595                    device_add(machine, tmps);
596          } else {          } else {
597                  /*  This is used by Linux and NetBSD:  */                  /*  This is used by Linux and NetBSD:  */
598                  dev_ns16550_init(machine, mem, 0xc000000,                  snprintf(tmps, sizeof(tmps), "ns16550 irq=%i addr=0x%x "
599                      8 + VRIP_INTR_SIU, 1, 1, "vr41xx serial");                      "name2=serial", 8+VRIP_INTR_SIU, 0xc000000);
600                    device_add(machine, tmps);
601          }          }
602    
603          /*  Hm... maybe this should not be here.  TODO  */          /*  Hm... maybe this should not be here.  TODO  */
# Line 603  struct vr41xx_data *dev_vr41xx_init(stru Line 608  struct vr41xx_data *dev_vr41xx_init(stru
608    
609          /*  Some machines (?) use ISA space at 0x15000000 instead of          /*  Some machines (?) use ISA space at 0x15000000 instead of
610              0x14000000, eg IBM WorkPad Z50.  */              0x14000000, eg IBM WorkPad Z50.  */
611          dev_ram_init(mem, 0x15000000, 0x1000000, DEV_RAM_MIRROR, 0x14000000);          dev_ram_init(machine, 0x15000000, 0x1000000, DEV_RAM_MIRROR,
612                0x14000000);
613    
614          return d;          return d;
615  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26