Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Slite with main branch, for discussion. #445

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composition_scripts/sched.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ description = "Simplest system with both capability manager and scheduler, from
[[components]]
name = "booter"
img = "no_interface.llbooter"
implements = [{interface = "init"}, {interface = "addr"}]
implements = [{interface = "init"}, {interface = "addr"}, {interface = "scb_mapping"}]
deps = [{srv = "kernel", interface = "init", variant = "kernel"}]
constructor = "kernel"

[[components]]
name = "capmgr"
img = "capmgr.simple"
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}]
deps = [{srv = "booter", interface = "init"}, {srv = "booter", interface = "addr"}, {srv = "booter", interface = "scb_mapping"}]
implements = [{interface = "capmgr"}, {interface = "init"}, {interface = "memmgr"}, {interface = "capmgr_create"}]
constructor = "booter"

Expand Down
2 changes: 1 addition & 1 deletion src/components/implementation/capmgr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INTERFACE_EXPORTS = capmgr
INTERFACE_DEPENDENCIES =
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component
LIBRARY_DEPENDENCIES = component dcb
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
Expand Down
2 changes: 1 addition & 1 deletion src/components/implementation/capmgr/simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INTERFACE_EXPORTS = capmgr capmgr_create init
INTERFACE_DEPENDENCIES = init addr
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component sl_kernel initargs crt util
LIBRARY_DEPENDENCIES = component sl_kernel initargs crt util dcb
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
Expand Down
77 changes: 70 additions & 7 deletions src/components/implementation/capmgr/simple/capmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sl.h>
#include <initargs.h>
#include <addr.h>
#include <dcb.h>

struct cm_rcv {
struct crt_rcv rcv;
Expand All @@ -41,6 +42,11 @@ struct cm_asnd {
struct crt_asnd asnd;
};

struct cm_dcb {
dcbcap_t dcb_cap;
vaddr_t dcb_addr;
};

/*
* Shared memory should be manager -> client, and between
* point-to-point channel recipients
Expand Down Expand Up @@ -76,6 +82,9 @@ SS_STATIC_SLAB(asnd, struct cm_asnd, MAX_NUM_THREADS);
SS_STATIC_SLAB(page, struct mm_page, MM_NPAGES);
SS_STATIC_SLAB(span, struct mm_span, MM_NPAGES);

#define MAX_DCB_NUM PAGE_SIZE/sizeof(struct cos_dcb_info)
SS_STATIC_SLAB(dcb, struct cm_dcb, MAX_DCB_NUM);

static struct cm_comp *
cm_self(void)
{
Expand Down Expand Up @@ -155,6 +164,22 @@ cm_thd_alloc_in(struct cm_comp *c, struct cm_comp *sched, thdclosure_index_t clo
return t;
}

struct cm_dcb *
cm_dcb_alloc_in(struct cm_comp *sched)
{
compid_t id = (compid_t)cos_inv_token();
struct cm_dcb *d = ss_dcb_alloc();
dcbcap_t dcbcap;
vaddr_t dcbaddr = 0;

dcbcap = crt_dcb_create_in(&sched->comp, &dcbaddr);
d->dcb_addr = dcbaddr;
d->dcb_cap = dcbcap;
ss_dcb_activate(d);

return d;
}

/**
* Allocate a page from the pool of physical memory into a component.
*
Expand Down Expand Up @@ -339,6 +364,28 @@ capmgr_comp_sched_get(compid_t cid)
return atoi(sched);
}

extern scbcap_t scb_mapping(compid_t id, vaddr_t scb_uaddr);

int
capmgr_scb_mapping(void)
{
compid_t schedid = (compid_t)cos_inv_token();
struct cos_compinfo *ci;
struct cm_comp *s;
vaddr_t scb_uaddr;

s = ss_comp_get(schedid);
assert(s);

ci = cos_compinfo_get(s->comp.comp_res);
assert(ci);

scb_uaddr = cos_page_bump_intern_valloc(ci, COS_SCB_SIZE);
assert(scb_uaddr);

return scb_mapping(schedid, scb_uaddr);
}

static void
capmgr_comp_init(void)
{
Expand Down Expand Up @@ -495,11 +542,13 @@ init_exit(int retval)
}

thdcap_t
capmgr_thd_create_ext(spdid_t client, thdclosure_index_t idx, thdid_t *tid)
capmgr_thd_create_ext(spdid_t client, thdclosure_index_t idx, thdid_t *tid, struct cos_dcb_info **dcb)
//capmgr_thd_create_ext(spdid_t client, thdclosure_index_t idx, thdid_t *tid)
{
compid_t schedid = (compid_t)cos_inv_token();
struct cm_thd *t;
struct cm_comp *s, *c;
struct cm_dcb *d;

if (schedid != capmgr_comp_sched_get(client)) {
/* don't have permission to create execution in that component. */
Expand All @@ -510,46 +559,57 @@ capmgr_thd_create_ext(spdid_t client, thdclosure_index_t idx, thdid_t *tid)

c = ss_comp_get(client);
s = ss_comp_get(schedid);

d = cm_dcb_alloc_in(s);

if (!c || !s) return 0;
t = cm_thd_alloc_in(c, s, idx);
if (!t) {
/* TODO: release resources */
return 0;
}
*tid = t->thd.tid;
*dcb = (struct cos_dcb_info *)d->dcb_addr;

return t->aliased_cap;
}

