pushing urpc experiments
This commit is contained in:
parent
976311cb3e
commit
e8fef8d87c
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
bootdriver /armv8/sbin/boot_armv8_generic
|
bootdriver /armv8/sbin/boot_armv8_generic
|
||||||
cpudriver /armv8/sbin/cpu_imx8x
|
cpudriver /armv8/sbin/cpu_imx8x
|
||||||
module /armv8/sbin/init
|
module /armv8/sbin/init
|
||||||
module /armv8/sbin/hello spawn
|
module /armv8/sbin/hello spawn
|
||||||
module /armv8/sbin/memeater
|
module /armv8/sbin/memeater
|
||||||
module /armv8/sbin/mallocator
|
module /armv8/sbin/mallocator
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
#include <aos/aos.h>
|
#include <aos/aos.h>
|
||||||
|
|
||||||
#define RPC_SHARED_SIZE PAGE_SIZE
|
#define RPC_SHARED_SIZE PAGE_SIZE
|
||||||
#define RPC_URPC_FRAME_SIZE PAGE_SIZE
|
|
||||||
|
|
||||||
// define some message types
|
// define some message types
|
||||||
enum rpc_mtype {
|
enum rpc_mtype {
|
||||||
|
|||||||
32
include/aos/aos_urpc.h
Normal file
32
include/aos/aos_urpc.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef _LIB_BARRELFISH_AOS_URPC_H
|
||||||
|
#define _LIB_BARRELFISH_AOS_URPC_H
|
||||||
|
|
||||||
|
#include <aos/aos.h>
|
||||||
|
|
||||||
|
#define RPC_URPC_FRAME_SIZE (ROUND_UP(sizeof(struct aos_urpc_meta), PAGE_SIZE) + PAGE_SIZE)
|
||||||
|
|
||||||
|
struct aos_urpc_meta {
|
||||||
|
volatile bool call_in_progress;
|
||||||
|
|
||||||
|
|
||||||
|
uintptr_t msg_type;
|
||||||
|
size_t arg_size;
|
||||||
|
uintptr_t arg0;
|
||||||
|
uintptr_t arg1;
|
||||||
|
struct capability arg_cap;
|
||||||
|
|
||||||
|
errval_t ret_errval;
|
||||||
|
size_t ret_size;
|
||||||
|
uintptr_t ret0;
|
||||||
|
uintptr_t ret1;
|
||||||
|
uint8_t has_ret_cap;
|
||||||
|
struct capability ret_cap;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct aos_urpc {
|
||||||
|
struct aos_urpc_meta *urpc;
|
||||||
|
void *shared_mem;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _LIB_BARRELFISH_AOS_URPC_H
|
||||||
@ -24,6 +24,7 @@
|
|||||||
"slot_alloc/range_slot_alloc.c",
|
"slot_alloc/range_slot_alloc.c",
|
||||||
"slot_alloc/twolevel_slot_alloc.c",
|
"slot_alloc/twolevel_slot_alloc.c",
|
||||||
"aos_rpc.c",
|
"aos_rpc.c",
|
||||||
|
"aos_urpc.c",
|
||||||
"capabilities.c",
|
"capabilities.c",
|
||||||
"coreset.c",
|
"coreset.c",
|
||||||
"coreboot.c",
|
"coreboot.c",
|
||||||
|
|||||||
70
lib/aos/aos_urpc.c
Normal file
70
lib/aos/aos_urpc.c
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \brief inter core messaging
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016, ETH Zurich.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is distributed under the terms in the attached LICENSE file.
|
||||||
|
* If you do not find this file, copies can be found by writing to:
|
||||||
|
* ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <aos/aos_urpc.h>
|
||||||
|
#include <aos/kernel_cap_invocations.h>
|
||||||
|
|
||||||
|
__attribute__((__used__))
|
||||||
|
static errval_t do_aos_urpc(
|
||||||
|
struct aos_urpc *rpc, uintptr_t msg_type,
|
||||||
|
struct capref arg_cap, size_t arg_size, uintptr_t arg0, uintptr_t arg1,
|
||||||
|
struct capref *ret_cap, size_t *ret_size, uintptr_t *ret0, uintptr_t *ret1
|
||||||
|
) {
|
||||||
|
errval_t err;
|
||||||
|
|
||||||
|
rpc->urpc->msg_type = msg_type;
|
||||||
|
|
||||||
|
struct capability arg_cap_info;
|
||||||
|
err = cap_direct_identify(arg_cap, &arg_cap_info);
|
||||||
|
if (err_is_fail(err)) return err_push(err, LIB_ERR_CAP_IDENTIFY);
|
||||||
|
// only allow ram capabilities or frame capabilities to be sent to other cores
|
||||||
|
assert(arg_cap_info.type == ObjType_RAM || arg_cap_info.type == ObjType_Frame);
|
||||||
|
|
||||||
|
rpc->urpc->arg_cap = arg_cap_info;
|
||||||
|
|
||||||
|
rpc->urpc->arg_size = arg_size;
|
||||||
|
rpc->urpc->arg0 = arg0;
|
||||||
|
rpc->urpc->arg1 = arg1;
|
||||||
|
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
rpc->urpc->call_in_progress = 1;
|
||||||
|
|
||||||
|
// wait until the rpc call completes
|
||||||
|
while(rpc->urpc->call_in_progress) {
|
||||||
|
// yield the thread because there might be useful stuff to do...
|
||||||
|
thread_yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
// read the response
|
||||||
|
if (ret_size != NULL) *ret_size = rpc->urpc->ret_size;
|
||||||
|
if (ret0 != NULL) *ret0 = rpc->urpc->ret0;
|
||||||
|
if (ret1 != NULL) *ret1 = rpc->urpc->ret1;
|
||||||
|
|
||||||
|
if(ret_cap != NULL && rpc->urpc->has_ret_cap) {
|
||||||
|
err = slot_alloc(ret_cap);
|
||||||
|
ram_forge(*ret_cap, rpc->urpc->ret_cap.u.ram.base, rpc->urpc->ret_cap.u.ram.bytes, );
|
||||||
|
}
|
||||||
|
|
||||||
|
return rpc->urpc->ret_errval;
|
||||||
|
}
|
||||||
|
|
||||||
@ -20,11 +20,13 @@
|
|||||||
#include <aos/paging.h>
|
#include <aos/paging.h>
|
||||||
#include <aos/waitset.h>
|
#include <aos/waitset.h>
|
||||||
#include <aos/aos_rpc.h>
|
#include <aos/aos_rpc.h>
|
||||||
|
#include <aos/aos_urpc.h>
|
||||||
#include <mm/mm.h>
|
#include <mm/mm.h>
|
||||||
#include <grading.h>
|
#include <grading.h>
|
||||||
|
|
||||||
#include "mem_alloc.h"
|
#include "mem_alloc.h"
|
||||||
#include <aos/coreboot.h>
|
#include <aos/coreboot.h>
|
||||||
|
#include <aos/cache.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +84,21 @@ bsp_main(int argc, char *argv[]) {
|
|||||||
default:
|
default:
|
||||||
USER_PANIC("Platform not implemented");
|
USER_PANIC("Platform not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *addr;
|
||||||
|
paging_map_frame(get_current_paging_state(), &addr, PAGE_SIZE, urpc_frame);
|
||||||
|
assert(err_is_ok(err));
|
||||||
|
*(uint8_t *)addr = 123;
|
||||||
|
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
cpu_idcache_wbinv_range((uintptr_t)addr, 64);
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
// TODO rueegges: can we get the mpid in a better way?
|
// TODO rueegges: can we get the mpid in a better way?
|
||||||
err = coreboot(1, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id);
|
err = coreboot(1, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id);
|
||||||
if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
||||||
@ -90,6 +107,21 @@ bsp_main(int argc, char *argv[]) {
|
|||||||
// err = coreboot(3, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id);
|
// err = coreboot(3, "boot_armv8_generic", cpu_driver_name, "init", urpc_frame_id);
|
||||||
// if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
// if (err_is_fail(err)) return err_push(err, MON_ERR_SPAWN_CORE);
|
||||||
|
|
||||||
|
while(*(volatile uint8_t *)addr == 123){
|
||||||
|
cpu_idcache_wbinv_range((uintptr_t)addr, 64);
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
|
||||||
|
debug_printf("Got response\n");
|
||||||
|
|
||||||
// Grading
|
// Grading
|
||||||
grading_test_late();
|
grading_test_late();
|
||||||
|
|
||||||
@ -131,6 +163,25 @@ app_main(int argc, char *argv[]) {
|
|||||||
grading_test_early();
|
grading_test_early();
|
||||||
|
|
||||||
// TODO: Spawn system processes etc. here
|
// TODO: Spawn system processes etc. here
|
||||||
|
|
||||||
|
// test communication
|
||||||
|
struct capref cap_urpc = {
|
||||||
|
.cnode = { .croot = CPTR_ROOTCN, .cnode = CPTR_TASKCN_BASE, .level = CNODE_TYPE_OTHER, },
|
||||||
|
.slot = TASKCN_SLOT_MON_URPC
|
||||||
|
};
|
||||||
|
void *addr;
|
||||||
|
err = paging_map_frame(get_current_paging_state(), &addr, PAGE_SIZE, cap_urpc);
|
||||||
|
if(err_is_fail(err)) {
|
||||||
|
USER_PANIC_ERR(err, "failed to map urpc frame");
|
||||||
|
}
|
||||||
|
assert(*(uint8_t *)addr == 123);
|
||||||
|
*(uint8_t *)addr = 21;
|
||||||
|
cpu_idcache_wbinv_range((uintptr_t)addr, 64);
|
||||||
|
// memory barrier
|
||||||
|
__asm volatile (
|
||||||
|
"dmb sy\n"
|
||||||
|
);
|
||||||
|
|
||||||
// Grading
|
// Grading
|
||||||
grading_test_late();
|
grading_test_late();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user