mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 11:53:15 +01:00
Added kernel + libl4 changes for full and extended ipc.
- Short ipc working as normal. Full/extended ipc haven't been tested. - Added automated compilation and inclusion of test executable in test0.
This commit is contained in:
@@ -53,7 +53,7 @@ END_PROC(l4_kread)
|
||||
|
||||
/*
|
||||
* For clone() we need special assembler handling
|
||||
* Same signature as ipc(): @r0 = to, @r1 = from
|
||||
* Same signature as ipc(): @r0 = to, @r1 = from @r2 = flags
|
||||
*
|
||||
* NOTE: Note that this breaks l4 system call interface,
|
||||
* this should be moved elsewhere and modified using existing l4 mechanisms.
|
||||
@@ -62,6 +62,11 @@ BEGIN_PROC(arch_clone)
|
||||
stmfd sp!, {r4-r8,lr} @ Save context.
|
||||
utcb_address r12 @ Get utcb address.
|
||||
ldmia r12!, {r3-r8} @ Load 6 Message registers from utcb. MR0-MR5
|
||||
|
||||
cmp r2, #0
|
||||
1:
|
||||
bne 1b
|
||||
|
||||
ldr r12, =__l4_ipc
|
||||
mov lr, pc
|
||||
ldr pc, [r12] @ Perform the ipc()
|
||||
@@ -101,6 +106,11 @@ BEGIN_PROC(l4_ipc)
|
||||
stmfd sp!, {r4-r8,lr} @ Save context.
|
||||
utcb_address r12 @ Get utcb address.
|
||||
ldmia r12!, {r3-r8} @ Load 6 Message registers from utcb. MR0-MR5
|
||||
|
||||
cmp r2, #0
|
||||
1:
|
||||
bne 1b
|
||||
|
||||
ldr r12, =__l4_ipc
|
||||
mov lr, pc
|
||||
ldr pc, [r12]
|
||||
|
||||
@@ -52,7 +52,7 @@ int fork(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int arch_clone(l4id_t to, l4id_t from);
|
||||
extern int arch_clone(l4id_t to, l4id_t from, unsigned int flags);
|
||||
|
||||
int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...)
|
||||
write_mr(L4SYS_ARG1, flags);
|
||||
|
||||
/* Perform an ipc but with different return logic. See implementation. */
|
||||
if ((ret = arch_clone(PAGER_TID, PAGER_TID)) < 0) {
|
||||
if ((ret = arch_clone(PAGER_TID, PAGER_TID, 0)) < 0) {
|
||||
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -68,11 +68,42 @@ env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
|
||||
CPPFLAGS = "-D__USERSPACE__",
|
||||
CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath])
|
||||
|
||||
|
||||
test_exec_ld_script = "include/test_exec_linker.lds"
|
||||
# The kernel build environment:
|
||||
test_exec_env = Environment(CC = 'arm-none-linux-gnueabi-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 = ['-O3', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'],
|
||||
LINKFLAGS = ['-nostdlib', '-T' + test_exec_ld_script, "-L" + libc_libpath, "-L" + libl4_path, \
|
||||
'-L' + libposix_libpath],
|
||||
ASFLAGS = ['-D__ASSEMBLY__'],
|
||||
PROGSUFFIX = '.axf', # The suffix to use for final executable
|
||||
ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path
|
||||
LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix', libc_name],
|
||||
CPPFLAGS = "-D__USERSPACE__",
|
||||
CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath])
|
||||
|
||||
src = [glob("src/*.c"), glob("*.c"), glob("*.S"), glob("src/arch/arm/*.c"), glob("../libcont/*.c")]
|
||||
objs = env.Object(src)
|
||||
physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base)
|
||||
crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0)
|
||||
|
||||
test_exec_src = [glob("src/test_exec/*.c")]
|
||||
test_exec_objs = test_exec_env.Object(test_exec_src)
|
||||
test_exec_name = "test_exec"
|
||||
test_exec = test_exec_env.Program(test_exec_name, test_exec_objs + [crt0_copied])
|
||||
test_exec_env.Alias(test_exec_name, test_exec)
|
||||
|
||||
env.Depends(objs, test_exec)
|
||||
task = env.Program(task_name, objs + [crt0_copied])
|
||||
env.Alias(task_name, task)
|
||||
|
||||
# I find this to be a BUG related to SCons. SCons is still good compared to
|
||||
# notoriously horrible makefiles, but it could have been better.
|
||||
# if test_exec doesn't depend on physical_base, test_exec is compiled but
|
||||
# task complains that physical_base is not there. However we already declared
|
||||
# its dependency below.
|
||||
|
||||
env.Depends(test_exec, physical_base)
|
||||
env.Depends(task, physical_base)
|
||||
|
||||
@@ -33,9 +33,9 @@ SECTIONS
|
||||
.data : AT (ADDR(.data) - offset)
|
||||
{
|
||||
. = ALIGN(4K);
|
||||
_start_test1 = .;
|
||||
*(.test1)
|
||||
_end_test1 = .;
|
||||
_start_test_exec = .;
|
||||
*(.testexec)
|
||||
_end_test_exec = .;
|
||||
*(.data)
|
||||
}
|
||||
.bss : AT (ADDR(.bss) - offset) { *(.bss) }
|
||||
|
||||
37
tasks/test0/include/test_exec_linker.lds
Normal file
37
tasks/test0/include/test_exec_linker.lds
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Simple linker script for userspace or svc tasks.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
|
||||
/*
|
||||
* The only catch with this linker script is that everything
|
||||
* is linked starting at virtual_base, and loaded starting
|
||||
* at physical_base. virtual_base is the predefined region
|
||||
* of virtual memory for userland applications. physical_base
|
||||
* is determined at build-time, it is one of the subsequent pages
|
||||
* that come after the kernel image's load area.
|
||||
*/
|
||||
/* USER_AREA_START, see memlayout.h */
|
||||
virtual_base = 0x10000000;
|
||||
__stack = (0x20000000 - 0x1000 - 8); /* First page before the env/args */
|
||||
INCLUDE "include/physical_base.lds"
|
||||
|
||||
/* physical_base = 0x228000; */
|
||||
offset = virtual_base - physical_base;
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = virtual_base;
|
||||
_start_text = .;
|
||||
.text : AT (ADDR(.text) - offset) { crt0.o(.text) *(.text) }
|
||||
/* rodata is needed else your strings will link at physical! */
|
||||
.rodata : AT (ADDR(.rodata) - offset) { *(.rodata) }
|
||||
.rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) }
|
||||
. = ALIGN(4K);
|
||||
.data : AT (ADDR(.data) - offset) { *(.data) }
|
||||
.bss : AT (ADDR(.bss) - offset) { *(.bss) }
|
||||
_end = .;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ void wait_pager(l4id_t partner)
|
||||
for (int i = 0; i < 6; i++)
|
||||
write_mr(i, i);
|
||||
l4_send(partner, L4_IPC_TAG_SYNC);
|
||||
// printf("Pager synced with us.\n");
|
||||
printf("Pager synced with us.\n");
|
||||
}
|
||||
|
||||
pid_t parent_of_all;
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern char _start_test1[];
|
||||
extern char _end_test1[];
|
||||
extern char _start_test_exec[];
|
||||
extern char _end_test_exec[];
|
||||
|
||||
int exectest(void)
|
||||
{
|
||||
int fd;
|
||||
void *exec_start = (void *)_start_test1;
|
||||
unsigned long size = _end_test1 - _start_test1;
|
||||
void *exec_start = (void *)_start_test_exec;
|
||||
unsigned long size = _end_test_exec - _start_test_exec;
|
||||
int left, cnt;
|
||||
char *argv[5];
|
||||
char filename[128];
|
||||
|
||||
25
tasks/test0/src/test_exec/container.c
Normal file
25
tasks/test0/src/test_exec/container.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Container entry point for this task.
|
||||
*
|
||||
* Copyright (C) 2007-2009 Bahadir Bilgehan Balban
|
||||
*/
|
||||
|
||||
#include <l4lib/types.h>
|
||||
#include <l4lib/init.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <posix_init.h> /* Initialisers for posix library */
|
||||
|
||||
void main(void);
|
||||
|
||||
void __container_init(void)
|
||||
{
|
||||
/* Generic L4 thread initialisation */
|
||||
__l4_init();
|
||||
|
||||
/* Initialise posix library for application */
|
||||
libposix_init();
|
||||
|
||||
/* Entry to main */
|
||||
main();
|
||||
}
|
||||
|
||||
BIN
tasks/test0/src/test_exec/container.o
Normal file
BIN
tasks/test0/src/test_exec/container.o
Normal file
Binary file not shown.
36
tasks/test0/src/test_exec/test_exec.c
Normal file
36
tasks/test0/src/test_exec/test_exec.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Some tests for posix syscalls.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <l4lib/arch/syslib.h>
|
||||
#include <l4lib/kip.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <l4lib/ipcdefs.h>
|
||||
#include <tests.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void wait_pager(l4id_t partner)
|
||||
{
|
||||
// printf("%s: Syncing with pager.\n", __TASKNAME__);
|
||||
for (int i = 0; i < 6; i++)
|
||||
write_mr(i, i);
|
||||
l4_send(partner, L4_IPC_TAG_SYNC);
|
||||
// printf("Pager synced with us.\n");
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
wait_pager(0);
|
||||
if (getpid() == 2) {
|
||||
printf("EXECVE TEST -- PASSED --\n", getpid());
|
||||
printf("\n(Thread %d): Continues to sync with the pager...\n", getpid());
|
||||
while (1)
|
||||
wait_pager(0);
|
||||
}
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
BIN
tasks/test0/src/test_exec/test_exec.o
Normal file
BIN
tasks/test0/src/test_exec/test_exec.o
Normal file
Binary file not shown.
5
tasks/test0/test_exec.S
Normal file
5
tasks/test0/test_exec.S
Normal file
@@ -0,0 +1,5 @@
|
||||
.section .testexec
|
||||
|
||||
.align 4
|
||||
.incbin "test_exec.axf"
|
||||
.align 4
|
||||
Reference in New Issue
Block a user