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

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

revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2004-2006  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_z8530.c,v 1.9 2006/10/07 02:05:21 debug Exp $   *  $Id: dev_z8530.c,v 1.16 2007/06/15 19:57:34 debug Exp $
29   *     *  
30   *  Zilog "zs" serial controller (Z8530).   *  COMMENT: Zilog Z8530 "zs" serial controller
31   *   *
32   *  Features:   *  Features:
33   *      o)  Two channels, 0 = "channel B", 1 = "channel A".   *      o)  Two channels, 0 = "channel B", 1 = "channel A".
# Line 46  Line 46 
46  #include "console.h"  #include "console.h"
47  #include "cpu.h"  #include "cpu.h"
48  #include "device.h"  #include "device.h"
49    #include "interrupt.h"
50  #include "machine.h"  #include "machine.h"
51  #include "memory.h"  #include "memory.h"
52  #include "misc.h"  #include "misc.h"
# Line 61  Line 62 
62  #define DEV_Z8530_LENGTH        4  #define DEV_Z8530_LENGTH        4
63    
64  struct z8530_data {  struct z8530_data {
65          int             irq_nr;          struct interrupt irq;
         int             dma_irq_nr;  
66          int             irq_asserted;          int             irq_asserted;
67          int             addr_mult;          int             addr_mult;
68    
# Line 95  static void check_incoming(struct cpu *c Line 95  static void check_incoming(struct cpu *c
95  DEVICE_TICK(z8530)  DEVICE_TICK(z8530)
96  {  {
97          /*  Generate transmit and receive interrupts at regular intervals.  */          /*  Generate transmit and receive interrupts at regular intervals.  */
98          struct z8530_data *d = (struct z8530_data *) extra;          struct z8530_data *d = extra;
99          int asserted = 0;          int asserted = 0;
100    
101          if (d->rr[1][3] & ZSRR3_IP_B_TX && d->wr[0][1] & ZSWR1_TIE)          if (d->rr[1][3] & ZSRR3_IP_B_TX && d->wr[0][1] & ZSWR1_TIE)
# Line 116  DEVICE_TICK(z8530) Line 116  DEVICE_TICK(z8530)
116                  asserted = 0;                  asserted = 0;
117    
118          if (asserted)          if (asserted)
119                  cpu_interrupt(cpu, d->irq_nr);                  INTERRUPT_ASSERT(d->irq);
120    
121          if (d->irq_asserted && !asserted)          if (d->irq_asserted && !asserted)
122                  cpu_interrupt_ack(cpu, d->irq_nr);                  INTERRUPT_DEASSERT(d->irq);
123    
124          d->irq_asserted = asserted;          d->irq_asserted = asserted;
125  }  }
# Line 203  DEVICE_ACCESS(z8530) Line 203  DEVICE_ACCESS(z8530)
203    
204  DEVINIT(z8530)  DEVINIT(z8530)
205  {  {
206          struct z8530_data *d = malloc(sizeof(struct z8530_data));          struct z8530_data *d;
207          char tmp[100];          char tmp[100];
208    
209          if (d == NULL) {          CHECK_ALLOCATION(d = malloc(sizeof(struct z8530_data)));
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
210          memset(d, 0, sizeof(struct z8530_data));          memset(d, 0, sizeof(struct z8530_data));
211          d->irq_nr     = devinit->irq_nr;  
         d->dma_irq_nr = devinit->dma_irq_nr;  
212          d->addr_mult  = devinit->addr_mult;          d->addr_mult  = devinit->addr_mult;
213    
214            INTERRUPT_CONNECT(devinit->interrupt_path, d->irq);
215    
216          snprintf(tmp, sizeof(tmp), "%s [ch-b]", devinit->name);          snprintf(tmp, sizeof(tmp), "%s [ch-b]", devinit->name);
217          d->console_handle[0] = console_start_slave(devinit->machine, tmp,          d->console_handle[0] = console_start_slave(devinit->machine, tmp,
218              devinit->in_use);              devinit->in_use);
# Line 232  DEVINIT(z8530) Line 230  DEVINIT(z8530)
230              NULL);              NULL);
231    
232          machine_add_tickfunction(devinit->machine, dev_z8530_tick, d,          machine_add_tickfunction(devinit->machine, dev_z8530_tick, d,
233              ZS_TICK_SHIFT, 0.0);              ZS_TICK_SHIFT);
234    
235          devinit->return_ptr = (void *)(size_t) d->console_handle[0];          devinit->return_ptr = (void *)(size_t) d->console_handle[0];
236    

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

  ViewVC Help
Powered by ViewVC 1.1.26