Ongoing work for adding per-thread UTCB structures.

Added setting of utcb address to l4_thread_control.
This is going to be moved to exchange_registers() since we need to pass
both the utcb physical and virtual address and exregs fits such context
modification better than thread_control.
This commit is contained in:
Bahadir Balban
2009-04-29 16:53:04 +03:00
parent 54a9b2901d
commit 7a81db8782
35 changed files with 424 additions and 72 deletions

View File

@@ -6,6 +6,7 @@
#ifndef __ARM_SYSCALLS_H__
#define __ARM_SYSCALLS_H__
#include <l4lib/arch/types.h>
#include <l4lib/arch/utcb.h>
#include <l4/generic/space.h>
@@ -14,6 +15,12 @@
#include <l4/api/ipc.h>
#include <l4/api/thread.h>
struct task_ids {
int tid;
int spid;
int tgid;
};
static inline void *
l4_kernel_interface(unsigned int *api_version, unsigned int *api_flags,
unsigned int *kernel_id)
@@ -46,9 +53,9 @@ 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);
typedef int (*__l4_thread_control_t)(unsigned int action, struct task_ids *ids, void *utcb_address);
extern __l4_thread_control_t __l4_thread_control;
int l4_thread_control(unsigned int action, struct task_ids *ids);
int l4_thread_control(unsigned int action, struct task_ids *ids, void *utcb_address);
typedef int (*__l4_space_control_t)(unsigned int action, void *kdata);
extern __l4_space_control_t __l4_space_control;

View File

@@ -1,13 +1,8 @@
#ifndef __L4_ARCH_ARM__
#define __L4_ARCH_ARM__
#ifndef __L4LIB_ARM_TYPES_H___
#define __L4LIB_ARM_TYPES_H__
#define TASK_ID_INVALID -1
struct task_ids {
int tid;
int spid;
int tgid;
};
#include <l4/arch/arm/types.h>
#endif
#endif /* __L4LIB_ARM_TYPES_H__ */

View File

@@ -1,9 +1,12 @@
/*
* Copyright (C) 2009 Bahadir Bilgehan Balban
*/
#ifndef __ARM_UTCB_H__
#define __ARM_UTCB_H__
#define USER_UTCB_REF 0xFF000FF0
#define USER_UTCB_REF 0xFF000050
#define L4_KIP_ADDRESS 0xFF000000
#define UTCB_KIP_OFFSET 0xFF0
#define UTCB_KIP_OFFSET 0x50
#ifndef __ASSEMBLY__
#include <l4lib/types.h>
@@ -13,27 +16,37 @@
#include <string.h>
#include <stdio.h>
/* UTCB implementation */
/*
* NOTE: In syslib.h the first few mrs are used by data frequently
* needed for all ipcs. Those mrs are defined the kernel message.h
*/
/*
* This is a per-task private structure where message registers are
* pushed for ipc. Its *not* TLS, but can be part of TLS when it is
* supported.
*/
struct utcb {
u32 mr[MR_TOTAL];
u32 saved_tag;
u32 saved_sender;
} __attribute__((__packed__));
u32 mr[MR_TOTAL]; /* MRs that are mapped to real registers */
u32 saved_tag; /* Saved tag field for stacked ipcs */
u32 saved_sender; /* Saved sender field for stacked ipcs */
u32 mr_rest[MR_REST]; /* Complete the utcb for up to 64 words */
};
extern struct utcb utcb;
extern struct kip *kip;
/*
* Pointer to Kernel Interface Page's UTCB pointer offset.
*/
extern struct utcb **kip_utcb_ref;
static inline struct utcb *l4_get_utcb()
{
return &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;
}
/* Functions to read/write utcb registers */

View File

@@ -7,6 +7,7 @@ void exregs_set_stack(struct exregs_data *s, unsigned long sp);
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 phys, unsigned long virt);
/*
exregs_set_stack(unsigned long sp)

View File

@@ -0,0 +1,6 @@
#ifndef __L4LIB_INIT__
#define __L4LIB_INIT__
void __l4_init(void);
#endif

View File

@@ -0,0 +1,14 @@
#ifndef __L4_THREAD_H__
#define __L4_THREAD_H__
#include <libl4/arch/utcb.h>
#include <libl4/arch/types.h>
struct l4_thread_struct {
l4id_t tlid; /* Thread local id */
struct task_ids ids; /* Thread L4-defined ids */
struct utcb *utcb; /* Thread utcb */
unsigned long stack_start; /* Thread start of stack */
};
#endif /* __L4_THREAD_H__ */