Changes since April

Clean up of build directories.
Simplifications to capability model.
This commit is contained in:
Bahadir Balban
2010-06-01 15:08:13 +03:00
parent aef14b55ec
commit 6fa4884a5a
450 changed files with 10449 additions and 7383 deletions

View File

@@ -0,0 +1,12 @@
# Inherit global environment
Import('env')
# The set of source files associated with this SConscript file.
src_local = Glob('*.[cS]')
src_local += Glob('src/*.[cS]')
src_local += Glob('src/arch/*.[cS]')
obj = env.Object(src_local)
Return('obj')

View File

@@ -7,64 +7,51 @@
import os, shelve, sys
from os.path import *
PROJRELROOT = '../..'
CONTS_XXX = '../..'
BAREMETAL_CONTS_XXX = '../../..'
sys.path.append(CONTS_XXX)
sys.path.append(BAREMETAL_CONTS_XXX)
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from configure import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
from scripts.conts.containers import *
from scripts.config.config_invoke import *
config = configuration_retrieve()
arch = config.arch
platform = config.platform
gcc_arch_flag = config.gcc_arch_flag
# Wrapper library for system calls
LIBL4_RELDIR = 'conts/libl4'
KERNEL_INCLUDE = join(PROJROOT, 'include')
LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR)
LIBL4_INCLUDE = join(LIBL4_DIR, 'include')
LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR)
cid = int(ARGUMENTS.get('cid', 0))
cont = find_container_from_cid(cid)
# Some user-space libraries
LIBC_RELDIR = 'conts/libc'
LIBC_DIR = join(PROJROOT, LIBC_RELDIR)
LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR)
LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
join(LIBC_DIR, 'include/arch' + '/' + arch)]
builddir = join(join(BUILDDIR, 'cont') + str(cid), cont.name)
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = join(LIBDEV_DIR, 'include')
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
# linker.lds is generated either in conts/xxx or build/contx/include
if cont.duplicate == 0:
linker_lds = join(builddir, 'include/linker.lds')
else:
linker_lds = 'include/linker.lds'
env = Environment(CC = config.toolchain_userspace + 'gcc',
# We don't use -nostdinc because sometimes we need standard headers,
# such as stdarg.h e.g. for variable args, as in printk().
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', \
'-Werror', '-march=' + gcc_arch_flag], \
LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", "-u_start"],\
ASFLAGS = ['-D__ASSEMBLY__'], \
PROGSUFFIX = '.elf', # The suffix to use for final executable
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', \
'libmm', 'libmc', 'libmalloc', 'gcc', 'c-userspace'],
# libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \
LIBC_INCLUDE, LIBMEM_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
# We don't use -nostdinc because sometimes we need standard headers,
# such as stdarg.h e.g. for variable args, as in printk().
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall',
'-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib', '-T' + linker_lds, '-u_start'],
ASFLAGS = ['-D__ASSEMBLY__'],
PROGSUFFIX = '.elf', # The suffix to use for final executable
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace',
'libmem', 'gcc', 'c-userspace'],
# libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_HEADERS, LIBL4_INCLUDE, LIBDEV_INCLUDE,
LIBC_INCLUDE, LIBMEM_INCLUDE, join(builddir, 'include')],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_USER_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
src += Glob('src/arch/*.[cS]')
objs = SConscript('SConscript', exports = { 'env' : env },
duplicate=0, build_dir = builddir)
objs = env.Object(src)
prog = env.Program('main.elf', objs)
Depends(prog, 'include/linker.lds')
Depends(objs, join(PROJROOT, CONFIG_H))
prog = env.Program(join(builddir, 'main.elf'), objs)
Depends(prog, linker_lds)

View File

@@ -7,6 +7,7 @@
#include <l4lib/init.h>
#include <l4lib/utcb.h>
#include <l4lib/lib/thread.h>
#include <l4lib/lib/cap.h>
void main(void);
@@ -18,6 +19,8 @@ void __container_init(void)
/* Thread library initialisation */
__l4_threadlib_init();
__l4_capability_init();
/* Entry to main */
main();
}

View File

@@ -78,7 +78,8 @@ struct timer {
unsigned int count; /* Counter/jiffies */
struct sleeper_task_bucket task_list; /* List of sleeping tasks */
struct l4_mutex task_list_lock; /* Lock for sleeper_task_bucket */
struct capability cap; /* Capability describing timer */
unsigned long phys_base; /* Physical address of Device */
int irq_no; /* IRQ number of device */
};
#endif /* __TIMER_H__ */

View File

