diff --git a/lib/aos/init.c b/lib/aos/init.c index 8ad7240..88b3206 100644 --- a/lib/aos/init.c +++ b/lib/aos/init.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "threads_priv.h" #include "init.h" @@ -243,6 +244,8 @@ errval_t barrelfish_init_onthread(struct spawn_domain_params *params) /* TODO MILESTONE 3: now we should have a channel with init set up and can * use it for the ram allocator */ + //afeer: script page 135, tell domain to use our memserver. + err = ram_alloc_set(NULL); // right now we don't have the nameservice & don't need the terminal // and domain spanning, so we return here diff --git a/lib/spawn/rpc_server.c b/lib/spawn/rpc_server.c index 6cb5e58..2a7b1e2 100644 --- a/lib/spawn/rpc_server.c +++ b/lib/spawn/rpc_server.c @@ -121,15 +121,22 @@ static errval_t handle_rpc_get_ram_cap( 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; + size_t bytes = arg0; size_t alignment = arg1; - grading_rpc_handler_ram_cap(bytes, alignment); - - // TODO + err = ram_alloc_aligned(ret_cap, bytes, alignment); + if (err_is_fail(err)) return err; *ret0 = bytes; - return LIB_ERR_NOT_IMPLEMENTED; + char buf[256]; + debug_print_cap_at_capref(buf, 256, *ret_cap); + debug_printf("cap allocated by memserver: %s\n", buf); + + grading_rpc_handler_ram_cap(bytes, alignment); + + return SYS_ERR_OK; } static errval_t handle_rpc_serial_getchar( diff --git a/usr/memeater/main.c b/usr/memeater/main.c index 48d5701..abbe910 100644 --- a/usr/memeater/main.c +++ b/usr/memeater/main.c @@ -51,6 +51,10 @@ static errval_t request_and_map_memory(void) return err; } + char buf[256]; + debug_print_cap_at_capref(buf, 256, cap1); + debug_printf("cap from rpc: %s\n", buf); + struct capref cap1_frame; err = slot_alloc(&cap1_frame); assert(err_is_ok(err)); @@ -70,7 +74,7 @@ static errval_t request_and_map_memory(void) void *buf1; err = paging_map_frame(pstate, &buf1, BASE_PAGE_SIZE, cap1_frame); if (err_is_fail(err)) { - DEBUG_ERR(err, "could not get BASE_PAGE_SIZE cap\n"); + DEBUG_ERR(err, "could not map BASE_PAGE_SIZE cap\n"); return err; }