Merge branch 'devel'

Conflicts:
	tools/gdbinit
This commit is contained in:
Bahadir Balban
2010-03-26 00:28:14 +02:00
519 changed files with 23076 additions and 4614 deletions

View File

@@ -13,33 +13,100 @@ config = configuration_retrieve()
arch = config.arch
subarch = config.subarch
platform = config.platform
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
all_syms = config.all
builddir='build/codezero/'
env = Environment(CC = config.kernel_toolchain + 'gcc',
# Generate kernel linker script at runtime using template file.
def generate_kernel_linker_script(target, source, env):
linker_in = source[0]
linker_out = target[0]
cmd = config.toolchain + "cpp -D__CPP__ " + \
"-I%s -imacros l4/macros.h -imacros %s -imacros %s -C -P %s -o %s" % \
('include', 'l4/platform/'+ platform + '/offsets.h', \
'l4/glue/' + arch + '/memlayout.h', linker_in, linker_out)
os.system(cmd)
create_kernel_linker = Command(join(builddir, 'include/l4/arch/arm/linker.lds'), \
join(PROJROOT, 'include/l4/arch/arm/linker.lds.in'), \
generate_kernel_linker_script)
'''
# Generate linker file with physical addresses,
# to be used for debug purpose only
def generate_kernel_phys_linker_script(target, source, env):
phys_linker_in = source[0]
phys_linker_out = target[0]
cmd = config.toolchain + "cpp -D__CPP__ " + \
"-I%s -imacros l4/macros.h -imacros %s -imacros %s -C -P %s -o %s" % \
('include', 'l4/platform/'+ platform + '/offsets.h', \
'l4/glue/' + arch + '/memlayout.h', phys_linker_in, phys_linker_out)
print cmd
os.system(cmd)
create_kernel_phys_linker = Command(join(builddir, 'include/physlink.lds'), \
join(PROJROOT, 'include/physlink.lds.in'), \
generate_kernel_phys_linker_script)
'''
env = Environment(CC = config.toolchain + 'gcc',
AR = config.toolchain + 'ar',
RANLIB = config.toolchain + 'ranlib',
# 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', ('-mcpu=' + gcc_cpu_flag)],
LINKFLAGS = ['-nostdlib', '-T' + "include/l4/arch/arm/linker.lds"],
'-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/l4/arch/arm/linker.lds')],
ASFLAGS = ['-D__ASSEMBLY__'],
PROGSUFFIX = '.elf', # The suffix to use for final executable
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
LIBS = 'gcc', # libgcc.a - This is required for division routines.
CPPPATH = "#include",
CPPPATH = ["#include"],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__')
objects = []
objects += SConscript('src/drivers/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/generic/SConscript',exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/arch/' + arch + '/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/platform/' + platform + '/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/arch/' + arch + '/' + subarch + '/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/glue/' + arch + '/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/lib/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/api/SConscript', exports = {'symbols' : all_syms, 'env' : env})
objects += SConscript('src/generic/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'generic')
objects += SConscript('src/glue/' + arch + '/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'glue' + '/' + arch)
objects += SConscript('src/arch/' + arch + '/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'arch/' + arch)
objects += SConscript('src/arch/' + arch + '/' + subarch + '/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'arch/' + arch + '/' + subarch)
objects += SConscript('src/lib/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'lib')
objects += SConscript('src/api/SConscript',
exports = {'symbols' : all_syms, 'env' : env},
duplicate=0, build_dir=builddir + 'api')
objects += SConscript('src/drivers/SConscript',
exports = {'symbols' : all_syms, 'env' : env, 'platform' : platform,'bdir' : 'driver/'},
duplicate=0, build_dir=builddir)
objects += SConscript('src/platform/' + platform + '/SConscript',
exports = {'symbols' : all_syms, 'env' : env,'platform' : platform}, duplicate=0,
build_dir=builddir + 'platform' + '/' +platform)
kernel_elf = env.Program(BUILDDIR + '/kernel.elf', objects)
#env_phys = env.Clone()
#env_phys.Replace(LINKFLAGS = ['-nostdlib', '-T' + join(builddir, 'include/physlink.lds')])
#env_phys.Program(BUILDDIR + '/kernel_phys.elf', objects)
Alias('kernel', kernel_elf)
Depends(kernel_elf, objects)
Depends(objects, create_kernel_linker)
#Depends(objects, create_kernel_phys_linker)
Depends(objects, 'include/l4/config.h')

View File

@@ -13,7 +13,7 @@ from config.projpaths import *
config = configuration_retrieve()
arch = config.arch
platform = config.platform
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
variant = 'baremetal'
@@ -24,18 +24,19 @@ LIBC_INCPATH = ['#' + join(LIBC_PATH, 'include'), \
'#' + join(LIBC_PATH, 'include/arch/' + arch)]
LIBDEV_PATH = 'conts/libdev'
LIBDEV_LIBPATH = join(LIBDEV_PATH, 'uart')
LIBDEV_INCPATH = ['#' + join(LIBDEV_PATH, 'uart/include'),]
LIBDEV_INCPATH = ['#' + join(LIBDEV_PATH, 'include'),]
LIBELF_PATH = 'loader/libs/elf'
LIBELF_LIBPATH = LIBELF_PATH
LIBELF_INCPATH = '#' + join(LIBELF_PATH, 'include')
env = Environment(CC = config.kernel_toolchain + 'gcc',
env = Environment(CC = config.toolchain + 'gcc',
AR = config.toolchain + 'ar',
RANLIB = config.toolchain + 'ranlib',
# 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', ('-mcpu=' + gcc_cpu_flag)],
'-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib', '-T' + join(BUILDDIR, 'loader/linker.lds'), "-u_start"],
ASFLAGS = ['-D__ASSEMBLY__'],
PROGSUFFIX = '.elf',
@@ -43,7 +44,8 @@ env = Environment(CC = config.kernel_toolchain + 'gcc',
LIBS = ['gcc', 'elf', 'libdev-baremetal', 'c-baremetal', 'gcc'],
LIBPATH = [join(join('build', LIBDEV_PATH), 'sys-' + variant), \
join('build', LIBELF_PATH), join('build', LIBC_PATH)],
CPPPATH = ['#include', LIBDEV_INCPATH, LIBC_INCPATH, LIBELF_INCPATH])
CPPPATH = ['#include', LIBDEV_INCPATH, LIBC_INCPATH, LIBELF_INCPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__')
libdev = SConscript('conts/libdev/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : variant}, \

View File

@@ -11,16 +11,18 @@ from os.path import *
config = configuration_retrieve()
arch = config.arch
subarcn = config.subarch
subarch = config.subarch
platform = config.platform
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
all_syms = config.all
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + 'gcc',
AR = config.toolchain + 'ar',
RANLIB = config.toolchain + 'ranlib',
# 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', ('-mcpu=' + gcc_cpu_flag)],
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall',
'-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
@@ -29,7 +31,7 @@ env = Environment(CC = config.user_toolchain + 'gcc',
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
libl4 = SConscript('conts/libl4/SConscript', \
exports = { 'arch' : arch }, duplicate = 0, \
exports = { 'env' : env, 'arch' : arch, 'subarch' : subarch }, duplicate = 0, \
variant_dir = join(BUILDDIR, os.path.relpath('conts/libl4', PROJROOT)))
e = env.Clone()
@@ -41,13 +43,12 @@ libdev = SConscript('conts/libdev/SConscript', \
join(join(BUILDDIR, os.path.relpath('conts/libdev', PROJROOT)), 'sys-' + type))
libc = SConscript('conts/libc/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform, 'type' : 'userspace' }, \
exports = { 'env' : env, 'arch' : arch, 'type' : 'userspace' }, \
duplicate = 0, variant_dir = \
join(BUILDDIR, os.path.relpath('conts/libc', PROJROOT)))
libmm, libmc, libmalloc = SConscript('conts/libmem/SConscript', \
exports = { 'env' : env, 'arch' : arch, 'platform' : platform }, \
duplicate = 0, variant_dir = \
exports = { 'env' : env, }, duplicate = 0, variant_dir = \
join(BUILDDIR, os.path.relpath('conts/libmem', PROJROOT)))
Alias('libl4', libl4)

View File

@@ -12,6 +12,7 @@ from os.path import join
from config.projpaths import *
from config.configuration import *
from config.config_check import *
from scripts.qemu import qemu_cmdline
from scripts.conts import containers
from configure import *
@@ -31,7 +32,10 @@ def main():
# Build userspace libraries
#
print "\nBuilding userspace libraries..."
os.system('scons -f SConstruct.userlibs')
ret = os.system('scons -f SConstruct.userlibs')
if(ret):
print "Build failed \n"
sys.exit(1)
#
# Build containers
@@ -49,17 +53,31 @@ def main():
#
print "\nBuilding the kernel..."
os.chdir(PROJROOT)
os.system("scons")
ret = os.system("scons")
if(ret):
print "Build failed \n"
sys.exit(1)
#
# Build libs and loader
#
os.chdir(PROJROOT)
print "\nBuilding the loader and packing..."
os.system("scons -f SConstruct.loader")
ret = os.system("scons -f SConstruct.loader")
if(ret):
print "Build failed \n"
sys.exit(1)
#
# Build qemu-insight-script
#
print "\nBuilding qemu-insight-script.."
qemu_cmdline.build_qemu_cmdline_script()
#build_qemu_cmdline_script()
print "\nBuild complete."
print "\nRun qemu with following command: ./tools/run-qemu-insight\n"
if __name__ == "__main__":
main()

View File

@@ -36,7 +36,7 @@ cap_strings = { 'ipc' : \
\t\t\t[${idx}] = {
\t\t\t\t.target = ${cid},
\t\t\t\t.type = CAP_TYPE_IRQCTRL | ${target_rtype},
\t\t\t\t.access = CAP_IRQCTRL_REGISTER
\t\t\t\t.access = CAP_IRQCTRL_REGISTER | CAP_IRQCTRL_WAIT
\t\t\t\t | CAP_CHANGEABLE | CAP_REPLICABLE
\t\t\t\t | CAP_TRANSFERABLE,
\t\t\t\t.start = 0, .end = 0, .size = 0,
@@ -146,10 +146,11 @@ cap_strings = { 'ipc' : \
\t\t\t\t.target = ${cid},
\t\t\t\t.type = CAP_TYPE_MAP_PHYSMEM | CAP_RTYPE_CONTAINER,
\t\t\t\t.access = CAP_MAP_READ | CAP_MAP_WRITE | CAP_MAP_EXEC |
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP,
\t\t\t\t\tCAP_MAP_CACHED | CAP_MAP_UNCACHED | CAP_MAP_UNMAP |
\t\t\t\t\tCAP_IRQCTRL_REGISTER,
\t\t\t\t.start = __pfn(PLATFORM_${devname}_BASE),
\t\t\t\t.end = __pfn(PLATFORM_${devname}_BASE + PLATFORM_${devname}_SIZE),
\t\t\t\t.size = 1,
\t\t\t\t.size = PLATFORM_${devname}_SIZE >> 12,
\t\t\t\t.attr = (CAP_DEVTYPE_${devtype} & CAP_DEVTYPE_MASK)
\t\t\t\t\t| ((${devnum} << CAP_DEVNUM_SHIFT) & CAP_DEVNUM_MASK),
\t\t\t\t.irq = IRQ_${devname},

View File

@@ -8,33 +8,42 @@ symbols
ARCH_ARM 'ARM'
arm_cpu_type 'ARM Processor Type'
CPU_ARM1136 'ARM1136 - To be added'
CPU_ARM11MPCORE 'ARM11 MPCore - To be added'
CPU_ARM1136 'ARM1136 - Experimental'
CPU_ARM11MPCORE 'ARM11 MPCore - Experimental'
CPU_ARM926 'ARM926EJ-S'
CPU_CORTEXA8 'ARM Cortex-A8 - Not supported'
arm_subarch_type 'ARM Architecture Family'
SUBARCH_V5 'ARM v5 Architecture'
SUBARCH_V6 'ARM v6 Architecture, To be added'
SUBARCH_V7 'ARM v7 Architecture, To be added'
CPU_CORTEXA8 'ARM Cortex-A8'
CPU_CORTEXA9 'ARM Cortex-A9'
arm_platform_type 'ARM Platform Type'
PLATFORM_EB 'Realview EB Platform, Unsupported yet'
PLATFORM_EB 'Realview EB Platform'
PLATFORM_PBA8 'Realview PB-A8 Platform, To be added'
PLATFORM_PB926 'Versatile PB926 Platform'
PLATFORM_PB11MPCORE 'Realview PB11MPCore Platform'
PLATFORM_BEAGLE 'OMAP3530/Cortex-A8 Beagle Board'
PLATFORM_PBA9 'Realview Express Cortex-A9'
main_menu 'Codezero Microkernel Configurator'
arm_menu 'ARM Architecture Configuration'
arm_cpu_menu 'ARM CPU type'
arm_platform_menu 'ARM Platform Type'
processor_properties 'Generic Processor Properties'
kernel_generic_options 'Generic Kernel Properties'
toolchain_menu 'Toolchain Prefix'
containers_menu 'Container Setup'
arch_type 'Main architecture'
TOOLCHAIN_KERNEL 'Toolchain prefix for kernel'
TOOLCHAIN_USER 'Toolchain prefix for userspace'
SMP 'Enable SMP Support'
NCPU 'Number of SMP CPUs'
DEBUG_ACCOUNTING 'Enable system operations accounting'
DEBUG_PERFMON 'Enable performance monitoring'
DEBUG_PERFMON_USER 'Userspace access to perfmon registers (in-kernel measurements disabled)'
DEBUG_SPINLOCKS 'Debug spinlocks, e.g. detect recursive locks, double unlocks'
SCHED_TICKS 'Scheduler ticks per second'
ICACHE_DISABLE 'Disable the L1 instruction cache'
DCACHE_DISABLE 'Disable the L1 data cache'
PREEMPT_DISABLE 'Disable Kernel Preemption'
TOOLCHAIN 'Toolchain prefix for kernel'
CONTAINERS 'Number of containers'
CAPABILITIES 'Enable capability checking'
#############
@@ -45,17 +54,13 @@ choices arch_type
ARCH_ARM
default ARCH_ARM
choices arm_subarch_type
SUBARCH_V5
SUBARCH_V6
SUBARCH_V7
default SUBARCH_V5
choices arm_platform_type
PLATFORM_EB
PLATFORM_PBA8
PLATFORM_PB926
PLATFORM_PB11MPCORE
PLATFORM_BEAGLE
PLATFORM_PBA9
default PLATFORM_PB926
choices arm_cpu_type
@@ -63,6 +68,7 @@ choices arm_cpu_type
CPU_ARM1136
CPU_ARM11MPCORE
CPU_CORTEXA8
CPU_CORTEXA9
default CPU_ARM926
#############
@@ -76,55 +82,119 @@ menu arm_platform_menu
arm_platform_type
menu arm_menu
arm_subarch_type
arm_cpu_menu
arm_platform_menu
arm_cpu_menu
menu processor_properties
SMP
NCPU%
ICACHE_DISABLE
DCACHE_DISABLE
menu kernel_generic_options
PREEMPT_DISABLE
DEBUG_ACCOUNTING
DEBUG_PERFMON
DEBUG_PERFMON_USER
DEBUG_SPINLOCKS
SCHED_TICKS%
menu toolchain_menu
TOOLCHAIN_KERNEL$
TOOLCHAIN_USER$
TOOLCHAIN$
menu main_menu
arch_type
arm_menu
processor_properties
kernel_generic_options
toolchain_menu
CONTAINERS%
containers_menu
#############`
#############
# RULES #
#############
#Capability/Container rules:
default CAPABILITIES from y
default CONTAINERS from 1
default DEBUG_ACCOUNTING from n
default DEBUG_PERFMON from n
default DEBUG_PERFMON_USER from n
default DEBUG_SPINLOCKS from n
default SCHED_TICKS from 1000
derive DEBUG_PERFMON_KERNEL from DEBUG_PERFMON == y and DEBUG_PERFMON_USER != y
#Platform rules:
unless SUBARCH_V5 suppress PLATFORM_PB926
unless SUBARCH_V6 suppress PLATFORM_PB11MPCORE
#Subarch Derivation Rules
derive SUBARCH_V5 from CPU_ARM926
derive SUBARCH_V6 from CPU_ARM1136 or
CPU_ARM11MPCORE
derive SUBARCH_V7 from CPU_CORTEXA8 or
CPU_CORTEXA9
#CPU rules:
unless SUBARCH_V5 suppress CPU_ARM926
unless SUBARCH_V6 suppress CPU_ARM1136
unless SUBARCH_V6 suppress CPU_ARM11MPCORE
unless SUBARCH_V7 suppress CPU_CORTEXA8
unless PLATFORM_PB926 suppress CPU_ARM926
unless PLATFORM_PB11MPCORE or PLATFORM_EB suppress CPU_ARM11MPCORE
unless PLATFORM_EB suppress CPU_ARM1136
unless PLATFORM_PBA9 or PLATFORM_EB suppress CPU_CORTEXA9
unless PLATFORM_BEAGLE or
PLATFORM_PBA8 or
PLATFORM_EB suppress CPU_CORTEXA8
#SMP support rules
unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress SMP
unless CPU_CORTEXA9 or CPU_ARM11MPCORE suppress NCPU
unless SMP suppress NCPU
unless DEBUG_ACCOUNTING suppress DEBUG_PERFMON
DEBUG_PERFMON_USER
unless DEBUG_PERFMON suppress DEBUG_PERFMON_USER
# NOTE: Unlike menus, choices dont take { sym } model of visibility
# dependencies. Instead, a choice symbol is declared in a menu, and
# suppress statement is used to make sym visible, instead of a
# { sym } model under the choices. (See manual for { sym } usage).
unless SUBARCH_V5 suppress PLATFORM_PB926
unless ARCH_ARM suppress arm_menu
unless PLATFORM_EB suppress CPU_ARM1136
derive DRIVER_UART_PL011 from SUBARCH_V5 or SUBARCH_V6 or SUBARCH_V7
derive DRIVER_TIMER_SP804 from SUBARCH_V5 or SUBARCH_V6 or SUBARCH_V7
derive DRIVER_IRQ_PL190 from PLATFORM_PB926
derive DRIVER_IRQ_GIC from PLATFORM_PB11MPCORE or PLATFORM_EB
derive DRIVER_UART_PL011 from PLATFORM_PB926 or
PLATFORM_PB11MPCORE or
PLATFORM_PBA9 or
PLATFORM_EB or
PLATFORM_PBA8
derive DRIVER_TIMER_SP804 from PLATFORM_PB926 or
PLATFORM_PB11MPCORE or
PLATFORM_PBA9 or
PLATFORM_EB or
PLATFORM_PBA8
derive DRIVER_IRQ_PL190 from PLATFORM_PB926
derive DRIVER_IRQ_GIC from PLATFORM_PB11MPCORE or
PLATFORM_PBA9 or
PLATFORM_EB or
PLATFORM_PBA8
derive DRIVER_UART_OMAP from PLATFORM_BEAGLE
derive DRIVER_TIMER_OMAP from PLATFORM_BEAGLE
derive DRIVER_INTC_OMAP from PLATFORM_BEAGLE
#SMP default value
default SMP from y
default NCPU from 4
default ICACHE_DISABLE from n
default DCACHE_DISABLE from n
default PREEMPT_DISABLE from n
require NCPU <= 4
# Derive Ram base address depending on platform selected
# we use this in setting containers physical regions
# default values
# FIXME: Find a better solution
derive RAM_BASE_PLAT from PLATFORM_BEAGLE ? 0x80000000 : 0x00000000
# Toolchains:
default TOOLCHAIN_KERNEL from 'arm-none-eabi-'
default TOOLCHAIN_USER from 'arm-none-linux-gnueabi-'
default TOOLCHAIN from 'arm-none-eabi-'
prefix CONFIG_

View File

@@ -4,6 +4,8 @@ CONT%(cn)d_TYPE_BAREMETAL 'Baremetal Container'
CONT%(cn)d_TYPE_POSIX 'POSIX Container'
CONT%(cn)d_OPT_NAME 'Container Name'
CONTAINERS 'Number of containers'
CONT%(cn)d_PHYSMEM_REGIONS 'Container %(cn)d Number of Physical Regions'
CONT%(cn)d_PHYS0_START 'Container %(cn)d Physical Region 0 Start Address'
CONT%(cn)d_PHYS0_END 'Container %(cn)d Physical Region 0 End Address'
@@ -58,7 +60,7 @@ default CONT%(cn)d_LINUX_PAGE_OFFSET from CONT%(cn)d_VIRT0_START
default CONT%(cn)d_LINUX_PHYS_OFFSET from CONT%(cn)d_PHYS0_START
default CONT%(cn)d_LINUX_ROOTFS_ADDRESS from (CONT%(cn)d_LINUX_PHYS_OFFSET + 0x500000)
default CONT%(cn)d_VIRTMEM_REGIONS from 1
default CONT%(cn)d_VIRTMEM_REGIONS from (CONT%(cn)d_TYPE_POSIX==y ? 4 : 1)
default CONT%(cn)d_PHYSMEM_REGIONS from 1
# Define limits on virtual and physical memory regions of a _single_ container 0. Too much code!
@@ -106,7 +108,7 @@ require CONT%(cn)d_PHYS3_START >= 0x40000
require CONT%(cn)d_LINUX_ZRELADDR > CONT%(cn)d_LINUX_PHYS_OFFSET + 0x8000
# TODO: Do we want to check if PAGER_LMA/VMA lies in allocated memory regions
default CONT%(cn)d_PHYS0_START from (%(cn)d == 0 ? 0x100000 : (0x100000 + %(cn)d * 0x1000000))
default CONT%(cn)d_PHYS0_START from ((%(cn)d == 0 ? 0x100000 : (0x100000 + %(cn)d * 0x1000000)) + RAM_BASE_PLAT)
default CONT%(cn)d_PHYS0_END from (CONT%(cn)d_PHYS0_START + 0xD00000)
default CONT%(cn)d_PHYS1_START from CONT%(cn)d_PHYS0_END
default CONT%(cn)d_PHYS1_END from (CONT%(cn)d_PHYS1_START + 0x100000)
@@ -128,16 +130,14 @@ default CONT%(cn)d_VIRT4_END from (CONT%(cn)d_VIRT4_START + 0x10000000)
default CONT%(cn)d_VIRT5_START from 0xe0000000
default CONT%(cn)d_VIRT5_END from 0xf0000000
derive baremetal%(cn)d from
(CONT%(cn)d_BAREMETAL_PROJ_EMPTY==y) ? "empty%(cn)d" :
default CONT%(cn)d_OPT_NAME from
(CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" :
((CONT%(cn)d_TYPE_POSIX==y) ? "posix%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD==y) ? "hello_world%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO==y) ? "thread_demo%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_TEST==y) ? "test%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE==y) ? "test_suite%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE==y) ? "uart_service%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_CLCD_SERVICE==y) ? "clcd_service%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE==y) ? "timer_service%(cn)d" : "baremetal_noname%(cn)d" ))))))
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_BAREMETAL==y) ? baremetal%(cn)d : "posix%(cn)d")
((CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE==y) ? "timer_service%(cn)d" : "empty%(cn)d"))))))
when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params
unless CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_posix_pager_params
@@ -165,19 +165,17 @@ cont%(cn)d_baremetal_params 'Baremetal Project'
CONT%(cn)d_BAREMETAL_PROJ_EMPTY 'Empty Project'
CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD 'Hello World'
CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO 'Thread Library Demo'
CONT%(cn)d_BAREMETAL_PROJ_TEST 'Test Project'
CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE 'Microkernel Tests'
CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE 'UART Service'
CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE 'Timer Service'
CONT%(cn)d_BAREMETAL_PROJ_CLCD_SERVICE 'CLCD Service'
choices cont%(cn)d_baremetal_params
CONT%(cn)d_BAREMETAL_PROJ_EMPTY
CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD
CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO
CONT%(cn)d_BAREMETAL_PROJ_TEST
CONT%(cn)d_BAREMETAL_PROJ_TEST_SUITE
CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE
CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE
CONT%(cn)d_BAREMETAL_PROJ_CLCD_SERVICE
default CONT%(cn)d_BAREMETAL_PROJ_EMPTY
menu cont%(cn)d_default_pager_params
@@ -234,19 +232,16 @@ cont%(cn)d_cap_device_uart1 'Container %(cn)d UART1 Menu'
cont%(cn)d_cap_device_uart2 'Container %(cn)d UART2 Menu'
cont%(cn)d_cap_device_uart3 'Container %(cn)d UART3 Menu'
cont%(cn)d_cap_device_timer1 'Container %(cn)d TIMER23 Menu'
cont%(cn)d_cap_device_clcd 'Container %(cn)d CLCD Menu'
CONT%(cn)d_CAP_DEVICE_UART1_USE 'Container %(cn)d UART1 Enable'
CONT%(cn)d_CAP_DEVICE_UART2_USE 'Container %(cn)d UART2 Enable'
CONT%(cn)d_CAP_DEVICE_UART3_USE 'Container %(cn)d UART3 Enable'
CONT%(cn)d_CAP_DEVICE_TIMER1_USE 'Container %(cn)d TIMER23 Enable'
CONT%(cn)d_CAP_DEVICE_CLCD0_USE 'Container %(cn)d CLCD Enable'
default CONT%(cn)d_CAP_DEVICE_UART1_USE from n
default CONT%(cn)d_CAP_DEVICE_UART2_USE from n
default CONT%(cn)d_CAP_DEVICE_UART3_USE from n
default CONT%(cn)d_CAP_DEVICE_TIMER1_USE from n
default CONT%(cn)d_CAP_DEVICE_CLCD0_USE from n
menu cont%(cn)d_cap_device_uart1
CONT%(cn)d_CAP_DEVICE_UART1_USE
@@ -260,15 +255,11 @@ menu cont%(cn)d_cap_device_uart3
menu cont%(cn)d_cap_device_timer1
CONT%(cn)d_CAP_DEVICE_TIMER1_USE
menu cont%(cn)d_cap_device_clcd
CONT%(cn)d_CAP_DEVICE_CLCD0_USE
menu cont%(cn)d_device_list
cont%(cn)d_cap_device_uart1
cont%(cn)d_cap_device_uart2
cont%(cn)d_cap_device_uart3
cont%(cn)d_cap_device_timer1
cont%(cn)d_cap_device_clcd
#
# Settings for Custom Capabilities
@@ -512,6 +503,10 @@ CONT%(cn)d_CAP_CAPCTRL_USE 'Enable this Capability'
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
CONT%(cn)d_CAP_IRQCTRL_USE 'Enable this Capability'
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
CONT%(cn)d_CAP_UMUTEX_USE 'Enable this Capability'
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER 'Capability Targets Current Container'
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE 'Capability Targets Current Pager`s Space'
@@ -539,6 +534,7 @@ cont%(cn)d_cap_tctrl 'Container %(cn)d Thread Control Capability'
cont%(cn)d_cap_exregs 'Container %(cn)d Exchange Registers Capability'
cont%(cn)d_cap_ipc 'Container %(cn)d IPC Capability'
cont%(cn)d_cap_capctrl 'Container %(cn)d Capability Control Capability'
cont%(cn)d_cap_irqctrl 'Container %(cn)d IRQ Control Capability'
cont%(cn)d_cap_umutex 'Container %(cn)d Userspace Mutex Control Capability'
cont%(cn)d_cap_custom0 'Container %(cn)d Custom Capability 0 Parameters'
cont%(cn)d_cap_custom1 'Container %(cn)d Custom Capability 1 Parameters'
@@ -589,6 +585,10 @@ when CONT%(cn)d_CAP_CAPCTRL_USE == n
suppress CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE
when CONT%(cn)d_CAP_IRQCTRL_USE == n
suppress CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
when CONT%(cn)d_CAP_UMUTEX_USE == n
suppress CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
@@ -615,6 +615,10 @@ choicegroup CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE
default CONT%(cn)d_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER from y
choicegroup CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
default CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER from y
choicegroup CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
default CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER from y
@@ -623,6 +627,7 @@ default CONT%(cn)d_CAP_TCTRL_USE from y
default CONT%(cn)d_CAP_EXREGS_USE from y
default CONT%(cn)d_CAP_IPC_USE from y
default CONT%(cn)d_CAP_CAPCTRL_USE from y
default CONT%(cn)d_CAP_IRQCTRL_USE from y
default CONT%(cn)d_CAP_UMUTEX_USE from y
default CONT%(cn)d_CAP_IPC_TARGET from 0
@@ -648,6 +653,11 @@ menu cont%(cn)d_cap_umutex
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE
menu cont%(cn)d_cap_irqctrl
CONT%(cn)d_CAP_IRQCTRL_USE
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER
CONT%(cn)d_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE
menu cont%(cn)d_cap_ipc
CONT%(cn)d_CAP_IPC_USE
CONT%(cn)d_CAP_IPC_TARGET_CURRENT_CONTAINER
@@ -687,6 +697,7 @@ menu cont%(cn)d_capability_list
cont%(cn)d_cap_ipc
cont%(cn)d_cap_capctrl
cont%(cn)d_cap_umutex
cont%(cn)d_cap_irqctrl
cont%(cn)d_cap_custom0
cont%(cn)d_cap_custom1
cont%(cn)d_cap_custom2

View File

@@ -0,0 +1,302 @@
#
# Automatically generated, don't edit
#
# Generated on: amit-laptop
# At: Tue, 23 Feb 2010 17:03:17 +0000
# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009
#
# Codezero Microkernel Configurator
#
#
# Main architecture
#
CONFIG_ARCH_ARM=y
#
# ARM Architecture Configuration
#
#
# ARM Platform Type
#
#
# ARM Platform Type
#
CONFIG_PLATFORM_EB=n
CONFIG_PLATFORM_PBA8=n
CONFIG_PLATFORM_PB926=n
CONFIG_PLATFORM_PB11MPCORE=n
CONFIG_PLATFORM_BEAGLE=y
CONFIG_PLATFORM_PBA9=n
#
# ARM CPU type
#
#
# ARM Processor Type
#
CONFIG_CPU_CORTEXA8=y
#
# Generic Processor Properties
#
CONFIG_ICACHE_DISABLE=n
CONFIG_DCACHE_DISABLE=n
#
# Generic Kernel Properties
#
CONFIG_PREEMPT_DISABLE=n
CONFIG_DEBUG_ACCOUNTING=y
CONFIG_DEBUG_PERFMON=n
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN="arm-none-eabi-"
#
# Container Setup
#
CONFIG_CAPABILITIES=y
CONFIG_CONTAINERS=1
#
# Container 0 Parameters
#
#
# Container 0 Type
#
CONFIG_CONT0_TYPE_BAREMETAL=y
CONFIG_CONT0_TYPE_POSIX=n
CONFIG_CONT0_TYPE_LINUX=n
#
# Container 0 Options
#
CONFIG_CONT0_OPT_NAME="hello_world0"
#
# Baremetal Project
#
CONFIG_CONT0_BAREMETAL_PROJ_EMPTY=n
CONFIG_CONT0_BAREMETAL_PROJ_HELLO_WORLD=y
CONFIG_CONT0_BAREMETAL_PROJ_THREADS_DEMO=n
CONFIG_CONT0_BAREMETAL_PROJ_TEST_SUITE=n
CONFIG_CONT0_BAREMETAL_PROJ_UART_SERVICE=n
CONFIG_CONT0_BAREMETAL_PROJ_TIMER_SERVICE=n
#
# Container 0 Default Pager Parameters
#
CONFIG_CONT0_PAGER_LMA=0x80100000
CONFIG_CONT0_PAGER_VMA=0xa0000000
#
# Container 0 Physical Memory Regions (Capabilities)
#
CONFIG_CONT0_PHYSMEM_REGIONS=1
CONFIG_CONT0_PHYS0_START=0x80100000
CONFIG_CONT0_PHYS0_END=0x80e00000
#
# Container 0 Virtual Memory Regions (Capabilities)
#
CONFIG_CONT0_VIRTMEM_REGIONS=1
CONFIG_CONT0_VIRT0_START=0xa0000000
CONFIG_CONT0_VIRT0_END=0xb0000000
#
# Container 0 Capability List
#
#
# Container 0 Thread Pool Capability
#
CONFIG_CONT0_CAP_THREADPOOL_USE=y
CONFIG_CONT0_CAP_THREADPOOL_SIZE=64
#
# Container 0 Space Pool Capability
#
CONFIG_CONT0_CAP_SPACEPOOL_USE=y
CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64
#
# Container 0 Mutex Pool Capability
#
CONFIG_CONT0_CAP_MUTEXPOOL_USE=y
CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100
#
# Container 0 Map Pool Capability
#
CONFIG_CONT0_CAP_MAPPOOL_USE=y
CONFIG_CONT0_CAP_MAPPOOL_SIZE=800
#
# Container 0 Capability Pool Capability
#
CONFIG_CONT0_CAP_CAPPOOL_USE=y
CONFIG_CONT0_CAP_CAPPOOL_SIZE=32
#
# Container 0 Thread Control Capability
#
CONFIG_CONT0_CAP_TCTRL_USE=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Exchange Registers Capability
#
CONFIG_CONT0_CAP_EXREGS_USE=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IPC Capability
#
CONFIG_CONT0_CAP_IPC_USE=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n
#
# Container 0 Capability Control Capability
#
CONFIG_CONT0_CAP_CAPCTRL_USE=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Userspace Mutex Control Capability
#
CONFIG_CONT0_CAP_UMUTEX_USE=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IRQ Control Capability
#
CONFIG_CONT0_CAP_IRQCTRL_USE=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Custom Capability 0 Parameters
#
CONFIG_CONT0_CAP_CUSTOM0_USE=n
#
# Container 0 Custom Capability 1 Parameters
#
CONFIG_CONT0_CAP_CUSTOM1_USE=n
#
# Container 0 Custom Capability 2 Parameters
#
CONFIG_CONT0_CAP_CUSTOM2_USE=n
#
# Container 0 Custom Capability 3 Parameters
#
CONFIG_CONT0_CAP_CUSTOM3_USE=n
#
# Container 0 Devices (Capabilities)
#
#
# Container 0 UART1 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART1_USE=n
#
# Container 0 UART2 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART2_USE=n
#
# Container 0 UART3 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART3_USE=n
#
# Container 0 TIMER23 Menu
#
CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n
#
# Derived symbols
#
CONFIG_DEBUG_PERFMON_KERNEL=n
CONFIG_CONT1_PAGER_LOAD_ADDR=0x81100000
CONFIG_DRIVER_IRQ_PL190=n
CONFIG_DRIVER_TIMER_SP804=n
CONFIG_CONT2_START_PC_ADDR=0xc0000000
CONFIG_CONT3_START_PC_ADDR=0xd0000000
CONFIG_DRIVER_IRQ_GIC=n
CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000
CONFIG_RAM_BASE_PLAT=2147483648
CONFIG_DRIVER_INTC_OMAP=y
CONFIG_CONT2_PAGER_LOAD_ADDR=0x82100000
CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000
CONFIG_CONT3_PAGER_LOAD_ADDR=0x83100000
CONFIG_SUBARCH_V5=n
CONFIG_SUBARCH_V7=y
CONFIG_SUBARCH_V6=n
CONFIG_DRIVER_TIMER_OMAP=y
CONFIG_CONT0_PAGER_LOAD_ADDR=0x80100000
CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000
CONFIG_DRIVER_UART_OMAP=y
CONFIG_DRIVER_UART_PL011=n
CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000
CONFIG_CONT0_START_PC_ADDR=0xa0000000
CONFIG_CONT1_START_PC_ADDR=0xb0000000
#
# That's all, folks!

View File

@@ -54,8 +54,7 @@ CONFIG_PLATFORM_PB926=y
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-"
CONFIG_TOOLCHAIN_USER="arm-none-linux-gnueabi-"
CONFIG_TOOLCHAIN="arm-none-eabi-"
CONFIG_CONTAINERS=1

View File

@@ -0,0 +1,292 @@
#
# Automatically generated, don't edit
#
# Generated on: amit-laptop
# At: Wed, 03 Mar 2010 21:07:44 +0000
# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009
#
# Codezero Microkernel Configurator
#
#
# Main architecture
#
CONFIG_ARCH_ARM=y
#
# ARM Architecture Configuration
#
#
# ARM Platform Type
#
#
# ARM Platform Type
#
CONFIG_PLATFORM_EB=n
CONFIG_PLATFORM_PBA8=n
CONFIG_PLATFORM_PB926=n
CONFIG_PLATFORM_PB11MPCORE=n
CONFIG_PLATFORM_BEAGLE=y
CONFIG_PLATFORM_PBA9=n
#
# ARM CPU type
#
#
# ARM Processor Type
#
CONFIG_CPU_CORTEXA8=y
#
# Generic Processor Properties
#
CONFIG_ICACHE_DISABLE=n
CONFIG_DCACHE_DISABLE=n
#
# Generic Kernel Properties
#
CONFIG_PREEMPT_DISABLE=n
CONFIG_DEBUG_ACCOUNTING=n
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN="arm-none-eabi-"
#
# Container Setup
#
CONFIG_CAPABILITIES=y
CONFIG_CONTAINERS=1
#
# Container 0 Parameters
#
#
# Container 0 Type
#
CONFIG_CONT0_TYPE_BAREMETAL=n
CONFIG_CONT0_TYPE_POSIX=n
CONFIG_CONT0_TYPE_LINUX=y
#
# Container 0 Options
#
CONFIG_CONT0_OPT_NAME="linux0"
#
# Container 0 Linux Pager Parameters
#
CONFIG_CONT0_LINUX_PHYS_OFFSET=0x80200000
CONFIG_CONT0_LINUX_ZRELADDR=0x80208000
CONFIG_CONT0_LINUX_ROOTFS_ADDRESS=0x80700000
CONFIG_CONT0_LINUX_PAGE_OFFSET=0xa0000000
#
# Container 0 Physical Memory Regions (Capabilities)
#
CONFIG_CONT0_PHYSMEM_REGIONS=1
CONFIG_CONT0_PHYS0_START=0x80200000
CONFIG_CONT0_PHYS0_END=0x80f00000
#
# Container 0 Virtual Memory Regions (Capabilities)
#
CONFIG_CONT0_VIRTMEM_REGIONS=1
CONFIG_CONT0_VIRT0_START=0xa0000000
CONFIG_CONT0_VIRT0_END=0xb0000000
#
# Container 0 Capability List
#
#
# Container 0 Thread Pool Capability
#
CONFIG_CONT0_CAP_THREADPOOL_USE=y
CONFIG_CONT0_CAP_THREADPOOL_SIZE=64
#
# Container 0 Space Pool Capability
#
CONFIG_CONT0_CAP_SPACEPOOL_USE=y
CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64
#
# Container 0 Mutex Pool Capability
#
CONFIG_CONT0_CAP_MUTEXPOOL_USE=y
CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100
#
# Container 0 Map Pool Capability
#
CONFIG_CONT0_CAP_MAPPOOL_USE=y
CONFIG_CONT0_CAP_MAPPOOL_SIZE=800
#
# Container 0 Capability Pool Capability
#
CONFIG_CONT0_CAP_CAPPOOL_USE=y
CONFIG_CONT0_CAP_CAPPOOL_SIZE=32
#
# Container 0 Thread Control Capability
#
CONFIG_CONT0_CAP_TCTRL_USE=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Exchange Registers Capability
#
CONFIG_CONT0_CAP_EXREGS_USE=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IPC Capability
#
CONFIG_CONT0_CAP_IPC_USE=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n
#
# Container 0 Capability Control Capability
#
CONFIG_CONT0_CAP_CAPCTRL_USE=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Userspace Mutex Control Capability
#
CONFIG_CONT0_CAP_UMUTEX_USE=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IRQ Control Capability
#
CONFIG_CONT0_CAP_IRQCTRL_USE=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Custom Capability 0 Parameters
#
CONFIG_CONT0_CAP_CUSTOM0_USE=n
#
# Container 0 Custom Capability 1 Parameters
#
CONFIG_CONT0_CAP_CUSTOM1_USE=n
#
# Container 0 Custom Capability 2 Parameters
#
CONFIG_CONT0_CAP_CUSTOM2_USE=n
#
# Container 0 Custom Capability 3 Parameters
#
CONFIG_CONT0_CAP_CUSTOM3_USE=n
#
# Container 0 Devices (Capabilities)
#
#
# Container 0 UART1 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART1_USE=n
#
# Container 0 UART2 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART2_USE=n
#
# Container 0 UART3 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART3_USE=n
#
# Container 0 TIMER23 Menu
#
CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n
#
# Derived symbols
#
CONFIG_DEBUG_PERFMON_KERNEL=n
CONFIG_CONT1_PAGER_LOAD_ADDR=0x81100000
CONFIG_DRIVER_IRQ_PL190=n
CONFIG_DRIVER_TIMER_SP804=n
CONFIG_CONT2_START_PC_ADDR=0xc0000000
CONFIG_CONT3_START_PC_ADDR=0xd0000000
CONFIG_DRIVER_IRQ_GIC=n
CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000
CONFIG_RAM_BASE_PLAT=2147483648
CONFIG_DRIVER_INTC_OMAP=y
CONFIG_CONT2_PAGER_LOAD_ADDR=0x82100000
CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000
CONFIG_CONT3_PAGER_LOAD_ADDR=0x83100000
CONFIG_SUBARCH_V5=n
CONFIG_SUBARCH_V7=y
CONFIG_SUBARCH_V6=n
CONFIG_DRIVER_TIMER_OMAP=y
CONFIG_CONT0_PAGER_LOAD_ADDR=0x80200000
CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000
CONFIG_DRIVER_UART_OMAP=y
CONFIG_DRIVER_UART_PL011=n
CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000
CONFIG_CONT0_START_PC_ADDR=0xa0008000
CONFIG_CONT1_START_PC_ADDR=0xb0000000
#
# That's all, folks!

View File

@@ -0,0 +1,292 @@
#
# Automatically generated, don't edit
#
# Generated on: amit-laptop
# At: Wed, 03 Mar 2010 08:42:40 +0000
# Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009
#
# Codezero Microkernel Configurator
#
#
# Main architecture
#
CONFIG_ARCH_ARM=y
#
# ARM Architecture Configuration
#
#
# ARM Platform Type
#
#
# ARM Platform Type
#
CONFIG_PLATFORM_EB=n
CONFIG_PLATFORM_PBA8=n
CONFIG_PLATFORM_PB926=y
CONFIG_PLATFORM_PB11MPCORE=n
CONFIG_PLATFORM_BEAGLE=n
CONFIG_PLATFORM_PBA9=n
#
# ARM CPU type
#
#
# ARM Processor Type
#
CONFIG_CPU_ARM926=y
#
# Generic Processor Properties
#
CONFIG_ICACHE_DISABLE=n
CONFIG_DCACHE_DISABLE=n
#
# Generic Kernel Properties
#
CONFIG_PREEMPT_DISABLE=n
CONFIG_DEBUG_ACCOUNTING=n
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN="arm-none-eabi-"
#
# Container Setup
#
CONFIG_CAPABILITIES=y
CONFIG_CONTAINERS=1
#
# Container 0 Parameters
#
#
# Container 0 Type
#
CONFIG_CONT0_TYPE_BAREMETAL=n
CONFIG_CONT0_TYPE_POSIX=n
CONFIG_CONT0_TYPE_LINUX=y
#
# Container 0 Options
#
CONFIG_CONT0_OPT_NAME="linux0"
#
# Container 0 Linux Pager Parameters
#
CONFIG_CONT0_LINUX_PHYS_OFFSET=0x200000
CONFIG_CONT0_LINUX_ZRELADDR=0x208000
CONFIG_CONT0_LINUX_ROOTFS_ADDRESS=0x700000
CONFIG_CONT0_LINUX_PAGE_OFFSET=0xa0000000
#
# Container 0 Physical Memory Regions (Capabilities)
#
CONFIG_CONT0_PHYSMEM_REGIONS=1
CONFIG_CONT0_PHYS0_START=0x200000
CONFIG_CONT0_PHYS0_END=0xf00000
#
# Container 0 Virtual Memory Regions (Capabilities)
#
CONFIG_CONT0_VIRTMEM_REGIONS=1
CONFIG_CONT0_VIRT0_START=0xa0000000
CONFIG_CONT0_VIRT0_END=0xb0000000
#
# Container 0 Capability List
#
#
# Container 0 Thread Pool Capability
#
CONFIG_CONT0_CAP_THREADPOOL_USE=y
CONFIG_CONT0_CAP_THREADPOOL_SIZE=64
#
# Container 0 Space Pool Capability
#
CONFIG_CONT0_CAP_SPACEPOOL_USE=y
CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64
#
# Container 0 Mutex Pool Capability
#
CONFIG_CONT0_CAP_MUTEXPOOL_USE=y
CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100
#
# Container 0 Map Pool Capability
#
CONFIG_CONT0_CAP_MAPPOOL_USE=y
CONFIG_CONT0_CAP_MAPPOOL_SIZE=800
#
# Container 0 Capability Pool Capability
#
CONFIG_CONT0_CAP_CAPPOOL_USE=y
CONFIG_CONT0_CAP_CAPPOOL_SIZE=32
#
# Container 0 Thread Control Capability
#
CONFIG_CONT0_CAP_TCTRL_USE=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Exchange Registers Capability
#
CONFIG_CONT0_CAP_EXREGS_USE=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IPC Capability
#
CONFIG_CONT0_CAP_IPC_USE=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n
#
# Container 0 Capability Control Capability
#
CONFIG_CONT0_CAP_CAPCTRL_USE=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Userspace Mutex Control Capability
#
CONFIG_CONT0_CAP_UMUTEX_USE=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IRQ Control Capability
#
CONFIG_CONT0_CAP_IRQCTRL_USE=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Custom Capability 0 Parameters
#
CONFIG_CONT0_CAP_CUSTOM0_USE=n
#
# Container 0 Custom Capability 1 Parameters
#
CONFIG_CONT0_CAP_CUSTOM1_USE=n
#
# Container 0 Custom Capability 2 Parameters
#
CONFIG_CONT0_CAP_CUSTOM2_USE=n
#
# Container 0 Custom Capability 3 Parameters
#
CONFIG_CONT0_CAP_CUSTOM3_USE=n
#
# Container 0 Devices (Capabilities)
#
#
# Container 0 UART1 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART1_USE=n
#
# Container 0 UART2 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART2_USE=n
#
# Container 0 UART3 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART3_USE=n
#
# Container 0 TIMER23 Menu
#
CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=n
#
# Derived symbols
#
CONFIG_DEBUG_PERFMON_KERNEL=n
CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000
CONFIG_DRIVER_IRQ_PL190=y
CONFIG_DRIVER_TIMER_SP804=y
CONFIG_CONT2_START_PC_ADDR=0xc0000000
CONFIG_CONT3_START_PC_ADDR=0xd0000000
CONFIG_DRIVER_IRQ_GIC=n
CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000
CONFIG_RAM_BASE_PLAT=0
CONFIG_DRIVER_INTC_OMAP=n
CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000
CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000
CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000
CONFIG_SUBARCH_V5=y
CONFIG_SUBARCH_V7=n
CONFIG_SUBARCH_V6=n
CONFIG_DRIVER_TIMER_OMAP=n
CONFIG_CONT0_PAGER_LOAD_ADDR=0x200000
CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000
CONFIG_DRIVER_UART_OMAP=n
CONFIG_DRIVER_UART_PL011=y
CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000
CONFIG_CONT0_START_PC_ADDR=0xa0008000
CONFIG_CONT1_START_PC_ADDR=0xb0000000
#
# That's all, folks!

View File

@@ -54,8 +54,7 @@ CONFIG_PLATFORM_PB926=y
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-"
CONFIG_TOOLCHAIN_USER="arm-none-linux-gnueabi-"
CONFIG_TOOLCHAIN="arm-none-eabi-"
CONFIG_CONTAINERS=1

View File

@@ -54,8 +54,7 @@ CONFIG_PLATFORM_PB926=y
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN_KERNEL="arm-none-eabi-"
CONFIG_TOOLCHAIN_USER="arm-none-linux-gnueabi-"
CONFIG_TOOLCHAIN="arm-none-eabi-"
CONFIG_CONTAINERS=2

View File

@@ -0,0 +1,302 @@
#
# Automatically generated, don't edit
#
# Generated on: bahadir-laptop
# At: Thu, 25 Feb 2010 16:06:59 +0000
# Linux version 2.6.31-19-generic (buildd@palmer) (gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8) ) #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010
#
# Codezero Microkernel Configurator
#
#
# Main architecture
#
CONFIG_ARCH_ARM=y
#
# ARM Architecture Configuration
#
#
# ARM Platform Type
#
#
# ARM Platform Type
#
CONFIG_PLATFORM_EB=n
CONFIG_PLATFORM_PBA8=n
CONFIG_PLATFORM_PB926=n
CONFIG_PLATFORM_PB11MPCORE=n
CONFIG_PLATFORM_BEAGLE=n
CONFIG_PLATFORM_PBA9=y
#
# ARM CPU type
#
#
# ARM Processor Type
#
CONFIG_CPU_CORTEXA9=y
#
# Generic Processor Properties
#
CONFIG_SMP=n
CONFIG_ICACHE_DISABLE=n
CONFIG_DCACHE_DISABLE=n
#
# Generic Kernel Properties
#
CONFIG_PREEMPT_DISABLE=n
CONFIG_DEBUG_ACCOUNTING=y
CONFIG_DEBUG_PERFMON=y
CONFIG_DEBUG_PERFMON_USER=y
#
# Toolchain Prefix
#
CONFIG_TOOLCHAIN="arm-none-eabi-"
CONFIG_CONTAINERS=1
#
# Container Setup
#
CONFIG_CAPABILITIES=y
#
# Container 0 Parameters
#
#
# Container 0 Type
#
CONFIG_CONT0_TYPE_BAREMETAL=y
CONFIG_CONT0_TYPE_POSIX=n
CONFIG_CONT0_TYPE_LINUX=n
#
# Container 0 Options
#
CONFIG_CONT0_OPT_NAME="test_suite0"
#
# Baremetal Project
#
CONFIG_CONT0_BAREMETAL_PROJ_EMPTY=y
CONFIG_CONT0_BAREMETAL_PROJ_HELLO_WORLD=n
CONFIG_CONT0_BAREMETAL_PROJ_THREADS_DEMO=n
CONFIG_CONT0_BAREMETAL_PROJ_TEST_SUITE=n
CONFIG_CONT0_BAREMETAL_PROJ_UART_SERVICE=n
CONFIG_CONT0_BAREMETAL_PROJ_TIMER_SERVICE=n
#
# Container 0 Default Pager Parameters
#
CONFIG_CONT0_PAGER_LMA=0x100000
CONFIG_CONT0_PAGER_VMA=0xa0000000
#
# Container 0 Physical Memory Regions (Capabilities)
#
CONFIG_CONT0_PHYSMEM_REGIONS=1
CONFIG_CONT0_PHYS0_START=0x100000
CONFIG_CONT0_PHYS0_END=0xe00000
#
# Container 0 Virtual Memory Regions (Capabilities)
#
CONFIG_CONT0_VIRTMEM_REGIONS=1
CONFIG_CONT0_VIRT0_START=0xa0000000
CONFIG_CONT0_VIRT0_END=0xb0000000
#
# Container 0 Capability List
#
#
# Container 0 Thread Pool Capability
#
CONFIG_CONT0_CAP_THREADPOOL_USE=y
CONFIG_CONT0_CAP_THREADPOOL_SIZE=64
#
# Container 0 Space Pool Capability
#
CONFIG_CONT0_CAP_SPACEPOOL_USE=y
CONFIG_CONT0_CAP_SPACEPOOL_SIZE=64
#
# Container 0 Mutex Pool Capability
#
CONFIG_CONT0_CAP_MUTEXPOOL_USE=y
CONFIG_CONT0_CAP_MUTEXPOOL_SIZE=100
#
# Container 0 Map Pool Capability
#
CONFIG_CONT0_CAP_MAPPOOL_USE=y
CONFIG_CONT0_CAP_MAPPOOL_SIZE=800
#
# Container 0 Capability Pool Capability
#
CONFIG_CONT0_CAP_CAPPOOL_USE=y
CONFIG_CONT0_CAP_CAPPOOL_SIZE=32
#
# Container 0 Thread Control Capability
#
CONFIG_CONT0_CAP_TCTRL_USE=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_TCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Exchange Registers Capability
#
CONFIG_CONT0_CAP_EXREGS_USE=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_EXREGS_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IPC Capability
#
CONFIG_CONT0_CAP_IPC_USE=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IPC_TARGET_CURRENT_PAGER_SPACE=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_CONTAINER=n
CONFIG_CONT0_CAP_IPC_TARGET_ANOTHER_PAGER=n
#
# Container 0 Capability Control Capability
#
CONFIG_CONT0_CAP_CAPCTRL_USE=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_CAPCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Userspace Mutex Control Capability
#
CONFIG_CONT0_CAP_UMUTEX_USE=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_UMUTEX_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 IRQ Control Capability
#
CONFIG_CONT0_CAP_IRQCTRL_USE=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_CONTAINER=y
CONFIG_CONT0_CAP_IRQCTRL_TARGET_CURRENT_PAGER_SPACE=n
#
# Container 0 Custom Capability 0 Parameters
#
CONFIG_CONT0_CAP_CUSTOM0_USE=n
#
# Container 0 Custom Capability 1 Parameters
#
CONFIG_CONT0_CAP_CUSTOM1_USE=n
#
# Container 0 Custom Capability 2 Parameters
#
CONFIG_CONT0_CAP_CUSTOM2_USE=n
#
# Container 0 Custom Capability 3 Parameters
#
CONFIG_CONT0_CAP_CUSTOM3_USE=n
#
# Container 0 Devices (Capabilities)
#
#
# Container 0 UART1 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART1_USE=n
#
# Container 0 UART2 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART2_USE=n
#
# Container 0 UART3 Menu
#
CONFIG_CONT0_CAP_DEVICE_UART3_USE=n
#
# Container 0 TIMER23 Menu
#
CONFIG_CONT0_CAP_DEVICE_TIMER1_USE=y
#
# Derived symbols
#
CONFIG_DEBUG_PERFMON_KERNEL=n
CONFIG_CONT1_PAGER_LOAD_ADDR=0x1100000
CONFIG_DRIVER_IRQ_PL190=n
CONFIG_DRIVER_TIMER_SP804=y
CONFIG_CONT2_START_PC_ADDR=0xc0000000
CONFIG_CONT3_START_PC_ADDR=0xd0000000
CONFIG_DRIVER_IRQ_GIC=y
CONFIG_CONT2_PAGER_VIRT_ADDR=0xc0000000
CONFIG_CONT2_PAGER_LOAD_ADDR=0x2100000
CONFIG_CONT1_PAGER_VIRT_ADDR=0xb0000000
CONFIG_CONT3_PAGER_LOAD_ADDR=0x3100000
CONFIG_SUBARCH_V5=n
CONFIG_SUBARCH_V7=y
CONFIG_SUBARCH_V6=n
CONFIG_DRIVER_TIMER_OMAP=n
CONFIG_CONT0_PAGER_LOAD_ADDR=0x100000
CONFIG_CONT0_PAGER_VIRT_ADDR=0xa0000000
CONFIG_DRIVER_UART_OMAP=n
CONFIG_DRIVER_UART_PL011=y
CONFIG_CONT3_PAGER_VIRT_ADDR=0xd0000000
CONFIG_CONT0_START_PC_ADDR=0xa0000000
CONFIG_CONT1_START_PC_ADDR=0xb0000000
#
# That's all, folks!

View File

@@ -55,19 +55,21 @@ class Container:
class configuration:
def __init__(self):
# Mapping between platform selected and gcc flags for it
self.cpu_to_gcc_flag = (['ARM926', 'arm926ej-s'],
['CORTEXA8', 'cortex-a8'],
['ARM11MPCORE', 'mpcore'],
['ARM1136', 'arm1136jf-s'],
['ARM1176', 'arm1176jz-s'],)
# Mapping between cpu and gcc flags for it.
# Optimized solution to derive gcc arch flag from cpu
# gcc flag here is "-march"
# cpu -march flag
self.arch_to_gcc_flag = (['ARM926', 'armv5'],
['ARM1136', 'armv6'],
['ARM11MPCORE', 'armv6k'],
['CORTEXA8', 'armv7-a'],
['CORTEXA9', 'armv7-a'])
self.arch = None
self.subarch = None
self.platform = None
self.cpu = None
self.gcc_cpu_flag = None
self.user_toolchain = None
self.kernel_toolchain = None
self.gcc_arch_flag = None
self.toolchain = None
self.all = []
self.containers = []
self.ncontainers = 0
@@ -102,26 +104,22 @@ class configuration:
parts = name.split("_", 3)
self.platform = parts[2].lower()
# Extract cpu and its gcc flag from a name value pair
# Extract cpu from a name value pair
def get_cpu(self, name, val):
if name[:len("CONFIG_CPU_")] == "CONFIG_CPU_":
parts = name.split("_", 3)
self.cpu = parts[2].lower()
for cputype, cpuflag in self.cpu_to_gcc_flag:
if parts[2] == cputype:
self.gcc_cpu_flag = cpuflag
# derive gcc "-march" flag
for cputype, archflag in self.arch_to_gcc_flag:
if cputype == parts[2]:
self.gcc_arch_flag = archflag
# Extract kernel space toolchain from a name value pair
def get_toolchain_kernel(self, name, val):
if name[:len("CONFIG_TOOLCHAIN_KERNEL")] == "CONFIG_TOOLCHAIN_KERNEL":
parts = val.split("\"", 3)
self.kernel_toolchain = parts[1]
# Extract user space toolchain from a name value pair
def get_toolchain_user(self, name, val):
if name[:len("CONFIG_TOOLCHAIN_USER")] == "CONFIG_TOOLCHAIN_USER":
parts = val.split("\"", 3)
self.user_toolchain = parts[1]
def get_toolchain(self, name, val):
if name[:len("CONFIG_TOOLCHAIN")] == "CONFIG_TOOLCHAIN":
parts = val.split("\"", 2)
self.toolchain = parts[1]
# Extract number of containers
def get_ncontainers(self, name, val):

View File

@@ -23,7 +23,7 @@ CONFIG_SHELVE_FILENAME = "configuration"
CONFIG_SHELVE = join(CONFIG_SHELVE_DIR, CONFIG_SHELVE_FILENAME)
KERNEL_CINFO_PATH = join(PROJROOT, "src/generic/cinfo.c")
LINUXDIR = join(PROJROOT, 'conts/linux')
LINUX_KERNELDIR = join(LINUXDIR, 'linux-2.6.28.10')
LINUX_KERNELDIR = join(LINUXDIR, 'linux-2.6.33')
LINUX_ROOTFSDIR = join(LINUXDIR, 'rootfs')
LINUX_ATAGSDIR = join(LINUXDIR, 'atags')

View File

@@ -36,21 +36,20 @@ def cml2_header_to_symbols(cml2_header, config):
if pair is not None:
name, value = pair
config.get_all(name, value)
config.get_cpu(name, value)
config.get_arch(name, value)
config.get_subarch(name, value)
config.get_platform(name, value)
config.get_cpu(name, value)
config.get_ncontainers(name, value)
config.get_container_parameters(name, value)
config.get_toolchain_kernel(name, value)
config.get_toolchain_user(name, value)
config.get_toolchain(name, value)
def cml2_update_config_h(config_h_path, config):
with open(config_h_path, "a") as config_h:
config_h.write("#define __ARCH__ " + config.arch + '\n')
config_h.write("#define __PLATFORM__ " + config.platform + '\n')
config_h.write("#define __SUBARCH__ " + config.subarch + '\n')
config_h.write("#define __CPU__ " + config.cpu + '\n')
def configure_kernel(cml_file):
config = configuration()
@@ -91,6 +90,10 @@ def build_parse_options():
default = False, dest = "print_config",
help = "Prints out configuration settings"
"(Symbol values and container parameters are printed)")
parser.add_option("-q", "--quite", action="store_true", dest="quite", default = False,
help = "Enable quite mode"
"(will not be presented with a configuration screen)")
(options, args) = parser.parse_args()
@@ -148,10 +151,17 @@ def configure_system(options, args):
if os.path.exists(CML2_CONFIG_FILE) and options.backup_config:
shutil.copy(CML2_CONFIG_FILE, CML2_CONFIG_FILE_SAVED)
# Create configuration from existing file
os.system(CML2TOOLSDIR + '/cmlconfigure.py -c -o ' + \
CML2_CONFIG_FILE + ' -i ' + cml2_config_file + \
' ' + CML2_COMPILED_RULES)
if options.quite:
# Create configuration from existing file
os.system(CML2TOOLSDIR + '/cmlconfigure.py -b -o ' + \
CML2_CONFIG_FILE + ' -i ' + cml2_config_file + \
' ' + CML2_COMPILED_RULES)
else:
# Create configuration from existing file
os.system(CML2TOOLSDIR + '/cmlconfigure.py -c -o ' + \
CML2_CONFIG_FILE + ' -i ' + cml2_config_file + \
' ' + CML2_COMPILED_RULES)
else:
rules_file = autogen_rules_file(options, args)

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -9,7 +9,7 @@
#include <l4/api/errno.h>
#include <l4/api/space.h>
#include <capability.h>
#include <l4lib/capability/cap_print.h>
#include <container.h>
#include <pl110_clcd.h> /* FIXME: Its best if this is <libdev/uart/pl011.h> */
#include <linker.h>
@@ -28,7 +28,7 @@ int cap_read_all()
/* Read number of capabilities */
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
0, 0, 0, &ncaps)) < 0) {
0, &ncaps)) < 0) {
printf("l4_capability_control() reading # of"
" capabilities failed.\n Could not "
"complete CAP_CONTROL_NCAPS request.\n");
@@ -38,7 +38,7 @@ int cap_read_all()
/* Read all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_READ,
0, 0, 0, caparray)) < 0) {
0, caparray)) < 0) {
printf("l4_capability_control() reading of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_READ_CAPS request.\n");

View File

@@ -17,7 +17,7 @@ from config.configuration import *
config = configuration_retrieve()
platform = config.platform
arch = config.arch
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
LIBL4_RELDIR = 'conts/libl4'
KERNEL_INCLUDE = join(PROJROOT, 'include')
@@ -36,18 +36,17 @@ LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + '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', ('-mcpu=' + gcc_cpu_flag), LIBDEV_CCFLAGS],
'-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\

View File

@@ -1,8 +1,10 @@
/*
* Main function for this container
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4/api/space.h>
int main(void)

View File

@@ -17,7 +17,7 @@ from config.configuration import *
config = configuration_retrieve()
platform = config.platform
arch = config.arch
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
LIBL4_RELDIR = 'conts/libl4'
KERNEL_INCLUDE = join(PROJROOT, 'include')
@@ -36,18 +36,17 @@ LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + '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', ('-mcpu=' + gcc_cpu_flag), LIBDEV_CCFLAGS],
'-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
@@ -58,7 +57,7 @@ env = Environment(CC = config.user_toolchain + 'gcc',
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')
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -include l4lib/macros.h')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')

View File

@@ -1,8 +1,10 @@
/*
* Main function for this container
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4/api/space.h>
extern int print_hello_world(void);

View File

@@ -0,0 +1,2 @@

View File

@@ -39,6 +39,11 @@ LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
# We don't use -nostdinc because sometimes we need standard headers,
# such as stdarg.h e.g. for variable args, as in printk().
@@ -48,13 +53,15 @@ env = Environment(CC = config.user_toolchain + 'gcc',
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', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH],
LIBS = ['gcc', 'libl4', 'c-userspace', 'libdev-userspace', 'gcc', 'libmalloc',
'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')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
src += Glob('src/arch/*.[cS]')
objs = env.Object(src)
prog = env.Program('main.elf', objs)

View File

@@ -1,12 +1,6 @@
#ifndef __CAPABILITY_H__
#define __CAPABILITY_H__
#include <l4/api/capability.h>
#include <l4/generic/capability.h>
#include <l4/generic/cap-types.h>
void capability_print(struct capability *cap);
int caps_read_all();
#endif /* __CAPABILITY_H__ */

View File

@@ -5,7 +5,6 @@
*/
#include <l4/api/errno.h>
#include <container.h>
#include <capability.h>
#include <thread.h>
#include <tests.h>
#include <l4lib/arch/syslib.h>

View File

@@ -1,11 +1,11 @@
#include <l4lib/arch/asm.h>
BEGIN_PROC(setup_new_thread)
BEGIN_PROC(local_setup_new_thread)
ldr r0, [sp, #-4]! @ Load first argument.
mov lr, pc @ Save return address
ldr pc, [sp, #-4]! @ Load function pointer from stack
new_thread_exit:
b new_thread_exit @ We infinitely loop for now.
END_PROC(setup_new_thread)
END_PROC(local_setup_new_thread)

View File

@@ -4,7 +4,7 @@
* Copyright (C) 2009 B Labs Ltd.
*/
#include <stdio.h>
#include <capability.h>
#include <l4lib/capability/cap_print.h>
#include <l4lib/arch/syscalls.h>
static struct capability cap_array[30];
@@ -76,78 +76,6 @@ void cap_grant_single(struct capability *orig, struct capability *share, l4id_t
#endif
void cap_print(struct capability *cap)
{
printf("Capability id:\t\t\t%d\n", cap->capid);
printf("Capability resource id:\t\t%d\n", cap->resid);
printf("Capability owner id:\t\t%d\n",cap->owner);
switch (cap_type(cap)) {
case CAP_TYPE_TCTRL:
printf("Capability type:\t\t%s\n", "Thread Control");
break;
case CAP_TYPE_EXREGS:
printf("Capability type:\t\t%s\n", "Exchange Registers");
break;
case CAP_TYPE_MAP_PHYSMEM:
printf("Capability type:\t\t%s\n", "Map/Physmem");
break;
case CAP_TYPE_MAP_VIRTMEM:
printf("Capability type:\t\t%s\n", "Map/Virtmem");
break;
case CAP_TYPE_IPC:
printf("Capability type:\t\t%s\n", "Ipc");
break;
case CAP_TYPE_UMUTEX:
printf("Capability type:\t\t%s\n", "Mutex");
break;
case CAP_TYPE_QUANTITY:
printf("Capability type:\t\t%s\n", "Quantitative");
break;
default:
printf("Capability type:\t\t%s\n", "Unknown");
break;
}
switch (cap_rtype(cap)) {
case CAP_RTYPE_THREAD:
printf("Capability resource type:\t%s\n", "Thread");
break;
case CAP_RTYPE_TGROUP:
printf("Capability resource type:\t%s\n", "Thread Group");
break;
case CAP_RTYPE_SPACE:
printf("Capability resource type:\t%s\n", "Space");
break;
case CAP_RTYPE_CONTAINER:
printf("Capability resource type:\t%s\n", "Container");
break;
case CAP_RTYPE_THREADPOOL:
printf("Capability resource type:\t%s\n", "Thread Pool");
break;
case CAP_RTYPE_SPACEPOOL:
printf("Capability resource type:\t%s\n", "Space Pool");
break;
case CAP_RTYPE_MUTEXPOOL:
printf("Capability resource type:\t%s\n", "Mutex Pool");
break;
case CAP_RTYPE_MAPPOOL:
printf("Capability resource type:\t%s\n", "Map Pool (PMDS)");
break;
case CAP_RTYPE_CPUPOOL:
printf("Capability resource type:\t%s\n", "Cpu Pool");
break;
case CAP_RTYPE_CAPPOOL:
printf("Capability resource type:\t%s\n", "Capability Pool");
break;
default:
printf("Capability resource type:\t%s\n", "Unknown");
break;
}
printf("\n");
}
int caps_read_all(void)
{
int ncaps;
@@ -170,9 +98,7 @@ int caps_read_all(void)
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
for (int i = 0; i < ncaps; i++)
cap_print(&cap_array[i]);
//cap_array_print(ncaps, caparray);
return 0;
}

View File

@@ -1,9 +1,10 @@
#include <thread.h>
#include <capability.h>
#include <container.h>
#include <capability.h>
#include <tests.h>
#include <l4/api/errno.h>
#include <l4lib/arch/syslib.h>
#include <l4/api/capability.h>
int simple_pager_thread(void *arg)
{
@@ -14,8 +15,8 @@ int simple_pager_thread(void *arg)
l4_getid(&ids);
//printf("Thread spawned from pager, "
// "trying to create new thread.\n");
printf("Thread spawned from pager, \
trying to create new thread.\n");
err = l4_thread_control(THREAD_CREATE |
TC_SHARE_SPACE |
TC_AS_PAGER, &ids);
@@ -23,8 +24,8 @@ int simple_pager_thread(void *arg)
if (res == 0)
if (err == -ENOCAP ||
err == -ENOMEM) {
//printf("Creation failed with %d "
// "as expected.\n", err);
printf("Creation failed with %d "
"as expected.\n", err);
testres = 0;
} else {
printf("Creation was supposed to fail "
@@ -58,7 +59,7 @@ int wait_check_test(struct task_ids *ids)
int result;
/* Wait for thread to finish */
//result = l4_thread_control(THREAD_WAIT, ids);
result = l4_thread_control(THREAD_WAIT, ids);
if (result < 0) {
printf("Waiting on (%d)'s exit failed.\n", ids->tid);
return -1;
@@ -66,6 +67,7 @@ int wait_check_test(struct task_ids *ids)
printf("Top-level test has failed\n");
}
/* Else it is a success */
return 0;
}
@@ -74,7 +76,7 @@ int capability_test(void)
int err;
struct task_ids ids;
int TEST_MUST_FAIL = 0;
int TEST_MUST_SUCCEED = 1;
//int TEST_MUST_SUCCEED = 1;
/* Read pager capabilities */
caps_read_all();
@@ -90,17 +92,17 @@ int capability_test(void)
goto out_err;
}
printf("waititng for result\n");
/* Wait for test to finish and check result */
if (wait_check_test(&ids) < 0)
goto out_err;
#if 0
/* Destroy test thread */
if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) {
printf("Destruction of top-level simple_pager failed.\n");
BUG();
}
#endif
/*
* Share operations with the same thread
@@ -129,7 +131,6 @@ int capability_test(void)
if (wait_check_test(&ids) < 0)
goto out_err;
#if 0
/* Destroy test thread */
if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) {
printf("Destruction of top-level simple_pager failed.\n");

View File

@@ -12,7 +12,7 @@ char *__stack_ptr = &stack[1][0];
char utcb[THREADS_TOTAL][UTCB_SIZE] ALIGN(8);
char *__utcb_ptr = &utcb[1][0];
extern void setup_new_thread(void);
extern void local_setup_new_thread(void);
int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids)
@@ -44,16 +44,16 @@ int thread_create(int (*func)(void *), void *args, unsigned int flags,
return -ENOMEM;
/* First word of new stack is arg */
((unsigned long *)__stack_ptr)[-1] = (unsigned long)args;
*(((unsigned int *)__stack_ptr) -1) = (unsigned int)args;
/* Second word of new stack is function address */
((unsigned long *)__stack_ptr)[-2] = (unsigned long)func;
*(((unsigned int *)__stack_ptr) -2) = (unsigned int)func;
/* Setup new thread pc, sp, utcb */
memset(&exregs, 0, sizeof(exregs));
exregs_set_stack(&exregs, (unsigned long)__stack_ptr);
exregs_set_utcb(&exregs, (unsigned long)__utcb_ptr);
exregs_set_pc(&exregs, (unsigned long)setup_new_thread);
exregs_set_pc(&exregs, (unsigned long)local_setup_new_thread);
if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0)
return err;

View File

@@ -0,0 +1,67 @@
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- Virtualization microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, shelve, sys
from os.path import *
PROJRELROOT = '../..'
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from config.lib import *
config = configuration_retrieve()
arch = config.arch
platform = config.platform
gcc_arch_flag = config.gcc_arch_flag
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)
# Locally important paths are here
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)]
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.toolchain + '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', 'gcc', 'libmalloc',
'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')
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
src += Glob('src/arch/*.[cS]')
objs = env.Object(src)
prog = env.Program('main.elf', objs)
Depends(prog, 'include/linker.lds')

