# HG changeset patch # User Paul Boddie # Date 1708648427 -3600 # Node ID a597a0af78f367018538a611cdc2e628e993b2d1 # Parent a8f1dba0cd6ac7144f6c82ab93caa47ed23f1f07 Changed the binding to existing IPC gates to occur in the configured thread. Added a remark about inappropriate gate labels. diff -r a8f1dba0cd6a -r a597a0af78f3 libipc/include/ipc/server.h --- a/libipc/include/ipc/server.h Fri Feb 23 01:29:50 2024 +0100 +++ b/libipc/include/ipc/server.h Fri Feb 23 01:33:47 2024 +0100 @@ -113,10 +113,6 @@ long ipc_server_apply_deletion_for_thread(l4_cap_idx_t cap, l4_cap_idx_t irq, l4_cap_idx_t thread); -/* Bind the main thread to a named IPC gate capability. */ - -long ipc_server_bind(const char *name, l4_umword_t id, l4_cap_idx_t *server); - /* Create a new IPC gate for the main thread. */ long ipc_server_new(l4_cap_idx_t *cap, void *obj); diff -r a8f1dba0cd6a -r a597a0af78f3 libipc/lib/src/server.c --- a/libipc/lib/src/server.c Fri Feb 23 01:29:50 2024 +0100 +++ b/libipc/lib/src/server.c Fri Feb 23 01:33:47 2024 +0100 @@ -1,7 +1,7 @@ /* * Server binding/registration. * - * Copyright (C) 2018, 2019, 2020, 2021, 2022 Paul Boddie + * Copyright (C) 2018-2022, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -88,26 +88,6 @@ return l4_error(l4_kobject_dec_refcnt(cap, 1)); } - - -/* Bind the main thread to the named capability, employing an identifier for - the IPC gate and returning the capability index. */ - -long ipc_server_bind(const char *name, l4_umword_t id, l4_cap_idx_t *server) -{ - /* Obtain a reference to the device. */ - - *server = l4re_env_get_cap(name); - - if (l4_is_invalid_cap(*server)) - return -L4_ENOENT; - - /* Bind to an IPC gate with the label identifying the server as message - destination. */ - - return l4_error(l4_rcv_ep_bind_thread(*server, l4re_env()->main_thread, id)); -} - /* Initialise a new server capability, binding it to the main thread. */ long ipc_server_new(l4_cap_idx_t *cap, void *obj) @@ -168,11 +148,7 @@ long err; if (name != NULL) - { - err = ipc_server_bind(name, (l4_umword_t) &config, &config.server); - if (err) - return err; - } + config.server = l4re_env_get_cap(name); _ipc_server_init_for(&config, default_config, handler_obj); @@ -247,6 +223,13 @@ label = label & ~3UL; + /* Since we interpret the label as a pointer, we should detect zero labels + and report them since they are likely to be interrupts inappropriately + bound to this thread. */ + + if (!label) + continue; + /* Ignore erroneous messages. */ if (l4_ipc_error(msg.tag, l4_utcb())) @@ -379,12 +362,15 @@ /* Allocate a new IPC gate if one is not already defined. */ if (l4_is_invalid_cap(config->server)) - { err = ipc_server_new_for_thread(&config->server, config, config->thread); - if (err) - return err; - } + /* Otherwise, bind the existing IPC gate to the thread. */ + + else + err = l4_error(l4_rcv_ep_bind_thread(config->server, config->thread, (l4_umword_t) config)); + + if (err) + return err; /* Allocate an IRQ for notifications if requested. */ diff -r a8f1dba0cd6a -r a597a0af78f3 libresource/lib/src/resource_server.cc --- a/libresource/lib/src/resource_server.cc Fri Feb 23 01:29:50 2024 +0100 +++ b/libresource/lib/src/resource_server.cc Fri Feb 23 01:33:47 2024 +0100 @@ -1,7 +1,7 @@ /* * Resource server functionality. * - * Copyright (C) 2018, 2019, 2020, 2021, 2022 Paul Boddie + * Copyright (C) 2018-2022, 2024 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -35,7 +35,8 @@ long ResourceServer::bind(const char *name) { - return ipc_server_bind(name, (l4_umword_t) _config, &_config->server); + _config->server = l4re_env_get_cap(name); + return L4_EOK; } /* Start in the same thread indicating whether the server can be finalised. If