OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [mn10300/] [dv-mn103iop.c] - Diff between revs 834 and 842

Only display areas with differences | Details | Blame | View Log

Rev 834 Rev 842
/*  This file is part of the program GDB, the GNU debugger.
/*  This file is part of the program GDB, the GNU debugger.
 
 
    Copyright (C) 1998, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Copyright (C) 1998, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
    Contributed by Cygnus Solutions.
 
 
    This program is free software; you can redistribute it and/or modify
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    (at your option) any later version.
 
 
    This program is distributed in the hope that it will be useful,
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    GNU General Public License for more details.
 
 
    You should have received a copy of the GNU General Public License
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
    */
    */
 
 
#include "sim-main.h"
#include "sim-main.h"
#include "hw-main.h"
#include "hw-main.h"
 
 
/* DEVICE
/* DEVICE
 
 
 
 
   mn103iop - mn103002 I/O ports 0-3.
   mn103iop - mn103002 I/O ports 0-3.
 
 
 
 
   DESCRIPTION
   DESCRIPTION
 
 
   Implements the mn103002 i/o ports as described in the mn103002 user guide.
   Implements the mn103002 i/o ports as described in the mn103002 user guide.
 
 
 
 
   PROPERTIES
   PROPERTIES
 
 
   reg = <ioport-addr> <ioport-size> ...
   reg = <ioport-addr> <ioport-size> ...
 
 
 
 
   BUGS
   BUGS
 
 
   */
   */
 
 
 
 
/* The I/O ports' registers' address block */
/* The I/O ports' registers' address block */
 
 
struct mn103iop_block {
struct mn103iop_block {
  unsigned_word base;
  unsigned_word base;
  unsigned_word bound;
  unsigned_word bound;
};
};
 
 
 
 
 
 
enum io_port_register_types {
enum io_port_register_types {
  P0OUT,
  P0OUT,
  P1OUT,
  P1OUT,
  P2OUT,
  P2OUT,
  P3OUT,
  P3OUT,
  P0MD,
  P0MD,
  P1MD,
  P1MD,
  P2MD,
  P2MD,
  P3MD,
  P3MD,
  P2SS,
  P2SS,
  P4SS,
  P4SS,
  P0DIR,
  P0DIR,
  P1DIR,
  P1DIR,
  P2DIR,
  P2DIR,
  P3DIR,
  P3DIR,
  P0IN,
  P0IN,
  P1IN,
  P1IN,
  P2IN,
  P2IN,
  P3IN,
  P3IN,
};
};
 
 
#define NR_PORTS  4
#define NR_PORTS  4
 
 
enum {
enum {
  OUTPUT_BLOCK,
  OUTPUT_BLOCK,
  MODE_BLOCK,
  MODE_BLOCK,
  DED_CTRL_BLOCK,
  DED_CTRL_BLOCK,
  CTRL_BLOCK,
  CTRL_BLOCK,
  PIN_BLOCK,
  PIN_BLOCK,
  NR_BLOCKS
  NR_BLOCKS
};
};
 
 
typedef struct _mn10300_ioport {
typedef struct _mn10300_ioport {
  unsigned8 output, output_mode, control, pin;
  unsigned8 output, output_mode, control, pin;
  struct hw_event *event;
  struct hw_event *event;
} mn10300_ioport;
} mn10300_ioport;
 
 
 
 
 
 
struct mn103iop {
struct mn103iop {
  struct mn103iop_block block[NR_BLOCKS];
  struct mn103iop_block block[NR_BLOCKS];
  mn10300_ioport port[NR_PORTS];
  mn10300_ioport port[NR_PORTS];
  unsigned8      p2ss, p4ss;
  unsigned8      p2ss, p4ss;
};
};
 
 
 
 
/* Finish off the partially created hw device.  Attach our local
/* Finish off the partially created hw device.  Attach our local
   callbacks.  Wire up our port names etc */
   callbacks.  Wire up our port names etc */
 
 