View File

@@ -0,0 +1,21 @@
/*
* Container entry point for pager
*
* Copyright (C) 2007-2009 B Labs Ltd.
*/
#include <l4lib/init.h>
#include <l4lib/utcb.h>
extern void main(void);
void __container_init(void)
{
/* Generic L4 initialisation */
__l4_init();
/* Entry to main */
main();
}

View File

@@ -0,0 +1,6 @@
#ifndef __CAPABILITY_H__
#define __CAPABILITY_H__
int caps_read_all();
#endif /* __CAPABILITY_H__ */

View File

@@ -0,0 +1,7 @@
#ifndef __TESTS_H__
#define __TESTS_H__
int capability_test(void);
#endif /* __TESTS_H__ */

View File

@@ -0,0 +1,19 @@
#ifndef __THREAD_H__
#define __THREAD_H__
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4lib/exregs.h>
#include <l4/api/thread.h>
int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids);
/* For same space */
#define STACK_SIZE 0x1000
#define THREADS_TOTAL 10
#endif /* __THREAD_H__ */

View File

@@ -0,0 +1,81 @@
/*
* Main function for all tests
*
* Copyright (C) 2009 B Labs Ltd.
*/
#include <l4/api/errno.h>
#include <container.h>
#include <thread.h>
#include <tests.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4/api/space.h>
int exit_test_thread(void *arg)
{
while (1)
;
//l4_thread_switch(0);
//l4_exit(5);
return 0;
}
int exit_test(void)
{
int ret;
struct task_ids ids;
/* Create and run a new thread */
if ((ret = thread_create(exit_test_thread, 0,
TC_SHARE_SPACE | TC_AS_PAGER,
&ids)) < 0) {
printf("Top-level simple_pager creation failed.\n");
goto out_err;
} else
printf("Thread (%d) created successfully.\n", ids.tid);
// l4_thread_switch(0);
/* Kill it */
printf("Killing Thread (%d).\n", ids.tid);
if ((ret = l4_thread_control(THREAD_DESTROY, &ids)) < 0)
printf("Error: Killing Thread (%d), err = %d\n", ids.tid, ret);
else
printf("Success: Killed Thread (%d)\n", ids.tid);
#if 0
/* Wait on it */
printf("Waiting on Thread (%d) to exit.\n", ids.tid);
if ((ret = l4_thread_control(THREAD_WAIT, &ids)) >= 0)
printf("Success. Paged child returned %d\n", ret);
else
printf("Error. Wait on (%d) failed. err = %d\n",
ids.tid, ret);
#endif
return 0;
out_err:
BUG();
}
int main(void)
{
printf("%s: Container %s started\n",
__CONTAINER__, __CONTAINER_NAME__);
capability_test();
//exit_test();
/* Now quit to demo self-paging quit */
//l4_exit(0);
/* Now quit by null pointer */
// *((int *)0) = 5;
return 0;
}

