if( self.transaction_direction == self.NVMEM_TRANSACTION_READ ):
                    self.nvmemlib.nvmem_read(  self.obj, self.nvmemory_sharedmemory_host_address, self.nvmemhandle, self.transaction_offset, self.transaction_size )
                elif( self.transaction_direction == self.NVMEM_TRANSACTION_WRITE ):
                    self.nvmemlib.nvmem_write(  self.obj, self.nvmemory_sharedmemory_host_address, self.nvmemhandle, self.transaction_offset, self.transaction_size )
                else:
                    error_msg = "syborg_nvmemorydevice: Transaction direction not set!" 
                    sys.exit( error_msg )
                self.transaction_offset_set = 0
                self.transaction_size_set = 0
                self.transaction_direction_set = 0
        elif offset == self.R_NVMEM_SHARED_MEMORY_BASE:
            self.shared_memory_base = value
        elif offset == self.R_NVMEM_SHARED_MEMORY_SIZE:
            self.shared_memory_size = value
        elif offset == self.R_NVMEM_ENABLE:
            if( value > 0 ):
                self.nvmemory_memregion = qemu.memregion( self.shared_memory_base, self.shared_memory_size )
                self.nvmemory_sharedmemory_host_address = self.nvmemory_memregion.region_host_addr()
                print"syborg_nvmemorydevice: host addr: 0x%08x" % (self.nvmemory_sharedmemory_host_address)
        else:
            reg_write_error = "syborg_nvmemorydevice: Illegal register write to: ", offset 
            sys.exit( reg_write_error )

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,nvmemorydevice"
    properties = {"drive_size":DEFAULT_DRIVE_SIZE, "sector_size":DEVICE_SECTOR_SIZE, "drive_image_name":DRIVE_NAME}

qemu.register_device(syborg_nvmemorydevice)
    offset >>= 2
    if offset == self.REG_LATCH:
      now = qemu.get_clock()
      if value >= 4:
        self.offset = self.data - now
      else:
        self.data = now + self.offset
        while value:
          self.data /= 1000
          value -= 1;
    elif offset == self.REG_DATA_LOW:
      self.data = (self.data & ~0xffffffff) | value
    elif offset == self.REG_DATA_HIGH:
      self.data = (self.data & 0xffffffff) | (value << 32)

  def save(self, f):
    f.put_s64(self.offset)
    f.put_u64(self.data)

  def load(self, f):
    self.offset = f.get_s64()
    self.data = f.get_u64()

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 0
  name = "syborg,rtc"
  properties = {}

qemu.register_device(syborg_timer)
Ejemplo n.º 3
0
  def read_reg(self, offset):
    offset >>= 2
    if offset == self.REG_ID:
      return 0xc600f000
    elif offset == self.REG_INT_ENABLE:
      return self.int_enable
    elif offset == self.REG_DMA_ADDR:
      return self.dma_addr
    elif offset == self.REG_DMA_SIZE:
      return self.dma_size
    return 0

  def save(self, f):
    f.put_u32(self.int_enable)
    f.put_u32(self.dma_addr)
    f.put_u32(self.dma_size)

  def load(self, f):
    self.int_enable = f.get_u32()
    self.dma_addr = f.get_u32()
    self.dma_size = f.get_u32()

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,usbtest"
  properties={"chardev":None}

qemu.register_device(syborg_usbtest)
Ejemplo n.º 4
0
    f.put_u32(self.int_enabled)
    f.put_u32(len(self.fifo) + 1)
    for d in [self.current] + self.fifo:
      f.put_u32(d.x)
      f.put_u32(d.y)
      f.put_u32(d.z)
      f.put_u32(d.buttons)

  def load(self, f):
    if self.fifo_size != f.get_u32():
      raise ValueError, "fifo size mismatch"
    self.int_enabled = f.get_u32()
    n = f.get_u32()
    self.fifo = []
    while n > 0:
      x = f.get_u32()
      y = f.get_u32()
      z = f.get_u32()
      buttons = f.get_u32()
      self.fifo.append(self.fifo_entry(x, y, z, buttons))
      n -= 1;
    self.current = self.fifo.pop(0);

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,pointer"
  properties = {"fifo-size":16, "absolute":1}

qemu.register_device(syborg_pointer)
Ejemplo n.º 5
0
    def read_reg(self, offset):
        offset >>= 2
        if offset == self.REG_ID:
            return 0xc600f000
        elif offset == self.REG_INT_ENABLE:
            return self.int_enable
        elif offset == self.REG_DMA_ADDR:
            return self.dma_addr
        elif offset == self.REG_DMA_SIZE:
            return self.dma_size
        return 0

    def save(self, f):
        f.put_u32(self.int_enable)
        f.put_u32(self.dma_addr)
        f.put_u32(self.dma_size)

    def load(self, f):
        self.int_enable = f.get_u32()
        self.dma_addr = f.get_u32()
        self.dma_size = f.get_u32()

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,usbtest"
    properties = {"chardev": None}