@@ -2,6 +2,7 @@
* Timer service for userspace
*/
#include <l4lib/lib/addr.h>
#include <l4lib/lib/cap.h>
#include <l4lib/irq.h>
#include <l4lib/lib/thread.h>
#include <l4lib/ipcdefs.h>
@@ -10,14 +11,15 @@
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
#include <l4/api/space.h>
#include <malloc/malloc.h>
#include <mem/malloc.h>
#include <container.h>
#include <linker.h>
#include <timer.h>
#include <libdev/timer.h>
#include <dev/timer.h>
#include <dev/platform.h>
/* Capabilities of this service */
static struct capability caparray[32];
static struct capability *caparray;
static int total_caps = 0;
/* Total number of timer chips being handled by us */
@@ -33,33 +35,6 @@ struct wake_task_list wake_tasks;
/* tid of handle_request thread */
l4id_t tid_ipc_handler;
int cap_read_all()
{
int ncaps;
int err;
/* Read number of capabilities */
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
0, &ncaps)) < 0) {
printf("l4_capability_control() reading # of"
" capabilities failed.\n Could not "
"complete CAP_CONTROL_NCAPS request.\n");
BUG();
}
total_caps = ncaps;
/* Read all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_READ,
0, caparray)) < 0) {
printf("l4_capability_control() reading of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
return 0;
}
int cap_share_all_with_space()
{
int err;
@@ -160,32 +135,6 @@ struct link* find_bucket_list(unsigned long seconds)
return vector;
}
/*
* Scans for up to TIMERS_TOTAL timer devices in capabilities.
*/
int timer_probe_devices(void)
{
int timers = 0;
/* Scan for timer devices */
for (int i = 0; i < total_caps; i++) {
/* Match device type */
if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_TIMER) {
/* Copy to correct device index */
memcpy(&global_timer[cap_devnum(&caparray[i]) - 1].cap,
&caparray[i], sizeof(global_timer[0].cap));
timers++;
}
}
if (timers != TIMERS_TOTAL) {
printf("%s: Error, not all timers could be found. "
"timers=%d\n", __CONTAINER_NAME__, timers);
return -ENODEV;
}
return 0;
}
/*
* Irq handler for timer interrupts
*/
@@ -204,7 +153,7 @@ int timer_irq_handler(void *arg)
/* Register self for timer irq, using notify slot 0 */
if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot,
timer->cap.irq)) < 0) {
timer->irq_no)) < 0) {
printf("%s: FATAL: Timer irq could not be registered. "
"err=%d\n", __FUNCTION__, err);
BUG();
@@ -219,7 +168,7 @@ int timer_irq_handler(void *arg)
struct link *task_list;
/* Block on irq */
if((count = l4_irq_wait(slot, timer->cap.irq)) < 0) {
if((count = l4_irq_wait(slot, timer->irq_no)) < 0) {
printf("l4_irq_wait() returned with negative value\n");
BUG();
}
@@ -234,6 +183,7 @@ int timer_irq_handler(void *arg)
/* find bucket list of taks to be woken for current count */
vector = find_bucket_list(timer->count);
l4_send(tid_ipc_handler,L4_IPC_TAG_TIMER_WAKE_THREADS);
if (!list_empty(vector)) {
/* Removing tasks from sleeper list */
@@ -300,19 +250,21 @@ int timer_setup_devices(void)
struct l4_thread *tptr = &thread;
int err;
global_timer[0].phys_base = PLATFORM_TIMER1_BASE;
global_timer[0].irq_no = IRQ_TIMER1;
for (int i = 0; i < TIMERS_TOTAL; i++) {
/* initialize timer */
timer_struct_init(&global_timer[i],(unsigned long)l4_new_virtual(1) );
/* Map timer to a virtual address region */
if (IS_ERR(l4_map((void *)__pfn_to_addr(global_timer[i].cap.start),
(void *)global_timer[i].base, global_timer[i].cap.size,
MAP_USR_IO,
self_tid()))) {
printf("%s: FATAL: Failed to map TIMER device "
"%d to a virtual address\n",
__CONTAINER_NAME__,
cap_devnum(&global_timer[i].cap));
if (IS_ERR(l4_map((void *)global_timer[i].phys_base,
(void *)global_timer[i].base, 1,
MAP_USR_IO, self_tid()))) {
printf("%s: FATAL: Failed to map TIMER device from 0x%lx"
" to 0x%lx\n", __CONTAINER_NAME__,
global_timer[i].phys_base,
global_timer[i].base);
BUG();
}
@@ -502,64 +454,20 @@ void handle_requests(void)
}
}
/*
* UTCB-size aligned utcb.
*
* BIG WARNING NOTE: This declaration is legal if we are
* running in a disjoint virtual address space, where the
* utcb declaration lies in a unique virtual address in
* the system.
*/
#define DECLARE_UTCB(name) \
struct utcb name ALIGN(sizeof(struct utcb))
DECLARE_UTCB(utcb);
/* Set up own utcb for ipc */
int l4_utcb_setup(void *utcb_address)
{
struct task_ids ids;
struct exregs_data exregs;
int err;
l4_getid(&ids);
/* Clear utcb */
memset(utcb_address, 0, sizeof(struct utcb));
/* Setup exregs for utcb request */
memset(&exregs, 0, sizeof(exregs));
exregs_set_utcb(&exregs, (unsigned long)utcb_address);
if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0)
return err;
return 0;
}
void main(void)
{
int err;
/* Read all capabilities */
cap_read_all();
caps_read_all();
total_caps = cap_get_count();
caparray = cap_get_all();
/* Share all with space */
cap_share_all_with_space();
/* Scan for timer devices in capabilities */
timer_probe_devices();
/* Initialize virtual address pool for timers */
init_vaddr_pool();
/* Setup own static utcb */
if ((err = l4_utcb_setup(&utcb)) < 0) {
printf("FATAL: Could not set up own utcb. "
"err=%d\n", err);
BUG();
}
/* initialise timed_out_task list */
wake_task_list_init();