thdcap_t
capmgr_initthd_create(spdid_t client, thdid_t *tid)
{
return capmgr_thd_create_ext(client, 0, tid);
struct cos_dcb_info *dcb;

return capmgr_thd_create_ext(client, 0, tid, &dcb);
}

thdcap_t capmgr_initaep_create(spdid_t child, struct cos_aep_info *aep, int owntc, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax, asndcap_t *sndret) { BUG(); return 0; }

thdcap_t
capmgr_thd_create_thunk(thdclosure_index_t idx, thdid_t *tid)
capmgr_thd_create_thunk(thdclosure_index_t idx, thdid_t *tid, struct cos_dcb_info **dcb)
{
compid_t client = (compid_t)cos_inv_token();
struct cm_thd *t;
struct cm_thd *t;
struct cm_comp *c;
struct cm_dcb *d;

assert(client > 0 && client <= MAX_NUM_COMPS);
c = ss_comp_get(client);
d = cm_dcb_alloc_in(c);
assert(d);
t = cm_thd_alloc_in(c, c, idx);

if (!t) {
/* TODO: release resources */
return 0;
}
*tid = t->thd.tid;
*dcb = (struct cos_dcb_info *)d->dcb_addr;

return t->aliased_cap;
}

thdcap_t capmgr_aep_create_thunk(struct cos_aep_info *a, thdclosure_index_t idx, int owntc, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax) { BUG(); return 0; }
thdcap_t capmgr_aep_create_ext(spdid_t child, struct cos_aep_info *a, thdclosure_index_t idx, int owntc, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax, arcvcap_t *extrcv) { BUG(); return 0; }
thdcap_t capmgr_aep_create_thunk(struct cos_aep_info *a, thdclosure_index_t idx, int owntc, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax, struct cos_dcb_info **dcb) { BUG(); return 0; }
thdcap_t capmgr_aep_create_ext(spdid_t child, struct cos_aep_info *a, thdclosure_index_t idx, int owntc, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax, struct cos_dcb_info **dcb, arcvcap_t *extrcv) { BUG(); return 0; }
arcvcap_t capmgr_rcv_create(spdid_t child, thdid_t tid, cos_channelkey_t key, microsec_t ipiwin, u32_t ipimax) { BUG(); return 0; }
asndcap_t capmgr_asnd_create(spdid_t child, thdid_t t) { BUG(); return 0; }
asndcap_t capmgr_asnd_rcv_create(arcvcap_t rcv) { BUG(); return 0; }
Expand Down Expand Up @@ -581,8 +641,11 @@ cos_init(void)
if (!cm_comp_self_alloc("capmgr")) BUG();

/* Initialize the other component's for which we're responsible */
scbcap_t scbc = cos_scb_alloc(ci);
assert(scbc);
vaddr_t scb_uaddr = cos_page_bump_intern_valloc(ci, COS_SCB_SIZE);
if (cos_scb_mapping(ci, ci->comp_cap, ci->pgtbl_cap, scbc, scb_uaddr)) BUG();
capmgr_comp_init();

sl_init(SL_MIN_PERIOD_US);

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# The set of interfaces that this component exports for use by other
# components. This is a list of the interface names.
INTERFACE_EXPORTS = init addr
INTERFACE_EXPORTS = init addr scb_mapping
# The interfaces this component is dependent on for compilation (this
# is a list of directory names in interface/)
INTERFACE_DEPENDENCIES = init
Expand Down
18 changes: 17 additions & 1 deletion src/components/implementation/no_interface/llbooter/llbooter.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <init.h>
#include <addr.h>
#include <scb_mapping.h>

