mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 10:53:16 +01:00
Capabilities will be shared among collection of threads. A pager will have a right to share its own capabilities with its space, its thread group and its container. Currently sharing is possible with only all of the caps. Next, it will be support for cap splitting, granting, and partial sharing and granting.
121 lines
2.9 KiB
C
121 lines
2.9 KiB
C
/*
|
|
* Definitions for Codezero Containers
|
|
*
|
|
* Copyright (C) 2009 Bahadir Balban
|
|
*/
|
|
#ifndef __CONTAINER_H__
|
|
#define __CONTAINER_H__
|
|
|
|
#include <l4/generic/scheduler.h>
|
|
#include <l4/generic/space.h>
|
|
#include <l4/generic/capability.h>
|
|
#include <l4/generic/resource.h>
|
|
#include <l4/generic/tcb.h>
|
|
#include <l4/lib/idpool.h>
|
|
#include <l4/api/mutex.h>
|
|
#include <l4/lib/list.h>
|
|
#include <l4/lib/idpool.h>
|
|
|
|
#define curcont (current->container)
|
|
|
|
#define CONFIG_CONTAINER_NAMESIZE 64
|
|
#define CONFIG_MAX_CAPS_USED 32
|
|
#define CONFIG_MAX_PAGERS_USED 4
|
|
|
|
/* Container macro. No locks needed! */
|
|
|
|
struct pager {
|
|
struct ktcb *tcb;
|
|
unsigned long start_lma;
|
|
unsigned long start_vma;
|
|
unsigned long start_address;
|
|
unsigned long stack_address;
|
|
unsigned long memsize;
|
|
struct cap_list cap_list;
|
|
};
|
|
|
|
|
|
struct container {
|
|
l4id_t cid; /* Unique container id */
|
|
int npagers; /* # of pagers */
|
|
struct link list; /* List ref for containers */
|
|
struct address_space_list space_list; /* List of address spaces */
|
|
char name[CONFIG_CONTAINER_NAMESIZE]; /* Name of container */
|
|
struct ktcb_list ktcb_list; /* List of threads */
|
|
struct link pager_list; /* List of pagers */
|
|
|
|
struct id_pool *thread_id_pool; /* Id pools for thread/spaces */
|
|
struct id_pool *space_id_pool;
|
|
|
|
struct mutex_queue_head mutex_queue_head; /* Userspace mutex list */
|
|
struct cap_list cap_list; /* Capabilities shared by whole container */
|
|
|
|
/*
|
|
* Capabilities that apply to this container
|
|
*
|
|
* Threads, address spaces, mutex queues, cpu share ...
|
|
* Pagers possess these capabilities.
|
|
*/
|
|
/* threadpool, spacepool, mutexpool, cpupool, mempool */
|
|
struct pager pager[CONFIG_MAX_PAGERS_USED];
|
|
};
|
|
|
|
/* Compact, raw capability structure */
|
|
struct cap_info {
|
|
unsigned int type;
|
|
u32 access;
|
|
unsigned long start;
|
|
unsigned long end;
|
|
unsigned long size;
|
|
};
|
|
|
|
|
|
struct pager_info {
|
|
unsigned long pager_lma;
|
|
unsigned long pager_vma;
|
|
unsigned long pager_size;
|
|
unsigned long start_address;
|
|
unsigned long stack_address;
|
|
|
|
/* Number of capabilities defined */
|
|
int ncaps;
|
|
|
|
/*
|
|
* Zero or more ipc caps,
|
|
* One or more thread pool caps,
|
|
* One or more space pool caps,
|
|
* One or more exregs caps,
|
|
* One or more tcontrol caps,
|
|
* One or more cputime caps,
|
|
* One or more physmem caps,
|
|
* One or more virtmem caps,
|
|
* Zero or more umutex caps,
|
|
*/
|
|
struct cap_info caps[CONFIG_MAX_CAPS_USED];
|
|
};
|
|
|
|
/*
|
|
* This auto-generated structure is
|
|
* used to create run-time containers
|
|
*/
|
|
struct container_info {
|
|
char name[CONFIG_CONTAINER_NAMESIZE];
|
|
int npagers;
|
|
struct pager_info pager[CONFIG_MAX_PAGERS_USED];
|
|
};
|
|
|
|
extern struct container_info cinfo[];
|
|
|
|
void kres_insert_container(struct container *c,
|
|
struct kernel_resources *kres);
|
|
|
|
struct container *container_create(void);
|
|
|
|
int container_init_pagers(struct kernel_resources *kres,
|
|
pgd_table_t *current_pgd);
|
|
|
|
int init_containers(struct kernel_resources *kres);
|
|
|
|
#endif /* __CONTAINER_H__ */
|
|
|