View File

@@ -0,0 +1,11 @@
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(asm.h)
BEGIN_PROC(local_setup_new_thread)
ldr r0, [sp, #-4]! @ Load first argument.
mov lr, pc @ Save return address
ldr pc, [sp, #-4]! @ Load function pointer from stack
new_thread_exit:
b new_thread_exit @ We infinitely loop for now.
END_PROC(local_setup_new_thread)

View File

@@ -0,0 +1,106 @@
/*
* Capability-related userspace helpers
*
* Copyright (C) 2009 B Labs Ltd.
*/
#include <stdio.h>
#include <l4lib/capability/cap_print.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syscalls.h)
static struct capability cap_array[30];
#if 0
struct cap_group {
struct cap_list virtmem;
struct cap_list physmem;
struct cap_list threadpool;
struct cap_list tctrl;
struct cap_list exregs;
struct cap_list ipc;
struct cap_list mutex;
struct cap_list sched;
struct cap_list mutexpool;
struct cap_list spacepool;
struct cap_list cappool;
};
static inline struct capability *cap_get_thread()
{
}
static inline struct capability *cap_get_space()
{
}
static inline struct capability *cap_get_ipc()
{
}
static inline struct capability *cap_get_virtmem()
{
}
static inline struct capability *cap_get_physmem()
{
}
static inline struct capability *cap_get_physmem(unsigned long phys)
{
}
static inline struct capability *cap_get_virtmem(unsigned long virt)
{
}
static inline struct capability *cap_get_byid(l4id_t id)
{
}
void cap_share_single(struct capability *orig, struct capability *share, l4id_t target, unsigned int flags)
{
}
void cap_grant_single(struct capability *orig, struct capability *share, l4id_t target, unsigned int flags)
{
}
#endif
int caps_read_all(void)
{
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();
}
/* Read all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_READ,
0, cap_array)) < 0) {
printf("l4_capability resource_control() reading of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
//cap_array_print(ncaps, caparray);
return 0;
}

View File

@@ -0,0 +1,149 @@
#include <thread.h>
#include <container.h>
#include <capability.h>
#include <tests.h>
#include <l4/api/errno.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include <l4/api/capability.h>
int simple_pager_thread(void *arg)
{
int err;
int res = *(int *)arg;
struct task_ids ids;
int testres = 0;
l4_getid(&ids);
printf("Thread spawned from pager, \
trying to create new thread.\n");
err = l4_thread_control(THREAD_CREATE |
TC_SHARE_SPACE |
TC_AS_PAGER, &ids);
if (res == 0)
if (err == -ENOCAP ||
err == -ENOMEM) {
printf("Creation failed with %d "
"as expected.\n", err);
testres = 0;
} else {
printf("Creation was supposed to fail "
"with %d or %d, but err = %d\n",
-ENOMEM, -ENOCAP, err);
testres = 1;
}
else
if (err == 0) {
// printf("Creation succeeded as expected.\n");
testres = 0;
} else {
printf("Creation was supposed to succeed, "
"but err = %d\n", err);
testres = 1;
}
/* Destroy thread we created */
if (err == 0 &&
res == 0)
l4_thread_control(THREAD_DESTROY, &ids);
/* Destroy self */
l4_exit(testres);
return 0;
}
int wait_check_test(struct task_ids *ids)
{
int result;
/* Wait for thread to finish */
result = l4_thread_control(THREAD_WAIT, ids);
if (result < 0) {
printf("Waiting on (%d)'s exit failed.\n", ids->tid);
return -1;
} else if (result > 0) {
printf("Top-level test has failed\n");
}
/* Else it is a success */
return 0;
}
int capability_test(void)
{
int err;
struct task_ids ids;
int TEST_MUST_FAIL = 0;
//int TEST_MUST_SUCCEED = 1;
/* Read pager capabilities */
caps_read_all();
/*
* Create new thread that will attempt
* a pager privileged operation
*/
if ((err = thread_create(simple_pager_thread,
&TEST_MUST_FAIL,
TC_SHARE_SPACE, &ids)) < 0) {
printf("Top-level simple_pager creation failed.\n");
goto out_err;
}
printf("waititng for result\n");
/* Wait for test to finish and check result */
if (wait_check_test(&ids) < 0)
goto out_err;
#if 0
/* Destroy test thread */
if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) {
printf("Destruction of top-level simple_pager failed.\n");
BUG();
}
/*
* Share operations with the same thread
* group
*/
if ((err = l4_capability_control(CAP_CONTROL_SHARE,
CAP_SHARE_CONTAINER, 0)) < 0) {
printf("Sharing capability with thread group failed.\n");
goto out_err;
}
/*
* Create new thread that will attempt a pager privileged
* operation. This should succeed as we shared caps with
* the thread group.
*/
if ((err = thread_create(simple_pager_thread,
&TEST_MUST_SUCCEED,
TC_SHARE_SPACE |
TC_SHARE_GROUP, &ids)) < 0) {
printf("Top-level simple_pager creation failed.\n");
goto out_err;
}
/* Wait for test to finish and check result */
if (wait_check_test(&ids) < 0)
goto out_err;
/* Destroy test thread */
if ((err = l4_thread_control(THREAD_DESTROY, &ids)) < 0) {
printf("Destruction of top-level simple_pager failed.\n");
BUG();
}
#endif
printf("Capability Sharing Test -- PASSED --\n");
return 0;
out_err:
printf("Capability Sharing Test -- FAILED --\n");
return 0;
}

