1.1 --- a/libipc/include/ipc/server.h Fri Feb 23 01:29:50 2024 +0100
1.2 +++ b/libipc/include/ipc/server.h Fri Feb 23 01:33:47 2024 +0100
1.3 @@ -113,10 +113,6 @@
1.4
1.5 long ipc_server_apply_deletion_for_thread(l4_cap_idx_t cap, l4_cap_idx_t irq, l4_cap_idx_t thread);
1.6
1.7 -/* Bind the main thread to a named IPC gate capability. */
1.8 -
1.9 -long ipc_server_bind(const char *name, l4_umword_t id, l4_cap_idx_t *server);
1.10 -
1.11 /* Create a new IPC gate for the main thread. */
1.12
1.13 long ipc_server_new(l4_cap_idx_t *cap, void *obj);
2.1 --- a/libipc/lib/src/server.c Fri Feb 23 01:29:50 2024 +0100
2.2 +++ b/libipc/lib/src/server.c Fri Feb 23 01:33:47 2024 +0100
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 * Server binding/registration.
2.6 *
2.7 - * Copyright (C) 2018, 2019, 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) 2018-2022, 2024 Paul Boddie <paul@boddie.org.uk>
2.9 *
2.10 * This program is free software; you can redistribute it and/or
2.11 * modify it under the terms of the GNU General Public License as
2.12 @@ -88,26 +88,6 @@
2.13 return l4_error(l4_kobject_dec_refcnt(cap, 1));
2.14 }
2.15
2.16 -
2.17 -
2.18 -/* Bind the main thread to the named capability, employing an identifier for
2.19 - the IPC gate and returning the capability index. */
2.20 -
2.21 -long ipc_server_bind(const char *name, l4_umword_t id, l4_cap_idx_t *server)
2.22 -{
2.23 - /* Obtain a reference to the device. */
2.24 -
2.25 - *server = l4re_env_get_cap(name);
2.26 -
2.27 - if (l4_is_invalid_cap(*server))
2.28 - return -L4_ENOENT;
2.29 -
2.30 - /* Bind to an IPC gate with the label identifying the server as message
2.31 - destination. */
2.32 -
2.33 - return l4_error(l4_rcv_ep_bind_thread(*server, l4re_env()->main_thread, id));
2.34 -}
2.35 -
2.36 /* Initialise a new server capability, binding it to the main thread. */
2.37
2.38 long ipc_server_new(l4_cap_idx_t *cap, void *obj)
2.39 @@ -168,11 +148,7 @@
2.40 long err;
2.41
2.42 if (name != NULL)
2.43 - {
2.44 - err = ipc_server_bind(name, (l4_umword_t) &config, &config.server);
2.45 - if (err)
2.46 - return err;
2.47 - }
2.48 + config.server = l4re_env_get_cap(name);
2.49
2.50 _ipc_server_init_for(&config, default_config, handler_obj);
2.51
2.52 @@ -247,6 +223,13 @@
2.53
2.54 label = label & ~3UL;
2.55
2.56 + /* Since we interpret the label as a pointer, we should detect zero labels
2.57 + and report them since they are likely to be interrupts inappropriately
2.58 + bound to this thread. */
2.59 +
2.60 + if (!label)
2.61 + continue;
2.62 +
2.63 /* Ignore erroneous messages. */
2.64
2.65 if (l4_ipc_error(msg.tag, l4_utcb()))
2.66 @@ -379,12 +362,15 @@
2.67 /* Allocate a new IPC gate if one is not already defined. */
2.68
2.69 if (l4_is_invalid_cap(config->server))
2.70 - {
2.71 err = ipc_server_new_for_thread(&config->server, config, config->thread);
2.72
2.73 - if (err)
2.74 - return err;
2.75 - }
2.76 + /* Otherwise, bind the existing IPC gate to the thread. */
2.77 +
2.78 + else
2.79 + err = l4_error(l4_rcv_ep_bind_thread(config->server, config->thread, (l4_umword_t) config));
2.80 +
2.81 + if (err)
2.82 + return err;
2.83
2.84 /* Allocate an IRQ for notifications if requested. */
2.85
3.1 --- a/libresource/lib/src/resource_server.cc Fri Feb 23 01:29:50 2024 +0100
3.2 +++ b/libresource/lib/src/resource_server.cc Fri Feb 23 01:33:47 2024 +0100
3.3 @@ -1,7 +1,7 @@
3.4 /*
3.5 * Resource server functionality.
3.6 *
3.7 - * Copyright (C) 2018, 2019, 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk>
3.8 + * Copyright (C) 2018-2022, 2024 Paul Boddie <paul@boddie.org.uk>
3.9 *
3.10 * This program is free software; you can redistribute it and/or
3.11 * modify it under the terms of the GNU General Public License as
3.12 @@ -35,7 +35,8 @@
3.13
3.14 long ResourceServer::bind(const char *name)
3.15 {
3.16 - return ipc_server_bind(name, (l4_umword_t) _config, &_config->server);
3.17 + _config->server = l4re_env_get_cap(name);
3.18 + return L4_EOK;
3.19 }
3.20
3.21 /* Start in the same thread indicating whether the server can be finalised. If