1/* 2 * Copyright 2017, 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/*- import 'helpers/error.c' as error with context -*/ 14 15#include <camkes/error.h> 16#include <sel4/sel4.h> 17#include <sync/sem-bare.h> 18#include <utils/util.h> 19 20/*? macros.show_includes(me.instance.type.includes) ?*/ 21 22/* Interface-specific error handling. */ 23/*- set error_handler = '%s_error_handler' % me.interface.name -*/ 24/*? error.make_error_handler(interface, error_handler) ?*/ 25 26/*- set my_index = me.parent.from_ends.index(me) -*/ 27 28/*- set eps = [] -*/ 29/*- for index in six.moves.range(len(me.parent.to_ends)) -*/ 30 /*- do eps.append(alloc('ep_%d' % index, seL4_EndpointObject, read=True, write=True)) -*/ 31 32 char from_/*? my_index ?*/_/*? me.interface.name ?*/_/*? index ?*/_data[ROUND_UP_UNSAFE(sizeof(int), PAGE_SIZE_4K)] 33 ALIGN(4096) 34 SECTION("align_12bit"); 35 volatile int *counter_/*? index ?*/ = (volatile int*)from_/*? my_index ?*/_/*? me.interface.name ?*/_/*? index ?*/_data; 36 /*? register_shared_variable('%s_%d_data' % (me.parent.name, index), 'from_%d_%s_%d_data' % (my_index, me.interface.name, index), 4096, perm='RW') ?*/ 37/*- endfor -*/ 38 39void /*? me.interface.name ?*/_emit_underlying(void) { 40 int result UNUSED; 41 /*- for index, ep in enumerate(eps) -*/ 42 result = sync_sem_bare_post(/*? ep ?*/, counter_/*? index ?*/); 43 ERR_IF(result != 0, /*? error_handler ?*/, ((camkes_error_t){ 44 .type = CE_OVERFLOW, 45 .instance = "/*? me.instance.name ?*/", 46 .interface = "/*? me.interface.name ?*/", 47 .description = "failed to send event to 'to' end #/*? index ?*/ due to potential overflow", 48 }), ({ 49 return; 50 })); 51 /*- endfor -*/ 52} 53