View File

@@ -0,0 +1,220 @@
#if 0
int mutex_user_thread(void *arg)
{
/* TODO: Create and access a mutex */
}
int independent_thread(void *arg)
{
/* TODO: Do whatever syscall available */
}
/*
* This example demonstrates how the capability-based
* security model can be bypassed and taken out of the
* way for the sake of implementing an application that
* doesn't worry too much about security.
*
* The benefit is that the user does neither worry about
* capabilities nor using its api to design correctly
* secure systems. The downside is that the system is
* less security-enforced, i.e. all parties must be
* trusted.
*/
int multi_threaded_nocaps_example(void)
{
/*
* We are the first pager with capabilities to
* create new tasks, spaces, in its own container.
*/
pager_read_caps();
/*
* We have all our capabilities private to us.
*
* If we create a new task, it won't be able to
* any kernel operations that we can do, because
* we hold our capabilities privately.
*
* In order to settle all capability access issues
* once and for all threads we will create and manage,
* we share our capabilities with the most global
* collection possible.
*/
/*
* Share all of our capabilities with all threads
* in the same container.
*
* From this point onwards, any thread we create and
* manage (i.e. whose container id is equal to our
* container id) will have the ability to leverage
* all of our capabilities as defined for us at
* configuration time.
*/
l4_cap_share(0, CAP_SHARE_CONTAINER | CAP_SHARE_ALL, self_tid());
/*
* Lets try it.
*
* Create new thread that we don't have any hieararchical
* relationship, i.e. one that is a pager of itself, one
* that runs in a new address space, and in a new thread
* group. All we share is the container.
*/
if ((err = thread_create(independent_thread, 0,
TC_NO_SHARING, &ids)) < 0) {
printf("mutex_user_thread creation failed.\n");
goto out_err;
}
/*
* We can inspect the new thread by doing an ipc to it.
* NOTE:
*
* We are able to send to this thread from the start,
* as we had a container-wide ipc capability defined at
* config-time.
*
* But we would not be able to receive from it, if we
* did not share this capability with the container. It
* would have no rights to do a send to us. But because
* we're in the same container, and we shared our
* capability, it now can.
*/
if ((err = l4_recv(ids->tid, ids->tid, 0)) < 0) {
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
goto out_err;
}
/*
* From this point onwards we can create more threads
* without worrying about whether they have the caps
* to do certain ops, and the caps api. because we shared
* them all at the beginning.
*/
out_err:
BUG();
}
/*
* This example demonstrates how a pager would
* share part of its capabilities on the system
* with its children.
*
* The example includes sharing of a mutex
* capability with a paged-child.
*/
int multi_threaded_capability_sharing_example(void)
{
struct capability *mutex_cap;
int thread_retval;
/*
* We are the first pager with capabilities to
* create new tasks, spaces, in its own container.
*/
pager_read_caps();
/*
* We have all our capabilities private to us.
*
* If we create a new task, it won't be able to
* create and use userspace mutexes, because we
* hold mutex capabilities privately.
*
* Lets try it.
*/
/*
* Create new thread that will attempt
* a mutex operation, and die on us with a
* negative return code if it fails.
*/
if ((err = thread_create(mutex_user_thread, 0,
TC_SHARE_SPACE |
TC_AS_PAGER, &ids)) < 0) {
printf("mutex_user_thread creation failed.\n");
goto out_err;
}
/* Check on how the thread has done */
if ((err = l4_thread_wait_on(ids, &thread_retval)) < 0) {
print("Waiting on thread %d failed. err = %d\n",
ids->tid, err);
goto out_err;
}
if (thread_retval == 0) {
printf("Thread %d returned with success, where "
"we expected failure.\n", ids->tid);
goto out_err;
}
/*
* Therefore, we share our capabilities with a
* collection so that our capabilities may be also
* used by them.
*/
/* Get our private mutex cap */
mutex_cap = cap_get(CAP_TYPE_MUTEX);
/* We have ability to create and use this many mutexes */
printf("%s: We have ability to create/use %d mutexes\n",
self_tid(), mutex_cap->size);
/* Split it */
cap_new = cap_split(mutex_cap, 10, CAP_SPLIT_SIZE);
/*
* Share the split part with paged-children.
*
* From this point onwards, any thread we create and
* manage (i.e. whose pagerid == self_tid()) will have
* the ability to use mutexes, as defined by cap_new
* we created.
*/
l4_cap_share(cap_new, CAP_SHARE_PGGROUP, self_tid());
/*
* Create new thread that will attempt
* a mutex operation, and die on us with a
* negative return code if it fails.
*/
if ((err = thread_create(mutex_user_thread, 0,
TC_SHARE_SPACE |
TC_AS_PAGER, &ids)) < 0) {
printf("mutex_user_thread creation failed.\n");
goto out_err;
}
/* Check on how the thread has done */
if ((err = l4_thread_wait_on(ids, &thread_retval)) < 0) {
printf("Waiting on thread %d failed. err = %d\n",
ids->tid, err);
goto out_err;
}
if (thread_retval < 0) {
printf("Thread %d returned with failure, where "
"we expected success.\n", ids->tid);
goto out_err;
}
out_err:
BUG();
}
#endif

View File

@@ -0,0 +1,73 @@
/*
* Thread creation userspace helpers
*
* Copyright (C) 2009 B Labs Ltd.
*/
#include <thread.h>
#include <l4/api/errno.h>
char stack[THREADS_TOTAL][STACK_SIZE] ALIGN(8);
char *__stack_ptr = &stack[1][0];
char utcb[THREADS_TOTAL][UTCB_SIZE] ALIGN(8);
char *__utcb_ptr = &utcb[1][0];
extern void local_setup_new_thread(void);
int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids)
{
struct task_ids ids;
struct exregs_data exregs;
int err;
l4_getid(&ids);
/* Shared space only */
if (!(TC_SHARE_SPACE & flags)) {
printf("%s: This function allows only "
"shared space thread creation.\n",
__FUNCTION__);
return -EINVAL;
}
/* Create thread */
if ((err = l4_thread_control(THREAD_CREATE | flags, &ids)) < 0)
return err;
/* Check if more stack/utcb available */
if ((unsigned long)__utcb_ptr ==
(unsigned long)&utcb[THREADS_TOTAL][0])
return -ENOMEM;
if ((unsigned long)__stack_ptr ==
(unsigned long)&stack[THREADS_TOTAL][0])
return -ENOMEM;
/* First word of new stack is arg */
*(((unsigned int *)__stack_ptr) -1) = (unsigned int)args;
/* Second word of new stack is function address */
*(((unsigned int *)__stack_ptr) -2) = (unsigned int)func;
/* Setup new thread pc, sp, utcb */
memset(&exregs, 0, sizeof(exregs));
exregs_set_stack(&exregs, (unsigned long)__stack_ptr);
exregs_set_utcb(&exregs, (unsigned long)__utcb_ptr);
exregs_set_pc(&exregs, (unsigned long)local_setup_new_thread);
if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0)
return err;
/* Update utcb, stack pointers */
__stack_ptr += STACK_SIZE;
__utcb_ptr += UTCB_SIZE;
/* Start the new thread */
if ((err = l4_thread_control(THREAD_RUN, &ids)) < 0)
return err;
memcpy(new_ids, &ids, sizeof(ids));
return 0;
}

View File

