mirror of
https://github.com/drasko/codezero.git
synced 2026-01-11 18:33:16 +01:00
Integrated libl4thread with libl4. Added device number to device caps.
A 16-bit device number or id further distinguishes a device on the system in addition to the device type. This is meant to be used for the very first identification of the device for further probing. Any further info is available by userspace mapping and probing.
This commit is contained in:
@@ -50,14 +50,9 @@ libmm, libmc, libmalloc = SConscript('conts/libmem/SConscript', \
|
||||
duplicate = 0, variant_dir = \
|
||||
join(BUILDDIR, os.path.relpath('conts/libmem', PROJROOT)))
|
||||
|
||||
libl4thread = SConscript('conts/libl4thread/SConscript', \
|
||||
exports = { 'env' : env }, duplicate = 0, \
|
||||
variant_dir = join(BUILDDIR, os.path.relpath('conts/libl4thread', PROJROOT)))
|
||||
|
||||
Alias('libl4', libl4)
|
||||
Alias('libdev', libdev)
|
||||
Alias('libc', libc)
|
||||
Alias('libmm', libmm)
|
||||
Alias('libmc', libmc)
|
||||
Alias('libmalloc', libmalloc)
|
||||
Alias('libl4thread', libl4thread)
|
||||
|
||||
@@ -375,6 +375,7 @@ static inline void pl011_rx_dma_disable(unsigned int base)
|
||||
write(val, (base +PL011_UARTDMACR));
|
||||
return;
|
||||
}
|
||||
int pl011_initialise(struct pl011_uart *uart);
|
||||
|
||||
#endif /* __PL011__UART__ */
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ struct pl011_uart uart;
|
||||
* Initialises the uart class data structures, and the device.
|
||||
* Terminal-like operation is assumed for default settings.
|
||||
*/
|
||||
int pl011_initialise(struct pl011_uart * uart)
|
||||
int pl011_initialise(struct pl011_uart *uart)
|
||||
{
|
||||
uart->frame_errors = 0;
|
||||
uart->parity_errors = 0;
|
||||
|
||||
@@ -30,14 +30,19 @@ Import('arch')
|
||||
|
||||
config = configuration_retrieve()
|
||||
|
||||
LIBMEM_RELDIR = 'conts/libmem'
|
||||
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
|
||||
|
||||
env = Environment(CC = config.user_toolchain + 'gcc',
|
||||
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding'],
|
||||
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') ])
|
||||
|
||||
env.Append(CPPPATH = [LIBMEM_DIR])
|
||||
|
||||
def create_symlinks(arch):
|
||||
print os.getcwd()
|
||||
prefix = 'conts/libl4/include/l4lib'
|
||||
|
||||
@@ -17,12 +17,12 @@ config = configuration_retrieve()
|
||||
arch = config.arch
|
||||
|
||||
env = Environment(CC = config.user_toolchain + 'gcc',
|
||||
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding'],
|
||||
CCFLAGS = ['-std=gnu99', '-g', '-nostdlib', '-ffreestanding'],
|
||||
LINKFLAGS = ['-nostdlib'],
|
||||
ASFLAGS = ['-D__ASSEMBLY__'],
|
||||
ENV = {'PATH' : os.environ['PATH']},
|
||||
LIBS = 'gcc',
|
||||
CPPPATH = ['#include', '#include/l4lib/arch', join(PROJROOT,'include') ])
|
||||
CPPPATH = ['#include', '#include/l4lib/arch', join(PROJROOT,'include')])
|
||||
|
||||
# TODO: There are errors in this code that -Werror gives problems with.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef __ADDR_H__
|
||||
#define __ADDR_H__
|
||||
|
||||
#include <idpool.h>
|
||||
#include <l4lib/idpool.h>
|
||||
|
||||
/* Address pool to allocate from a range of addresses */
|
||||
struct address_pool {
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef __BIT_H__
|
||||
#define __BIT_H__
|
||||
|
||||
#include <l4lib/types.h>
|
||||
|
||||
unsigned int __clz(unsigned int bitvector);
|
||||
int find_and_set_first_free_bit(u32 *word, unsigned int lastbit);
|
||||
int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit,
|
||||
@@ -1,8 +1,9 @@
|
||||
#ifndef __IDPOOL_H__
|
||||
#define __IDPOOL_H__
|
||||
|
||||
#include <bit.h>
|
||||
#include <l4lib/bit.h>
|
||||
#include <string.h>
|
||||
#include <l4/macros.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
|
||||
struct id_pool {
|
||||
@@ -11,4 +11,22 @@ struct l4_thread_struct {
|
||||
unsigned long stack_start; /* Thread start of stack */
|
||||
};
|
||||
|
||||
|
||||
/* -- Bora start -- */
|
||||
|
||||
/* A helper macro easing utcb space creation. */
|
||||
#define DECLARE_UTCB_SPACE(name, entries) \
|
||||
char name[(entries + PAGE_SIZE / UTCB_SIZE) * UTCB_SIZE] ALIGN(PAGE_SIZE);
|
||||
|
||||
int l4_set_stack_params(unsigned long stack_top,
|
||||
unsigned long stack_bottom,
|
||||
unsigned long stack_size);
|
||||
int l4_set_utcb_params(unsigned long utcb_start, unsigned long utcb_end);
|
||||
|
||||
int l4_thread_create(struct task_ids *ids, unsigned int flags,
|
||||
int (*func)(void *), void *arg);
|
||||
void l4_thread_exit(int retval);
|
||||
|
||||
/* -- Bora start -- */
|
||||
|
||||
#endif /* __L4_THREAD_H__ */
|
||||
|
||||
@@ -9,4 +9,14 @@
|
||||
|
||||
int utcb_init(void);
|
||||
|
||||
/* Bora start */
|
||||
#include <l4lib/tcb.h>
|
||||
|
||||
/* Checks if l4_set_stack_params is called. */
|
||||
#define IS_UTCB_SETUP() (lib_utcb_range_size)
|
||||
|
||||
unsigned long get_utcb_addr(struct tcb *task);
|
||||
int delete_utcb_addr(struct tcb *task);
|
||||
/* Bora end */
|
||||
|
||||
#endif /* __UTCB_H__ */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <addr.h>
|
||||
#include <l4lib/addr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
@@ -3,8 +3,9 @@
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <bit.h>
|
||||
#include <l4lib/bit.h>
|
||||
#include <stdio.h>
|
||||
#include <l4/macros.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
|
||||
/* Emulation of ARM's CLZ (count leading zeroes) instruction */
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#include <idpool.h>
|
||||
#include <l4lib/idpool.h>
|
||||
#include <stdio.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <malloc/malloc.h>
|
||||
@@ -4,10 +4,10 @@
|
||||
* Copyright © 2009 B Labs Ltd.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <addr.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <l4lib/addr.h>
|
||||
#include <l4lib/mutex.h>
|
||||
#include <stack.h>
|
||||
#include <l4lib/stack.h>
|
||||
|
||||
/* Extern declarations */
|
||||
extern struct l4_mutex lib_mutex;
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <malloc/malloc.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <l4/api/thread.h>
|
||||
#include <tcb.h>
|
||||
#include <l4lib/tcb.h>
|
||||
#include <l4/macros.h>
|
||||
|
||||
/* Global task list. */
|
||||
struct global_list global_tasks = {
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <l4/api/thread.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <malloc/malloc.h>
|
||||
#include <utcb.h>
|
||||
#include <stack.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <l4lib/stack.h>
|
||||
|
||||
/* Extern declarations */
|
||||
extern void setup_new_thread(void);
|
||||
@@ -4,8 +4,8 @@
|
||||
* Copyright © 2009 B Labs Ltd.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <addr.h>
|
||||
#include <utcb-common.h>
|
||||
#include <l4lib/addr.h>
|
||||
#include <l4lib/utcb-common.h>
|
||||
#include <malloc/malloc.h>
|
||||
|
||||
/* Globally disjoint utcb virtual region pool */
|
||||
@@ -4,13 +4,13 @@
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <malloc/malloc.h>
|
||||
#include <l4/api/errno.h>
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <l4lib/exregs.h>
|
||||
#include <errno.h>
|
||||
#include <malloc/malloc.h>
|
||||
#include <idpool.h>
|
||||
#include <utcb-common.h>
|
||||
#include <utcb.h>
|
||||
#include <l4lib/idpool.h>
|
||||
#include <l4lib/utcb-common.h>
|
||||
#include <l4lib/utcb.h>
|
||||
|
||||
/* Extern declarations */
|
||||
extern struct global_list global_tasks;
|
||||
@@ -1,32 +0,0 @@
|
||||
# -*- mode: python; coding: utf-8; -*-
|
||||
#
|
||||
# Codezero -- Virtualization microkernel for embedded systems.
|
||||
#
|
||||
# Copyright © 2009 B Labs Ltd
|
||||
|
||||
import os, sys
|
||||
|
||||
# Get global paths
|
||||
PROJRELROOT = '../..'
|
||||
|
||||
sys.path.append(PROJRELROOT)
|
||||
|
||||
from config.projpaths import *
|
||||
|
||||
Import('env')
|
||||
|
||||
LIBMEM_RELDIR = 'conts/libmem'
|
||||
LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR)
|
||||
|
||||
LIBL4_RELDIR = 'conts/libl4'
|
||||
LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR)
|
||||
LIBL4_INCLUDE = join(LIBL4_DIR, 'include')
|
||||
|
||||
e = env.Clone()
|
||||
e.Append(CPPPATH = ['include/l4thread', LIBMEM_DIR, LIBL4_INCLUDE])
|
||||
|
||||
source = [Glob('*.[cS]') + Glob('src/*.[cS]') + Glob('src/arch/*.[cS]')]
|
||||
objects = e.StaticObject(source)
|
||||
library = e.StaticLibrary('l4thread', objects)
|
||||
|
||||
Return('library')
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Thread creation userspace helpers
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#ifndef __LIB_THREAD_H__
|
||||
#define __LIB_THREAD_H__
|
||||
|
||||
/* A helper macro easing utcb space creation. */
|
||||
#define DECLARE_UTCB_SPACE(name, entries) \
|
||||
char name[(entries + PAGE_SIZE / UTCB_SIZE) * UTCB_SIZE] ALIGN(PAGE_SIZE);
|
||||
|
||||
int l4_set_stack_params(unsigned long stack_top,
|
||||
unsigned long stack_bottom,
|
||||
unsigned long stack_size);
|
||||
int l4_set_utcb_params(unsigned long utcb_start, unsigned long utcb_end);
|
||||
|
||||
int l4_thread_create(struct task_ids *ids, unsigned int flags,
|
||||
int (*func)(void *), void *arg);
|
||||
void l4_thread_exit(int retval);
|
||||
|
||||
#endif /* __LIB_THREAD_H__ */
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* UTCB handling helper routines.
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#ifndef __LIB_UTCB_H__
|
||||
#define __LIB_UTCB_H__
|
||||
|
||||
#include <tcb.h>
|
||||
|
||||
/* Checks if l4_set_stack_params is called. */
|
||||
#define IS_UTCB_SETUP() (lib_utcb_range_size)
|
||||
|
||||
unsigned long get_utcb_addr(struct tcb *task);
|
||||
int delete_utcb_addr(struct tcb *task);
|
||||
|
||||
#endif /* __LIB_UTCB_H__ */
|
||||
@@ -1 +0,0 @@
|
||||
arch-arm/
|
||||
@@ -40,8 +40,6 @@
|
||||
{(c)->type &= ~CAP_RTYPE_MASK; \
|
||||
(c)->type |= CAP_RTYPE_MASK & rtype;}
|
||||
|
||||
#define cap_devmem(c) (c)->uattr
|
||||
|
||||
/*
|
||||
* User-defined device-types
|
||||
* (Kept in the user field)
|
||||
@@ -50,7 +48,20 @@
|
||||
#define CAP_DEVTYPE_UART 2
|
||||
#define CAP_DEVTYPE_CLCD 3
|
||||
#define CAP_DEVTYPE_OTHER 0xF
|
||||
#define CAP_DEVTYPE_MASK 0xF
|
||||
#define CAP_DEVTYPE_MASK 0xFFFF
|
||||
#define CAP_DEVNUM_MASK 0xFFFF0000
|
||||
#define CAP_DEVNUM_SHIFT 16
|
||||
|
||||
#define cap_is_devmem(c) (c)->uattr
|
||||
#define cap_set_devtype(c, devtype) \
|
||||
{(c)->uattr &= ~CAP_DEVTYPE_MASK; \
|
||||
(c)->uattr |= CAP_DEVTYPE_MASK & devtype;}
|
||||
#define cap_set_devnum(c, devnum) \
|
||||
{(c)->uattr &= ~CAP_DEVNUM_MASK; \
|
||||
(c)->uattr |= CAP_DEVNUM_MASK & devnum;}
|
||||
#define cap_devnum(c) \
|
||||
(((c)->uattr & CAP_DEVNUM_MASK) >> CAP_DEVNUM_SHIFT)
|
||||
#define cap_devtype(c) ((c)->uattr & CAP_DEVTYPE_MASK)
|
||||
|
||||
/*
|
||||
* Access permissions
|
||||
|
||||
@@ -849,7 +849,7 @@ int process_cap_info(struct cap_info *cap,
|
||||
&kres->virtmem_free,
|
||||
cap->start, cap->end);
|
||||
} else if (cap_type(cap) == CAP_TYPE_MAP_PHYSMEM) {
|
||||
if (!cap_devmem(cap))
|
||||
if (!cap_is_devmem(cap))
|
||||
memcap_unmap(&kres->physmem_used,
|
||||
&kres->physmem_free,
|
||||
cap->start, cap->end);
|
||||
|
||||
@@ -27,68 +27,29 @@
|
||||
int platform_setup_device_caps(struct kernel_resources *kres)
|
||||
{
|
||||
struct capability *uart[4], *timer[2];
|
||||
// struct capability *irqctrl[2], *sysctrl;
|
||||
|
||||
#if 0
|
||||
/* Setup kernel capability for uart0 as used */
|
||||
uart[0] = alloc_bootmem(sizeof(*uart[0]), 0);
|
||||
uart[0]->start = __pfn(PB926_UART0_BASE);
|
||||
uart[0]->end = uart[0]->start + 1;
|
||||
uart[0]->uattr = CAP_DEVTYPE_UART;
|
||||
link_init(&uart[0]->list);
|
||||
cap_list_insert(uart[0], &kres->devmem_used);
|
||||
|
||||
/* Setup timer0 capability as used */
|
||||
timer[0] = alloc_bootmem(sizeof(*timer[0]), 0);
|
||||
timer[0]->start = __pfn(PB926_TIMER01_BASE);
|
||||
timer[0]->end = timer[0]->start + 1;
|
||||
timer[0]->uattr = CAP_DEVTYPE_TIMER;
|
||||
link_init(&timer[0]->list);
|
||||
cap_list_insert(timer[0], &kres->devmem_used);
|
||||
|
||||
/* Setup irq controller 0 and 1 as used */
|
||||
irqctrl[0] = alloc_bootmem(sizeof(*irqctrl[0]), 0);
|
||||
irqctrl[0]->start = __pfn(PB926_VIC_BASE);
|
||||
irqctrl[0]->end = irqctrl[0]->start + 1;
|
||||
irqctrl[0]->uattr = CAP_DEVTYPE_IRQCTRL;
|
||||
link_init(&irqctrl[0]->list);
|
||||
cap_list_insert(irqctrl[0], &kres->devmem_used);
|
||||
|
||||
irqctrl[1] = alloc_bootmem(sizeof(*irqctrl[1]), 0);
|
||||
irqctrl[1]->start = __pfn(PB926_SIC_BASE);
|
||||
irqctrl[1]->end = irqctrl[1]->start + 1;
|
||||
irqctrl[1]->uattr = CAP_DEVTYPE_IRQCTRL;
|
||||
link_init(&irqctrl[1]->list);
|
||||
cap_list_insert(irqctrl[1], &kres->devmem_used);
|
||||
|
||||
/* Set up system controller as used */
|
||||
sysctrl = alloc_bootmem(sizeof(*sysctrl), 0);
|
||||
sysctrl->start = __pfn(PB926_SYSCTRL_BASE);
|
||||
sysctrl->end = sysctrl->start + 1;
|
||||
sysctrl->uattr = CAP_DEVTYPE_SYSCTRL;
|
||||
link_init(&sysctrl->list);
|
||||
cap_list_insert(sysctrl, &kres->devmem_used);
|
||||
#endif
|
||||
|
||||
/* Setup capabilities for other uarts as free */
|
||||
/* Setup capabilities for userspace uarts and timers */
|
||||
uart[1] = alloc_bootmem(sizeof(*uart[1]), 0);
|
||||
uart[1]->start = __pfn(PB926_UART1_BASE);
|
||||
uart[1]->end = uart[1]->start + 1;
|
||||
uart[1]->uattr = CAP_DEVTYPE_UART;
|
||||
cap_set_devtype(uart[1], CAP_DEVTYPE_UART);
|
||||
cap_set_devnum(uart[1], 1);
|
||||
link_init(&uart[1]->list);
|
||||
cap_list_insert(uart[1], &kres->devmem_free);
|
||||
|
||||
uart[2] = alloc_bootmem(sizeof(*uart[2]), 0);
|
||||
uart[2]->start = __pfn(PB926_UART2_BASE);
|
||||
uart[2]->end = uart[2]->start + 1;
|
||||
uart[2]->uattr = CAP_DEVTYPE_UART;
|
||||
cap_set_devtype(uart[2], CAP_DEVTYPE_UART);
|
||||
cap_set_devnum(uart[2], 2);
|
||||
link_init(&uart[2]->list);
|
||||
cap_list_insert(uart[2], &kres->devmem_free);
|
||||
|
||||
uart[3] = alloc_bootmem(sizeof(*uart[3]), 0);
|
||||
uart[3]->start = __pfn(PB926_UART3_BASE);
|
||||
uart[3]->end = uart[3]->start + 1;
|
||||
uart[3]->uattr = CAP_DEVTYPE_UART;
|
||||
cap_set_devtype(uart[3], CAP_DEVTYPE_UART);
|
||||
cap_set_devnum(uart[3], 3);
|
||||
link_init(&uart[3]->list);
|
||||
cap_list_insert(uart[3], &kres->devmem_free);
|
||||
|
||||
@@ -96,7 +57,8 @@ int platform_setup_device_caps(struct kernel_resources *kres)
|
||||
timer[1] = alloc_bootmem(sizeof(*timer[1]), 0);
|
||||
timer[1]->start = __pfn(PB926_TIMER23_BASE);
|
||||
timer[1]->end = timer[1]->start + 1;
|
||||
timer[1]->uattr = CAP_DEVTYPE_TIMER;
|
||||
cap_set_devtype(timer[1], CAP_DEVTYPE_TIMER);
|
||||
cap_set_devnum(timer[1], 1);
|
||||
link_init(&timer[1]->list);
|
||||
cap_list_insert(timer[1], &kres->devmem_free);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user