Skip to main content.

5.7.7. Kernel library functions

      make htmldocs
      firefox Documentation/DocBook/index.html

-> kernel api

API: linked lists

type:

struct list_head {
       struct list_head *next, *prev;
};

Initalize head pointer:

struct list_head mempool;
INIT_LIST_HEAD(&mempool);   /* at runtime or ... */
LIST_HEAD(mempool);      /* at compile time */

Embedd struct list_head in list element:

struct mem_chunk {
       unsigned char *ptr;
       int len;
       struct list_head list;
}

add element:

struct mem_chunk mc;
mc.ptr = this;
mc.len = 128;

list_add(&mc.list, &mempool);

remove element:

struct list_head myelement = list_del(&mempool.next);

find superstructure:

mc = list_entry(myelement, struct mem_chunk, list);

Functions:

see kernel-api documentation and include/list.h

5.7.6. How to delay execution 1. Denx Training Topics 5.7.8. Userspace kernel communication
Prev Home Next