L4Re/departure

Changeset

480:f8f29bf0e4d7
2023-02-17 Paul Boddie raw files shortlog changelog graph Added initial support for communicating process/task signals as notifications.
libexec/include/exec/external_pager.h (file) libexec/include/exec/process_creator.h (file) libexec/lib/src/Makefile (file) libexec/lib/src/external_pager.cc (file) libexec/lib/src/process_creator.cc (file) tests/Makefile (file) tests/dstest_exec.cc (file)
     1.1 --- a/libexec/include/exec/external_pager.h	Fri Feb 17 18:39:43 2023 +0100
     1.2 +++ b/libexec/include/exec/external_pager.h	Fri Feb 17 18:41:18 2023 +0100
     1.3 @@ -1,7 +1,7 @@
     1.4  /*
     1.5   * A system pager implementation residing in a separate task.
     1.6   *
     1.7 - * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
     1.8 + * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
     1.9   *
    1.10   * This program is free software; you can redistribute it and/or
    1.11   * modify it under the terms of the GNU General Public License as
    1.12 @@ -23,6 +23,7 @@
    1.13  
    1.14  #include <exec/pager.h>
    1.15  
    1.16 +#include "notifier_interface.h"
    1.17  #include "parent_pager_object_interface.h"
    1.18  
    1.19  
    1.20 @@ -31,6 +32,9 @@
    1.21  
    1.22  class ExternalPager : public ExecPager, public ParentPagerObject
    1.23  {
    1.24 +protected:
    1.25 +  Notifier *_notifier = NULL;
    1.26 +
    1.27  public:
    1.28    explicit ExternalPager(address_t start = 0, address_t end = 0);
    1.29  
    1.30 @@ -50,6 +54,11 @@
    1.31    /* Parent methods. */
    1.32  
    1.33    virtual long signal(unsigned long sig, unsigned long val);
    1.34 +
    1.35 +  /* Notification methods. */
    1.36 +
    1.37 +  virtual void set_notifier(Notifier *notifier)
    1.38 +  { _notifier = notifier; }
    1.39  };
    1.40  
    1.41  /* vim: tabstop=2 expandtab shiftwidth=2
     2.1 --- a/libexec/include/exec/process_creator.h	Fri Feb 17 18:39:43 2023 +0100
     2.2 +++ b/libexec/include/exec/process_creator.h	Fri Feb 17 18:41:18 2023 +0100
     2.3 @@ -83,6 +83,8 @@
     2.4    explicit ProcessCreator(const char *rm_filename);
     2.5  
     2.6    long start(file_t *file, int argc, const char *argv[]);
     2.7 +
     2.8 +  void set_notifier(Notifier *notifier);
     2.9  };
    2.10  
    2.11  /* vim: tabstop=2 expandtab shiftwidth=2
     3.1 --- a/libexec/lib/src/Makefile	Fri Feb 17 18:39:43 2023 +0100
     3.2 +++ b/libexec/lib/src/Makefile	Fri Feb 17 18:41:18 2023 +0100
     3.3 @@ -15,7 +15,7 @@
     3.4  
     3.5  # Required interfaces.
     3.6  
     3.7 -CLIENT_INTERFACES_CC		= dataspace mapped_file
     3.8 +CLIENT_INTERFACES_CC		= dataspace mapped_file notifier
     3.9  
    3.10  SERVER_INTERFACES_CC		= pager_object parent_pager_object
    3.11  
     4.1 --- a/libexec/lib/src/external_pager.cc	Fri Feb 17 18:39:43 2023 +0100
     4.2 +++ b/libexec/lib/src/external_pager.cc	Fri Feb 17 18:41:18 2023 +0100
     4.3 @@ -163,7 +163,9 @@
     4.4  
     4.5  long ExternalPager::signal(unsigned long sig, unsigned long val)
     4.6  {
     4.7 -  printf("Signal %ld with value %ld received.\n", sig, val);
     4.8 +  if (_notifier != NULL)
     4.9 +    _notifier->notify(NOTIFY_TASK_SIGNAL);
    4.10 +
    4.11    return L4_EOK;
    4.12  }
    4.13  
     5.1 --- a/libexec/lib/src/process_creator.cc	Fri Feb 17 18:39:43 2023 +0100
     5.2 +++ b/libexec/lib/src/process_creator.cc	Fri Feb 17 18:41:18 2023 +0100
     5.3 @@ -306,5 +306,10 @@
     5.4    return start_program(argc, argv);
     5.5  }
     5.6  
     5.7 +void ProcessCreator::set_notifier(Notifier *notifier)
     5.8 +{
     5.9 +  _exec_pager.set_notifier(notifier);
    5.10 +}
    5.11 +
    5.12  /* vim: tabstop=2 expandtab shiftwidth=2
    5.13  */
     6.1 --- a/tests/Makefile	Fri Feb 17 18:39:43 2023 +0100
     6.2 +++ b/tests/Makefile	Fri Feb 17 18:41:18 2023 +0100
     6.3 @@ -32,11 +32,14 @@
     6.4  
     6.5  # Required interfaces.
     6.6  
     6.7 -CLIENT_INTERFACES_CC		= dataspace
     6.8 +CLIENT_INTERFACES_CC_dstest_exec		= notifier
     6.9 +CLIENT_INTERFACES_CC_dstest_file_mapping	= dataspace
    6.10 +CLIENT_INTERFACES_CC				= dataspace notifier
    6.11  
    6.12  # Generated and plain source files.
    6.13  
    6.14 -CLIENT_INTERFACES_SRC_CC	= $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC))
    6.15 +CLIENT_INTERFACES_SRC_CC_dstest_exec		= $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC_dstest_exec))
    6.16 +CLIENT_INTERFACES_SRC_CC_dstest_file_mapping	= $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC_dstest_file_mapping))
    6.17  
    6.18  # Normal source files.
    6.19  
    6.20 @@ -66,10 +69,11 @@
    6.21  
    6.22  SRC_CC_dstest_test_client		= dstest_test_client.cc
    6.23  
    6.24 -SRC_CC_dstest_exec			= dstest_exec.cc
    6.25 +PLAIN_SRC_CC_dstest_exec		= dstest_exec.cc
    6.26 +SRC_CC_dstest_exec			= $(PLAIN_SRC_CC_dstest_exec) $(CLIENT_INTERFACES_SRC_CC_dstest_exec)
    6.27  
    6.28  PLAIN_SRC_CC_dstest_file_mapping	= dstest_file_mapping.cc
    6.29 -SRC_CC_dstest_file_mapping		= $(PLAIN_SRC_CC_dstest_file_mapping) $(CLIENT_INTERFACES_SRC_CC)
    6.30 +SRC_CC_dstest_file_mapping		= $(PLAIN_SRC_CC_dstest_file_mapping) $(CLIENT_INTERFACES_SRC_CC_dstest_file_mapping)
    6.31  
    6.32  SRC_CC_dstest_align			= dstest_align.cc
    6.33  
    6.34 @@ -79,4 +83,6 @@
    6.35  include $(L4DIR)/mk/prog.mk
    6.36  include $(IDL_MK_DIR)/interface_rules.mk
    6.37  
    6.38 -$(PLAIN_SRC_CC_dstest_file_mapping): $(CLIENT_INTERFACES_SRC_CC)
    6.39 +$(PLAIN_SRC_CC_dstest_exec): $(CLIENT_INTERFACES_SRC_CC_dstest_exec)
    6.40 +
    6.41 +$(PLAIN_SRC_CC_dstest_file_mapping): $(CLIENT_INTERFACES_SRC_CC_dstest_file_mapping)
     7.1 --- a/tests/dstest_exec.cc	Fri Feb 17 18:39:43 2023 +0100
     7.2 +++ b/tests/dstest_exec.cc	Fri Feb 17 18:41:18 2023 +0100
     7.3 @@ -25,11 +25,25 @@
     7.4  
     7.5  #include <exec/process_creator.h>
     7.6  #include <systypes/fcntl.h>
     7.7 +#include <systypes/format.h>
     7.8  
     7.9  #include <stdio.h>
    7.10  
    7.11  
    7.12  
    7.13 +class local_Notifier : public Notifier
    7.14 +{
    7.15 +public:
    7.16 +  long notify(notify_flags_t flags)
    7.17 +  {
    7.18 +    printf("Notified with flags: %" pFMTnotify_flags "x\n", flags);
    7.19 +
    7.20 +    return L4_EOK;
    7.21 +  }
    7.22 +};
    7.23 +
    7.24 +
    7.25 +
    7.26  int main(int argc, char *argv[])
    7.27  {
    7.28    long err;
    7.29 @@ -52,6 +66,9 @@
    7.30      return 1;
    7.31    }
    7.32  
    7.33 +  local_Notifier notifier;
    7.34 +
    7.35 +  creator.set_notifier(&notifier);
    7.36    err = creator.start(program_file, argc - 2, (const char **) argv + 2);
    7.37  
    7.38    if (err)