@@ -17,7 +17,7 @@ from config.configuration import *
config = configuration_retrieve()
platform = config.platform
arch = config.arch
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
LIBL4_RELDIR = 'conts/libl4'
KERNEL_INCLUDE = join(PROJROOT, 'include')
@@ -36,33 +36,25 @@ LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
LIBL4THREAD_RELDIR = 'conts/libl4thread'
LIBL4THREAD_DIR = join(PROJROOT, LIBL4THREAD_RELDIR)
LIBL4THREAD_LIBPATH = join(BUILDDIR, LIBL4THREAD_RELDIR)
LIBL4THREAD_INCLUDE = join(LIBL4THREAD_DIR, 'include')
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + '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', ('-mcpu=' + gcc_cpu_flag), LIBDEV_CCFLAGS],
'-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 = ['libl4thread', 'libl4', 'libmalloc', 'c-userspace', \
'libdev-userspace', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, \
LIBC_INCLUDE, LIBL4THREAD_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBL4THREAD_LIBPATH, \
LIBMEM_LIBPATH],
LIBS = ['libl4', 'libmalloc', 'c-userspace', 'libdev-userspace', \
'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
CPPPATH = ["#include", KERNEL_INCLUDE, LIBL4_INCLUDE, LIBDEV_INCLUDE, LIBC_INCLUDE],
LIBPATH = [LIBL4_LIBPATH, LIBDEV_LIBPATH, LIBC_LIBPATH, LIBMEM_LIBPATH],
CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h')
src = Glob('*.[cS]')

View File

@@ -1,10 +1,11 @@
/*
* Main function for this container
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4/api/space.h>
#include <l4thread/thread.h>
#include <l4lib/thread/thread.h>
/* Symbolic constants */
#define STACK_SIZE 0x1000

View File

@@ -18,7 +18,7 @@ from configure import *
config = configuration_retrieve()
arch = config.arch
platform = config.platform
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
# Wrapper library for system calls
LIBL4_RELDIR = 'conts/libl4'
@@ -37,20 +37,18 @@ LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include'),
join(LIBDEV_DIR, 'timer/sp804/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
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
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + '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', ('-mcpu=' + gcc_cpu_flag), LIBDEV_CCFLAGS], \
'-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
@@ -65,6 +63,7 @@ env = Environment(CC = config.user_toolchain + 'gcc',
src = Glob('*.[cS]')
src += Glob('src/*.[cS]')
src += Glob('src/arch/*.[cS]')
objs = env.Object(src)
prog = env.Program('main.elf', objs)

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -0,0 +1,19 @@
#ifndef __THREAD_H__
#define __THREAD_H__
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4lib/exregs.h>
#include <l4/api/thread.h>
int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids);
/* For same space */
#define STACK_SIZE 0x1000
#define THREADS_TOTAL 10
#endif /* __THREAD_H__ */

View File

@@ -1,36 +1,84 @@
/*
* Timer details.
*/
#ifndef __TIMER_H__
#define __TIMER_H__
/*
* Timer specific things are here
*/
#include <l4lib/mutex.h>
#include <l4/lib/list.h>
#include <l4lib/types.h>
/*
* Structure representing the sleeping tasks,
* tgid: tgid of sleeping task
* wait_count: time left, in microseconds, after which task
* will be signalled to get out of sleep
*/
struct timer_task {
/* Structure representing the sleeping tasks */
struct sleeper_task {
struct link list;
l4id_t tgid;
unsigned int wait_count;
l4id_t tid; /* tid of sleeping task */
int retval; /* return value on wakeup */
};
/* list of tasks to be woken up */
struct wake_task_list {
struct link head;
struct link *end; /* optimization */
struct l4_mutex lock; /* lock for sanity of head */
};
#define BUCKET_BASE_LEVEL_BITS 8
#define BUCKET_HIGHER_LEVEL_BITS 6
#define BUCKET_BASE_LEVEL_SIZE (1 << BUCKET_BASE_LEVEL_BITS)
#define BUCKET_HIGHER_LEVEL_SIZE (1 << BUCKET_HIGHER_LEVEL_BITS)
#define BUCKET_BASE_LEVEL_MASK 0xFF
#define BUCKET_HIGHER_LEVEL_MASK 0x3F
/*
* Timer structure,
* base: base address of sp804 timer encapsulated
* count: Count in microseconds from the start of this timer
* tasklist: list of tasks sleeping for some value of count
* lock: lock protecting the corruption of tasklist
*/
struct sp804_timer {
unsigned int base;
unsigned int count;
struct link tasklist;
struct l4_mutex lock;
* Web of sleeping tasks
* based on timer wheel base algorithm
*/
struct sleeper_task_bucket {
struct link bucket_level0[BUCKET_BASE_LEVEL_SIZE];
struct link bucket_level1[BUCKET_HIGHER_LEVEL_SIZE];
struct link bucket_level2[BUCKET_HIGHER_LEVEL_SIZE];
struct link bucket_level3[BUCKET_HIGHER_LEVEL_SIZE];
struct link bucket_level4[BUCKET_HIGHER_LEVEL_SIZE];
};
/* Macros to extract bucket levels */
#define GET_BUCKET_LEVEL4(x) \
((x >> (BUCKET_BASE_LEVEL_BITS + (3 * BUCKET_HIGHER_LEVEL_BITS))) & \
BUCKET_HIGHER_LEVEL_MASK)
#define GET_BUCKET_LEVEL3(x) \
((x >> (BUCKET_BASE_LEVEL_BITS + (2 * BUCKET_HIGHER_LEVEL_BITS))) & \
BUCKET_HIGHER_LEVEL_MASK)
#define GET_BUCKET_LEVEL2(x) \
((x >> (BUCKET_BASE_LEVEL_BITS + (1 * BUCKET_HIGHER_LEVEL_BITS))) & \
BUCKET_HIGHER_LEVEL_MASK)
#define GET_BUCKET_LEVEL1(x) \
((x >> BUCKET_BASE_LEVEL_BITS) & BUCKET_HIGHER_LEVEL_MASK)
#define GET_BUCKET_LEVEL0(x) (x & BUCKET_BASE_LEVEL_MASK)
/* Macros to find bucket level */
#define IS_IN_LEVEL0_BUCKET(x) \
(x < (1 << BUCKET_BASE_LEVEL_BITS))
#define IS_IN_LEVEL1_BUCKET(x) \
(x < (1 << (BUCKET_BASE_LEVEL_BITS + BUCKET_HIGHER_LEVEL_BITS)))
#define IS_IN_LEVEL2_BUCKET(x) \
(x < (1 << (BUCKET_BASE_LEVEL_BITS + (2 * BUCKET_HIGHER_LEVEL_BITS))))
#define IS_IN_LEVEL3_BUCKET(x) \
(x < (1 << (BUCKET_BASE_LEVEL_BITS + (3 * BUCKET_HIGHER_LEVEL_BITS))))
/*
* Timer structure
* TODO: Keep timer 32 bit for time being,
* we will make it 64 in future
*/
struct timer {
int slot; /* Notify slot on utcb */
unsigned long base; /* Virtual base address */
unsigned int count; /* Counter/jiffies */
struct sleeper_task_bucket task_list; /* List of sleeping tasks */
struct l4_mutex lock; /* Lock for sleeper_task_bucket */
struct capability cap; /* Capability describing timer */
};
#endif /* __TIMER_H__ */

View File

@@ -1,136 +1,37 @@
/*
* Timer service for userspace
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/addr.h>
#include <l4lib/exregs.h>
#include <l4lib/lib/addr.h>
#include <l4lib/irq.h>
#include <l4lib/ipcdefs.h>
#include <l4/api/errno.h>
#include <l4/api/irq.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
#include <l4/api/space.h>
#include <malloc/malloc.h>
#include <capability.h>
#include <container.h>
#include "sp804_timer.h"
#include <linker.h>
#include <timer.h>
#include <thread.h>
#include <libdev/timer.h>
/* Frequency of timer in MHz */
#define TIMER_FREQUENCY 1
#define TIMERS_TOTAL 1
/* Capabilities of this service */
static struct capability caparray[32];
static int total_caps = 0;
struct capability timer_cap[TIMERS_TOTAL];
/* Total number of timer chips being handled by us */
#define TIMERS_TOTAL 1
static struct timer timer[TIMERS_TOTAL];
/* Deafult timer to be used for sleep/wake etc purposes */
#define SLEEP_WAKE_TIMER 0
void cap_dev_print(struct capability *cap)
{
switch (cap_devtype(cap)) {
case CAP_DEVTYPE_UART:
printf("Device type:\t\t\t%s%d\n", "UART", cap_devnum(cap));
break;
case CAP_DEVTYPE_TIMER:
printf("Device type:\t\t\t%s%d\n", "Timer", cap_devnum(cap));
break;
case CAP_DEVTYPE_CLCD:
printf("Device type:\t\t\t%s%d\n", "CLCD", cap_devnum(cap));
break;
default:
return;
}
printf("Device Irq:\t\t%d\n", cap->irq);
}
/* tasks whose sleep time has finished */
struct wake_task_list wake_tasks;
void cap_print(struct capability *cap)
{
printf("Capability id:\t\t\t%d\n", cap->capid);
printf("Capability resource id:\t\t%d\n", cap->resid);
printf("Capability owner id:\t\t%d\n",cap->owner);
switch (cap_type(cap)) {
case CAP_TYPE_TCTRL:
printf("Capability type:\t\t%s\n", "Thread Control");
break;
case CAP_TYPE_EXREGS:
printf("Capability type:\t\t%s\n", "Exchange Registers");
break;
case CAP_TYPE_MAP_PHYSMEM:
if (!cap_is_devmem(cap)) {
printf("Capability type:\t\t%s\n", "Map/Physmem");
} else {
printf("Capability type:\t\t%s\n", "Map/Physmem/Device");
cap_dev_print(cap);
}
break;
case CAP_TYPE_MAP_VIRTMEM:
printf("Capability type:\t\t%s\n", "Map/Virtmem");
break;
case CAP_TYPE_IPC:
printf("Capability type:\t\t%s\n", "Ipc");
break;
case CAP_TYPE_UMUTEX:
printf("Capability type:\t\t%s\n", "Mutex");
break;
case CAP_TYPE_IRQCTRL:
printf("Capability type:\t\t%s\n", "IRQ Control");
break;
case CAP_TYPE_QUANTITY:
printf("Capability type:\t\t%s\n", "Quantitative");
break;
default:
printf("Capability type:\t\t%s\n", "Unknown");
break;
}
switch (cap_rtype(cap)) {
case CAP_RTYPE_THREAD:
printf("Capability resource type:\t%s\n", "Thread");
break;
case CAP_RTYPE_SPACE:
printf("Capability resource type:\t%s\n", "Space");
break;
case CAP_RTYPE_CONTAINER:
printf("Capability resource type:\t%s\n", "Container");
break;
case CAP_RTYPE_THREADPOOL:
printf("Capability resource type:\t%s\n", "Thread Pool");
break;
case CAP_RTYPE_SPACEPOOL:
printf("Capability resource type:\t%s\n", "Space Pool");
break;
case CAP_RTYPE_MUTEXPOOL:
printf("Capability resource type:\t%s\n", "Mutex Pool");
break;
case CAP_RTYPE_MAPPOOL:
printf("Capability resource type:\t%s\n", "Map Pool (PMDS)");
break;
case CAP_RTYPE_CPUPOOL:
printf("Capability resource type:\t%s\n", "Cpu Pool");
break;
case CAP_RTYPE_CAPPOOL:
printf("Capability resource type:\t%s\n", "Capability Pool");
break;
default:
printf("Capability resource type:\t%s\n", "Unknown");
break;
}
printf("\n");
}
void cap_array_print()
{
printf("Capabilities\n"
"~~~~~~~~~~~~\n");
for (int i = 0; i < total_caps; i++)
cap_print(&caparray[i]);
printf("\n");
}
/* tid of handle_request thread */
l4id_t tid_ipc_handler;
int cap_read_all()
{
@@ -139,7 +40,7 @@ int cap_read_all()
/* Read number of capabilities */
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
0, 0, 0, &ncaps)) < 0) {
0, &ncaps)) < 0) {
printf("l4_capability_control() reading # of"
" capabilities failed.\n Could not "
"complete CAP_CONTROL_NCAPS request.\n");
@@ -149,18 +50,116 @@ int cap_read_all()
/* Read all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_READ,
0, 0, 0, caparray)) < 0) {
0, caparray)) < 0) {
printf("l4_capability_control() reading of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
#if 0
cap_array_print(&caparray);
#endif
return 0;
}
int cap_share_all_with_space()
{
int err;
/* Share all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_SHARE,
CAP_SHARE_ALL_SPACE, 0)) < 0) {
printf("l4_capability_control() sharing of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_SHARE request. err=%d\n",
err);
BUG();
}
return 0;
}
/*
* Initialize timer devices
*/
void timer_struct_init(struct timer* timer, unsigned long base)
{
timer->base = base;
timer->count = 0;
timer->slot = 0;
l4_mutex_init(&timer->lock);
for (int i = 0; i < BUCKET_BASE_LEVEL_SIZE ; ++i) {
link_init(&timer->task_list.bucket_level0[i]);
}
for (int i = 0; i < BUCKET_HIGHER_LEVEL_SIZE ; ++i) {
link_init(&timer->task_list.bucket_level1[i]);
link_init(&timer->task_list.bucket_level2[i]);
link_init(&timer->task_list.bucket_level3[i]);
link_init(&timer->task_list.bucket_level4[i]);
}
}
/*
* Initialize wake list head structure
*/
void wake_task_list_init(void)
{
link_init(&wake_tasks.head);
wake_tasks.end = &wake_tasks.head;
l4_mutex_init(&wake_tasks.lock);
}
/*
* Allocate new sleeper task struct
*/
struct sleeper_task *new_sleeper_task(l4id_t tid, int ret)
{
struct sleeper_task *task;
/* May be we can prepare a cache for timer_task structs */
task = (struct sleeper_task *)kzalloc(sizeof(struct sleeper_task));
link_init(&task->list);
task->tid = tid;
task->retval = ret;
return task;
}
void free_sleeper_task(struct sleeper_task *task)
{
kfree(task);
task = NULL;
}
/*
* Find the bucket list correspongding to seconds value
*/
struct link* find_bucket_list(unsigned long seconds)
{
struct link *vector;
struct sleeper_task_bucket *bucket;
bucket = &timer[SLEEP_WAKE_TIMER].task_list;
/*
* TODO: Check if we have already surpassed seconds
*/
if (IS_IN_LEVEL0_BUCKET(seconds)) {
vector = &bucket->bucket_level0[GET_BUCKET_LEVEL0(seconds)];
} else if (IS_IN_LEVEL1_BUCKET(seconds)) {
vector = &bucket->bucket_level1[GET_BUCKET_LEVEL1(seconds)];
} else if (IS_IN_LEVEL2_BUCKET(seconds)) {
vector = &bucket->bucket_level2[GET_BUCKET_LEVEL2(seconds)];
} else if (IS_IN_LEVEL3_BUCKET(seconds)) {
vector = &bucket->bucket_level3[GET_BUCKET_LEVEL3(seconds)];
} else {
vector = &bucket->bucket_level4[GET_BUCKET_LEVEL4(seconds)];
}
return vector;
}
/*
* Scans for up to TIMERS_TOTAL timer devices in capabilities.
*/
@@ -173,8 +172,8 @@ int timer_probe_devices(void)
/* Match device type */
if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_TIMER) {
/* Copy to correct device index */
memcpy(&timer_cap[cap_devnum(&caparray[i]) - 1],
&caparray[i], sizeof(timer_cap[0]));
memcpy(&timer[cap_devnum(&caparray[i]) - 1].cap,
&caparray[i], sizeof(timer[0].cap));
timers++;
}
}
@@ -187,57 +186,164 @@ int timer_probe_devices(void)
return 0;
}
static struct sp804_timer timer[TIMERS_TOTAL];
struct timer_task *get_timer_task(l4id_t tgid)
/*
* Irq handler for timer interrupts
*/
int timer_irq_handler(void *arg)
{
/* May be we can prepare a cache for timer_task structs */
struct timer_task *task = (struct timer_task *)kzalloc(sizeof(struct timer_task));
int err;
struct timer *timer = (struct timer *)arg;
struct link *vector;
const int slot = 0;
link_init(&task->list);
task->tgid = tgid;
task->wait_count = timer[0].count;
/* Initialise timer */
timer_init(timer->base);
return task;
/* Register self for timer irq, using notify slot 0 */
if ((err = l4_irq_control(IRQ_CONTROL_REGISTER, slot,
timer->cap.irq)) < 0) {
printf("%s: FATAL: Timer irq could not be registered. "
"err=%d\n", __FUNCTION__, err);
BUG();
}
/* Enable Timer */
timer_start(timer->base);
/* Handle irqs forever */
while (1) {
int count;
struct link *task_list;
/* Block on irq */
if((count = l4_irq_wait(slot, timer->cap.irq)) < 0) {
printf("l4_irq_wait() returned with negative value\n");
BUG();
}
//printf("Got irq(count 0x%x)\n", timer->count);
/*
* Update timer count
* TODO: Overflow check, we have 1 interrupt/sec from timer
* with 32bit count it will take 9years to overflow
*/
timer->count += count;
/* find bucket list of taks to be woken for current count */
vector = find_bucket_list(timer->count);
if (!list_empty(vector)) {
/* Removing tasks from sleeper list */
l4_mutex_lock(&timer[SLEEP_WAKE_TIMER].lock);
task_list = list_detach(vector);
l4_mutex_unlock(&timer[SLEEP_WAKE_TIMER].lock);
/* Add tasks to wake_task_list */
l4_mutex_lock(&wake_tasks.lock);
list_attach(task_list,
&wake_tasks.head, wake_tasks.end);
l4_mutex_unlock(&wake_tasks.lock);
/*
* Send ipc to handle_request
* thread to send wake signals
*/
printf("sending ipc %d to thread %d\n", L4_IPC_TAG_TIMER_WAKE_THREADS, tid_ipc_handler);
l4_send(tid_ipc_handler,L4_IPC_TAG_TIMER_WAKE_THREADS);
}
}
}
void free_timer_task(struct timer_task *task)
/*
* Helper routine to wake tasks from wake list
*/
void task_wake(void)
{
kfree(task);
struct sleeper_task *struct_ptr, *temp_ptr;
int ret;
if (!list_empty(&wake_tasks.head)) {
list_foreach_removable_struct(struct_ptr, temp_ptr,
&wake_tasks.head, list) {
/* Remove task from wake list */
l4_mutex_lock(&wake_tasks.lock);
list_remove(&struct_ptr->list);
l4_mutex_unlock(&wake_tasks.lock);
/* Set sender correctly */
l4_set_sender(struct_ptr->tid);
#if 0
printf("waking thread at time %x\n",
(unsigned int)timer[SLEEP_WAKE_TIMER].count);
#endif
/* send wake ipc */
if ((ret = l4_ipc_return(struct_ptr->retval)) < 0) {
printf("%s: IPC return error: %d.\n",
__FUNCTION__, ret);
BUG();
}
/* free allocated sleeper task struct */
free_sleeper_task(struct_ptr);
}
}
/* If wake list is empty set end = start */
if (list_empty(&wake_tasks.head))
wake_tasks.end = &wake_tasks.head;
}
int timer_setup_devices(void)
{
for (int i = 0; i < TIMERS_TOTAL; i++) {
/* Get one page from address pool */
timer[i].base = (unsigned long)l4_new_virtual(1);
timer[i].count = 0;
link_init(&timer[i].tasklist);
l4_mutex_init(&timer[i].lock);
struct task_ids irq_tids;
int err;
/* Map timers to a virtual address region */
if (IS_ERR(l4_map((void *)__pfn_to_addr(timer_cap[i].start),
(void *)timer[i].base, timer_cap[i].size, MAP_USR_IO_FLAGS,
for (int i = 0; i < TIMERS_TOTAL; i++) {
/* initialize timer */
timer_struct_init(&timer[i],(unsigned long)l4_new_virtual(1) );
/* Map timer to a virtual address region */
if (IS_ERR(l4_map((void *)__pfn_to_addr(timer[i].cap.start),
(void *)timer[i].base, 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(&timer_cap[i]));
cap_devnum(&timer[i].cap));
BUG();
}
/* Initialise timer */
sp804_init(timer[i].base, SP804_TIMER_RUNMODE_PERIODIC, \
SP804_TIMER_WRAPMODE_WRAPPING, SP804_TIMER_WIDTH32BIT, \
SP804_TIMER_IRQDISABLE);
/* Enable Timer */
sp804_enable(timer[i].base, 1);
/*
* Create new timer irq handler thread.
*
* This will initialize its timer argument, register
* itself as its irq handler, initiate the timer and
* wait on irqs.
*/
if ((err = thread_create(timer_irq_handler, &timer[i],
TC_SHARE_SPACE,
&irq_tids)) < 0) {
printf("FATAL: Creation of irq handler "
"thread failed.\n");
BUG();
}
}
return 0;
}
/*
* Declare a statically allocated char buffer
* with enough bitmap size to cover given size
*/
#define DECLARE_IDPOOL(name, size) \
char name[(sizeof(struct id_pool) + ((size >> 12) >> 3))]
#define PAGE_POOL_SIZE SZ_1MB
static struct address_pool device_vaddr_pool;
DECLARE_IDPOOL(device_id_pool, PAGE_POOL_SIZE);
/*
* Initialize a virtual address pool
@@ -247,8 +353,8 @@ void init_vaddr_pool(void)
{
for (int i = 0; i < total_caps; i++) {
/* Find the virtual memory region for this process */
if (cap_type(&caparray[i]) == CAP_TYPE_MAP_VIRTMEM &&
__pfn_to_addr(caparray[i].start) ==
if (cap_type(&caparray[i]) == CAP_TYPE_MAP_VIRTMEM
&& __pfn_to_addr(caparray[i].start) ==
(unsigned long)vma_start) {
/*
@@ -265,8 +371,10 @@ void init_vaddr_pool(void)
* We may allocate virtual memory
* addresses from this pool.
*/
address_pool_init(&device_vaddr_pool, page_align_up(__end),
__pfn_to_addr(caparray[i].end), TIMERS_TOTAL);
address_pool_init(&device_vaddr_pool,
(struct id_pool *)&device_id_pool,
page_align_up(__end),
__pfn_to_addr(caparray[i].end));
return;
} else
goto out_err;
@@ -285,46 +393,23 @@ void *l4_new_virtual(int npages)
return address_new(&device_vaddr_pool, npages, PAGE_SIZE);
}
void timer_irq_handler(void)
/*
* Got request for sleep for seconds,
* right now max sleep allowed is 2^32 sec
*/
void task_sleep(l4id_t tid, unsigned long seconds, int ret)
{
struct timer_task *struct_ptr, *temp_ptr;
struct sleeper_task *task = new_sleeper_task(tid, ret);
struct link *vector;
timer[0].count += 1;
/* can overflow happen here?, timer is in 32bit mode */
seconds += timer[SLEEP_WAKE_TIMER].count;
/*
* FIXME:
* Traverse through the sleeping process list and
* wake any process if required, we need to put this part in bottom half
*/
list_foreach_removable_struct(struct_ptr, temp_ptr, &timer[0].tasklist, list)
if (struct_ptr->wait_count == timer[0].count) {
vector = find_bucket_list(seconds);
/* Remove task from list */
l4_mutex_lock(&timer[0].lock);
list_remove(&struct_ptr->list);
l4_mutex_unlock(&timer[0].lock);
/* wake the sleeping process, send wake ipc */
free_timer_task(struct_ptr);
}
}
int timer_gettime(void)
{
return timer[0].count;
}
void timer_sleep(l4id_t tgid, int sec)
{
struct timer_task *task = get_timer_task(tgid);
/* Check for overflow */
task->wait_count += (sec * 1000000);
l4_mutex_lock(&timer[0].lock);
list_insert_tail(&task->list, &timer[0].tasklist);
l4_mutex_unlock(&timer[0].lock);
l4_mutex_lock(&timer[SLEEP_WAKE_TIMER].lock);
list_insert(&task->list, vector);
l4_mutex_unlock(&timer[SLEEP_WAKE_TIMER].lock);
}
void handle_requests(void)
@@ -334,10 +419,9 @@ void handle_requests(void)
u32 tag;
int ret;
printf("%s: Initiating ipc.\n", __CONTAINER__);
if ((ret = l4_receive(L4_ANYTHREAD)) < 0) {
printf("%s: %s: IPC Error: %d. Quitting...\n", __CONTAINER__,
__FUNCTION__, ret);
printf("%s: %s: IPC Error: %d. Quitting...\n",
__CONTAINER__, __FUNCTION__, ret);
BUG();
}
@@ -361,13 +445,35 @@ void handle_requests(void)
* inside the current container
*/
switch (tag) {
/* Return time in seconds, since the timer was started */
case L4_IPC_TAG_TIMER_GETTIME:
mr[0] = timer_gettime();
mr[0] = timer[SLEEP_WAKE_TIMER].count;
/* Reply */
if ((ret = l4_ipc_return(ret)) < 0) {
printf("%s: IPC return error: %d.\n", __FUNCTION__, ret);
BUG();
}
break;
case L4_IPC_TAG_TIMER_SLEEP:
timer_sleep(senderid, mr[0]);
/* TODO: Halt the caller for mr[0] seconds */
printf("%s: Got sleep request from thread 0x%x, duration %d\n", __CONTAINER_NAME__,
senderid, mr[0]);
if (mr[0] > 0) {
task_sleep(senderid, mr[0], ret);
}
else {
if ((ret = l4_ipc_return(ret)) < 0) {
printf("%s: IPC return error: %d.\n",
__FUNCTION__, ret);
BUG();
}
}
break;
/* Intra container ipc by irq_thread */
case L4_IPC_TAG_TIMER_WAKE_THREADS:
task_wake();
break;
default:
@@ -376,12 +482,6 @@ void handle_requests(void)
"0x%x\n", __CONTAINER__, senderid,
__cid(senderid), tag);
}
/* Reply */
if ((ret = l4_ipc_return(ret)) < 0) {
printf("%s: IPC return error: %d.\n", __FUNCTION__, ret);
BUG();
}
}
/*
@@ -426,25 +526,33 @@ void main(void)
/* Read all capabilities */
cap_read_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();
/* Map and initialize timer devices */
timer_setup_devices();
/* Setup own utcb */
/* 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();
/* Map and initialize timer devices */
timer_setup_devices();
/* Set the tid of ipc handler */
tid_ipc_handler = self_tid();
/* Listen for timer requests */
while (1)
handle_requests();
}

View File

@@ -0,0 +1,11 @@
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(asm.h)
BEGIN_PROC(local_setup_new_thread)
ldr r0, [sp, #-4]! @ Load first argument.
mov lr, pc @ Save return address
ldr pc, [sp, #-4]! @ Load function pointer from stack
new_thread_exit:
b new_thread_exit @ We infinitely loop for now.
END_PROC(local_setup_new_thread)

View File

@@ -0,0 +1,75 @@
/*
* Thread creation userspace helpers
*
* Copyright (C) 2009 B Labs Ltd.
*/
#include <thread.h>
#include <l4/api/errno.h>
char stack[THREADS_TOTAL][STACK_SIZE] ALIGN(8);
char *__stack_ptr = &stack[1][0];
char utcb[THREADS_TOTAL][UTCB_SIZE] ALIGN(8);
//char utcb[THREADS_TOTAL][0x1000] ALIGN(0x1000);
char *__utcb_ptr = &utcb[1][0];
extern void local_setup_new_thread(void);
int thread_create(int (*func)(void *), void *args, unsigned int flags,
struct task_ids *new_ids)
{
struct task_ids ids;
struct exregs_data exregs;
int err;
l4_getid(&ids);
/* Shared space only */
if (!(TC_SHARE_SPACE & flags)) {
printf("%s: Warning - This function allows only "
"shared space thread creation.\n",
__FUNCTION__);
return -EINVAL;
}
/* Create thread */
if ((err = l4_thread_control(THREAD_CREATE | flags, &ids)) < 0)
return err;
/* Check if more stack/utcb available */
if ((unsigned long)__utcb_ptr ==
(unsigned long)&utcb[THREADS_TOTAL][0])
return -ENOMEM;
if ((unsigned long)__stack_ptr ==
(unsigned long)&stack[THREADS_TOTAL][0])
return -ENOMEM;
/* First word of new stack is arg */
((unsigned long *)__stack_ptr)[-1] = (unsigned long)args;
/* Second word of new stack is function address */
((unsigned long *)__stack_ptr)[-2] = (unsigned long)func;
/* Setup new thread pc, sp, utcb */
memset(&exregs, 0, sizeof(exregs));
exregs_set_stack(&exregs, (unsigned long)__stack_ptr);
exregs_set_utcb(&exregs, (unsigned long)__utcb_ptr);
exregs_set_pc(&exregs, (unsigned long)local_setup_new_thread);
if ((err = l4_exchange_registers(&exregs, ids.tid)) < 0)
return err;
/* Update utcb, stack pointers */
__stack_ptr += STACK_SIZE;
__utcb_ptr += UTCB_SIZE;
//__utcb_ptr += 0x1000;
/* Start the new thread */
if ((err = l4_thread_control(THREAD_RUN, &ids)) < 0)
return err;
memcpy(new_ids, &ids, sizeof(ids));
return 0;
}

View File

@@ -17,7 +17,7 @@ from config.configuration import *
config = configuration_retrieve()
platform = config.platform
arch = config.arch
gcc_cpu_flag = config.gcc_cpu_flag
gcc_arch_flag = config.gcc_arch_flag
LIBL4_RELDIR = 'conts/libl4'
KERNEL_INCLUDE = join(PROJROOT, 'include')
@@ -35,8 +35,7 @@ LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_LIBPATH = join(join(BUILDDIR, LIBDEV_RELDIR), 'sys-userspace')
LIBDEV_INCLUDE = [join(LIBDEV_DIR, 'uart/include')]
LIBDEV_CCFLAGS = '-DPLATFORM_' + platform.upper()
LIBDEV_INCLUDE = join(LIBDEV_DIR, 'include')
# FIXME: Add these to autogenerated SConstruct !!!
LIBMEM_RELDIR = 'conts/libmem'
@@ -44,16 +43,17 @@ LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR)
LIBMEM_INCLUDE = LIBMEM_DIR
env = Environment(CC = config.user_toolchain + 'gcc',
env = Environment(CC = config.toolchain + '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', ('-mcpu=' + gcc_cpu_flag), LIBDEV_CCFLAGS],
'-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', 'libmalloc', 'c-userspace', 'libdev-userspace', 'gcc', 'c-userspace'], # libgcc.a - This is required for division routines.
LIBS = ['gcc', 'libl4', 'libmalloc', 'c-userspace', 'libdev-userspace',
'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')

View File

@@ -1,12 +0,0 @@
#ifndef __UART_SERVICE_CAPABILITY_H__
#define __UART_SERVICE_CAPABILITY_H__
#include <l4lib/capability.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_print(struct capability *cap);
void cap_list_print(struct cap_list *cap_list);
int cap_read_all();
#endif /* header */

View File

@@ -1,130 +1,28 @@
/*
* UART service for userspace
*/
#include <l4lib/arch/syslib.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/addr.h>
#include <l4lib/macros.h>
#include L4LIB_INC_ARCH(syslib.h)
#include L4LIB_INC_ARCH(syscalls.h)
#include <l4lib/exregs.h>
#include <l4lib/lib/addr.h>
#include <l4lib/ipcdefs.h>
#include <l4/api/errno.h>
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
#include <l4/api/space.h>
#include <capability.h>
#include <container.h>
#include <pl011_uart.h> /* FIXME: Its best if this is <libdev/uart/pl011.h> */
#include <linker.h>
#include <uart.h>
#include <libdev/uart.h>
#define UARTS_TOTAL 3
/* Capabilities of this service */
static struct capability caparray[32];
static int total_caps = 0;
struct capability uart_cap[UARTS_TOTAL];
void cap_dev_print(struct capability *cap)
{
switch (cap_devtype(cap)) {
case CAP_DEVTYPE_UART:
printf("Device type:\t\t\t%s%d\n", "UART", cap_devnum(cap));
break;
case CAP_DEVTYPE_TIMER:
printf("Device type:\t\t\t%s%d\n", "Timer", cap_devnum(cap));
break;
case CAP_DEVTYPE_CLCD:
printf("Device type:\t\t\t%s%d\n", "CLCD", cap_devnum(cap));
break;
default:
return;
}
printf("Device Irq:\t\t%d\n", cap->irq);
}
void cap_print(struct capability *cap)
{
printf("Capability id:\t\t\t%d\n", cap->capid);
printf("Capability resource id:\t\t%d\n", cap->resid);
printf("Capability owner id:\t\t%d\n",cap->owner);
switch (cap_type(cap)) {
case CAP_TYPE_TCTRL:
printf("Capability type:\t\t%s\n", "Thread Control");
break;
case CAP_TYPE_EXREGS:
printf("Capability type:\t\t%s\n", "Exchange Registers");
break;
case CAP_TYPE_MAP_PHYSMEM:
if (!cap_is_devmem(cap)) {
printf("Capability type:\t\t%s\n", "Map/Physmem");
} else {
printf("Capability type:\t\t%s\n", "Map/Physmem/Device");
cap_dev_print(cap);
}
break;
case CAP_TYPE_MAP_VIRTMEM:
printf("Capability type:\t\t%s\n", "Map/Virtmem");
break;
case CAP_TYPE_IPC:
printf("Capability type:\t\t%s\n", "Ipc");
break;
case CAP_TYPE_UMUTEX:
printf("Capability type:\t\t%s\n", "Mutex");
break;
case CAP_TYPE_IRQCTRL:
printf("Capability type:\t\t%s\n", "IRQ Control");
break;
case CAP_TYPE_QUANTITY:
printf("Capability type:\t\t%s\n", "Quantitative");
break;
default:
printf("Capability type:\t\t%s\n", "Unknown");
break;
}
switch (cap_rtype(cap)) {
case CAP_RTYPE_THREAD:
printf("Capability resource type:\t%s\n", "Thread");
break;
case CAP_RTYPE_SPACE:
printf("Capability resource type:\t%s\n", "Space");
break;
case CAP_RTYPE_CONTAINER:
printf("Capability resource type:\t%s\n", "Container");
break;
case CAP_RTYPE_THREADPOOL:
printf("Capability resource type:\t%s\n", "Thread Pool");
break;
case CAP_RTYPE_SPACEPOOL:
printf("Capability resource type:\t%s\n", "Space Pool");
break;
case CAP_RTYPE_MUTEXPOOL:
printf("Capability resource type:\t%s\n", "Mutex Pool");
break;
case CAP_RTYPE_MAPPOOL:
printf("Capability resource type:\t%s\n", "Map Pool (PMDS)");
break;
case CAP_RTYPE_CPUPOOL:
printf("Capability resource type:\t%s\n", "Cpu Pool");
break;
case CAP_RTYPE_CAPPOOL:
printf("Capability resource type:\t%s\n", "Capability Pool");
break;
default:
printf("Capability resource type:\t%s\n", "Unknown");
break;
}
printf("\n");
}
void cap_array_print()
{
printf("Capabilities\n"
"~~~~~~~~~~~~\n");
for (int i = 0; i < total_caps; i++)
cap_print(&caparray[i]);
printf("\n");
}
/* Number of UARTS to be managed by this service */
#define UARTS_TOTAL 1
static struct uart uart[UARTS_TOTAL];
int cap_read_all()
{
@@ -133,7 +31,7 @@ int cap_read_all()
/* Read number of capabilities */
if ((err = l4_capability_control(CAP_CONTROL_NCAPS,
0, 0, 0, &ncaps)) < 0) {
0, &ncaps)) < 0) {
printf("l4_capability_control() reading # of"
" capabilities failed.\n Could not "
"complete CAP_CONTROL_NCAPS request.\n");
@@ -143,15 +41,27 @@ int cap_read_all()
/* Read all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_READ,
0, 0, 0, caparray)) < 0) {
0, caparray)) < 0) {
printf("l4_capability_control() reading of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_READ_CAPS request.\n");
BUG();
}
#if 0
cap_array_print(&caparray);
#endif
return 0;
}
int cap_share_all_with_space()
{
int err;
/* Share all capabilities */
if ((err = l4_capability_control(CAP_CONTROL_SHARE,
CAP_SHARE_ALL_SPACE, 0)) < 0) {
printf("l4_capability_control() sharing of "
"capabilities failed.\n Could not "
"complete CAP_CONTROL_SHARE request. err=%d\n", err);
BUG();
}
return 0;
}
@@ -168,8 +78,8 @@ int uart_probe_devices(void)
/* Match device type */
if (cap_devtype(&caparray[i]) == CAP_DEVTYPE_UART) {
/* Copy to correct device index */
memcpy(&uart_cap[cap_devnum(&caparray[i]) - 1],
&caparray[i], sizeof(uart_cap[0]));
memcpy(&uart[cap_devnum(&caparray[i]) - 1].cap,
&caparray[i], sizeof(uart[0].cap));
uarts++;
}
}
@@ -182,7 +92,7 @@ int uart_probe_devices(void)
return 0;
}
static struct pl011_uart uart[UARTS_TOTAL];
static struct uart uart[UARTS_TOTAL];
int uart_setup_devices(void)
{
@@ -191,24 +101,32 @@ int uart_setup_devices(void)
uart[i].base = (unsigned long)l4_new_virtual(1);
/* Map uart to a virtual address region */
if (IS_ERR(l4_map((void *)__pfn_to_addr(uart_cap[i].start),
(void *)uart[i].base, uart_cap[i].size,
MAP_USR_IO_FLAGS,
self_tid()))) {
if (IS_ERR(l4_map((void *)__pfn_to_addr(uart[i].cap.start),
(void *)uart[i].base, uart[i].cap.size,
MAP_USR_IO, self_tid()))) {
printf("%s: FATAL: Failed to map UART device "
"%d to a virtual address\n",
__CONTAINER_NAME__,
cap_devnum(&uart_cap[i]));
cap_devnum(&uart[i].cap));
BUG();
}
/* Initialize uart */
pl011_initialise(&uart[i]);
uart_init(uart[i].base);
}
return 0;
}
/*
* Declare a statically allocated char buffer
* with enough bitmap size to cover given size
*/
#define DECLARE_IDPOOL(name, size) \
char name[(sizeof(struct id_pool) + ((size >> 12) >> 3))]
#define PAGE_POOL_SIZE SZ_1MB
static struct address_pool device_vaddr_pool;
DECLARE_IDPOOL(device_id_pool, PAGE_POOL_SIZE);
/*
* Initialize a virtual address pool
@@ -237,9 +155,9 @@ void init_vaddr_pool(void)
* addresses from this pool.
*/
address_pool_init(&device_vaddr_pool,
(struct id_pool *)&device_id_pool,
page_align_up(__end),
__pfn_to_addr(caparray[i].end),
UARTS_TOTAL);
__pfn_to_addr(caparray[i].end));
return;
} else
goto out_err;
@@ -260,16 +178,12 @@ void *l4_new_virtual(int npages)
void uart_generic_tx(char c, int devno)
{
pl011_tx_char(uart[devno].base, c);
uart_tx_char(uart[devno].base, c);
}
char uart_generic_rx(int devno)
{
char c;
pl011_rx_char(uart[devno].base, &c);
return c;
return uart_rx_char(uart[devno].base);
}
void handle_requests(void)
@@ -375,6 +289,9 @@ void main(void)
/* Read all capabilities */
cap_read_all();
/* Share all with space */
cap_share_all_with_space();
/* Scan for uart devices in capabilities */
uart_probe_devices();

View File