#ifndef BOOTER_MAX_SINV
#define BOOTER_MAX_SINV 256
Expand Down Expand Up @@ -411,14 +412,29 @@ addr_get(compid_t id, addr_t type)
}
}

int
scb_mapping(compid_t id, vaddr_t scb_uaddr)
{
struct cos_compinfo *ci;
struct crt_comp *target;

target = boot_comp_get(id);

ci = cos_compinfo_get(target->comp_res);
if (cos_scb_mapping(ci, ci->comp_cap, ci->pgtbl_cap, ci->scb_cap, scb_uaddr)) BUG();
return 0;
}


static void
booter_init(void)
{
struct cos_compinfo *boot_info = cos_compinfo_get(cos_defcompinfo_curr_get());

cos_meminfo_init(&(boot_info->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT);
cos_defcompinfo_init();

vaddr_t scb_uaddr = cos_page_bump_intern_valloc(boot_info, COS_SCB_SIZE);
if (cos_scb_mapping(boot_info, BOOT_CAPTBL_SELF_COMP, BOOT_CAPTBL_SELF_PT, LLBOOT_CAPTBL_SCB, scb_uaddr)) BUG();
cos_hw_cycles_per_usec(BOOT_CAPTBL_SELF_INITHW_BASE);
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/implementation/sched/root_fprr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INTERFACE_EXPORTS = sched init
INTERFACE_DEPENDENCIES = capmgr
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component sl_capmgr
LIBRARY_DEPENDENCIES = component sl_capmgr dcb
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
Expand Down
3 changes: 3 additions & 0 deletions src/components/implementation/sched/root_fprr/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static compid_t init_schedule[MAX_NUM_COMPS] = { 0 };
/* internalizer threads simply orchestrate the initialization */
static struct sl_thd *__initializer_thd[NUM_CPU] CACHE_ALIGNED;

extern int capmgr_scb_mapping(void);

void
schedinit_next(compid_t cid)
{
Expand Down Expand Up @@ -233,6 +235,7 @@ cos_init(void)
cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT);
cos_defcompinfo_init();
cos_init_args_cpubmp(cpubmp);
if (capmgr_scb_mapping()) BUG();
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/components/implementation/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ sched_thd_create_closure(thdclosure_index_t idx)
dci = sched_child_defci_get(sched_childinfo_find(c));
if (!dci) return 0;

t = sl_thd_aep_alloc_ext(dci, NULL, idx, 0, 0, 0, 0, 0, NULL);
t = sl_thd_aep_alloc_ext(dci, NULL, idx, 0, 0, 0, 0, 0, NULL, NULL);
if (!t) return 0;

return sl_thd_thdid(t);
Expand All @@ -105,7 +105,7 @@ sched_aep_create_closure(thdclosure_index_t id, int owntc, cos_channelkey_t key,
dci = sched_child_defci_get(sched_childinfo_find(c));
if (!dci) return 0;

t = sl_thd_aep_alloc_ext(dci, NULL, id, 1, owntc, key, ipiwin, ipimax, rcv);
t = sl_thd_aep_alloc_ext(dci, NULL, id, 1, owntc, key, ipiwin, ipimax, NULL, rcv);
if (!t) return 0;

return sl_thd_thdid(t);
Expand Down
2 changes: 1 addition & 1 deletion src/components/implementation/sched/sched_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sched_childinfo_init_component(compid_t id)
}

assert(bitmap_check(schedinfo->cpubmp, cos_cpuid()));
initthd = sl_thd_initaep_alloc(child_dci, NULL, childflags & COMP_FLAG_SCHED, childflags & COMP_FLAG_SCHED ? 1 : 0, 0, 0, 0); /* TODO: rate information */
initthd = sl_thd_initaep_alloc(child_dci, NULL, childflags & COMP_FLAG_SCHED, childflags & COMP_FLAG_SCHED ? 1 : 0, 0, 0, 0, NULL); /* TODO: rate information */
assert(initthd); /* Failure here? Capability manager likely needs to be depended on with capmgr_create */
sched_child_initthd_set(schedinfo, initthd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test_thds_create_switch(void)

perfdata_init(&pd[cos_cpuid()], "COS THD => COS_THD_SWITCH", test_results, ARRAY_SIZE);

ts = cos_thd_alloc(&booter_info, booter_info.comp_cap, bounceback, NULL);
ts = cos_thd_alloc(&booter_info, booter_info.comp_cap, bounceback, NULL, 0, 0);
if (EXPECT_LL_LT(1, ts, "Thread Creation: Cannot Allocate")) {
return;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ test_async_endpoints_perf(void)

/* parent rcv capabilities */
tcp = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_parent_perf,
(void *)BOOT_CAPTBL_SELF_INITTHD_CPU_BASE);
(void *)BOOT_CAPTBL_SELF_INITTHD_CPU_BASE, 0, 0);
if(EXPECT_LL_LT(1, tcp, "Test Async Endpoints")) return;
tccp = cos_tcap_alloc(&booter_info);
if(EXPECT_LL_LT(1, tccp, "Test Async Endpoints")) return;
Expand All @@ -164,7 +164,7 @@ test_async_endpoints_perf(void)
}

/* child rcv capabilities */
tcc = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_fn_perf, (void *)tcp);
tcc = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_fn_perf, (void *)tcp, 0, 0);
if(EXPECT_LL_LT(1, tcc, "Test Async Endpoints")) return;
tccc = cos_tcap_alloc(&booter_info);
if(EXPECT_LL_LT(1, tccc, "Test Async Endpoints")) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test_async_endpoints(void)

