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

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

revision 28 by dpavlin, Mon Oct 8 16:20:26 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  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_asc.c,v 1.81 2006/07/21 16:55:41 debug Exp $   *  $Id: dev_asc.c,v 1.86 2007/06/15 18:44:19 debug Exp $
29   *   *
30   *  'asc' SCSI controller for some DECstation/DECsystem models and PICA-61.   *  COMMENT: NCR53C9X "ASC" SCSI controller
31     *
32     *  This is the SCSI controller used in some DECstation/DECsystem models and
33     *  the PICA-61 machine.
34   *   *
35   *  Supposed to support SCSI-1 and SCSI-2. I've not yet found any docs   *  Supposed to support SCSI-1 and SCSI-2. I've not yet found any docs
36   *  on NCR53C9X, so I'll try to implement this device from LSI53CF92A docs   *  on NCR53C9X, so I'll try to implement this device from LSI53CF92A docs
# Line 101  struct asc_data { Line 104  struct asc_data {
104          int             mode;          int             mode;
105    
106          void            *turbochannel;          void            *turbochannel;
107          int             irq_nr;          struct interrupt irq;
108          int             irq_caused_last_time;          int             irq_asserted;
109    
110          /*  Current state and transfer:  */          /*  Current state and transfer:  */
111          int             cur_state;          int             cur_state;
# Line 155  static int dev_asc_select(struct cpu *cp Line 158  static int dev_asc_select(struct cpu *cp
158  DEVICE_TICK(asc)  DEVICE_TICK(asc)
159  {  {
160          struct asc_data *d = extra;          struct asc_data *d = extra;
161            int new_assert = d->reg_ro[NCR_STAT] & NCRSTAT_INT;
162    
163            if (new_assert && !d->irq_asserted)
164                    INTERRUPT_ASSERT(d->irq);
165    
166          if (d->reg_ro[NCR_STAT] & NCRSTAT_INT)          d->irq_asserted = new_assert;
                 cpu_interrupt(cpu, d->irq_nr);  
167  }  }
168    
169    
# Line 369  if (d->dma_controller != NULL) Line 375  if (d->dma_controller != NULL)
375                                              (int)len, (int)len2);  */                                              (int)len, (int)len2);  */
376    
377                                          d->xferp->data_in_len -= len2;                                          d->xferp->data_in_len -= len2;
378                                          n = malloc(d->xferp->data_in_len);                                          CHECK_ALLOCATION(n =
379                                          if (n == NULL) {                                              malloc(d->xferp->data_in_len));
                                                 fprintf(stderr, "out of memory"  
                                                     " in dev_asc\n");  
                                                 exit(1);  
                                         }  
380                                          memcpy(n, d->xferp->data_in + len2,                                          memcpy(n, d->xferp->data_in + len2,
381                                              d->xferp->data_in_len);                                              d->xferp->data_in_len);
382                                          free(d->xferp->data_in);                                          free(d->xferp->data_in);
# Line 504  fatal("TODO.......asdgasin\n"); Line 506  fatal("TODO.......asdgasin\n");
506                          }                          }
507    
508                          newlen = oldlen + d->n_bytes_in_fifo;                          newlen = oldlen + d->n_bytes_in_fifo;
509                          d->xferp->msg_out = realloc(d->xferp->msg_out, newlen);                          CHECK_ALLOCATION(d->xferp->msg_out =
510                                realloc(d->xferp->msg_out, newlen));
511                          d->xferp->msg_out_len = newlen;                          d->xferp->msg_out_len = newlen;
                         if (d->xferp->msg_out == NULL) {  
                                 fprintf(stderr, "out of memory realloc'ing "  
                                     "msg_out\n");  
                                 exit(1);  
                         }  
512    
513                          i = oldlen;                          i = oldlen;
514                          while (d->fifo_in != d->fifo_out) {                          while (d->fifo_in != d->fifo_out) {
# Line 1196  break; Line 1194  break;
1194                          d->reg_ro[NCR_STAT] = PHASE_COMMAND;                          d->reg_ro[NCR_STAT] = PHASE_COMMAND;
1195                  }                  }
1196    
1197                  cpu_interrupt_ack(cpu, d->irq_nr);                  INTERRUPT_DEASSERT(d->irq);
1198                    d->irq_asserted = 0;
1199          }          }
1200    
1201          if (regnr == NCR_CFG1) {          if (regnr == NCR_CFG1) {
# Line 1226  break; Line 1225  break;
1225   *  Register an 'asc' device.   *  Register an 'asc' device.
1226   */   */
1227  void dev_asc_init(struct machine *machine, struct memory *mem,  void dev_asc_init(struct machine *machine, struct memory *mem,
1228          uint64_t baseaddr, int irq_nr, void *turbochannel,          uint64_t baseaddr, char *irq_path, void *turbochannel, int mode,
         int mode,  
1229          size_t (*dma_controller)(void *dma_controller_data,          size_t (*dma_controller)(void *dma_controller_data,
1230                  unsigned char *data, size_t len, int writeflag),                  unsigned char *data, size_t len, int writeflag),
1231          void *dma_controller_data)          void *dma_controller_data)
1232  {  {
1233          struct asc_data *d;          struct asc_data *d;
1234    
1235          d = malloc(sizeof(struct asc_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct asc_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
1236          memset(d, 0, sizeof(struct asc_data));          memset(d, 0, sizeof(struct asc_data));
1237          d->irq_nr       = irq_nr;  
1238            INTERRUPT_CONNECT(irq_path, d->irq);
1239          d->turbochannel = turbochannel;          d->turbochannel = turbochannel;
1240          d->mode         = mode;          d->mode         = mode;
1241    
1242          d->reg_ro[NCR_CFG3] = NCRF9XCFG3_CDB;          d->reg_ro[NCR_CFG3] = NCRF9XCFG3_CDB;
1243    
1244          d->dma_address_reg_memory = malloc(machine->arch_pagesize);          CHECK_ALLOCATION(d->dma_address_reg_memory =
1245          d->dma = malloc(ASC_DMA_SIZE);              malloc(machine->arch_pagesize));
         if (d->dma == NULL || d->dma_address_reg_memory == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
1246          memset(d->dma_address_reg_memory, 0, machine->arch_pagesize);          memset(d->dma_address_reg_memory, 0, machine->arch_pagesize);
1247    
1248            CHECK_ALLOCATION(d->dma = malloc(ASC_DMA_SIZE));
1249          memset(d->dma, 0, ASC_DMA_SIZE);          memset(d->dma, 0, ASC_DMA_SIZE);
1250    
1251          d->dma_controller      = dma_controller;          d->dma_controller      = dma_controller;
# Line 1272  void dev_asc_init(struct machine *machin Line 1265  void dev_asc_init(struct machine *machin
1265                      DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK, d->dma);                      DM_DYNTRANS_OK | DM_DYNTRANS_WRITE_OK, d->dma);
1266          }          }
1267    
1268          machine_add_tickfunction(machine, dev_asc_tick, d, ASC_TICK_SHIFT, 0.0);          machine_add_tickfunction(machine, dev_asc_tick, d, ASC_TICK_SHIFT);
1269  }  }
1270    

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

  ViewVC Help
Powered by ViewVC 1.1.26