@@ -18,17 +18,18 @@ from config.projpaths import *
Import('env', 'arch', 'type')
variant = type
# Needed by fputc(), for declaration of pl011_uart_tx()
LIBDEV_PATH = join(PROJROOT, 'conts/libdev')
LIBDEV_INCPATH = [LIBDEV_PATH + '/uart/include']
# Needed by fputc(), for declaration of uart_tx()
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_INC = join(LIBDEV_DIR, 'include')
e = env.Clone()
e.Append(CPPPATH = ['include', 'include/sys-' + variant + '/arch-' + arch,
LIBDEV_INCPATH],
CCFLAGS = '-nostdinc')
e.Append(CPPPATH = ['include', 'include/sys-' + variant + \
'/arch-' + arch, LIBDEV_INC],
CCFLAGS = ['-nostdinc'])
source = \
Glob('src/*.c') + \
Glob('src/*.[cS]') + \
Glob('src/sys-' + variant + '/*.c') + \
Glob('src/sys-' + variant + '/arch-' + arch + '/*.c') + \
Glob('src/arch-' + arch + '/*.c') + \

50
conts/libc/SConstruct Normal file
View File

@@ -0,0 +1,50 @@
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- a microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, sys
PROJRELROOT = '../..'
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
config = configuration_retrieve()
gcc_arch_flag = config.gcc_arch_flag
arch = config.arch
# We assume we are compiling for userspace.
# variant can be specified from cmdline using
# scons variant=xxx
variant = ARGUMENTS.get('variant', 'userspace')
print '\nCompiling for variant: ' + variant + '\n'
# Needed by fputc(), for declaration of uart_tx()
LIBDEV_RELDIR = 'conts/libdev'
LIBDEV_DIR = join(PROJROOT, LIBDEV_RELDIR)
LIBDEV_INC = join(LIBDEV_DIR, 'include')
env = Environment(CC = config.toolchain + 'gcc',
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \
'-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
ENV = {'PATH' : os.environ['PATH']},
CPPPATH = ['include', LIBDEV_INC, join(PROJROOT,'include'), \
'include/sys-' + variant + '/arch-' + arch])
source = \
Glob('src/*.[cS]') + \
Glob('src/sys-' + variant + '/*.c') + \
Glob('src/sys-' + variant + '/arch-' + arch + '/*.c') + \
Glob('src/arch-' + arch + '/*.c') + \
Glob('src/arch-' + arch + '/*.S') + \
Glob('crt/sys-' + variant + '/arch-' + arch + '/*.[cS]')
objects = env.StaticObject(source)
library = env.StaticLibrary('c-' + variant, objects)

View File

@@ -181,7 +181,8 @@ int vsprintf(char *, const char *format, va_list arg);
int vsscanf(const char *s, const char *format, va_list arg);
/* 7.19.7 Character i/o functions */
int fgetc(FILE *);
char fgetc(FILE *);
char *fgetline(FILE *);
char *fgets(char *, int, FILE *);
int fputc(int, FILE *);
int fputs(const char *, FILE *);

View File

@@ -3,15 +3,15 @@
*
* Version 1-0
*
* Copyright (c) 2004 University of New South Wales
* Copyright (c) 2004 National ICT Australia
*
* All rights reserved.
*
* Developed by: Operating Systems and Distributed Systems Group (DiSy)
* University of New South Wales
* http://www.disy.cse.unsw.edu.au
* Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
* National ICT Australia
* http://www.ertos.nicta.com.au
*
* Permission is granted by University of New South Wales, free of charge, to
* Permission is granted by National ICT Australia, free of charge, to
* any person obtaining a copy of this software and any associated
* documentation files (the "Software") to deal with the Software without
* restriction, including (without limitation) the rights to use, copy,
@@ -28,7 +28,7 @@
* disclaimers in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of University of New South Wales, nor the names of its
* * Neither the name of National ICT Australia, nor the names of its
* contributors, may be used to endorse or promote products derived
* from this Software without specific prior written permission.
*
@@ -57,10 +57,10 @@
* DAMAGES OR OTHER LIABILITY.
*
* If applicable legislation implies representations, warranties, or
* conditions, or imposes obligations or liability on University of New South
* Wales or one of its contributors in respect of the Software that
* conditions, or imposes obligations or liability on National ICT
* Australia or one of its contributors in respect of the Software that
* cannot be wholly or partly excluded, restricted or modified, the
* liability of University of New South Wales or the contributor is limited, to
* liability of National ICT Australia or the contributor is limited, to
* the full extent permitted by the applicable legislation, at its
* option, to:
* a. in the case of goods, any one or more of the following:
@@ -77,39 +77,16 @@
* by the laws in force in New South Wales, Australia.
*/
/*
Author: Carl van Schaik
Author: Ben Leslie
*/
#include <string.h>
#include <stdint.h>
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
/*
* copy n bytes from s to d; the regions must not overlap
*/
/* THREAD SAFE */
void *
memcpy(void *d, const void *s, size_t n)
{
size_t i;
uintptr_t align = sizeof(uintptr_t)-1;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
if (((uintptr_t)d & align) || ((uintptr_t)s & align) || (n & align))
{
char *bs = (char *)s;
char *bd = (char *)d;
/* XXX - optimize this */
for (i = 0; i < n; i++)
*bd++ = *bs++;
}
else
{ /* memcpy - word aligned */
uintptr_t *ws = (uintptr_t*)s;
uintptr_t *wd = (uintptr_t*)d;
n /= sizeof(uintptr_t);
for (i = 0; i < n; i++)
*wd++ = *ws++;
}
return d;
}
#define __PTR_SIZE 32

60
conts/libc/src/memcpy.S Normal file
View File

@@ -0,0 +1,60 @@
/*
* Copyright 2010 B Labs.Ltd.
*
* Author: Prem Mallappa <prem.mallappa@b-labs.co.uk>
*
* Description: Optimized memcpy for ARM
*
*/
#include INC_ARCH(asm.h)
/*
void*
memcpy(void *dst, const void *src, register uint len)
*/
BEGIN_PROC(memcpy)
push {r0, r4-r11, lr}
loop32:
cmp r2, #32
blt loop16
ldmia r1!, {r4 - r11}
stmia r0!, {r4 - r11}
sub r2, r2, #32
b loop32
loop16:
cmp r2, #16
blt loop8
ldmia r1!, {r4 - r7}
stmia r0!, {r4 - r7}
sub r2, r2, #16
b loop16
loop8:
cmp r2, #8
blt loop4
ldmia r1!, {r4, r5}
stmia r0!, {r4, r5}
sub r2, r2, #8
b loop8
loop4:
cmp r2, #4
blt end
ldmia r1!, {r4}
stmia r0!, {r4}
sub r2, r2, #4
b loop4
end:
last:
teq r2, #0
ldrgtb r4, [r1]
strneb r4, [r0] // V7 supports strneb <rt>, [<rb>, +/-<index>] !, with write back
lsrne r4, r4, #8
subne r2, r2, #1 // Can be reduced to 1 LDR, but has a catch if it is end of memory
addne r0, r0, #1 // we dont want to fetch 1 byte extra to end up in abort
addne r1, r1, #1 // so, playing safe, worst case 3 LDRs
bne last
1:
pop {r0, r4 - r11, pc}
END_PROC(_memcpy)

68
conts/libc/src/memset.S Normal file
View File

@@ -0,0 +1,68 @@
/*
* Copyright 2010 (C) B Labs.
* Author: Prem Mallappa <prem.mallappa@b-labs.co.uk>
* Description: Optimized memset for ARM
*/
#include INC_ARCH(asm.h)
/*
void *
memset(void *dst, int c, int len)
*/
BEGIN_PROC(memset)
stmfd sp!, {r4 - r11, lr}
and r1, r1, #255 /* c &= 0xff */
orr r1, r1, lsl #8 /* c |= c<<8 */
orr r1, r1, lsl #16 /* c |= c<<16 */
mov r4, r1
cmp r2, #8
blt 4f
movge r5, r4
cmpge r2, #16
blt 8f
movge r6, r4
movge r7, r4
cmpge r2, #32
blt 16f
movge r8, r4
movge r9, r4
movge r10, r4
movge r11, r4
32:
cmp r2, #32
blt 16f
stmia r0!, {r4 - r11}
sub r2, r2, #32
b 32b
16:
cmp r2, #16
blt 8f
stmia r0!, {r4 - r7}
sub r2, r2, #16
b 16b
8:
cmp r2, #8
blt 4f
stmia r0!, {r4, r5}
sub r2, r2, #8
b 8b
4:
cmp r2, #4
blt end
stmia r0!, {r4}
sub r2, r2, #4
b 4b
end:
teq r2, #0
strneb r4, [r0, #0]
subne r2, r2, #1
addne r0, r0, #1
bne end
ldmfd sp!, {r4 - r11, pc}
END_PROC(_memset)

View File

@@ -2,19 +2,12 @@
* Ties up platform's uart driver functions with printf
*
* Copyright (C) 2009 B Labs Ltd.
*
*/
#include <stdio.h>
#include <pl011_uart.h>
extern struct pl011_uart uart;
#include <libdev/uart.h>
int __fputc(int c, FILE *stream)
{
int res;
do {
res = pl011_tx_char(uart.base, c);
} while( res < 0);
return(0);
uart_tx_char(uart_print_base, c);
return 0;
}

View File

@@ -0,0 +1,31 @@
/*
* Library calls for uart rx.
*
* Copyright (C) 2009 B Labs Ltd.
*
*/
#include <stdio.h>
#include <libdev/uart.h>
char fgetc(FILE * file)
{
return uart_rx_char(uart_print_base);
}
#define MAX_LINE_LEN 256
char data[MAX_LINE_LEN];
char *fgetline(FILE * file)
{
int index = 0;
/*
* Line will end if,
* 1. We have recieved 256 chars or
* 2. we recieved EOL: '\n' followed by '\r'
*/
while((data[index] != '\n' && ((data[index++] = fgetc(file)) != '\r')) ||
index != MAX_LINE_LEN);
return data;
}

View File

@@ -15,29 +15,32 @@ sys.path.append(PROJRELROOT)
from config.configuration import *
from config.projpaths import *
Import('env', 'arch', 'platform', 'type')
Import('env', 'platform', 'type')
variant = type
# Path for uart files
LIBDEV_UART_PATH = join(PROJROOT, 'conts/libdev/uart')
# To include setbit/clrbit functions
LIBL4_RELDIR = 'conts/libl4'
LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR)
LIBL4_INC = join(LIBL4_DIR, 'include')
# Path for timer files
LIBDEV_TIEMR_PATH = join(PROJROOT, 'conts/libdev/timer/sp804')
# Path for clcd files
LIBDEV_CLCD_PATH = join(PROJROOT, 'conts/libdev/clcd/pl110')
LIBC_RELDIR = 'conts/libc'
LIBC_DIR = join(PROJROOT, LIBC_RELDIR)
LIBC_INC = join(LIBC_DIR, 'include')
e = env.Clone()
e.Append(CPPPATH = [LIBDEV_UART_PATH + '/include', LIBDEV_TIEMR_PATH + '/include',
LIBDEV_CLCD_PATH + '/include',],
CCFLAGS = ['-nostdinc', '-DVARIANT_' + variant.upper(),
'-DPLATFORM_' + platform.upper()])
e.Append(CPPPATH = ['#conts/libdev/include', LIBC_INC, LIBL4_INC],
CCFLAGS = ['-DVARIANT_' + variant.upper()])
source = Glob('uart/src' + '/*.c') + \
Glob('timer/sp804/src' + '/*.c') + \
Glob('clcd/pl110/src' + '/*.c')
objects = []
objects += SConscript('uart/pl011/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : e})
objects += SConscript('timer/sp804/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : e})
objects += SConscript('uart/omap/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : e})
objects += SConscript('timer/omap/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : e})
objects = e.StaticObject(source)
library = e.StaticLibrary('libdev-' + variant, objects)
Return('library')

51
conts/libdev/SConstruct Normal file
View File

@@ -0,0 +1,51 @@
# -*- mode: python; coding: utf-8; -*-
#
# Codezero -- a microkernel for embedded systems.
#
# Copyright © 2009 B Labs Ltd
#
import os, sys
PROJRELROOT = '../..'
sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
config = configuration_retrieve()
gcc_arch_flag = config.gcc_arch_flag
platform = config.platform
# We assume we are compiling for userspace.
# variant can be specified from cmdline using
# scons variant=xxx
variant = ARGUMENTS.get('variant', 'userspace')
print '\nCompiling for variant: ' + variant + '\n'
# To include setbit/clrbit functions
LIBL4_RELDIR = 'conts/libl4'
LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR)
LIBL4_INC = join(LIBL4_DIR, 'include')
LIBC_RELDIR = 'conts/libc'
LIBC_DIR = join(PROJROOT, LIBC_RELDIR)
LIBC_INC = join(LIBC_DIR, 'include')
env = Environment(CC = config.toolchain + 'gcc',
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \
'-nostdinc', '-Wall', '-DVARIANT_' + variant.upper(), \
'-march=' + gcc_arch_flag, '-Werror'],
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
ENV = {'PATH' : os.environ['PATH']},
CPPPATH = ['#include', LIBC_INC, LIBL4_INC, join(PROJROOT,'include')])
objects = []
objects += SConscript('uart/pl011/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : env})
objects += SConscript('timer/sp804/SConscript', duplicate=0, \
exports = {'platform' : platform, 'env' : env})
library = env.StaticLibrary('libdev-' + variant, objects)

View File

@@ -0,0 +1,12 @@
/*
* IO functions/macros.
*
* Copyright (C) 2007 Bahadir Balban
*/
#ifndef __LIBDEV_IO_H__
#define __LIBDEV_IO_H__
#define read(address) *((volatile unsigned int *)(address))
#define write(val, address) *((volatile unsigned int *)(address)) = val
#endif /* __LIBDEV_IO_H__ */

View File

@@ -0,0 +1,23 @@
/*
* Generic timer library API
*
* Copyright (C) 2010 B Labs Ltd.
*
* Author: Bahadir Balban
*/
#ifndef __LIBDEV_TIMER_H__
#define __LIBDEV_TIMER_H__
/*
* Simple API for the primary timer
* for userspace
*/
void timer_start(unsigned long timer_base);
void timer_load(u32 val, unsigned long timer_base);
u32 timer_read(unsigned long timer_base);
void timer_stop(unsigned long timer_base);
void timer_init_oneshot(unsigned long timer_base);
void timer_init_periodic(unsigned long timer_base);
void timer_init(unsigned long timer_base);
#endif /* __LIBDEV_TIMER_H__ */

View File

@@ -0,0 +1,21 @@
/*
* Generic uart API
*
* Copyright (C) 2010 B Labs Ltd.
*
* Author: Bahadir Balban
*/
#ifndef __LIBDEV_UART_H__
#define __LIBDEV_UART_H__
void uart_tx_char(unsigned long uart_base, char c);
char uart_rx_char(unsigned long uart_base);
void uart_set_baudrate(unsigned long uart_base, unsigned int val);
void uart_init(unsigned long base);
/*
* Base of primary uart used for printf
*/
extern unsigned long uart_print_base;
#endif /* __LIBDEV_UART_H__ */

View File

@@ -0,0 +1,15 @@
Import('env', 'platform')
#Platforms using omap_uart
plat_list = 'beagle'
# The set of source files associated with this SConscript file.
src_local = []
#for plat_supported in plat_list:
#if plat_supported == platform:
if plat_list == platform:
src_local += ['timer.c']
obj = env.StaticObject(src_local)
Return('obj')

View File

@@ -0,0 +1,97 @@
/*
* omap GP timer driver honoring generic
* timer library API
*
* Copyright (C) 2010 B Labs Ltd.
*
* Author: Bahadir Balban
*/
#include <libdev/io.h>
#include <l4lib/types.h>
#include "timer.h"
#define OMAP_TIMER_MAT_IT_FLAG (1 << 0)
#define OMAP_TIMER_OVR_IT_FLAG (1 << 1)
#define OMAP_TIMER_TCAR_IT_FLAG (1 << 2)
u32 timer_periodic_intr_status(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + OMAP_TIMER_TISR);
return (reg & OMAP_TIMER_OVR_IT_FLAG);
}
#define OMAP_TIMER_SOFT_RESET (1 << 1)
void timer_reset(unsigned long timer_base)
{
/* Reset Timer */
write(OMAP_TIMER_SOFT_RESET, timer_base + OMAP_TIMER_TIOCP);
/* Wait for reset completion */
while (!read(timer_base + OMAP_TIMER_TSTAT));
}
void timer_load(unsigned long timer_base, u32 value)
{
write(value, timer_base + OMAP_TIMER_TLDR);
write(value, timer_base + OMAP_TIMER_TCRR);
}
u32 timer_read(unsigned long timer_base)
{
return read(timer_base + OMAP_TIMER_TCRR);
}
#define OMAP_TIMER_START (1 << 0)
void timer_start(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + OMAP_TIMER_TCLR);
reg |= OMAP_TIMER_START;
write(reg, timer_base + OMAP_TIMER_TCLR);
}
void timer_stop(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + OMAP_TIMER_TCLR);
reg &= (~OMAP_TIMER_START);
write(reg, timer_base + OMAP_TIMER_TCLR);
}
void timer_init_periodic(unsigned long timer_base)
{
volatile u32 reg;
/* Reset the timer */
timer_reset(timer_base);
/* Set timer to autoreload mode */
reg = read(timer_base + OMAP_TIMER_TCLR);
reg |= (1 << OMAP_TIMER_MODE_AUTORELAOD);
write(reg, timer_base + OMAP_TIMER_TCLR);
/*
* Beagle Board RevC manual:
* overflow period = (0xffffffff - TLDR + 1)*PS*(1/TIMER_FCLK)
* where,
* PS: Prescaler divisor (we are not using this)
*
* Beagle board manual says, 26MHz oscillator present on board.
* U-Boot divides the sys_clock by 2 if sys_clk is >19MHz,
* so,we have sys_clk frequency = 13MHz
*
* TIMER_FCLK = 13MHz
* So, for 1ms period, TLDR = 0xffffcd38
*
*/
timer_load(timer_base, 0xffffcd38);
/* Clear pending Interrupts, if any */
write(7, timer_base + OMAP_TIMER_TISR);
/* Enable inteerupts */
write((1 << OMAP_TIMER_INTR_OVERFLOW), timer_base + OMAP_TIMER_TIER);
}
void timer_init(unsigned long timer_base)
{
timer_init_periodic(timer_base);
}

View File

@@ -0,0 +1,51 @@
/*
* OMAP GP Timer offsets
*
* Copyright (C) 2007 Bahadir Balban
*
*/
#ifndef __OMAP_GPTIMER_H__
#define __OMAP_GPTIMER_H__
/* Register offsets */
#define OMAP_TIMER_TIOCP 0x10
#define OMAP_TIMER_TSTAT 0x14
#define OMAP_TIMER_TISR 0x18
#define OMAP_TIMER_TIER 0x1C
#define OMAP_TIMER_TCLR 0x24
#define OMAP_TIMER_TCRR 0x28
#define OMAP_TIMER_TLDR 0x2C
#define OMAP_TIMER_TPIR 0x48
#define OMAP_TIMER_TNIR 0x4C
#define OMAP_TIMER_TCVR 0x50
/* Enable/Disable IRQ */
#define OMAP_TIMER_IRQENABLE 1
#define OMAP_TIMER_IRQDISABLE 0
/* Timer modes supported */
#define OMAP_TIMER_MODE_AUTORELAOD 1
#define OMAP_TIMER_MODE_COMPARE 6
#define OMAP_TIMER_MODE_CAPTURE 13
/* Interrupt types */
#define OMAP_TIMER_INTR_MATCH 0x0
#define OMAP_TIMER_INTR_OVERFLOW 0x1
#define OMAP_TIMER_INTR_CAPTURE 0x2
/* Clock source for timer */
#define OMAP_TIMER_CLKSRC_SYS_CLK 0x1
#define OMAP_TIMER_CLKSRC_32KHZ_CLK 0x0
u32 timer_periodic_intr_status(unsigned long timer_base);
void timer_start(unsigned long base);
void timer_set_mode(unsigned long base, int mode);
void timer_reset(unsigned long timer_base);
void timer_load(unsigned long timer_base, u32 value);
u32 timer_read(unsigned long timer_base);
void timer_start(unsigned long timer_base);
void timer_stop(unsigned long timer_base);
void timer_init_periodic(unsigned long timer_base);
void timer_init(unsigned long timer_base);
#endif /* __OMAP_GPTIMER_H__*/

View File

@@ -0,0 +1,14 @@
Import('env', 'platform')
#Platforms using sp804
plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926')
# The set of source files associated with this SConscript file.
src_local = []
for plat_supported in plat_list:
if plat_supported == platform:
src_local += Glob('*.c')
obj = env.StaticObject(src_local)
Return('obj')

View File

@@ -0,0 +1,65 @@
/*
* SP804 primecell driver honoring generic
* timer library API
*
* Copyright (C) 2010 B Labs Ltd.
*
* Author: Bahadir Balban
*/
#include <l4lib/types.h>
#include "timer.h"
/* Enable timer with its current configuration */
void timer_start(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + SP804_CTRL);
reg |= SP804_ENABLE;
write(reg, timer_base + SP804_CTRL);
}
/* Load the timer with ticks value */
void timer_load(u32 loadval, unsigned long timer_base)
{
write(loadval, timer_base + SP804_LOAD);
}
u32 timer_read(unsigned long timer_base)
{
return read(timer_base + SP804_VALUE);
}
void timer_stop(unsigned long timer_base)
{
write(0, timer_base + SP804_CTRL);
}
void timer_init_periodic(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + SP804_CTRL);
reg |= SP804_PERIODIC | SP804_32BIT | SP804_IRQEN;
write(reg, timer_base + SP804_CTRL);
/* 1 tick per usec, 1 irq per msec */
timer_load(1000, timer_base);
}
void timer_init_oneshot(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + SP804_CTRL);
/* One shot, 32 bits, no irqs */
reg |= SP804_32BIT | SP804_ONESHOT;
write(reg, timer_base + SP804_CTRL);
}
void timer_init(unsigned long timer_base)
{
timer_stop(timer_base);
timer_init_periodic(timer_base);
}

View File

@@ -0,0 +1,63 @@
/*
* SP804 Primecell Timer offsets
*
* Copyright (C) 2007 Bahadir Balban
*
*/
#ifndef __SP804_TIMER_H__
#define __SP804_TIMER_H__
#include <libdev/io.h>
/* Register offsets */
#define SP804_LOAD 0x0
#define SP804_VALUE 0x4
#define SP804_CTRL 0x8
#define SP804_INTCLR 0xC
#define SP804_RIS 0x10
#define SP804_MIS 0x14
#define SP804_BGLOAD 0x18
#define SP804_ENABLE (1 << 7)
#define SP804_PERIODIC (1 << 6)
#define SP804_IRQEN (1 << 5)
#define SP804_32BIT (1 << 1)
#define SP804_ONESHOT (1 << 0)
/* Timer prescaling */
#define SP804_SCALE_SHIFT 2
#define SP804_SCALE_DIV16 1
#define SP804_SCALE_DIV256 2
/* Wrapping = 0, Oneshot = 1 */
#define SP804_ONESHOT (1 << 0)
static inline __attribute__ ((always_inline))
void sp804_load(unsigned long timer_base, u32 val)
{
write(val, timer_base + SP804_LOAD);
}
static inline __attribute__ ((always_inline))
void sp804_irq_clear(unsigned long timer_base)
{
write(1, timer_base + SP804_INTCLR);
}
static inline __attribute__ ((always_inline))
void sp804_enable(unsigned long timer_base)
{
volatile u32 reg = read(timer_base + SP804_CTRL);
write(reg | SP804_ENABLE, timer_base + SP804_CTRL);
}
void timer_start(unsigned long timer_base);
void timer_load(u32 loadval, unsigned long timer_base);
u32 timer_read(unsigned long timer_base);
void timer_stop(unsigned long timer_base);
void timer_init_periodic(unsigned long timer_base);
void timer_init_oneshot(unsigned long timer_base);
void timer_init(unsigned long timer_base);
#endif /* __SP804_TIMER_H__ */

View File

@@ -0,0 +1,15 @@
Import('env', 'platform')
#Platforms using omap_uart
plat_list = 'beagle'
# The set of source files associated with this SConscript file.
src_local = []
#for plat_supported in plat_list:
#if plat_supported == platform:
if plat_list == platform:
src_local += ['uart.c']
obj = env.StaticObject(src_local)
Return('obj')

View File