/* parent rcv capabilities */
tcp = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_parent,
(void *)BOOT_CAPTBL_SELF_INITTHD_CPU_BASE);
(void *)BOOT_CAPTBL_SELF_INITTHD_CPU_BASE, 0, 0);
if (EXPECT_LL_LT(1, tcp, "Test Async Endpoints")) {
return;
}
Expand All @@ -118,7 +118,7 @@ test_async_endpoints(void)
}

/* child rcv capabilities */
tcc = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_fn, (void *)tcp);
tcc = cos_thd_alloc(&booter_info, booter_info.comp_cap, async_thd_fn, (void *)tcp, 0, 0);
if (EXPECT_LL_LT(1, tcc, "Test Async Endpoints")) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_captbl_expands(void)
int i;
compcap_t cc;

cc = cos_comp_alloc(&booter_info, booter_info.captbl_cap, booter_info.pgtbl_cap, (vaddr_t)NULL);
cc = cos_comp_alloc(&booter_info, booter_info.captbl_cap, booter_info.pgtbl_cap, 0, (vaddr_t)NULL);
if (EXPECT_LL_LT(1, cc, "Capability Table Expansion")) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ test_inv(void)

perfdata_init(&result, "SINV", test_results, ARRAY_SIZE);

cc = cos_comp_alloc(&booter_info, booter_info.captbl_cap, booter_info.pgtbl_cap, (vaddr_t)NULL);
cc = cos_comp_alloc(&booter_info, booter_info.captbl_cap, booter_info.pgtbl_cap, 0, (vaddr_t)NULL);
if (EXPECT_LL_LT(1, cc, "Invocation: Cannot Allocate")) return;
ic = cos_sinv_alloc(&booter_info, cc, (vaddr_t)__inv_test_serverfn, 0xdead);
if (EXPECT_LL_LT(1, ic, "Invocation: Cannot Allocate")) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ test_timer(void)
long long time, mask;
tcap_time_t timer, thd_timeout;

tc = cos_thd_alloc(&booter_info, booter_info.comp_cap, spinner, NULL);

tc = cos_thd_alloc(&booter_info, booter_info.comp_cap, spinner, NULL, 0, 0);
perfdata_init(&result, "COS THD => COS_THD_SWITCH", test_results, ARRAY_SIZE);

for (i = 0; i <= TEST_ITER; i++){
Expand Down Expand Up @@ -139,7 +138,7 @@ exec_cluster_alloc(struct exec_cluster *e, cos_thd_fn_t fn, void *d, arcvcap_t p
{
e->tcc = cos_tcap_alloc(&booter_info);
if (EXPECT_LL_LT(1, e->tcc, "Cluster Allocation: TCAP ALLOC")) return -1;
e->tc = cos_thd_alloc(&booter_info, booter_info.comp_cap, fn, d);
e->tc = cos_thd_alloc(&booter_info, booter_info.comp_cap, fn, d, 0, 0);
if (EXPECT_LL_LT(1, e->tc, "Cluster Allocation: THD ALLOC")) return -1;
e->rc = cos_arcv_alloc(&booter_info, e->tc, e->tcc, booter_info.comp_cap, parentc);
if (EXPECT_LL_LT(1, e->rc, "Cluster Allocation: ARCV ALLOC")) return -1;
Expand Down
Loading