Files
codezero/include/l4/generic/resource.h
Bahadir Balban cfa35e4a66 Added support for faulty pagers and their threads to become zombies
Added support for pagers that fault to suspend and become zombies
along with all the threads that they manage. Zombie killing is to
be done at a later time, from this special zombie queue.

The implementation works same as a suspension, with the added action
that the thread is moved to a queue in kernel container.
2009-10-19 18:48:55 +03:00

118 lines
2.6 KiB
C

/*
* Description of resources on the system
*
* Copyright (C) 2009 Bahadir Balban
*/
#ifndef __RESOURCES_H__
#define __RESOURCES_H__
/* Number of containers defined at compile-time */
#include <l4/generic/capability.h>
#include <l4/lib/idpool.h>
#include INC_SUBARCH(mm.h)
struct boot_resources {
int nconts;
int ncaps;
int nthreads;
int nspaces;
int npmds;
int nmutex;
/* Kernel resource usage */
int nkpmds;
int nkpgds;
int nkcaps;
};
/* List of containers */
struct container_head {
int ncont;
struct link list;
};
static inline void
container_head_init(struct container_head *chead)
{
chead->ncont = 0;
link_init(&chead->list);
}
/* Hash table for all existing tasks */
struct ktcb_list {
struct link list;
struct spinlock list_lock;
int count;
};
/*
* Everything on the platform is described and stored
* in the structure below.
*/
struct kernel_container {
l4id_t cid;
/* System id pools */
struct id_pool space_ids;
struct id_pool ktcb_ids;
struct id_pool resource_ids;
struct id_pool container_ids;
struct id_pool mutex_ids;
struct id_pool capability_ids;
/* List of all containers */
struct container_head containers;
/* Physical memory caps, used/unused */
struct cap_list physmem_used;
struct cap_list physmem_free;
/* Virtual memory caps, used/unused */
struct cap_list virtmem_used;
struct cap_list virtmem_free;
/* Device memory caps, used/unused */
struct cap_list devmem_used;
struct cap_list devmem_free;
/* All other caps that belong to the kernel */
struct cap_list non_memory_caps;
struct mem_cache *pgd_cache;
struct mem_cache *pmd_cache;
struct mem_cache *ktcb_cache;
struct mem_cache *space_cache;
struct mem_cache *mutex_cache;
struct mem_cache *cap_cache;
struct mem_cache *cont_cache;
/* Zombie thread list */
struct ktcb_list zombie_list;
};
extern struct kernel_container kernel_container;
void free_pgd(void *addr);
void free_pmd(void *addr);
void free_space(void *addr);
void free_ktcb(void *addr);
void free_capability(void *addr);
void free_container(void *addr);
void free_user_mutex(void *addr);
pgd_table_t *alloc_pgd(void);
pmd_table_t *alloc_pmd(void);
struct address_space *alloc_space(void);
struct ktcb *alloc_ktcb(void);
struct ktcb *alloc_ktcb_use_capability(struct capability *cap);
struct capability *boot_alloc_capability(void);
struct capability *alloc_capability(void);
struct container *alloc_container(void);
struct mutex_queue *alloc_user_mutex(void);
int free_boot_memory(struct kernel_container *kcont);
int init_system_resources(struct kernel_container *kcont);
#endif /* __RESOURCES_H__ */