1/*# 2 *#Copyright 2019, Data61 3 *#Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 *#ABN 41 687 119 230. 5 *# 6 *#This software may be distributed and modified according to the terms of 7 *#the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 *#See "LICENSE_BSD2.txt" for details. 9 *# 10 *#@TAG(DATA61_BSD) 11 #*/ 12 13/*# Assign client ids and badges #*/ 14/*- from 'rpc-connector.c' import allocate_badges with context -*/ 15/*- from 'global-endpoint.template.c' import allocate_cap with context -*/ 16/*- set client_ids = namespace() -*/ 17/*- do allocate_badges(client_ids) -*/ 18 19/*- set badges = client_ids.badges -*/ 20 21/*- for c in me.parent.from_ends -*/ 22 /*- do allocate_cap(c, is_reader=False) -*/ 23 /*- set notification = pop('notification') -*/ 24 void /*? me.interface.name ?*/_emit_/*? badges[loop.index0] ?*/(void) { 25 seL4_Signal(/*? notification ?*/); 26 } 27/*- endfor -*/ 28 29/*- do badges.sort() -*/ 30 31void /*? me.interface.name ?*/_emit(unsigned int badge) { 32 /*# create a lookup table under the assumption that the 33 badges are sensibly made as low as possible #*/ 34 static void (*lookup[])(void) = { 35 /*- for badge in badges -*/ 36 [/*? badge ?*/] = /*? me.interface.name ?*/_emit_/*? badge ?*/, 37 /*- endfor -*/ 38 }; 39 assert(badge < ARRAY_SIZE(lookup)); 40 assert(lookup[badge]); 41 lookup[badge](); 42} 43 44int /*? me.interface.name ?*/_largest_badge(void) { 45 return /*? badges[len(badges) - 1] ?*/; 46} 47