L4 Environment library

The L4 Environment library provides a more convenviant set of abstractions than the L4::Pistachio conveniance interface.

This environment is not meant as a general purpose L4 library; it actually makes some policy decisions, which are not always going to be the best policy, but it certainly encapsulates a set of commonly used policies to make implementing a new OS personality a fair bit easier, especially in undergraduate projects.

Most of these policies are based on experience using the L4v2 API.

All of the functions here, with the exception of the printing functions, are designed to be used by the priviledged root server, and won't work if called from unpriviledged threads.


int l4e_init(void)

l4e_init initalises various bits of state for the l4e library. It should only be called by the priviledged task. It must be called before any other functions (excluding printf). This should be called by the privilidged thread, that is the first executing thread.

L4_ThreadId_t root_thread

root_thread is a global variable pointing to the privilidged thread in the system.


int l4e_print_string(char *s);

l4e_print_string outputs a string to the debug console.


int l4e_printf(const char *fmt, ...);

l4e_printf provides a simple printf that uses the underlying L4_KDB_PrintChar routine to produce output. This function can be used in any task. Most operating systems will want to provide their own printf routine for user programs.


void l4e_print_error(L4_Word_t ec);

l4e_print_error will pretty print an L4 error code to the debug console.


void l4e_print_fpage(L4_Fpage_t fpage);

l4e_print_fpage will pretty print an L4 fpage code to the debug console.


L4_ThreadId_t l4e_task_2_tid (int taskid);

l4e_task_2_tid provides a simple way for managing tasks. This allocation scheme encodes the task id in bits 10-27 of the thread id.


int l4e_tid_2_task (L4_ThreadId_t tid);

l4e_task_2_tid returns the task number based on the thread id.


L4_ThreadId_t l4e_get_new_tid (void);

l4e_get_new_tid provides a simple kernel thread id (TID) allocator.


int l4e_start_thread(L4_ThreadId_t tid, void *entrypoint, void *stack);

l4e_start_thread creates and starts a thread tid at a given entrypoint with a given stack.


int l4e_task_new(L4_ThreadId_t task, L4_ThreadId_t pager, void *entrypoint, void *stack);

l4e_task_new creates and starts a thread in a new task at a given entrypoint with a given stack. The new memory space has the specified pager


int l4e_request_page(void *physaddr, int cached);

l4e_request_page will request a given physical page from sigma0. The page may be requested as cache or uncached. (Useful when talking to device mappings.)


void l4e_cache_flush(void)

l4e_cache_flush will flush the memory caches.


void l4e_find_memory(L4_Word_t *low, L4_Word_t *high);

l4e_find_memory parses the memory descriptors to find the largest usable area of physical memory.


struct Dite_Dhdr * dite_gethdr(void);

dite_gethdr will find and return a pointer to the dite header structure.


struct Dite_Phdr *dite_getentry(struct Dite_Dhdr * dite_hdr, int pos);

dite_getentry will find the program header in a given pos and return a pointer to it.

Last modified: Mon Aug 11 09:41:42 EST 2003