@@ -0,0 +1,115 @@
/*
* UART driver used by OMAP devices
*
* Copyright (C) 2007 Bahadir Balban
*/
#include <libdev/uart.h>
#include <libdev/io.h>
#include "uart.h"
#define OMAP_UART_TXFE 0x20
void uart_tx_char(unsigned long uart_base, char c)
{
volatile u32 reg;
/* Check if there is space for tx */
do {
reg = read(uart_base + OMAP_UART_LSR);
} while(!(reg & OMAP_UART_TXFE));
write(c, uart_base + OMAP_UART_THR);
}
#define OMAP_UART_RXFNE 0x1
#define OMAP_UART_RX_FIFO_STATUS 0x8
char uart_rx_char(unsigned long uart_base)
{
volatile u32 reg;
/* Check if pending data is there */
do {
reg = read(uart_base + OMAP_UART_LSR);
} while(!(reg & OMAP_UART_RXFNE));
#if 0
/* Check if there is some error in recieve */
if(reg & OMAP_UART_RX_FIFO_STATUS)
return -1;
#endif
return (char)read(uart_base + OMAP_UART_RHR);
}
void uart_set_baudrate(unsigned long uart_base, u32 baudrate)
{
u32 clk_div;
/* 48Mhz clock fixed on beagleboard */
const u32 clkrate = 48000000;
/* If baud out of range, set default rate */
if(baudrate > 3686400 || baudrate < 300)
baudrate = 115200;
clk_div = clkrate/(16 * baudrate);
/* Set clockrate in DLH and DLL */
write((clk_div & 0xff), uart_base + OMAP_UART_DLL);
write(((clk_div >> 8) & 0xff ), uart_base + OMAP_UART_DLH);
}
void uart_init(unsigned long uart_base)
{
/* Disable UART */
uart_select_mode(uart_base, OMAP_UART_MODE_DEFAULT);
/* Disable interrupts */
uart_disable_interrupt(uart_base);
/* Change to config mode, to set baud divisor */
uart_set_link_control(uart_base, OMAP_UART_BANKED_MODE_CONFIG_A);
/* Set the baud rate */
uart_set_baudrate(uart_base, 115200);
/* Switch to operational mode */
uart_set_link_control(uart_base, OMAP_UART_BANKED_MODE_OPERATIONAL);
/* Set up the link- parity, data bits stop bits to 8N1 */
uart_disable_parity(uart_base);
uart_set_data_bits(uart_base, OMAP_UART_DATA_BITS_8);
uart_set_stop_bits(uart_base, OMAP_UART_STOP_BITS_1);
/* Disable Fifos */
uart_disable_fifo(uart_base);
/* Enable modem Rx/Tx */
uart_enable_tx(uart_base);
uart_enable_rx(uart_base);
/* Enable UART in 16x mode */
uart_select_mode(uart_base, OMAP_UART_MODE_UART16X);
}
unsigned long uart_print_base;
void platform_init(void)
{
uart_print_base = OMAP_UART_BASE;
/*
* We dont need to initialize uart here for variant-userspace,
* as this is the same uart as used by kernel and hence
* already initialized, we just need
* a uart struct instance with proper base address.
*
* But in case of baremetal like loader, no one has done
* initialization, so we need to do it.
*/
#if defined(VARIANT_BAREMETAL)
uart_init(uart_print_base);
#endif
}

View File

@@ -0,0 +1,195 @@
/*
* OMAP UART Generic driver implementation.
*
* Copyright (C) 2007 Bahadir Balban
*
* The particular intention of this code is that it has been carefully written
* as decoupled from os-specific code and in a verbose way such that it clearly
* demonstrates how the device operates, reducing the amount of time to be spent
* for understanding the operational model and implementing a driver from
* scratch. This is the very first to be such a driver so far, hopefully it will
* turn out to be useful.
*/
#ifndef __OMAP_UART_H__
#define __OMAP_UART_H__
#include <l4/config.h> /* To get PLATFORM */
#include <l4lib/types.h>
#if defined(VARIANT_USERSPACE)
/* FIXME: Take this value in agreement from kernel, or from kernel only */
#include <l4/macros.h>
#include INC_ARCH(io.h)
#define OMAP_UART_BASE USERSPACE_CONSOLE_VBASE
#endif
#if defined(VARIANT_BAREMETAL)
#if defined(CONFIG_PLATFORM_BEAGLE)
#define OMAP_UART_BASE 0x49020000
#endif
#endif
/* Register offsets */
#define OMAP_UART_DLL 0x00
#define OMAP_UART_THR 0x00
#define OMAP_UART_RHR 0x00
#define OMAP_UART_DLH 0x04
#define OMAP_UART_IER 0x04
#define OMAP_UART_FCR 0x08
#define OMAP_UART_MCR 0x10
#define OMAP_UART_LSR 0x14
#define OMAP_UART_MDR1 0x20
#define OMAP_UART_LCR 0x0C
/* Modes supported by OMAP UART/IRDA/CIR IP */
#define OMAP_UART_MODE_UART16X 0x0
#define OMAP_UART_MODE_SIR 0x1
#define OMAP_UART_MODE_UART16X_AUTO_BAUD 0x2
#define OMAP_UART_MODE_UART13X 0x3
#define OMAP_UART_MODE_MIR 0x4
#define OMAP_UART_MODE_FIR 0x5
#define OMAP_UART_MODE_CIR 0x6
#define OMAP_UART_MODE_DEFAULT 0x7 /* Disable */
/* Number of data bits for UART */
#define OMAP_UART_DATA_BITS_5 0x0
#define OMAP_UART_DATA_BITS_6 0x1
#define OMAP_UART_DATA_BITS_7 0x2
#define OMAP_UART_DATA_BITS_8 0x3
/* Stop bits to be used for UART data */
#define OMAP_UART_STOP_BITS_1 0x0
#define OMAP_UART_STOP_BITS_1_5 0x1
/* Banked Register modes- ConfigA, ConfigB, Operational */
#define OMAP_UART_BANKED_MODE_OPERATIONAL 0x00
#define OMAP_UART_BANKED_MODE_CONFIG_A 0x80
#define OMAP_UART_BANKED_MODE_CONFIG_B 0xBF
void uart_tx_char(unsigned long uart_base, char c);
char uart_rx_char(unsigned long uart_base);
void uart_set_baudrate(unsigned long uart_base, u32 baudrate);
void uart_init(unsigned long uart_base);
#define OMAP_UART_FIFO_ENABLE (1 << 0)
#define OMAP_UART_RX_FIFO_CLR (1 << 1)
#define OMAP_UART_TX_FIFO_CLR (1 << 2)
static inline void uart_enable_fifo(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_FCR);
reg |= (OMAP_UART_FIFO_ENABLE | OMAP_UART_RX_FIFO_CLR |
OMAP_UART_TX_FIFO_CLR);
write(reg, uart_base + OMAP_UART_FCR);
}
static inline void uart_disable_fifo(unsigned long uart_base)
{
volatile u32 reg= read(uart_base + OMAP_UART_FCR);
reg &= (~OMAP_UART_FIFO_ENABLE | OMAP_UART_RX_FIFO_CLR |
OMAP_UART_TX_FIFO_CLR);
write(reg, uart_base + OMAP_UART_FCR);
}
#define OMAP_UART_TX_ENABLE (1 << 0)
static inline void uart_enable_tx(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_MCR);
reg |= OMAP_UART_TX_ENABLE;
write(reg, uart_base + OMAP_UART_MCR);
}
static inline void uart_disable_tx(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_MCR);
reg &= ~OMAP_UART_TX_ENABLE;
write(reg, uart_base + OMAP_UART_MCR);
}
#define OMAP_UART_RX_ENABLE (1 << 1)
static inline void uart_enable_rx(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_MCR);
reg |= OMAP_UART_RX_ENABLE;
write(reg, uart_base + OMAP_UART_MCR);
}
static inline void uart_disable_rx(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_MCR);
reg &= ~OMAP_UART_RX_ENABLE;
write(reg, uart_base + OMAP_UART_MCR);
}
#define OMAP_UART_STOP_BITS_MASK (1 << 2)
static inline void uart_set_stop_bits(unsigned long uart_base, int bits)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg &= ~OMAP_UART_STOP_BITS_MASK;
reg |= (bits << 2);
write(reg, uart_base + OMAP_UART_LCR);
}
#define OMAP_UART_DATA_BITS_MASK (0x3)
static inline void uart_set_data_bits(unsigned long uart_base, int bits)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg &= ~OMAP_UART_DATA_BITS_MASK;
reg |= bits;
write(reg, uart_base + OMAP_UART_LCR);
}
#define OMAP_UART_PARITY_ENABLE (1 << 3)
static inline void uart_enable_parity(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg |= OMAP_UART_PARITY_ENABLE;
write(reg, uart_base + OMAP_UART_LCR);
}
static inline void uart_disable_parity(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg &= ~OMAP_UART_PARITY_ENABLE;
write(reg, uart_base + OMAP_UART_LCR);
}
#define OMAP_UART_PARITY_EVEN (1 << 4)
static inline void uart_set_even_parity(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg |= OMAP_UART_PARITY_EVEN;
write(reg, uart_base + OMAP_UART_LCR);
}
static inline void uart_set_odd_parity(unsigned long uart_base)
{
volatile u32 reg = read(uart_base + OMAP_UART_LCR);
reg &= ~OMAP_UART_PARITY_EVEN;
write(reg, uart_base + OMAP_UART_LCR);
}
static inline void uart_select_mode(unsigned long uart_base, int mode)
{
write(mode, uart_base + OMAP_UART_MDR1);
}
#define OMAP_UART_INTR_EN 1
static inline void uart_enable_interrupt(unsigned long uart_base)
{
write(OMAP_UART_INTR_EN, uart_base + OMAP_UART_IER);
}
static inline void uart_disable_interrupt(unsigned long uart_base)
{
write((~OMAP_UART_INTR_EN), uart_base + OMAP_UART_IER);
}
static inline void uart_set_link_control(unsigned long uart_base, int mode)
{
write(mode, uart_base + OMAP_UART_LCR);
}
#endif /* __OMAP_UART_H__ */

View File

@@ -0,0 +1,14 @@
Import('env', 'platform')
#Platforms using pl011
plat_list = ('eb', 'pba8', 'pba9', 'pb11mpcore', 'pb926')
# The set of source files associated with this SConscript file.
src_local = []
for plat_supported in plat_list:
if plat_supported == platform:
src_local += Glob('*.c')
obj = env.StaticObject(src_local)
Return('obj')

View File

@@ -0,0 +1,127 @@
/*
* PL011 UART driver
*
* Copyright (C) 2009 B Labs Ltd.
*/
#include <libdev/uart.h>
#include <libdev/io.h>
#include "uart.h"
/* Error status bits in receive status register */
#define PL011_FE (1 << 0)
#define PL011_PE (1 << 1)
#define PL011_BE (1 << 2)
#define PL011_OE (1 << 3)
/* Status bits in flag register */
#define PL011_TXFE (1 << 7)
#define PL011_RXFF (1 << 6)
#define PL011_TXFF (1 << 5)
#define PL011_RXFE (1 << 4)
#define PL011_BUSY (1 << 3)
#define PL011_DCD (1 << 2)
#define PL011_DSR (1 << 1)
#define PL011_CTS (1 << 0)
void uart_tx_char(unsigned long base, char c)
{
unsigned int val = 0;
do {
val = read((base + PL011_UARTFR));
} while (val & PL011_TXFF); /* TX FIFO FULL */
write(c, (base + PL011_UARTDR));
}
char uart_rx_char(unsigned long base)
{
unsigned int val = 0;
do {
val = read(base + PL011_UARTFR);
} while (val & PL011_RXFE); /* RX FIFO Empty */
return (char)read((base + PL011_UARTDR));
}
/*
* Sets the baud rate in kbps. It is recommended to use
* standard rates such as: 1200, 2400, 3600, 4800, 7200,
* 9600, 14400, 19200, 28800, 38400, 57600 76800, 115200.
*/
void pl011_set_baudrate(unsigned long base, unsigned int baud,
unsigned int clkrate)
{
const unsigned int uartclk = 24000000; /* 24Mhz clock fixed on pb926 */
unsigned int val = 0, ipart = 0, fpart = 0;
/* Use default pb926 rate if no rate is supplied */
if (clkrate == 0)
clkrate = uartclk;
if (baud > 115200 || baud < 1200)
baud = 38400; /* Default rate. */
/* 24000000 / (38400 * 16) */
ipart = 39;
write(ipart, base + PL011_UARTIBRD);
write(fpart, base + PL011_UARTFBRD);
/*
* For the IBAUD and FBAUD to update, we need to
* write to UARTLCR_H because the 3 registers are
* actually part of a single register in hardware
* which only updates by a write to UARTLCR_H
*/
val = read(base + PL011_UARTLCR_H);
write(val, base + PL011_UARTLCR_H);
}
void uart_init(unsigned long uart_base)
{
/* Initialise data register for 8 bit data read/writes */
pl011_set_word_width(uart_base, 8);
/*
* Fifos are disabled because by default it is assumed the port
* will be used as a user terminal, and in that case the typed
* characters will only show up when fifos are flushed, rather than
* when each character is typed. We avoid this by not using fifos.
*/
pl011_disable_fifos(uart_base);
/* Set default baud rate of 38400 */
pl011_set_baudrate(uart_base, 38400, 24000000);
/* Set default settings of 1 stop bit, no parity, no hw flow ctrl */
pl011_set_stopbits(uart_base, 1);
pl011_parity_disable(uart_base);
/* Enable rx, tx, and uart chip */
pl011_tx_enable(uart_base);
pl011_rx_enable(uart_base);
pl011_uart_enable(uart_base);
}
unsigned long uart_print_base;
void platform_init(void)
{
uart_print_base = PL011_BASE;
/*
* We dont need to initialize uart here for variant-userspace,
* as this is the same uart as used by kernel and hence
* already initialized, we just need
* a uart struct instance with proper base address.
*
* But in case of baremetal like loader, no one has done
* initialization, so we need to do it.
*/
#if defined(VARIANT_BAREMETAL)
uart_init(uart_print_base);
#endif
}

View File

@@ -0,0 +1,252 @@
/*
* PL011 UART Generic driver implementation.
* Copyright Bahadir Balban (C) 2009
*/
#ifndef __PL011_H__
#define __PL011_H__
#include <l4/config.h> /* To get PLATFORM */
#include <libdev/io.h>
#if defined(VARIANT_USERSPACE)
/* FIXME: Take this value in agreement from kernel, or from kernel only */
#include <l4/macros.h>
#include INC_ARCH(io.h)
#define PL011_BASE USERSPACE_CONSOLE_VBASE
#endif
#if defined(VARIANT_BAREMETAL)
#if defined(CONFIG_PLATFORM_PB926)
#define PL011_BASE 0x101F1000
#elif defined(CONFIG_PLATFORM_EB) || defined(CONFIG_PLATFORM_PB11MPCORE)
#define PL011_BASE 0x10009000
#elif defined(CONFIG_PLATFORM_PBA9) || defined(CONFIG_PLATFORM_PBA8)
#define PL011_BASE 0x10009000
#endif
#endif
/* Register offsets */
#define PL011_UARTDR 0x00
#define PL011_UARTRSR 0x04
#define PL011_UARTECR 0x04
#define PL011_UARTFR 0x18
#define PL011_UARTILPR 0x20
#define PL011_UARTIBRD 0x24
#define PL011_UARTFBRD 0x28
#define PL011_UARTLCR_H 0x2C
#define PL011_UARTCR 0x30
#define PL011_UARTIFLS 0x34
#define PL011_UARTIMSC 0x38
#define PL011_UARTRIS 0x3C
#define PL011_UARTMIS 0x40
#define PL011_UARTICR 0x44
#define PL011_UARTDMACR 0x48
/* IRQ bits for each uart irq event */
#define PL011_RXIRQ (1 << 4)
#define PL011_TXIRQ (1 << 5)
#define PL011_RXTIMEOUTIRQ (1 << 6)
#define PL011_FEIRQ (1 << 7)
#define PL011_PEIRQ (1 << 8)
#define PL011_BEIRQ (1 << 9)
#define PL011_OEIRQ (1 << 10)
void pl011_set_baudrate(unsigned long base, unsigned int baud,
unsigned int clkrate);
#define PL011_UARTEN (1 << 0)
static inline void pl011_uart_enable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTCR));
val |= PL011_UARTEN;
write(val, (base + PL011_UARTCR));
return;
}
static inline void pl011_uart_disable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTCR));
val &= ~PL011_UARTEN;
write(val, (base + PL011_UARTCR));
return;
}
#define PL011_TXE (1 << 8)
static inline void pl011_tx_enable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTCR));
val |= PL011_TXE;
write(val, (base + PL011_UARTCR));
return;
}
static inline void pl011_tx_disable(unsigned long base)
{
unsigned int val = 0;
val =read((base + PL011_UARTCR));
val &= ~PL011_TXE;
write(val, (base + PL011_UARTCR));
return;
}
#define PL011_RXE (1 << 9)
static inline void pl011_rx_enable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTCR));
val |= PL011_RXE;
write(val, (base + PL011_UARTCR));
return;
}
static inline void pl011_rx_disable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTCR));
val &= ~PL011_RXE;
write(val, (base + PL011_UARTCR));
return;
}
#define PL011_TWO_STOPBITS_SELECT (1 << 3)
static inline void pl011_set_stopbits(unsigned long base, int stopbits)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
if(stopbits == 2) { /* Set to two bits */
val |= PL011_TWO_STOPBITS_SELECT;
} else { /* Default is 1 */
val &= ~PL011_TWO_STOPBITS_SELECT;
}
write(val, (base + PL011_UARTLCR_H));
return;
}
#define PL011_PARITY_ENABLE (1 << 1)
static inline void pl011_parity_enable(unsigned long base)
{
unsigned int val = 0;
val = read((base +PL011_UARTLCR_H));
val |= PL011_PARITY_ENABLE;
write(val, (base + PL011_UARTLCR_H));
return;
}
static inline void pl011_parity_disable(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
val &= ~PL011_PARITY_ENABLE;
write(val, (base + PL011_UARTLCR_H));
return;
}
#define PL011_PARITY_EVEN (1 << 2)
static inline void pl011_set_parity_even(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
val |= PL011_PARITY_EVEN;
write(val, (base + PL011_UARTLCR_H));
return;
}
static inline void pl011_set_parity_odd(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
val &= ~PL011_PARITY_EVEN;
write(val, (base + PL011_UARTLCR_H));
return;
}
#define PL011_ENABLE_FIFOS (1 << 4)
static inline void pl011_enable_fifos(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
val |= PL011_ENABLE_FIFOS;
write(val, (base + PL011_UARTLCR_H));
return;
}
static inline void pl011_disable_fifos(unsigned long base)
{
unsigned int val = 0;
val = read((base + PL011_UARTLCR_H));
val &= ~PL011_ENABLE_FIFOS;
write(val, (base + PL011_UARTLCR_H));
return;
}
/* Sets the transfer word width for the data register. */
static inline void pl011_set_word_width(unsigned long base, int size)
{
unsigned int val = 0;
if(size < 5 || size > 8) /* Default is 8 */
size = 8;
/* Clear size field */
val = read((base + PL011_UARTLCR_H));
val &= ~(0x3 << 5);
write(val, (base + PL011_UARTLCR_H));
/*
* The formula is to write 5 less of size given:
* 11 = 8 bits
* 10 = 7 bits
* 01 = 6 bits
* 00 = 5 bits
*/
val = read((base + PL011_UARTLCR_H));
val |= (size - 5) << 5;
write(val, (base + PL011_UARTLCR_H));
return;
}
/*
* Defines at which level of fifo fullness an irq will be generated.
* @xfer: tx fifo = 0, rx fifo = 1
* @level: Generate irq if:
* 0 rxfifo >= 1/8 full txfifo <= 1/8 full
* 1 rxfifo >= 1/4 full txfifo <= 1/4 full
* 2 rxfifo >= 1/2 full txfifo <= 1/2 full
* 3 rxfifo >= 3/4 full txfifo <= 3/4 full
* 4 rxfifo >= 7/8 full txfifo <= 7/8 full
* 5-7 reserved reserved
*/
static inline void pl011_set_irq_fifolevel(unsigned long base, \
unsigned int xfer, unsigned int level)
{
if(xfer != 1 && xfer != 0) /* Invalid fifo */
return;
if(level > 4) /* Invalid level */
return;
write(level << (xfer * 3), (base + PL011_UARTIFLS));
return;
}
#endif /* __PL011__UART__ */

View File

@@ -26,36 +26,36 @@ sys.path.append(PROJRELROOT)
from config.projpaths import *
from configure import *
Import('arch')
Import('env', 'arch', 'subarch')
config = configuration_retrieve()
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
env = Environment(CC = config.user_toolchain + 'gcc',
CCFLAGS = ['-g', '-std=gnu99', '-nostdlib', '-ffreestanding'],
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
ENV = {'PATH' : os.environ['PATH']},
LIBS = 'gcc',
CPPPATH = ['include', 'include/l4lib/arch', join(PROJROOT, 'include') ])
e = env.Clone()
e.Append(CPPPATH = ['include', 'include/l4lib/arch',
LIBMEM_DIR],
CPPFLAGS = ' -include l4lib/macros.h ')
env.Append(CPPPATH = [LIBMEM_DIR])
#Do we need to remove CPPFLAGS coming from top level env?
def create_symlinks(arch):
print os.getcwd()
prefix = 'conts/libl4/include/l4lib'
symlink = join(prefix, 'arch')
reallink = join(prefix, 'arch-' + arch)
# Use os.path.walk(dirname, glob_by_walk, ['*.[cS]', filelist])
# To collect all files in the tree.
if not os.path.exists(symlink):
cmd = "ln -s %s %s" % (reallink, symlink)
print cmd
os.system(cmd)
def glob_by_walk(arg, dirname, names):
ext, imglist = arg
files = glob.glob(join(dirname, ext))
imglist.extend(files)
#create_symlinks(arch)
objects = env.StaticObject(Glob('src/*.c') + Glob('src/thread/*.c') + Glob('src/' + arch + '/*.[cS]'))
library = env.StaticLibrary('l4', objects)
objects = e.StaticObject(Glob('src/*.c') + \
Glob('src/lib/*.c') + \
Glob('src/lib/cap/*.c')) + \
Glob('src/lib/thread/*.c') + \
Glob('src/arch/' + arch + '/exregs.c') + \
Glob('src/arch/' + arch + '/*.S') + \
Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]')
library = e.StaticLibrary('l4', objects)
Return('library')

View File

@@ -14,23 +14,35 @@ from config.projpaths import *
from config.configuration import *
config = configuration_retrieve()
gcc_arch_flag = config.gcc_arch_flag
arch = config.arch
subarch = config.subarch
LIBMEM_RELDIR = 'conts/libmem'
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
env = Environment(CC = config.user_toolchain + 'gcc',
CCFLAGS = ['-std=gnu99', '-g', '-nostdlib', '-ffreestanding', '-Werror'],
LIBC_RELDIR = 'conts/libc'
LIBC_DIR = join(PROJROOT, LIBC_RELDIR)
LIBC_INC = join(LIBC_DIR, 'include')
env = Environment(CC = config.toolchain + 'gcc',
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', \
'-nostdinc', '-Wall', '-Werror', '-march=' + gcc_arch_flag],
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
ENV = {'PATH' : os.environ['PATH']},
LIBS = 'gcc',
CPPPATH = ['#include', '#include/l4lib/arch', join(PROJROOT,'include'), \
LIBMEM_DIR])
CPPPATH = ['include', 'include/l4lib/arch', LIBC_INC, \
join(PROJROOT,'include'), LIBMEM_DIR],
CPPFLAGS = ' -include l4lib/macros.h ')
objects = env.StaticObject(Glob('src/*.c') + \
Glob('src/lib/*.c') + \
Glob('src/arch/' + arch + '/exregs.c') + \
Glob('src/arch/' + arch + '/*.[cS]') + \
Glob('src/arch/' + arch + '/' + subarch + '/*.[cS]') + \
Glob('src/lib/cap/*.c')) + \
Glob('src/lib/thread/*.c')
# TODO: There are errors in this code that -Werror gives problems with.
objects = env.StaticObject(Glob('src/*.c') + Glob('src/thread/*.c') + Glob('src/' + arch + '/*.[cS]'))
library = env.StaticLibrary('l4', objects)
#Return('library')

View File

@@ -0,0 +1,11 @@
#ifndef __L4LIB_ARCH_IRQ_H__
#define __L4LIB_ARCH_IRQ_H__
/*
* Destructive atomic-read.
*
* Write 0 to byte at @location as its contents are read back.
*/
char l4_atomic_dest_readb(void *location);
#endif

View File

@@ -0,0 +1,15 @@
#ifndef __ARM_ASM_H__
#define __ARM_ASM_H__
#define BEGIN_PROC(name) \
.global name; \
.type name,function; \
.align; \
name:
#define END_PROC(name) \
.fend_##name: \
.size name,.fend_##name - name;
#endif /* __ARM_ASM_H__ */

View File

@@ -0,0 +1,11 @@
#ifndef __L4LIB_ARCH_IRQ_H__
#define __L4LIB_ARCH_IRQ_H__
/*
* Destructive atomic-read.
*
* Write 0 to byte at @location as its contents are read back.
*/
char l4_atomic_dest_readb(void *location);
#endif

View File

