1.1 --- a/tests/dstest_exec.cc Sun May 08 23:51:50 2022 +0200
1.2 +++ b/tests/dstest_exec.cc Mon May 09 01:00:51 2022 +0200
1.3 @@ -20,6 +20,7 @@
1.4 */
1.5
1.6 #include <l4/re/env.h>
1.7 +#include <l4/re/l4aux.h>
1.8 #include <l4/sys/err.h>
1.9 #include <l4/sys/factory.h>
1.10 #include <l4/sys/task.h>
1.11 @@ -472,11 +473,13 @@
1.12
1.13 l4_addr_t _caps;
1.14 char *_arg_top, *_env_top;
1.15 + char **_argv;
1.16 char *_auxv_end;
1.17 int _env_entries;
1.18
1.19 - /* L4Re environment region. */
1.20 + /* L4Re auxiliary and environment regions. */
1.21
1.22 + l4re_aux_t *_aux;
1.23 l4re_env_t *_env;
1.24
1.25 public:
1.26 @@ -551,11 +554,11 @@
1.27 /* Loader flags, debugging flags, and the KIP capability index.
1.28 See: generate_l4aux in Remote_app_model */
1.29
1.30 - void push_l4re_flags()
1.31 + void push_l4re_aux()
1.32 {
1.33 - *(--_element) = 0;
1.34 - *(--_element) = 0;
1.35 - *(--_element) = 0x14 << L4_CAP_SHIFT;
1.36 + _aux = (l4re_aux_t *) _element;
1.37 + _aux--;
1.38 + _element = (l4_umword_t *) _aux;
1.39 }
1.40
1.41 void push_l4re_env()
1.42 @@ -565,6 +568,17 @@
1.43 _element = (l4_umword_t *) _env;
1.44 }
1.45
1.46 + /* Set the common auxiliary information. */
1.47 +
1.48 + void set_l4re_aux(l4re_aux_t *aux)
1.49 + {
1.50 + memcpy(_aux, aux, sizeof(l4re_aux_t));
1.51 +
1.52 + /* Take the binary name from the first program argument. */
1.53 +
1.54 + _aux->binary = (char *) _argv[0];
1.55 + }
1.56 +
1.57 /* Set the common environment, introducing the reference to additional
1.58 capabilities. */
1.59
1.60 @@ -590,6 +604,10 @@
1.61
1.62 *(--auxv_base) = {0xf1, _segment.region_address((char *) _env)};
1.63
1.64 + /* L4Re auxiliary structure pointer. */
1.65 +
1.66 + *(--auxv_base) = {0xf0, _segment.region_address((char *) _aux)};
1.67 +
1.68 /* Apparently required entries.
1.69 NOTE: The user/group identifiers should be obtained from the broader
1.70 environment. */
1.71 @@ -645,11 +663,11 @@
1.72
1.73 /* Reserve space and fill the stack from the top inwards. */
1.74
1.75 - char **ap = (char **) (_element - argc);
1.76 + _argv = (char **) (_element - argc);
1.77 char *arg = _arg_top;
1.78
1.79 for (int i = 0; i < argc; i++)
1.80 - arg -= write_address(arg, &ap[i], argv[i]);
1.81 + arg -= write_address(arg, &_argv[i], argv[i]);
1.82
1.83 /* Write the count. */
1.84
1.85 @@ -684,7 +702,7 @@
1.86
1.87 /* Push L4Re flags, environment and auxiliary vector. */
1.88
1.89 - push_l4re_flags();
1.90 + push_l4re_aux();
1.91 push_l4re_env();
1.92 push_auxv();
1.93
1.94 @@ -711,6 +729,7 @@
1.95 l4_cap_idx_t _pager_cap = 0x10 << L4_CAP_SHIFT;
1.96 l4_cap_idx_t _rm_cap = 0x11 << L4_CAP_SHIFT;
1.97 l4_cap_idx_t _ma_cap = 0x12 << L4_CAP_SHIFT;
1.98 + l4_cap_idx_t _kip_cap = 0x14 << L4_CAP_SHIFT;
1.99 unsigned int _first_cap = 0x15;
1.100
1.101 /* UTCB details. */
1.102 @@ -719,6 +738,7 @@
1.103
1.104 /* Common environment details. */
1.105
1.106 + l4re_aux_t _aux;
1.107 l4re_env_t _env;
1.108
1.109 /* Task and thread initialisation. */
1.110 @@ -763,6 +783,12 @@
1.111 _env.first_free_cap = _first_cap;
1.112 _env.utcb_area = utcb_fpage;
1.113 _env.first_free_utcb = l4_fpage_memaddr(utcb_fpage) + L4_UTCB_OFFSET;
1.114 +
1.115 + /* Populate auxiliary information. */
1.116 +
1.117 + _aux.kip_ds = _kip_cap;
1.118 + _aux.dbg_lvl = 0;
1.119 + _aux.ldr_flags = 0;
1.120 }
1.121
1.122 /* Configure the task environment. */
1.123 @@ -834,6 +860,7 @@
1.124
1.125 /* Populate the initial environment in the thread. */
1.126
1.127 + st.set_l4re_aux(&_aux);
1.128 st.set_l4re_env(&_env);
1.129
1.130 /* Set the start details. */