qemu.register_device(syborg_usbtest)
  def save(self, f):
    f.put_u32(self.fifo_size)
    f.put_u32(self.int_enable)
    f.put_u32(self.dma_tx_addr)
    f.put_u32(self.dma_rx_addr)
    f.put_u32(self.dma_rx_count)
    f.put_u32(len(self.fifo))
    for x in self.fifo:
      f.put_u32(x)

  def load(self, f):
    if self.fifo_size != f.get_u32():
      raise ValueError, "fifo size mismatch"
    self.int_enable = f.get_u32()
    self.dma_tx_addr = f.get_u32()
    self.dma_rx_addr = f.get_u32()
    self.dma_rx_count = f.get_u32()
    n = f.get_u32()
    self.fifo = []
    while n > 0:
      self.fifo.append(f.get_u32())
      n -= 1;

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,serial"
  properties = {"fifo-size":16, "chardev":None}

qemu.register_device(syborg_serial)
Ejemplo n.º 7
0
        f.put_u32(len(self.fifo) + 1)
        for d in [self.current] + self.fifo:
            f.put_u32(d.x)
            f.put_u32(d.y)
            f.put_u32(d.z)
            f.put_u32(d.buttons)

    def load(self, f):
        if self.fifo_size != f.get_u32():
            raise ValueError, "fifo size mismatch"
        self.int_enabled = f.get_u32()
        n = f.get_u32()
        self.fifo = []
        while n > 0:
            x = f.get_u32()
            y = f.get_u32()
            z = f.get_u32()
            buttons = f.get_u32()
            self.fifo.append(self.fifo_entry(x, y, z, buttons))
            n -= 1
        self.current = self.fifo.pop(0)

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,pointer"
    properties = {"fifo-size": 16, "absolute": 1}


qemu.register_device(syborg_pointer)
Ejemplo n.º 8
0
    f.put_u32(self.num_inputs)
    for i in range(self.num_inputs):
      val = 0
      if i in self.enabled:
        val |= 1
      if i in self.level:
        val |= 2
      f.put_u32(val)

  def load(self, f):
    val = f.get_u32()
    if val != self.num_inputs:
      raise ValueError, "Incorrect number of IRQs"
    self.level = set()
    self.enabled = set()
    for i in range(self.num_inputs):
      val = f.get_u32()
      if (val & 1) != 0:
        self.enabled.add(i)
      if (val & 2) != 0:
        self.level.add(i)
    self.update()

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,interrupt"
  properties = {"num-interrupts":64}

qemu.register_device(syborg_interrupt)
Ejemplo n.º 9
0
        if offset == self.REG_LATCH:
            now = qemu.get_clock()
            if value >= 4:
                self.offset = self.data - now
            else:
                self.data = now + self.offset
                while value:
                    self.data /= 1000
                    value -= 1
        elif offset == self.REG_DATA_LOW:
            self.data = (self.data & ~0xffffffff) | value
        elif offset == self.REG_DATA_HIGH:
            self.data = (self.data & 0xffffffff) | (value << 32)

    def save(self, f):
        f.put_s64(self.offset)
        f.put_u64(self.data)

    def load(self, f):
        self.offset = f.get_s64()
        self.data = f.get_u64()

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 0
    name = "syborg,rtc"
    properties = {}


qemu.register_device(syborg_timer)
                if( self.transaction_direction == self.NVMEM_TRANSACTION_READ ):
                    self.nvmemlib.nvmem_read(  self.obj, self.nvmemory_sharedmemory_host_address, self.nvmemhandle, self.transaction_offset, self.transaction_size )
                elif( self.transaction_direction == self.NVMEM_TRANSACTION_WRITE ):
                    self.nvmemlib.nvmem_write(  self.obj, self.nvmemory_sharedmemory_host_address, self.nvmemhandle, self.transaction_offset, self.transaction_size )
                else:
                    error_msg = "syborg_nvmemorydevice: Transaction direction not set!" 
                    sys.exit( error_msg )
                self.transaction_offset_set = 0
                self.transaction_size_set = 0
                self.transaction_direction_set = 0
        elif offset == self.R_NVMEM_SHARED_MEMORY_BASE:
            self.shared_memory_base = value
        elif offset == self.R_NVMEM_SHARED_MEMORY_SIZE:
            self.shared_memory_size = value
        elif offset == self.R_NVMEM_ENABLE:
            if( value > 0 ):
                self.nvmemory_memregion = qemu.memregion( self.shared_memory_base, self.shared_memory_size )
                self.nvmemory_sharedmemory_host_address = self.nvmemory_memregion.region_host_addr()
                print"syborg_nvmemorydevice: host addr: 0x%08x" % (self.nvmemory_sharedmemory_host_address)
        else:
            reg_write_error = "syborg_nvmemorydevice: Illegal register write to: ", offset 
            sys.exit( reg_write_error )

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,nvmemorydevice"
    properties = {"drive_size":DEFAULT_DRIVE_SIZE, "sector_size":DEVICE_SECTOR_SIZE, "drive_image_name":DRIVE_NAME}

