mirror of
https://github.com/drasko/codezero.git
synced 2026-02-26 16:53:14 +01:00
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:
28
tasks/mm0/container.c
Normal file
28
tasks/mm0/container.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Container entry point for pager
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
|
||||
#include <posix/posix_init.h>
|
||||
#include <l4lib/init.h>
|
||||
#include <l4lib/utcb.h>
|
||||
|
||||
/*
|
||||
* Application specific utcb allocation
|
||||
* for this container.
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Balban
|
||||
*/
|
||||
|
||||
void main(void);
|
||||
|
||||
void __container_init(void)
|
||||
{
|
||||
/* Generic L4 initialisation */
|
||||
__l4_init();
|
||||
|
||||
/* Entry to main */
|
||||
main();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@ SECTIONS
|
||||
/* rodata is needed else your strings will link at physical! */
|
||||
.rodata : AT (ADDR(.rodata) - offset) { *(.rodata) }
|
||||
.rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) }
|
||||
.data : AT (ADDR(.data) - offset) { *(.data) }
|
||||
.data : AT (ADDR(.data) - offset)
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
. = ALIGN(4K);
|
||||
_start_init = .;
|
||||
.init : AT (ADDR(.init) - offset) { *(.init.stack) }
|
||||
. = ALIGN(8);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include INC_GLUE(memlayout.h)
|
||||
#include <l4/lib/list.h>
|
||||
#include <l4lib/arch/types.h>
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <lib/addr.h>
|
||||
#include <l4/api/kip.h>
|
||||
@@ -53,6 +54,20 @@ struct task_vma_head {
|
||||
int tcb_refs;
|
||||
};
|
||||
|
||||
/*
|
||||
* TLS and UTCB bookkeeping:
|
||||
*
|
||||
* This structure is shared among threads whose utcbs are on the same
|
||||
* physical page. Threads with utcbs on different physical pages have
|
||||
* their own utcb_data structure, even though they are in the same
|
||||
* address space, and share their vm_area_list structure.
|
||||
*/
|
||||
struct utcb_data {
|
||||
unsigned long phys; /* Physical utcb address */
|
||||
unsigned long virt; /* Virtual utcb address */
|
||||
u32 bit; /* Bitvector of free utcb slots on page */
|
||||
struct page *p; /* Physical page */
|
||||
};
|
||||
|
||||
/* Stores all task information that can be kept in userspace. */
|
||||
struct tcb {
|
||||
@@ -104,6 +119,9 @@ struct tcb {
|
||||
/* Default ipc-shared-page information */
|
||||
void *shared_page;
|
||||
|
||||
/* Task's utcb data */
|
||||
struct utcb_data *utcb;
|
||||
|
||||
/* Virtual memory areas */
|
||||
struct task_vma_head *vm_area_head;
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#define __VM_AREA_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <task.h>
|
||||
#include <l4/macros.h>
|
||||
#include <l4/config.h>
|
||||
#include <l4/types.h>
|
||||
#include <task.h>
|
||||
#include <arch/mm.h>
|
||||
#include <lib/spinlock.h>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <test.h>
|
||||
#include <boot.h>
|
||||
|
||||
|
||||
/* A separate list than the generic file list that keeps just the boot files */
|
||||
LIST_HEAD(boot_file_list);
|
||||
|
||||
|
||||
27
tasks/mm0/src/utcb.c
Normal file
27
tasks/mm0/src/utcb.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Management of task utcb regions and own utcb.
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
|
||||
#include <l4lib/arch/utcb.h>
|
||||
#include <l4/macros.h>
|
||||
|
||||
/*
|
||||
* UTCB management in Codezero:
|
||||
*
|
||||
* 1.) Every task in the system defines an array of utcbs in a special .utcb
|
||||
* section that is page-aligned and to be kept wired in by the pager.
|
||||
* 2.) The region marks are written to bootdesc structure at compile-time.
|
||||
* 3.) Pager reads the bootdesc struct from the microkernel during init.
|
||||
* 4.) Pager initialises structures to alloc/dealloc new utcbs for every address
|
||||
* space.
|
||||
* 5.) Pagers dynamically allocate utcb addresses as each thread is created
|
||||
* via a thread_control() system call.
|
||||
* 6.) Each thread in an address space learns their utcb address from a
|
||||
* well-defined KIP offset. This is updated as each thread becomes runnable.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user