1 /*
2 * Copyright (c) 2014-2015, 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 #include <assert.h>
25 #include <err.h>
26 #include <trace.h>
27
28 #include <lib/trusty/tipc_virtio_dev.h>
29 #include <lk/init.h>
30
31 #include "trusty_virtio.h"
32
33 /* Default TIPC device (/dev/trusty-ipc-dev0) */
34 DECLARE_TIPC_DEVICE_DESCR(_descr0, 0, 32, 32, "dev0");
35
tipc_init(struct trusty_virtio_bus * vb)36 static status_t tipc_init(struct trusty_virtio_bus* vb) {
37 status_t res;
38
39 res = create_tipc_device(vb, &_descr0, sizeof(_descr0), &zero_uuid, NULL);
40 if (res != NO_ERROR) {
41 TRACEF("WARNING: failed (%d) to register tipc device\n", res);
42 }
43 return res;
44 }
45
register_tipc_init(uint level)46 static void register_tipc_init(uint level) {
47 static struct trusty_virtio_bus_notifier vb_notifier = {
48 .on_create = tipc_init,
49 };
50 trusty_virtio_register_bus_notifier(&vb_notifier);
51 }
52
53 LK_INIT_HOOK_FLAGS(register_tipc_init,
54 register_tipc_init,
55 LK_INIT_LEVEL_APPS - 2,
56 LK_INIT_FLAG_PRIMARY_CPU);
57