1 /* 2 * Copyright (c) 2019, Google, Inc. All rights reserved 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24 #pragma once 25 26 #include <stdint.h> 27 #include <sys/types.h> 28 29 #include <lib/trusty/event.h> 30 #include <lib/trusty/handle.h> 31 #include <lib/trusty/uuid.h> 32 33 /** 34 * struct uirq - UIRQ descriptor 35 * @name: UIRQ name (must be non-empty) 36 * @uuids: pointer to array of &struct uuids that represents 37 * client uuids that are allowed to open this UIRQ object. 38 * @uuids_num: number of entries in array pointed by @uuids parameter 39 * @cfg_flags: reserved, must be set to 0 40 */ 41 struct uirq { 42 const char* name; 43 const struct uuid* uuids; 44 const unsigned int uuids_num; 45 const unsigned int cfg_flags; 46 }; 47 48 #define UIRQ_INITIALIZER(nm, uu, uunum, cfg) \ 49 { .name = nm, .uuids = uu, .uuids_num = uunum, .cfg_flags = cfg, } 50 51 /** 52 * uirq_register_sw_irq() - register SW IRQ backed UIRQ object 53 * @uirq: pointer to &struct uirq describing object to create 54 * @ops: pointer to &struct event_source_ops 55 * @ops_arg: an optional argument that will be passed to callbacks 56 * specified by @ops parameter 57 * @ph: pointer to &struct handle to return handle to caller 58 * 59 * SW IRQ is not backed by normal interrupt but rather some sort of 60 * software object that implements &struct event_source_ops ops 61 * 62 * Return: 0 on success, negative error otherwise 63 */ 64 int uirq_register_sw_irq(const struct uirq* uirq, 65 const struct event_source_ops* ops, 66 const void* ops_arg, 67 struct handle** ph); 68 69 /** 70 * uirq_register_hw_irq() - register hardware interrupt backed UIRQ object 71 * @vector: hardware interrupt 72 * @uirq: pointer to &struct uirq describing object to create 73 * @ph: pointer to &struct handle to return handle to caller 74 * 75 * Return: 0 on success, negative error otherwise 76 */ 77 int uirq_register_hw_irq(unsigned int vector, 78 const struct uirq* uirq, 79 struct handle** ph); 80