static hw_io_read_buffer_method mn103iop_io_read_buffer;
static hw_io_read_buffer_method mn103iop_io_read_buffer;
static hw_io_write_buffer_method mn103iop_io_write_buffer;
static hw_io_write_buffer_method mn103iop_io_write_buffer;
 
 
static void
static void
attach_mn103iop_regs (struct hw *me,
attach_mn103iop_regs (struct hw *me,
                      struct mn103iop *io_port)
                      struct mn103iop *io_port)
{
{
  int i;
  int i;
  unsigned_word attach_address;
  unsigned_word attach_address;
  int attach_space;
  int attach_space;
  unsigned attach_size;
  unsigned attach_size;
  reg_property_spec reg;
  reg_property_spec reg;
 
 
  if (hw_find_property (me, "reg") == NULL)
  if (hw_find_property (me, "reg") == NULL)
    hw_abort (me, "Missing \"reg\" property");
    hw_abort (me, "Missing \"reg\" property");
 
 
  for (i=0; i < NR_BLOCKS; ++i )
  for (i=0; i < NR_BLOCKS; ++i )
    {
    {
      if (!hw_find_reg_array_property (me, "reg", i, &reg))
      if (!hw_find_reg_array_property (me, "reg", i, &reg))
        hw_abort (me, "\"reg\" property must contain five addr/size entries");
        hw_abort (me, "\"reg\" property must contain five addr/size entries");
      hw_unit_address_to_attach_address (hw_parent (me),
      hw_unit_address_to_attach_address (hw_parent (me),
                                         &reg.address,
                                         &reg.address,
                                         &attach_space,
                                         &attach_space,
                                         &attach_address,
                                         &attach_address,
                                         me);
                                         me);
      io_port->block[i].base = attach_address;
      io_port->block[i].base = attach_address;
      hw_unit_size_to_attach_size (hw_parent (me),
      hw_unit_size_to_attach_size (hw_parent (me),
                                   &reg.size,
                                   &reg.size,
                                   &attach_size, me);
                                   &attach_size, me);
      io_port->block[i].bound = attach_address + (attach_size - 1);
      io_port->block[i].bound = attach_address + (attach_size - 1);
      hw_attach_address (hw_parent (me),
      hw_attach_address (hw_parent (me),
                         0,
                         0,
                         attach_space, attach_address, attach_size,
                         attach_space, attach_address, attach_size,
                         me);
                         me);
    }
    }
}
}
 
 
static void
static void
mn103iop_finish (struct hw *me)
mn103iop_finish (struct hw *me)
{
{
  struct mn103iop *io_port;
  struct mn103iop *io_port;
  int i;
  int i;
 
 
  io_port = HW_ZALLOC (me, struct mn103iop);
  io_port = HW_ZALLOC (me, struct mn103iop);
  set_hw_data (me, io_port);
  set_hw_data (me, io_port);
  set_hw_io_read_buffer (me, mn103iop_io_read_buffer);
  set_hw_io_read_buffer (me, mn103iop_io_read_buffer);
  set_hw_io_write_buffer (me, mn103iop_io_write_buffer);
  set_hw_io_write_buffer (me, mn103iop_io_write_buffer);
 
 
  /* Attach ourself to our parent bus */
  /* Attach ourself to our parent bus */
  attach_mn103iop_regs (me, io_port);
  attach_mn103iop_regs (me, io_port);
 
 
  /* Initialize the i/o port registers. */
  /* Initialize the i/o port registers. */
  for ( i=0; i<NR_PORTS; ++i )
  for ( i=0; i<NR_PORTS; ++i )
    {
    {
      io_port->port[i].output = 0;
      io_port->port[i].output = 0;
      io_port->port[i].output_mode = 0;
      io_port->port[i].output_mode = 0;
      io_port->port[i].control = 0;
      io_port->port[i].control = 0;
      io_port->port[i].pin = 0;
      io_port->port[i].pin = 0;
    }
    }
  io_port->port[2].output_mode = 0xff;
  io_port->port[2].output_mode = 0xff;
  io_port->p2ss = 0;
  io_port->p2ss = 0;
  io_port->p4ss = 0x0f;
  io_port->p4ss = 0x0f;
}
}
 
 
 
 
/* read and write */
/* read and write */
 
 
static int
static int
decode_addr (struct hw *me,
decode_addr (struct hw *me,
             struct mn103iop *io_port,
             struct mn103iop *io_port,
             unsigned_word address)
             unsigned_word address)
{
{
  unsigned_word offset;
  unsigned_word offset;
  offset = address - io_port->block[0].base;
  offset = address - io_port->block[0].base;
  switch (offset)
  switch (offset)
    {
    {
    case 0x00: return P0OUT;
    case 0x00: return P0OUT;
    case 0x01: return P1OUT;
    case 0x01: return P1OUT;
    case 0x04: return P2OUT;
    case 0x04: return P2OUT;
    case 0x05: return P3OUT;
    case 0x05: return P3OUT;
    case 0x20: return P0MD;
    case 0x20: return P0MD;
    case 0x21: return P1MD;
    case 0x21: return P1MD;
    case 0x24: return P2MD;
    case 0x24: return P2MD;
    case 0x25: return P3MD;
    case 0x25: return P3MD;
    case 0x44: return P2SS;
    case 0x44: return P2SS;
    case 0x48: return P4SS;
    case 0x48: return P4SS;
    case 0x60: return P0DIR;
    case 0x60: return P0DIR;
    case 0x61: return P1DIR;
    case 0x61: return P1DIR;
    case 0x64: return P2DIR;
    case 0x64: return P2DIR;
    case 0x65: return P3DIR;
    case 0x65: return P3DIR;
    case 0x80: return P0IN;
    case 0x80: return P0IN;
    case 0x81: return P1IN;
    case 0x81: return P1IN;
    case 0x84: return P2IN;
    case 0x84: return P2IN;
    case 0x85: return P3IN;
    case 0x85: return P3IN;
    default:
    default:
      {
      {
        hw_abort (me, "bad address");
        hw_abort (me, "bad address");
        return -1;
        return -1;
      }
      }
    }
    }
}
}
 
 
 
 
static void
static void
read_output_reg (struct hw *me,
read_output_reg (struct hw *me,
                 struct mn103iop *io_port,
                 struct mn103iop *io_port,
                 unsigned_word io_port_reg,
                 unsigned_word io_port_reg,
                 const void *dest,
                 const void *dest,
                 unsigned  nr_bytes)
                 unsigned  nr_bytes)
{
{
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      *(unsigned8 *)dest = io_port->port[io_port_reg].output;
      *(unsigned8 *)dest = io_port->port[io_port_reg].output;
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes from P%dOUT.", nr_bytes,
      hw_abort (me, "bad read size of %d bytes from P%dOUT.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
read_output_mode_reg (struct hw *me,
read_output_mode_reg (struct hw *me,
                      struct mn103iop *io_port,
                      struct mn103iop *io_port,
                      unsigned_word io_port_reg,
                      unsigned_word io_port_reg,
                      const void *dest,
                      const void *dest,
                      unsigned  nr_bytes)
                      unsigned  nr_bytes)
{
{
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      /* check if there are fields which can't be written and
      /* check if there are fields which can't be written and
         take appropriate action depending what bits are set */
         take appropriate action depending what bits are set */
      *(unsigned8 *)dest = io_port->port[io_port_reg].output_mode;
      *(unsigned8 *)dest = io_port->port[io_port_reg].output_mode;
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes to P%dMD.", nr_bytes,
      hw_abort (me, "bad read size of %d bytes to P%dMD.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
read_control_reg (struct hw *me,
read_control_reg (struct hw *me,
                  struct mn103iop *io_port,
                  struct mn103iop *io_port,
                  unsigned_word io_port_reg,
                  unsigned_word io_port_reg,
                  const void *dest,
                  const void *dest,
                  unsigned  nr_bytes)
                  unsigned  nr_bytes)
{
{
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      *(unsigned8 *)dest = io_port->port[io_port_reg].control;
      *(unsigned8 *)dest = io_port->port[io_port_reg].control;
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes to P%dDIR.", nr_bytes,
      hw_abort (me, "bad read size of %d bytes to P%dDIR.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
read_pin_reg (struct hw *me,
read_pin_reg (struct hw *me,
              struct mn103iop *io_port,
              struct mn103iop *io_port,
              unsigned_word io_port_reg,
              unsigned_word io_port_reg,
              const void *dest,
              const void *dest,
              unsigned  nr_bytes)
              unsigned  nr_bytes)
{
{
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      *(unsigned8 *)dest = io_port->port[io_port_reg].pin;
      *(unsigned8 *)dest = io_port->port[io_port_reg].pin;
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes to P%dIN.", nr_bytes,
      hw_abort (me, "bad read size of %d bytes to P%dIN.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
read_dedicated_control_reg (struct hw *me,
read_dedicated_control_reg (struct hw *me,
                            struct mn103iop *io_port,
                            struct mn103iop *io_port,
                            unsigned_word io_port_reg,
                            unsigned_word io_port_reg,
                            const void *dest,
                            const void *dest,
                            unsigned  nr_bytes)
                            unsigned  nr_bytes)
{
{
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      /* select on io_port_reg: */
      /* select on io_port_reg: */
      if ( io_port_reg == P2SS )
      if ( io_port_reg == P2SS )
        {
        {
          *(unsigned8 *)dest = io_port->p2ss;
          *(unsigned8 *)dest = io_port->p2ss;
        }
        }
      else
      else
        {
        {
          *(unsigned8 *)dest = io_port->p4ss;
          *(unsigned8 *)dest = io_port->p4ss;
        }
        }
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes to PSS.", nr_bytes);
      hw_abort (me, "bad read size of %d bytes to PSS.", nr_bytes);
    }
    }
}
}
 
 
 
 
static unsigned
static unsigned
mn103iop_io_read_buffer (struct hw *me,
mn103iop_io_read_buffer (struct hw *me,
                         void *dest,
                         void *dest,
                         int space,
                         int space,
                         unsigned_word base,
                         unsigned_word base,
                         unsigned nr_bytes)
                         unsigned nr_bytes)
{
{
  struct mn103iop *io_port = hw_data (me);
  struct mn103iop *io_port = hw_data (me);
  enum io_port_register_types io_port_reg;
  enum io_port_register_types io_port_reg;
  HW_TRACE ((me, "read 0x%08lx %d", (long) base, (int) nr_bytes));
  HW_TRACE ((me, "read 0x%08lx %d", (long) base, (int) nr_bytes));
 
 
  io_port_reg = decode_addr (me, io_port, base);
  io_port_reg = decode_addr (me, io_port, base);
  switch (io_port_reg)
  switch (io_port_reg)
    {
    {
    /* Port output registers */
    /* Port output registers */
    case P0OUT:
    case P0OUT:
    case P1OUT:
    case P1OUT:
    case P2OUT:
    case P2OUT:
    case P3OUT:
    case P3OUT:
      read_output_reg(me, io_port, io_port_reg-P0OUT, dest, nr_bytes);
      read_output_reg(me, io_port, io_port_reg-P0OUT, dest, nr_bytes);
      break;
      break;
 
 
    /* Port output mode registers */
    /* Port output mode registers */
    case P0MD:
    case P0MD:
    case P1MD:
    case P1MD:
    case P2MD:
    case P2MD:
    case P3MD:
    case P3MD:
      read_output_mode_reg(me, io_port, io_port_reg-P0MD, dest, nr_bytes);
      read_output_mode_reg(me, io_port, io_port_reg-P0MD, dest, nr_bytes);
      break;
      break;
 
 
    /* Port control registers */
    /* Port control registers */
    case P0DIR:
    case P0DIR:
    case P1DIR:
    case P1DIR:
    case P2DIR:
    case P2DIR:
    case P3DIR:
    case P3DIR:
      read_control_reg(me, io_port, io_port_reg-P0DIR, dest, nr_bytes);
      read_control_reg(me, io_port, io_port_reg-P0DIR, dest, nr_bytes);
      break;
      break;
 
 
    /* Port pin registers */
    /* Port pin registers */
    case P0IN:
    case P0IN:
    case P1IN:
    case P1IN:
    case P2IN:
    case P2IN:
      read_pin_reg(me, io_port, io_port_reg-P0IN, dest, nr_bytes);
      read_pin_reg(me, io_port, io_port_reg-P0IN, dest, nr_bytes);
      break;
      break;
 
 
    case P2SS:
    case P2SS:
    case P4SS:
    case P4SS:
      read_dedicated_control_reg(me, io_port, io_port_reg, dest, nr_bytes);
      read_dedicated_control_reg(me, io_port, io_port_reg, dest, nr_bytes);
      break;
      break;
 
 
    default:
    default:
      hw_abort(me, "invalid address");
      hw_abort(me, "invalid address");
    }
    }
 
 
  return nr_bytes;
  return nr_bytes;
}
}
 
 
 
 
static void
static void
write_output_reg (struct hw *me,
write_output_reg (struct hw *me,
                  struct mn103iop *io_port,
                  struct mn103iop *io_port,
                  unsigned_word io_port_reg,
                  unsigned_word io_port_reg,
                  const void *source,
                  const void *source,
                  unsigned  nr_bytes)
                  unsigned  nr_bytes)
{
{
  unsigned8 buf = *(unsigned8 *)source;
  unsigned8 buf = *(unsigned8 *)source;
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
        {
        {
          hw_abort(me, "Cannot write to read-only bits of P3OUT.");
          hw_abort(me, "Cannot write to read-only bits of P3OUT.");
        }
        }
      else
      else
        {
        {
          io_port->port[io_port_reg].output = buf;
          io_port->port[io_port_reg].output = buf;
        }
        }
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad read size of %d bytes from P%dOUT.", nr_bytes,
      hw_abort (me, "bad read size of %d bytes from P%dOUT.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
write_output_mode_reg (struct hw *me,
write_output_mode_reg (struct hw *me,
                       struct mn103iop *io_port,
                       struct mn103iop *io_port,
                       unsigned_word io_port_reg,
                       unsigned_word io_port_reg,
                       const void *source,
                       const void *source,
                       unsigned  nr_bytes)
                       unsigned  nr_bytes)
{
{
  unsigned8 buf = *(unsigned8 *)source;
  unsigned8 buf = *(unsigned8 *)source;
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      /* check if there are fields which can't be written and
      /* check if there are fields which can't be written and
         take appropriate action depending what bits are set */
         take appropriate action depending what bits are set */
      if ( ( io_port_reg == 3 && (buf & 0xfc) != 0 )
      if ( ( io_port_reg == 3 && (buf & 0xfc) != 0 )
           || ( (io_port_reg == 0 || io_port_reg == 1)  && (buf & 0xfe) != 0 ) )
           || ( (io_port_reg == 0 || io_port_reg == 1)  && (buf & 0xfe) != 0 ) )
        {
        {
          hw_abort(me, "Cannot write to read-only bits of output mode register.");
          hw_abort(me, "Cannot write to read-only bits of output mode register.");
        }
        }
      else
      else
        {
        {
          io_port->port[io_port_reg].output_mode = buf;
          io_port->port[io_port_reg].output_mode = buf;
        }
        }
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad write size of %d bytes to P%dMD.", nr_bytes,
      hw_abort (me, "bad write size of %d bytes to P%dMD.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
write_control_reg (struct hw *me,
write_control_reg (struct hw *me,
                   struct mn103iop *io_port,
                   struct mn103iop *io_port,
                   unsigned_word io_port_reg,
                   unsigned_word io_port_reg,
                   const void *source,
                   const void *source,
                   unsigned  nr_bytes)
                   unsigned  nr_bytes)
{
{
  unsigned8 buf = *(unsigned8 *)source;
  unsigned8 buf = *(unsigned8 *)source;
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
      if ( io_port_reg == 3 && (buf & 0xfc) != 0 )
        {
        {
          hw_abort(me, "Cannot write to read-only bits of P3DIR.");
          hw_abort(me, "Cannot write to read-only bits of P3DIR.");
        }
        }
      else
      else
        {
        {
          io_port->port[io_port_reg].control = buf;
          io_port->port[io_port_reg].control = buf;
        }
        }
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad write size of %d bytes to P%dDIR.", nr_bytes,
      hw_abort (me, "bad write size of %d bytes to P%dDIR.", nr_bytes,
                io_port_reg);
                io_port_reg);
    }
    }
}
}
 
 
 
 
static void
static void
write_dedicated_control_reg (struct hw *me,
write_dedicated_control_reg (struct hw *me,
                             struct mn103iop *io_port,
                             struct mn103iop *io_port,
                             unsigned_word io_port_reg,
                             unsigned_word io_port_reg,
                             const void *source,
                             const void *source,
                             unsigned  nr_bytes)
                             unsigned  nr_bytes)
{
{
  unsigned8 buf = *(unsigned8 *)source;
  unsigned8 buf = *(unsigned8 *)source;
  if ( nr_bytes == 1 )
  if ( nr_bytes == 1 )
    {
    {
      /* select on io_port_reg: */
      /* select on io_port_reg: */
      if ( io_port_reg == P2SS )
      if ( io_port_reg == P2SS )
        {
        {
          if ( (buf && 0xfc)  != 0 )
          if ( (buf && 0xfc)  != 0 )
            {
            {
              hw_abort(me, "Cannot write to read-only bits in p2ss.");
              hw_abort(me, "Cannot write to read-only bits in p2ss.");
            }
            }
          else
          else
            {
            {
              io_port->p2ss = buf;
              io_port->p2ss = buf;
            }
            }
        }
        }
      else
      else
        {
        {
          if ( (buf && 0xf0) != 0 )
          if ( (buf && 0xf0) != 0 )
            {
            {
              hw_abort(me, "Cannot write to read-only bits in p4ss.");
              hw_abort(me, "Cannot write to read-only bits in p4ss.");
            }
            }
          else
          else
            {
            {
              io_port->p4ss = buf;
              io_port->p4ss = buf;
            }
            }
        }
        }
    }
    }
  else
  else
    {
    {
      hw_abort (me, "bad write size of %d bytes to PSS.", nr_bytes);
      hw_abort (me, "bad write size of %d bytes to PSS.", nr_bytes);
    }
    }
}
}
 
 
 
 
static unsigned
static unsigned
mn103iop_io_write_buffer (struct hw *me,
mn103iop_io_write_buffer (struct hw *me,
                          const void *source,
                          const void *source,
                          int space,
                          int space,
                          unsigned_word base,
                          unsigned_word base,
                          unsigned nr_bytes)
                          unsigned nr_bytes)
{
{
  struct mn103iop *io_port = hw_data (me);
  struct mn103iop *io_port = hw_data (me);
  enum io_port_register_types io_port_reg;
  enum io_port_register_types io_port_reg;
  HW_TRACE ((me, "write 0x%08lx %d", (long) base, (int) nr_bytes));
  HW_TRACE ((me, "write 0x%08lx %d", (long) base, (int) nr_bytes));
 
 
  io_port_reg = decode_addr (me, io_port, base);
  io_port_reg = decode_addr (me, io_port, base);
  switch (io_port_reg)
  switch (io_port_reg)
    {
    {
    /* Port output registers */
    /* Port output registers */
    case P0OUT:
    case P0OUT:
    case P1OUT:
    case P1OUT:
    case P2OUT:
    case P2OUT:
    case P3OUT:
    case P3OUT:
      write_output_reg(me, io_port, io_port_reg-P0OUT, source, nr_bytes);
      write_output_reg(me, io_port, io_port_reg-P0OUT, source, nr_bytes);
      break;
      break;
 
 
    /* Port output mode registers */
    /* Port output mode registers */
    case P0MD:
    case P0MD:
    case P1MD:
    case P1MD:
    case P2MD:
    case P2MD:
    case P3MD:
    case P3MD:
      write_output_mode_reg(me, io_port, io_port_reg-P0MD, source, nr_bytes);
      write_output_mode_reg(me, io_port, io_port_reg-P0MD, source, nr_bytes);
      break;
      break;
 
 
    /* Port control registers */
    /* Port control registers */
    case P0DIR:
    case P0DIR:
    case P1DIR:
    case P1DIR:
    case P2DIR:
    case P2DIR:
    case P3DIR:
    case P3DIR:
      write_control_reg(me, io_port, io_port_reg-P0DIR, source, nr_bytes);
      write_control_reg(me, io_port, io_port_reg-P0DIR, source, nr_bytes);
      break;
      break;
 
 
    /* Port pin registers */
    /* Port pin registers */
    case P0IN:
    case P0IN:
    case P1IN:
    case P1IN:
    case P2IN:
    case P2IN:
      hw_abort(me, "Cannot write to pin register.");
      hw_abort(me, "Cannot write to pin register.");
      break;
      break;
 
 
    case P2SS:
    case P2SS:
    case P4SS:
    case P4SS:
      write_dedicated_control_reg(me, io_port, io_port_reg, source, nr_bytes);
      write_dedicated_control_reg(me, io_port, io_port_reg, source, nr_bytes);
      break;
      break;
 
 
    default:
    default:
      hw_abort(me, "invalid address");
      hw_abort(me, "invalid address");
    }
    }
 
 
  return nr_bytes;
  return nr_bytes;
}
}
 
 
 
 
const struct hw_descriptor dv_mn103iop_descriptor[] = {
const struct hw_descriptor dv_mn103iop_descriptor[] = {
  { "mn103iop", mn103iop_finish, },
  { "mn103iop", mn103iop_finish, },
  { NULL },
  { NULL },
};
};
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.