This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question about StellarisWare, SW-RDK-S2E, stellarisif.c

stellarisif.c

static err_t
stellarisif_transmit(struct netif *netif, struct pbuf *p)
{
  int iBuf;
  unsigned char *pucBuf;
  unsigned long *pulBuf;
  struct pbuf *q;
  int iGather;
  unsigned long ulGather;
  unsigned char *pucGather;

........................... [omitted]

    /* Initialze a long pointer into the pbuf for 32-bit access. */
    pulBuf = (unsigned long *)&pucBuf[iBuf];

    /**
     * Copy words of pbuf data into the Tx FIFO, but don't go past
     * the end of the pbuf.
     *
     */
    while((iBuf + 4) <= q->len) {
      HWREG(ETH_BASE + MAC_O_DATA) = *pulBuf++;
      iBuf += 4;
    }

The above code is part of the latest version of the TI/Luminary StellarisWare.

I think it is a bug? And I hope to fix it with

  __packed unsigned long *pulBuf;


in the KEIL toolchain. (Tested.)

But due to my very limited C programming skill, I am afraid that, I might be doing something stupid. So I would like to learn something from our experts, please kindly give me some advices.

Is that, the __packed qualifier (in this case) leads to the lower performance?

Parents
  • "TI/Luminary StellarisWare"

    It's TI/Luminary code - so why not post on the TI/Luminary forum?

    It's their code; they wrote the code, so they should know why they did this!

    You are right that it is not generally safe to arbitrarily cast a byte pointer to a word pointer - but maybe the rest of their code should ensure that, in this particular case, it is OK...?

    I hope to fix it with

     __packed unsigned long *pulBuf;
    

    You really need to check with TI/Luminary whether that is compatible with what they are trying to achieve here!

    Note: unlike Keil, TI/Luminary technical staff do monitor their forum and do respond to issues like this!

    So post this on the TI/Luminary forum: e2e.ti.com/.../default.aspx

    Being sure, of course, to include a link to this thread, and give a link here to the thread over there...

Reply
  • "TI/Luminary StellarisWare"

    It's TI/Luminary code - so why not post on the TI/Luminary forum?

    It's their code; they wrote the code, so they should know why they did this!

    You are right that it is not generally safe to arbitrarily cast a byte pointer to a word pointer - but maybe the rest of their code should ensure that, in this particular case, it is OK...?

    I hope to fix it with

     __packed unsigned long *pulBuf;
    

    You really need to check with TI/Luminary whether that is compatible with what they are trying to achieve here!

    Note: unlike Keil, TI/Luminary technical staff do monitor their forum and do respond to issues like this!

    So post this on the TI/Luminary forum: e2e.ti.com/.../default.aspx

    Being sure, of course, to include a link to this thread, and give a link here to the thread over there...

Children