qemu.register_device(syborg_nvmemorydevice)
Ejemplo n.º 11
0
            self.int_enabled = ((value & 1) != 0)
            self.update_irq()

    def save(self, f):
        f.put_u32(self.fifo_size)
        f.put_u32(self.int_enabled)
        f.put_u32(self.extension_bit)
        f.put_u32(len(self.fifo))
        for x in self.fifo:
            f.put_u32(x)

    def load(self, f):
        if self.fifo_size != f.get_u32():
            raise ValueError, "fifo size mismatch"
        self.int_enabled = f.get_u32()
        self.extension_bit = f.get_u32()
        n = f.get_u32()
        self.fifo = []
        while n > 0:
            self.fifo.append(f.get_u32())
            n -= 1

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,keyboard"
    properties = {"fifo-size": 16}


qemu.register_device(syborg_keyboard)
Ejemplo n.º 12
0
        self.dma_rx_addr = f.get_u32()
        self.dma_rx_count = f.get_u32()
        n = f.get_u32()
        self.fifo = []
        while n > 0:
            self.fifo.append(f.get_u32())
            n -= 1

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,serial"
    properties = {"fifo-size": 16, "chardev": None, "target": ""}


qemu.register_device(syborg_serial)


class syborg_modem(syborg_serial):
    def create(self):
        syborg_serial.create(self)

        # Find the path of the emulator executable
        path = os.path.dirname(sys.executable)
        executable = os.getenv("SVP_MODEM_EXECUTABLE")
        if None == executable:
            executable = self.modem_executable

        executable_name = executable
        fq_executable = os.path.join(path, executable_name)
        print(fq_executable)
Ejemplo n.º 13
0
        for i in range(self.num_inputs):
            val = 0
            if i in self.enabled:
                val |= 1
            if i in self.level:
                val |= 2
            f.put_u32(val)

    def load(self, f):
        val = f.get_u32()
        if val != self.num_inputs:
            raise ValueError, "Incorrect number of IRQs"
        self.level = set()
        self.enabled = set()
        for i in range(self.num_inputs):
            val = f.get_u32()
            if (val & 1) != 0:
                self.enabled.add(i)
            if (val & 2) != 0:
                self.level.add(i)
        self.update()

    # Device class properties
    regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
    irqs = 1
    name = "syborg,interrupt"
    properties = {"num-interrupts": 64}


qemu.register_device(syborg_interrupt)
Ejemplo n.º 14
0
    elif offset == self.REG_PIXEL_ORDER:
      self.render.pixel_order = value;
    elif offset == self.REG_ROW_PITCH:
      self.render.row_pitch = value;
    elif offset == self.REG_ENABLED:
      self.enabled = value != 0;
    elif (offset >= self.REG_PALETTE) and (offset < self.REG_PALETTE + 256):
      self.render.palette[offset - self.REG_PALETTE] = value;

  def save(self, f):
    f.put_u32(1 if self.need_int else 0)
    f.put_u32(self.int_status)
    f.put_u32(self.int_enable)
    f.put_u32(1 if self.enabled else 0)
    self.render.put(f)

  def load(self, f):
    self.need_int = (f.get_u32() != 0)
    self.int_status = f.get_u32();
    self.int_enable = f.get_u32();
    self.enabled = (f.get_u32() != 0)
    self.render.get(f)

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,framebuffer"
  properties = {"width":0, "height":0}

qemu.register_device(syborg_fb)
    if offset == self.REG_INT_ENABLE:
      self.int_enabled = ((value & 1) != 0)
      self.update_irq()

  def save(self, f):
    f.put_u32(self.fifo_size)
    f.put_u32(self.int_enabled)
    f.put_u32(self.extension_bit)
    f.put_u32(len(self.fifo))
    for x in self.fifo:
      f.put_u32(x)

  def load(self, f):
    if self.fifo_size != f.get_u32():
      raise ValueError, "fifo size mismatch"
    self.int_enabled = f.get_u32()
    self.extension_bit = f.get_u32()
    n = f.get_u32()
    self.fifo = []
    while n > 0:
      self.fifo.append(f.get_u32())
      n -= 1;

  # Device class properties
  regions = [qemu.ioregion(0x1000, readl=read_reg, writel=write_reg)]
  irqs = 1
  name = "syborg,keyboard"
  properties = {"fifo-size":16}

qemu.register_device(syborg_keyboard)