Skip to content
This repository was archived by the owner on Jan 4, 2019. It is now read-only.
This repository was archived by the owner on Jan 4, 2019. It is now read-only.

Convert words to bytes endianness-aware before sending to GLIP #5

@imphil

Description

@imphil
  • GLIP (glip_read/glip_write) operates on bytes.
  • When assembling words out of those bytes, it does so using big endian encoding ("All data transfer is big endian. This means for a 2 byte wide FIFO (check the FIFO width with glip_get_fifo_width()) the first byte written will be the MSB in the FIFO, the second byte written will be the LSB." -- http://www.glip.io/group__communication.html#ga7b3737ebb2d1f601f0c987cf50f0c43a)
  • libopensocdebug uses memcpy() to convert uint16 -> uint8_t[2]. On (little endian) x86 systems, this results in byte[0] = LSB, byte[1] = MSB.
  • After being transmitted through GLIP, the fifo_out_data[15:0] signal contains fifo_out_data[15:8] = LSB, fifo_out_data[7:0] = MSB.
  • Since this is not what all other parts of the OSD spec (or any hardware developer) expect, the byte order is swapped again in HIM (https://github.com/opensocdebug/hardware/blob/master/modules/him/common/osd_him.sv#L24)

This swapping in HIM is a workaround which only works on little endian host systems (i.e. libopensocdebug won't work on power pc).

To solve this issue, we should

  • not use memcpy() inside libopensocdebug, but to use a endianness-aware copy function instead
  • Remove the byte swapping in HIM
  • Clearly spell out this fact in the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions