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

How can I install a list?

How can I install a list in a ARM controller?

typedef struct {
        volatile unsigned int *p_NextHdr;                       volatile unsigned int *p_PrevHdr;                       volatile unsigned int *p_data;
}*Hdr;

*p_NextHdr: ptr to the next list element
*p_PrevHdr: ptr to the previous list element
*p_data: ptr to the buffer (for this list element)

Hdr HdrPtr;

// ptr to the struct

At the beginning:

*p_NextHdr = *p_PrevHdr = *p_data = NULL;

But how can I install a few list elements? Could you tell me the next steps I have to do? How can I allocate storage for the struct?

best regards
Ingo

Parents
  • number of list elements with the struct data:

    struct data *Header[NB_ETH_RX_PACKETS];
    

    ptr to the tail and the start of the list

    struct data *HdrEnd;
    struct RxData *HdrBegin;
    

    struct data

    typedef struct data {
            volatile unsigned int Data;
            struct RxData *p_NextHdr;
            struct RxData *p_PrevHdr;
    } *Hdr;
    

    Hdr p_HdrLisPtr;

    init pointers at the beginning:

    HdrBegin->p_PrevHdr = HdrEnd->p_PrevHdr = HdrBegin;                  /* */
            HdrBegin->p_NextHdr = HdrEnd->p_NextHdr = HdrBufEnd;                  /* */
            p_HdrLisPtr = HdrBegin;
    

    so now I should be able to install some list elements in a for-loop (for i=0; i<8; i++)

    Header[i]->Data = i;
    
    
                    // element in liste eintragen
                    Header[i]->p_PrevHdr = p_HdrLisPtr;                                                          /* */
                    Header[i]->p_NextHdr = p_HdrLisPtr->p_NextHdr;                                    /* */
                    p_HdrLisPtr->p_NextHdr->p_PrevHdr = Header[i];                                    /* */
                    p_HdrLisPtr->p_NextHdr = Header[i];
    

    Are there any mistakes?

    Ingo

Reply
  • number of list elements with the struct data:

    struct data *Header[NB_ETH_RX_PACKETS];
    

    ptr to the tail and the start of the list

    struct data *HdrEnd;
    struct RxData *HdrBegin;
    

    struct data

    typedef struct data {
            volatile unsigned int Data;
            struct RxData *p_NextHdr;
            struct RxData *p_PrevHdr;
    } *Hdr;
    

    Hdr p_HdrLisPtr;

    init pointers at the beginning:

    HdrBegin->p_PrevHdr = HdrEnd->p_PrevHdr = HdrBegin;                  /* */
            HdrBegin->p_NextHdr = HdrEnd->p_NextHdr = HdrBufEnd;                  /* */
            p_HdrLisPtr = HdrBegin;
    

    so now I should be able to install some list elements in a for-loop (for i=0; i<8; i++)

    Header[i]->Data = i;
    
    
                    // element in liste eintragen
                    Header[i]->p_PrevHdr = p_HdrLisPtr;                                                          /* */
                    Header[i]->p_NextHdr = p_HdrLisPtr->p_NextHdr;                                    /* */
                    p_HdrLisPtr->p_NextHdr->p_PrevHdr = Header[i];                                    /* */
                    p_HdrLisPtr->p_NextHdr = Header[i];
    

    Are there any mistakes?

    Ingo

Children
No data