@@ -0,0 +1,95 @@
/*
* System call prototypes.
*
* Copyright (C) 2007 Bahadir Balban
*/
#ifndef __ARM_SYSCALLS_H__
#define __ARM_SYSCALLS_H__
#include L4LIB_INC_ARCH(types.h)
#include L4LIB_INC_ARCH(utcb.h)
#include <l4/generic/space.h>
#include <l4/api/space.h>
#include <l4/api/kip.h>
#include <l4/api/ipc.h>
#include <l4/api/thread.h>
struct task_ids {
l4id_t tid;
l4id_t spid;
l4id_t tgid;
};
static inline void *
l4_kernel_interface(unsigned int *api_version, unsigned int *api_flags,
unsigned int *kernel_id)
{
return (void *)L4_KIP_ADDRESS;
}
typedef unsigned int (*__l4_thread_switch_t)(u32);
extern __l4_thread_switch_t __l4_thread_switch;
unsigned int l4_thread_switch (u32 dest);
typedef int (*__l4_getid_t)(struct task_ids *ids);
extern __l4_getid_t __l4_getid;
int l4_getid(struct task_ids *ids);
typedef int (*__l4_ipc_t)(l4id_t to, l4id_t from, u32 flags);
extern __l4_ipc_t __l4_ipc;
int l4_ipc(l4id_t to, l4id_t from, u32 flags);
typedef int (*__l4_capability_control_t)(unsigned int req, unsigned int flags, void *buf);
extern __l4_capability_control_t __l4_capability_control;
int l4_capability_control(unsigned int req, unsigned int flags, void *buf);
typedef int (*__l4_map_t)(void *phys, void *virt,
u32 npages, u32 flags, l4id_t tid);
extern __l4_map_t __l4_map;
int l4_map(void *p, void *v, u32 npages, u32 flags, l4id_t tid);
typedef int (*__l4_unmap_t)(void *virt, unsigned long npages, l4id_t tid);
extern __l4_unmap_t __l4_unmap;
int l4_unmap(void *virtual, unsigned long numpages, l4id_t tid);
typedef int (*__l4_thread_control_t)(unsigned int action, struct task_ids *ids);
extern __l4_thread_control_t __l4_thread_control;
int l4_thread_control(unsigned int action, struct task_ids *ids);
typedef int (*__l4_irq_control_t)(unsigned int req, unsigned int flags, l4id_t id);
extern __l4_irq_control_t __l4_irq_control;
int l4_irq_control(unsigned int req, unsigned int flags, l4id_t id);
typedef int (*__l4_ipc_control_t)(unsigned int action, l4id_t blocked_sender,
u32 blocked_tag);
extern __l4_ipc_control_t __l4_ipc_control;
int l4_ipc_control(unsigned int, l4id_t blocked_sender, u32 blocked_tag);
typedef int (*__l4_exchange_registers_t)(void *exregs_struct, l4id_t tid);
extern __l4_exchange_registers_t __l4_exchange_registers;
int l4_exchange_registers(void *exregs_struct, l4id_t tid);
typedef int (*__l4_container_control_t)(unsigned int req, unsigned int flags, void *buf);
extern __l4_container_control_t __l4_container_control;
int l4_container_control(unsigned int req, unsigned int flags, void *buf);
typedef int (*__l4_time_t)(void *timeval, int set);
extern __l4_time_t __l4_time;
int l4_time(void *timeval, int set);
typedef int (*__l4_mutex_control_t)(void *mutex_word, int op);
extern __l4_mutex_control_t __l4_mutex_control;
int l4_mutex_control(void *mutex_word, int op);
typedef int (*__l4_cache_control_t)(void *start, void *end, unsigned int flags);
extern __l4_cache_control_t __l4_cache_control;
int l4_cache_control(void *start, void *end, unsigned int flags);
/* To be supplied by server tasks. */
void *virt_to_phys(void *);
void *phys_to_virt(void *);
#endif /* __ARM_SYSCALLS_H__ */

View File

@@ -0,0 +1,366 @@
/*
* Helper functions that wrap raw l4 syscalls.
*
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
*/
#ifndef __L4LIB_SYSLIB_H__
#define __L4LIB_SYSLIB_H__
#include <stdio.h>
#include <l4/macros.h>
#include L4LIB_INC_ARCH(syscalls.h)
/*
* NOTE:
* Its best to use these wrappers because they generalise the way
* common ipc data like sender id, error, ipc tag are passed
* between ipc parties.
*
* The arguments to l4_ipc() are used by the microkernel to initiate
* the ipc. Any data passed in message registers may or may not be
* a duplicate of this data, but the distinction is that anything
* that is passed via the mrs are meant to be used by the other party
* participating in the ipc.
*/
/* For system call arguments */
#define L4SYS_ARG0 (MR_UNUSED_START)
#define L4SYS_ARG1 (MR_UNUSED_START + 1)
#define L4SYS_ARG2 (MR_UNUSED_START + 2)
#define L4SYS_ARG3 (MR_UNUSED_START + 3)
#define L4_IPC_TAG_MASK 0x00000FFF
/*
* Servers get sender.
*/
static inline l4id_t l4_get_sender(void)
{
return (l4id_t)read_mr(MR_SENDER);
}
/*
* When doing an ipc the sender never has to be explicitly set in
* the utcb via this function since this information is found out
* by the microkernel by checking the system caller's id. This is
* only used for restoring the sender on the utcb in order to
* complete an earlier ipc.
*/
static inline void l4_set_sender(l4id_t sender)
{
write_mr(MR_SENDER, sender);
}
static inline unsigned int l4_set_ipc_size(unsigned int word, unsigned int size)
{
word &= ~L4_IPC_FLAGS_SIZE_MASK;
word |= ((size << L4_IPC_FLAGS_SIZE_SHIFT) & L4_IPC_FLAGS_SIZE_MASK);
return word;
}
static inline unsigned int l4_get_ipc_size(unsigned int word)
{
return (word & L4_IPC_FLAGS_SIZE_MASK) >> L4_IPC_FLAGS_SIZE_SHIFT;
}
static inline unsigned int l4_set_ipc_msg_index(unsigned int word, unsigned int index)
{
/* FIXME: Define MR_PRIMARY_TOTAL, MR_TOTAL etc. and use MR_TOTAL HERE! */
BUG_ON(index > UTCB_SIZE);
word &= ~L4_IPC_FLAGS_MSG_INDEX_MASK;
word |= (index << L4_IPC_FLAGS_MSG_INDEX_SHIFT) &
L4_IPC_FLAGS_MSG_INDEX_MASK;
return word;
}
static inline unsigned int l4_get_ipc_msg_index(unsigned int word)
{
return (word & L4_IPC_FLAGS_MSG_INDEX_MASK)
>> L4_IPC_FLAGS_MSG_INDEX_SHIFT;
}
static inline unsigned int l4_set_ipc_flags(unsigned int word, unsigned int flags)
{
word &= ~L4_IPC_FLAGS_TYPE_MASK;
word |= flags & L4_IPC_FLAGS_TYPE_MASK;
return word;
}
static inline unsigned int l4_get_ipc_flags(unsigned int word)
{
return word & L4_IPC_FLAGS_TYPE_MASK;
}
static inline unsigned int l4_get_tag(void)
{
return read_mr(MR_TAG) & L4_IPC_TAG_MASK;
}
static inline void l4_set_tag(unsigned int tag)
{
unsigned int tag_flags = read_mr(MR_TAG);
tag_flags &= ~L4_IPC_TAG_MASK;
tag_flags |= tag & L4_IPC_TAG_MASK;
write_mr(MR_TAG, tag_flags);
}
/* Servers:
* Sets the message register for returning errors back to client task.
* These are usually posix error codes.
*/
static inline void l4_set_retval(int retval)
{
write_mr(MR_RETURN, retval);
}
/* Clients:
* Learn result of request.
*/
static inline int l4_get_retval(void)
{
return read_mr(MR_RETURN);
}
/*
* This is useful for stacked IPC. A stacked IPC happens
* when a new IPC is initiated before concluding the current
* one.
*
* This saves the last ipc's parameters such as the sender
* and tag information. Any previously saved data in save
* slots are destroyed. This is fine as IPC stacking is only
* useful if done once.
*/
static inline void l4_save_ipcregs(void)
{
l4_get_utcb()->saved_sender = l4_get_sender();
l4_get_utcb()->saved_tag = l4_get_tag();
}
static inline void l4_restore_ipcregs(void)
{
l4_set_tag(l4_get_utcb()->saved_tag);
l4_set_sender(l4_get_utcb()->saved_sender);
}
#define TASK_CID_MASK 0xFF000000
#define TASK_ID_MASK 0x00FFFFFF
#define TASK_CID_SHIFT 24
static inline l4id_t __raw_tid(l4id_t tid)
{
return tid & TASK_ID_MASK;
}
static inline l4id_t __cid(l4id_t tid)
{
return (tid & TASK_CID_MASK) >> TASK_CID_SHIFT;
}
static inline l4id_t self_tid(void)
{
struct task_ids ids;
l4_getid(&ids);
return ids.tid;
}
static inline l4id_t __raw_self_tid(void)
{
return __raw_tid(self_tid());
}
static inline int l4_send_full(l4id_t to, unsigned int tag)
{
l4_set_tag(tag);
return l4_ipc(to, L4_NILTHREAD, L4_IPC_FLAGS_FULL);
}
static inline int l4_receive_full(l4id_t from)
{
return l4_ipc(L4_NILTHREAD, from, L4_IPC_FLAGS_FULL);
}
static inline int l4_sendrecv_full(l4id_t to, l4id_t from, unsigned int tag)
{
int err;
BUG_ON(to == L4_NILTHREAD || from == L4_NILTHREAD);
l4_set_tag(tag);
err = l4_ipc(to, from, L4_IPC_FLAGS_FULL);
return err;
}
static inline int l4_send_extended(l4id_t to, unsigned int tag,
unsigned int size, void *buf)
{
unsigned int flags = 0;
l4_set_tag(tag);
/* Set up flags word for extended ipc */
flags = l4_set_ipc_flags(flags, L4_IPC_FLAGS_EXTENDED);
flags = l4_set_ipc_size(flags, size);
flags = l4_set_ipc_msg_index(flags, L4SYS_ARG0);
/* Write buffer pointer to MR index that we specified */
write_mr(L4SYS_ARG0, (unsigned long)buf);
return l4_ipc(to, L4_NILTHREAD, flags);
}
static inline int l4_receive_extended(l4id_t from, unsigned int size, void *buf)
{
unsigned int flags = 0;
/* Indicate extended receive */
flags = l4_set_ipc_flags(flags, L4_IPC_FLAGS_EXTENDED);
/* How much data is accepted */
flags = l4_set_ipc_size(flags, size);
/* Indicate which MR index buffer pointer is stored */
flags = l4_set_ipc_msg_index(flags, L4SYS_ARG0);
/* Set MR with buffer to receive data */
write_mr(L4SYS_ARG0, (unsigned long)buf);
return l4_ipc(L4_NILTHREAD, from, flags);
}
/*
* Return result value as extended IPC.
*
* Extended IPC copies up to 2KB user address space buffers.
* Along with such an ipc, a return value is sent using a primary
* mr that is used as the return register.
*
* It may not be desirable to return a payload on certain conditions,
* (such as an error return value) So a nopayload field is provided.
*/
static inline int l4_return_extended(int retval, unsigned int size,
void *buf, int nopayload)
{
unsigned int flags = 0;
l4id_t sender = l4_get_sender();
l4_set_retval(retval);
/* Set up flags word for extended ipc */
flags = l4_set_ipc_flags(flags, L4_IPC_FLAGS_EXTENDED);
flags = l4_set_ipc_msg_index(flags, L4SYS_ARG0);
/* Write buffer pointer to MR index that we specified */
write_mr(L4SYS_ARG0, (unsigned long)buf);
if (nopayload)
flags = l4_set_ipc_size(flags, 0);
else
flags = l4_set_ipc_size(flags, size);
return l4_ipc(sender, L4_NILTHREAD, flags);
}
static inline int l4_sendrecv_extended(l4id_t to, l4id_t from,
unsigned int tag, void *buf)
{
/* Need to imitate sendrecv but with extended send/recv flags */
return 0;
}
static inline int l4_send(l4id_t to, unsigned int tag)
{
l4_set_tag(tag);
return l4_ipc(to, L4_NILTHREAD, 0);
}
static inline int l4_sendrecv(l4id_t to, l4id_t from, unsigned int tag)
{
int err;
BUG_ON(to == L4_NILTHREAD || from == L4_NILTHREAD);
l4_set_tag(tag);
err = l4_ipc(to, from, 0);
return err;
}
static inline int l4_receive(l4id_t from)
{
return l4_ipc(L4_NILTHREAD, from, 0);
}
static inline void l4_print_mrs()
{
printf("Message registers: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
read_mr(0), read_mr(1), read_mr(2), read_mr(3),
read_mr(4), read_mr(5));
}
/* Servers:
* Return the ipc result back to requesting task.
*/
static inline int l4_ipc_return(int retval)
{
l4id_t sender = l4_get_sender();
l4_set_retval(retval);
/* Setting the tag would overwrite retval so we l4_send without tagging */
return l4_ipc(sender, L4_NILTHREAD, 0);
}
void *l4_new_virtual(int npages);
void *l4_del_virtual(void *virt, int npages);
/* A helper that translates and maps a physical address to virtual */
static inline void *l4_map_helper(void *phys, int npages)
{
struct task_ids ids;
int err;
void *virt = l4_new_virtual(npages);
l4_getid(&ids);
if ((err = l4_map(phys, virt, npages,
MAP_USR_DEFAULT, ids.tid)) < 0)
return PTR_ERR(err);
return virt;
}
/* A helper that translates and maps a physical address to virtual */
static inline void *l4_unmap_helper(void *virt, int npages)
{
struct task_ids ids;
l4_getid(&ids);
l4_unmap(virt, npages, ids.tid);
l4_del_virtual(virt, npages);
return 0;
}
#define L4_EXIT_MASK 0xFFFF
static inline void l4_exit(unsigned int exit_code)
{
struct task_ids ids;
l4_getid(&ids);
l4_thread_control(THREAD_DESTROY |
(exit_code & L4_EXIT_MASK),
&ids);
}
#endif /* __L4LIB_SYSLIB_H__ */

View File

@@ -0,0 +1,8 @@
#ifndef __L4LIB_ARM_TYPES_H___
#define __L4LIB_ARM_TYPES_H__
#define TASK_ID_INVALID 0xFFFFFFFF
#include <l4/arch/arm/types.h>
#endif /* __L4LIB_ARM_TYPES_H__ */

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2009 Bahadir Bilgehan Balban
*/
#ifndef __ARM_UTCB_H__
#define __ARM_UTCB_H__
#define USER_UTCB_REF 0xFF000050
#define L4_KIP_ADDRESS 0xFF000000
#define UTCB_KIP_OFFSET 0x50
#ifndef __ASSEMBLY__
#include <l4lib/types.h>
#include <l4/macros.h>
#include <l4/lib/math.h>
#include INC_GLUE(message.h)
#include INC_GLUE(memory.h)
#include <string.h>
#include <stdio.h>
#include L4LIB_INC_SUBARCH(utcb.h)
/*
* See kernel glue/arch/message.h for utcb details
*/
extern struct kip *kip;
/* Functions to read/write utcb registers */
static inline unsigned int read_mr(int offset)
{
if (offset < MR_TOTAL)
return l4_get_utcb()->mr[offset];
else
return l4_get_utcb()->mr_rest[offset - MR_TOTAL];
}
static inline void write_mr(unsigned int offset, unsigned int val)
{
if (offset < MR_TOTAL)
l4_get_utcb()->mr[offset] = val;
else
l4_get_utcb()->mr_rest[offset - MR_TOTAL] = val;
}
static inline void *utcb_full_buffer()
{
return &l4_get_utcb()->mr_rest[0];
}
static inline char *utcb_full_strcpy_from(const char *src)
{
return strncpy((char *)&l4_get_utcb()->mr_rest[0], src,
L4_UTCB_FULL_BUFFER_SIZE);
}
static inline void *utcb_full_memcpy_from(const char *src, int size)
{
return memcpy(&l4_get_utcb()->mr_rest[0], src,
min(size, L4_UTCB_FULL_BUFFER_SIZE));
}
static inline char *utcb_full_strcpy_to(char *dst)
{
return strncpy(dst, (char *)&l4_get_utcb()->mr_rest[0],
L4_UTCB_FULL_BUFFER_SIZE);
}
static inline void *utcb_full_memcpy_to(char *dst, int size)
{
return memcpy(dst, &l4_get_utcb()->mr_rest[0],
min(size, L4_UTCB_FULL_BUFFER_SIZE));
}
#endif /* !__ASSEMBLY__ */
#endif /* __ARM_UTCB_H__ */

View File

@@ -0,0 +1,3 @@
#ifndef __PERFMON_H__
#endif

View File

@@ -0,0 +1,21 @@
#ifndef __ARM_V5_UTCB_H__
#define __ARM_V5_UTCB_H__
/*
* Pointer to Kernel Interface Page's UTCB pointer offset.
*/
extern struct utcb **kip_utcb_ref;
static inline struct utcb *l4_get_utcb()
{
/*
* By double dereferencing, we get the private TLS
* (aka UTCB). First reference is to the KIP's utcb
* offset, second is to the utcb itself, to which
* the KIP's utcb reference had been updated during
* context switch.
*/
return *kip_utcb_ref;
}
#endif /* __ARM_V5_UTCB_H__ */

View File

@@ -0,0 +1,405 @@
/*
* ARMv7 Performance Monitor operations
*
* Copyright (C) 2010 B Labs Ltd.
*
* Author: Bahadir Balban
*/
#ifndef __PERFMON_H__
#define __PERFMON_H__
#include <l4lib/types.h>
/* Perfmon control register */
#define PMCR_DP_BIT 5 /* Disable prohibited */
#define PMCR_X_BIT 4 /* Export event enable */
#define PMCR_D_BIT 3 /* 64-cycle granularity */
#define PMCR_C_BIT 2 /* PMCCNTR reset */
#define PMCR_P_BIT 1 /* Events all reset */
#define PMCR_E_BIT 0 /* Enable all */
/* Obtain number of event counters */
#define PMCR_N_SHIFT 11
#define PMCR_N_MASK 0x1F
/* Special bit for cycle counter */
#define PMCCNTR_BIT 31
/*
* Performance Events
*/
/* Generic v7 events */
#define PERFMON_EVENT_SOFTINC 0
#define PERFMON_EVENT_IFETCH_L1CREFILL 1
#define PERFMON_EVENT_IFETCH_TLBREFILL 2
#define PERFMON_EVENT_DFETCH_L1CREFILL 3
#define PERFMON_EVENT_DFETCH_L1CACCESS 4
#define PERFMON_EVENT_DFETCH_TLBREFILL 5
#define PERFMON_EVENT_MEMREAD_INSTR 6
#define PERFMON_EVENT_MEMWRITE_INSTR 7
#define PERFMON_EVENT_ALL_INSTR 8
#define PERFMON_EVENT_EXCEPTION 9
#define PERFMON_EVENT_EXCEPTION_RETURN 10
#define PERFMON_EVENT_CONTEXTIDR_CHANGE 11
#define PERFMON_EVENT_PC_CHANGE 12
#define PERFMON_EVENT_IMM_BRANCH 13
#define PERFMON_EVENT_FUNCTION_RETURN 14
#define PERFMON_EVENT_UNALIGNED_ACCESS 15
#define PERFMON_EVENT_BRANCH_MISS 16
#define PERFMON_EVENT_RAW_CYCLE_COUNT 17
#define PERFMON_EVENT_BRANCH_MAYBEHIT 18
/*
* Cortex-A9 events (only relevant ones)
* 0x40-2, 0x6E, 0x70, 0x71-4, 0x80-0x81, 0x8A-8B
* 0xA0-5 omitted
*/
/*
* Linefill not satisfied from other cpu caches but
* has to go to external memory
*/
#define PERFMON_EVENT_SMP_LINEFILL_MISS 0x50
/* Linefill satisfied from other cpu caches */
#define PERFMON_EVENT_SMP_LINEFILL_HIT 0x51
/* Icache refill stall cycles on cpu pipeline */
#define PERFMON_EVENT_ICACHE_CPU_STALL 0x60
/* Dcache refill stall cycles on cpu pipeline */
#define PERFMON_EVENT_DCACHE_CPU_STALL 0x61
/* TLB miss stall cycles on cpu pipeline */
#define PERFMON_EVENT_TLBMISS_CPU_STALL 0x62
#define PERFMON_EVENT_STREX_SUCCESS 0x63
#define PERFMON_EVENT_STREX_FAIL 0x64
#define PERFMON_EVENT_DCACHE_EVICTION 0x65
/* Issue stage can't proceed to dispatch any instruction */
#define PERFMON_EVENT_PIPELINE_CANT_ISSUE 0x66
/* Issue stage empty */
#define PERFMON_EVENT_PIPELINE_ISSUE_EMPTY 0x67
/* Register renamed instructions */
#define PERFMON_EVENT_REGRENAMED_INSTR 0x68
#define PERFMON_EVENT_CPUSTALL_ITLB_MISS 0x82
#define PERFMON_EVENT_CPUSTALL_DTLB_MISS 0x83
#define PERFMON_EVENT_CPUSTALL_IUTLB_MISS 0x84
#define PERFMON_EVENT_CPUSTALL_DUTLB_MISS 0x85
#define PERFMON_EVENT_CPUSTALL_DMB 0x86
#define PERFMON_EVENT_ISB_COUNT 0x90
#define PERFMON_EVENT_DSB_COUNT 0x91
#define PERFMON_EVENT_DMB_COUNT 0x92
#define PERFMON_EVENT_EXTIRQ_COUNT 0x93
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_ctrl(void)
{
volatile u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 0\n"
"isb\n"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_ctrl(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 0"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_cntenset(void)
{
volatile u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 1\n"
"isb\n"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_cntenset(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 1"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_cntenclr(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 2"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_cntenclr(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 2"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_overflow(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 3"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_overflow(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 3"
:
: "r" (word)
);
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_softinc(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 4"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_evcntsel(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c12, 5"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_evcntsel(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c12, 5"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_cyccnt(void)
{
volatile u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c13, 0\n"
"isb\n"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_cyccnt(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c13, 0"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_evtypesel(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c13, 1"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_evtypesel(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c13, 1"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_evcnt(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c13, 2"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_evcnt(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c13, 2"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_useren(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c14, 0"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_useren(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c14, 0"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_intenset(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c14, 1"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_intenset(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c14, 1"
:
: "r" (word)
);
}
static inline u32 __attribute__((always_inline))
cp15_read_perfmon_intenclr(void)
{
u32 val = 0;
__asm__ __volatile__ (
"mrc p15, 0, %0, c9, c14, 2"
: "=r" (val)
:
);
return val;
}
static inline void __attribute__((always_inline))
cp15_write_perfmon_intenclr(volatile u32 word)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c9, c14, 2"
:
: "r" (word)
);
}
#include <stdio.h>
#if defined (CONFIG_DEBUG_PERFMON_USER)
static inline
u32 perfmon_read_cyccnt()
{
u32 cnt = cp15_read_perfmon_cyccnt();
u32 ovfl = cp15_read_perfmon_overflow();
/* Detect overflow and signal something was wrong */
if (ovfl & (1 << PMCCNTR_BIT))
printf("%s: Overflow.\n", __FUNCTION__);
return cnt;
}
void perfmon_reset_start_cyccnt();
u32 perfmon_read_reset_start_cyccnt();
#endif
void perfmon_init();
#endif /* __PERFMON_H__ */

View File

@@ -0,0 +1,59 @@
#ifndef __ARM_V5_UTCB_H__
#define __ARM_V5_UTCB_H__
/*
* NOTE: Any changes you make here, you *MUST* change
* utcb_address() macro in syscall.S assembler.
*/
/* Read Thread ID User RW register */
static inline u32 l4_cp15_read_tid_usr_rw(void)
{
volatile u32 val;
__asm__ __volatile__ (
"mrc p15, 0, %0, c13, c0, 2"
: "=r" (val)
:
);
return val;
}
/* Write Thread ID User RW register */
static inline void l4_cp15_write_tid_usr_rw(volatile u32 val)
{
__asm__ __volatile__ (
"mcr p15, 0, %0, c13, c0, 2"
:
: "r" (val)
);
}
/* Read Thread ID User RO register */
static inline u32 l4_cp15_read_tid_usr_ro(void)
{
volatile u32 val;
__asm__ __volatile__ (
"mrc p15, 0, %0, c13, c0, 3"
: "=r" (val)
:
);
return val;
}
/*
* In ARMv7, utcb resides in the userspace read-only
* thread register. This adds the benefit of avoiding
* dirtying the cache and extra management for smp since
* it is per-cpu.
*/
static inline struct utcb *l4_get_utcb()
{
// printf("%s: UTCB Adddress: 0x%x\n", __FUNCTION__, l4_cp15_read_tid_usr_ro());
return (struct utcb *)l4_cp15_read_tid_usr_ro();
}
#endif /* __ARM_V5_UTCB_H__ */

View File

@@ -0,0 +1,13 @@
/*
* Cache control operations
*
* Copyright (C) 2009 Bora Sahin
*/
#ifndef __L4_CACHE_CONTROL__
#define __L4_CACHE_CONTROL__
#include <l4/api/cache.h>
#endif /* __L4_CACHE_CONTROL__ */

View File

@@ -0,0 +1,12 @@
#ifndef __CAP_PRINT_H__
#define __CAP_PRINT_H__
#include <l4/api/capability.h>
#include <l4/generic/cap-types.h>
void cap_dev_print(struct capability *cap);
void cap_print(struct capability *cap);
void cap_array_print(int total_caps, struct capability *caparray);
#endif /* __CAP_PRINT_H__*/

View File

@@ -8,7 +8,10 @@ void exregs_set_mr(struct exregs_data *s, int offset, unsigned long val);
void exregs_set_pc(struct exregs_data *s, unsigned long pc);
void exregs_set_pager(struct exregs_data *s, l4id_t pagerid);
void exregs_set_utcb(struct exregs_data *s, unsigned long virt);
void exregs_set_read(struct exregs_data *exregs);
unsigned long exregs_get_utcb(struct exregs_data *s);
unsigned long exregs_get_stack(struct exregs_data *s);
/*
exregs_set_stack(unsigned long sp)
exregs_set_pc(unsigned long pc)

View File

@@ -10,6 +10,7 @@
#define __IPCDEFS_H__
#include <l4/api/ipc.h>
#include <l4lib/types.h>
/*** IPC Tags used between server tasks ***/
@@ -69,7 +70,8 @@ extern l4id_t pagerid;
#define L4_IPC_TAG_UART_RECVBUF 54 /* Buffered recv */
/* For ipc to timer service (TODO: Shared mapping buffers???) */
#define L4_IPC_TAG_TIMER_GETTIME 55
#define L4_IPC_TAG_TIMER_SLEEP 56
#define L4_IPC_TAG_TIMER_GETTIME 55
#define L4_IPC_TAG_TIMER_SLEEP 56
#define L4_IPC_TAG_TIMER_WAKE_THREADS 57
#endif /* __IPCDEFS_H__ */

Some files were not shown because too many files have changed in this diff Show More