Code that compiles until initialization of containers and pagers.

This commit is contained in:
Bahadir Balban
2009-08-02 23:43:14 +03:00
parent 82807c2f0a
commit 7e8845abf8
29 changed files with 1012 additions and 700 deletions

View File

@@ -33,9 +33,10 @@ struct mutex_queue_head {
struct link list;
struct mutex mutex_control_mutex;
int count;
} mutex_queue_head;
};
void init_mutex_queue_head(struct mutex_queue_head *mqhead);
void init_mutex_queue_head(void);
#endif
#define L4_MUTEX_LOCK 0

View File

@@ -148,7 +148,8 @@ int copy_user_tables(struct address_space *new, struct address_space *orig);
pgd_table_t *copy_page_tables(pgd_table_t *from);
void remap_as_pages(void *vstart, void *vend);
void relocate_page_tables(void);
int pgd_count_pmds(pgd_table_t *pgd);
pgd_table_t *realloc_page_tables(void);
void remove_section_mapping(unsigned long vaddr);
void copy_pgds_by_vrange(pgd_table_t *to, pgd_table_t *from,

View File

@@ -32,8 +32,10 @@
#define CAP_RTYPE_CPUPOOL (1 << 23)
#define CAP_RTYPE_THREADPOOL (1 << 24)
#define CAP_RTYPE_SPACEPOOL (1 << 25)
#define CAP_RTYPE_MUTEXPOOL (1 << 27)
#define CAP_RTYPE_MEMPOOL (1 << 26) /* Do we need this ??? */
#define CAP_RTYPE_MUTEXPOOL (1 << 26)
#define CAP_RTYPE_MAPPOOL (1 << 27) /* For pmd spending */
#define CAP_RTYPE_CAPPOOL (1 << 28) /* For new cap generation */
/*
* Access permissions
*/
@@ -61,6 +63,7 @@
#define CAP_MAP_CACHED (1 << 3)
#define CAP_MAP_UNCACHED (1 << 4)
#define CAP_MAP_UNMAP (1 << 5)
#define CAP_MAP_UTCB (1 << 6)
/* Ipc capability */
#define CAP_IPC_SEND (1 << 0)

View File

@@ -14,21 +14,23 @@
*
* In this structure:
*
* The capid denotes the unique capability ID. The resid denotes the unique ID
* of targeted resource. The owner denotes the unique ID of capability owner.
* This is almost always a thread ID.
* The capid denotes the unique capability ID.
* The resid denotes the unique ID of targeted resource.
* The owner denotes the unique ID of the one and only capability owner. This is
* almost always a thread ID.
*
* The type field contains two types: The capability type, and the targeted
* resource type. The targeted resouce type denotes what type of resource the
* capability is allowed to operate on. For example a thread, a thread group,
* an address space or a memory can be of this type.
* The type field contains two types:
* - The capability type,
* - The targeted resource type.
*
* The targeted resouce type denotes what type of resource the capability is
* allowed to operate on. For example a thread, a thread group, an address space
* or a memory can be of this type.
*
* The capability type defines the general set of operations allowed on a
* particular resource. The resource type defines the type of resource that
* the capability is targeting. For example a capability type may be
* thread_control, exchange_registers, ipc, or map operations. A resource type
* may be such as a thread, a thread group, a virtual or physical memory
* region.
* particular resource. For example a capability type may be thread_control,
* exchange_registers, ipc, or map operations. A resource type may be such as a
* thread, a thread group, a virtual or physical memory region.
*
* There are also quantitative capability types. While their names denote
* quantitative objects such as memory, threads, and address spaces, these
@@ -64,6 +66,9 @@ struct cap_list {
struct link caps;
};
void capability_init(struct capability *cap);
struct capability *capability_create(void);
#if 0
/* Virtual memory space allocated to container */
struct capability cap_virtmap = {

View File

@@ -9,34 +9,47 @@
#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 14
#define CONFIG_MAX_PAGERS_USED 2
/* Container macro. No locks needed! */
#define this_container (current->container)
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 {
/* Unique container id */
l4id_t cid;
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 */
/* List of address spaces */
struct address_space_list space_list;
/* List of threads */
struct ktcb_list ktcb_list;
/* ID pools for threads and spaces */
struct id_pool *thread_id_pool;
struct id_pool *thread_id_pool; /* Id pools for thread/spaces */
struct id_pool *space_id_pool;
/* Scheduling structs */
struct scheduler scheduler;
struct scheduler scheduler; /* Scheduling structs */
/* Mutex list for all userspace mutexes */
struct mutex_queue_head mutex_queue_head;
struct mutex_queue_head mutex_queue_head; /* Userspace mutex list */
/*
* Capabilities that apply to this container
@@ -44,13 +57,10 @@ struct container {
* Threads, address spaces, mutex queues, cpu share ...
* Pagers possess these capabilities.
*/
struct capability caps[5]; /* threadpool, spacepool, mutexpool, cpupool, mempool */
/* threadpool, spacepool, mutexpool, cpupool, mempool */
struct pager pager[CONFIG_MAX_PAGERS_USED];
};
#define CONFIG_MAX_CAPS_USED 11
#define CONFIG_MAX_PAGERS_USED 2
/* Compact, raw capability structure */
struct cap_info {
unsigned int type;
@@ -60,10 +70,13 @@ struct cap_info {
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;
@@ -87,12 +100,22 @@ struct pager_info {
* used to create run-time containers
*/
struct container_info {
char name[64];
char name[CONFIG_CONTAINER_NAMESIZE];
int npagers;
struct pager_info pager[CONFIG_MAX_PAGERS_USED];
};
extern struct container_info cinfo[];
void kcont_insert_container(struct container *c,
struct kernel_container *kcont);
struct container *container_create(void);
int container_init_pagers(struct kernel_container *kcont,
pgd_table_t *current_pgd);
int init_containers(struct kernel_container *kcont);
#endif /* __CONTAINER_H__ */

View File

@@ -1,15 +0,0 @@
#ifndef __PGALLOC_H__
#define __PGALLOC_H__
void *zalloc_page(void);
void *alloc_page(void);
void *alloc_pmd(void);
void *alloc_pgd(void);
int free_page(void *);
int free_pmd(void *);
int free_pgd(void *);
int pgalloc_add_new_grant(unsigned long pfn, int npages);
void init_pgalloc();
#endif /* __PGALLOC_H__ */

View File

@@ -1,10 +1,18 @@
/*
* Description of resources on the system
*
* Copyright (C) 2009 Bahadir Balban
*/
#ifndef __RESOURCES_H__
#define __RESOURCES_H__
/* Number of containers defined at compile-time */
#define TOTAL_CONTAINERS 1
#define CONFIG_TOTAL_CONTAINERS 1
#include <l4/generic/capability.h>
#include <l4/lib/idpool.h>
#include INC_SUBARCH(mm.h)
struct boot_resources {
int nconts;
@@ -21,8 +29,30 @@ struct boot_resources {
int nkmemcaps;
};
/* List of containers */
struct container_head {
int ncont;
struct link list;
};
/*
* 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;
@@ -38,7 +68,7 @@ struct kernel_container {
struct mem_cache *pgd_cache;
struct mem_cache *pmd_cache;
struct mem_cache *ktcb_cache;
struct mem_cache *address_space_cache;
struct mem_cache *space_cache;
struct mem_cache *mutex_cache;
struct mem_cache *cap_cache;
struct mem_cache *cont_cache;
@@ -46,6 +76,22 @@ struct kernel_container {
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 capability *alloc_capability(void);
struct container *alloc_container(void);
struct mutex_queue *alloc_user_mutex(void);
int init_system_resources(struct kernel_container *kcont);
#endif /* __RESOURCES_H__ */

View File

@@ -45,6 +45,7 @@ struct runqueue {
struct link task_list; /* List of tasks in rq */
unsigned int total; /* Total tasks */
};
/* Contains per-container scheduling structures */
struct scheduler {
struct runqueue sched_rq[SCHED_RQ_TOTAL];
@@ -55,6 +56,7 @@ struct scheduler {
int prio_total;
};
void sched_init_runqueue(struct runqueue *rq);
void sched_init_task(struct ktcb *task, int priority);
void sched_prepare_sleep(void);
void sched_suspend_sync(void);
@@ -63,5 +65,6 @@ void sched_resume_sync(struct ktcb *task);
void sched_resume_async(struct ktcb *task);
void scheduler_start(void);
void schedule(void);
void sched_init(struct scheduler *scheduler);
#endif /* __SCHEDULER_H__ */

View File

@@ -54,7 +54,7 @@ void address_space_add(struct address_space *space);
void address_space_remove(struct address_space *space);
void address_space_reference_lock();
void address_space_reference_unlock();
void init_address_space_list(void);
void init_address_space_list(struct address_space_list *space_list);
int check_access(unsigned long vaddr, unsigned long size,
unsigned int flags, int page_in);
#endif

View File

@@ -10,7 +10,7 @@
#include <l4/lib/mutex.h>
#include <l4/lib/spinlock.h>
#include <l4/generic/scheduler.h>
#include <l4/generic/pgalloc.h>
#include <l4/generic/resource.h>
#include <l4/generic/space.h>
#include INC_GLUE(memory.h)
#include INC_GLUE(syscall.h)
@@ -42,6 +42,8 @@ struct task_ids {
l4id_t tgid;
};
struct container;
struct ktcb {
/* User context */
task_context_t context;
@@ -94,6 +96,9 @@ struct ktcb {
/* Page table information */
struct address_space *space;
/* Container */
struct container *container;
/* Fields for ipc rendezvous */
struct waitqueue_head wqh_recv;
struct waitqueue_head wqh_send;
@@ -121,7 +126,6 @@ union ktcb_union {
char kstack[PAGE_SIZE];
};
/* Hash table for all existing tasks */
struct ktcb_list {
struct link list;
@@ -157,7 +161,7 @@ void tcb_init(struct ktcb *tcb);
struct ktcb *tcb_alloc_init(void);
void tcb_delete(struct ktcb *tcb);
void init_ktcb_list(void);
void init_ktcb_list(struct ktcb_list *ktcb_list);
void task_update_utcb(struct ktcb *cur, struct ktcb *next);
int tcb_check_and_lazy_map_utcb(struct ktcb *task);

View File

@@ -121,5 +121,8 @@ pte_t virt_to_pte(unsigned long virtual);
pte_t virt_to_pte_from_pgd(unsigned long virtual, pgd_table_t *pgd);
unsigned long virt_to_phys_by_pgd(unsigned long vaddr, pgd_table_t *pgd);
struct ktcb;
void task_init_registers(struct ktcb *task, unsigned long pc);
#endif /* __GLUE_ARM_MEMORY_H__ */

View File

@@ -4,7 +4,17 @@
#include <l4/lib/bit.h>
#include <l4/lib/spinlock.h>
/* One page size minus the structure fields */
#define CONFIG_MAX_SYSTEM_IDS (1023*32)
#define SYSTEM_IDS_MAX (CONFIG_MAX_SYSTEM_IDS >> 5)
struct id_pool {
struct spinlock lock;
int nwords;
u32 bitmap[SYSTEM_IDS_MAX];
};
struct id_pool_variable {
struct spinlock lock;
int nwords;
u32 bitmap[];