summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneal <neal>2008-02-11 16:16:20 +0000
committerneal <neal>2008-02-11 16:16:20 +0000
commit17ff98d116f5ca83a24d23b7a2e7ac3c54f3b4ae (patch)
treef0d680358d7275e38e9dde935e3472fda8af9bc1
parenta778792e357f2c8ee711139f19c9af59055f8154 (diff)
hieronymus/
2008-02-11 Neal H. Walfield <neal@gnu.org> * ChangeLog: New file. * Makefile.am: Likewise. * module.S: Likewise. * hieronymus.c: Likewise. / 2008-02-11 Neal H. Walfield <neal@gnu.org> * configure.ac: Generate hieronymus/Makefile. * Makefile.am (SUBDIRS): Add hieronymus. * README: Update boot instructions.
-rw-r--r--ChangeLog6
-rw-r--r--Makefile.am1
-rw-r--r--README6
-rw-r--r--configure.ac3
-rw-r--r--hieronymus/ChangeLog7
-rw-r--r--hieronymus/Makefile.am67
-rw-r--r--hieronymus/hieronymus.c155
-rw-r--r--hieronymus/module.S39
8 files changed, 280 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 83c8f3c..5f08ca5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-11 Neal H. Walfield <neal@gnu.org>
+
+ * configure.ac: Generate hieronymus/Makefile.
+ * Makefile.am (SUBDIRS): Add hieronymus.
+ * README: Update boot instructions.
+
2008-02-08 Thomas Schwinge <tschwinge@gnu.org>
* configure.ac (STATIC_GLIBC): Remove.
diff --git a/Makefile.am b/Makefile.am
index a6431ac..dd281ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -38,4 +38,5 @@ SUBDIRS = libl4 platform \
libhurd-mm \
libc-parts laden viengoos \
ruth \
+ hieronymus \
doc
diff --git a/README b/README
index 8528cdf..c07af80 100644
--- a/README
+++ b/README
@@ -22,7 +22,7 @@ $ make install
$ mkdir /l4/boot
$ install -s laden/laden /l4/boot
$ install -s viengoos/viengoos /l4/boot
-$ install -s ruth/ruth /l4/boot
+$ install -s hieronymus/hieronymus /l4/boot
You need at least automake 1.7 and autoconf 2.53.
@@ -50,7 +50,7 @@ distribution. You may want to install the other programs and
utilities as well to test your L4 kernel, though.
Then set up GRUB to boot laden as the kernel, and the L4 kernel,
-sigma0, viengoos and ruth (in that order).
+sigma0, viengoos and hieronymus (in that order).
Try the debug option (-D 3) to laden and viengoos to see some output
from them. They are relatively silent by default.
@@ -63,7 +63,7 @@ kernel /boot/laden -D
module /boot/ia32-kernel
module /boot/sigma0
module /boot/viengoos -D 3
-module /boot/ruth -D 3
+module /boot/hieronymus -D 3
Pistachio Patch
diff --git a/configure.ac b/configure.ac
index 8013708..779e4e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,7 +210,8 @@ AC_CONFIG_FILES([Makefile
viengoos/Makefile
libc/Makefile
newlib/Makefile
- ruth/Makefile
+ hieronymus/Makefile
+ ruth/Makefile
doc/Makefile
])
AC_OUTPUT
diff --git a/hieronymus/ChangeLog b/hieronymus/ChangeLog
new file mode 100644
index 0000000..4dbc780
--- /dev/null
+++ b/hieronymus/ChangeLog
@@ -0,0 +1,7 @@
+2008-02-11 Neal H. Walfield <neal@gnu.org>
+
+ * ChangeLog: New file.
+ * Makefile.am: Likewise.
+ * module.S: Likewise.
+ * hieronymus.c: Likewise.
+
diff --git a/hieronymus/Makefile.am b/hieronymus/Makefile.am
new file mode 100644
index 0000000..724bfe9
--- /dev/null
+++ b/hieronymus/Makefile.am
@@ -0,0 +1,67 @@
+# Makefile.am - Makefile for Hieronymus.
+# Copyright (C) 2008 Free Software Foundation, Inc.
+# Written by Neal H. Walfield.
+#
+# This file is part of the GNU Hurd.
+#
+# The GNU Hurd is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This GNU Hurd is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+bootdir = $(prefix)/boot
+boot_PROGRAMS = hieronymus
+
+AM_CPPFLAGS = -Wall -g -std=gnu99 -D_GNU_SOURCE -I$(srcdir) \
+ -I$@LIBC@/include -I$(top_builddir)/include \
+ -I$(top_srcdir)/libc-parts
+AM_LDFLAGS = -u_start -e_start -nostdlib
+
+hieronymus_SOURCES = hieronymus.c modules.h
+hieronymus_LDADD = $(top_builddir)/libc.a $(addsuffix .o, $(files))
+
+# List of modules to load followed by their priority, share, and then
+# command line. Each component is separated by a !
+modules = ruth!1!100
+ruth_commandline = "-D 3"
+
+# List of directories relative to the top of the build tree to search
+# for binaries.
+module_paths = ruth
+
+files = $(foreach module,$(modules),$(firstword $(subst !, ,$(module))))
+
+modules.h: $(addsuffix .S, $(files)) Makefile
+ echo ' \
+ $(foreach module,$(modules), \
+ extern char $(firstword $(subst !, ,$(module)))_start; \
+ extern char $(firstword $(subst !, ,$(module)))_end;) \
+ struct module modules[] = { \
+ $(foreach module,$(modules), \
+ { \
+ STRINGIFY ( $(firstword $(subst !, ,$(module))) ), \
+ $(wordlist 2, 2, $(subst !, ,$(module))), \
+ $(wordlist 3, 3, $(subst !, ,$(module))), \
+ $($(firstword $(subst !, ,$(module)))_commandline), \
+ &$(firstword $(subst !, ,$(module)))_start, \
+ &$(firstword $(subst !, ,$(module)))_end \
+ }, \
+ ) \
+ };' > $@
+
+hieronymus.c: modules.h
+
+$(addsuffix .S, $(files)): %.S: module.S
+ $(CPP) -DMODULE=$* $< -o $@
+
+$(addsuffix .o, $(files)): %.o: %.S
+ $(AS) $(addprefix -I$(top_builddir)/, $(module_paths)) $< -o $@
+
diff --git a/hieronymus/hieronymus.c b/hieronymus/hieronymus.c
new file mode 100644
index 0000000..7991bfa
--- /dev/null
+++ b/hieronymus/hieronymus.c
@@ -0,0 +1,155 @@
+/* hieronymus.c - initrd implementation.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <hurd/activity.h>
+#include <hurd/folio.h>
+#include <hurd/storage.h>
+#include <hurd/capalloc.h>
+#include <hurd/thread.h>
+#include <hurd/as.h>
+#include <hurd/rm.h>
+#include <hurd/ihash.h>
+#include <process-spawn.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#define STRINGIFY_(id) #id
+#define STRINGIFY(id) STRINGIFY_(id)
+
+struct module
+{
+ const char *name;
+ int priority;
+ int share;
+ const char *commandline;
+ char *start;
+ char *end;
+};
+
+#include "modules.h"
+
+/* Initialized by the machine-specific startup-code. */
+extern struct hurd_startup_data *__hurd_startup_data;
+
+#define root_activity __hurd_startup_data->activity
+
+/* Allocate a new activity out of our storage. */
+static struct storage
+activity_alloc (struct activity_policy policy)
+{
+ struct storage storage
+ = storage_alloc (root_activity, cap_activity_control, STORAGE_LONG_LIVED,
+ ADDR_VOID);
+ if (! storage.cap)
+ panic ("Failed to allocate storage.");
+
+ struct activity_policy out;
+ error_t err = rm_activity_policy (storage.addr,
+ ACTIVITY_POLICY_STORAGE_SET
+ | ACTIVITY_POLICY_CHILD_REL_SET,
+ policy, &out);
+ if (err)
+ panic ("Failed to set policy on activity");
+
+ return storage;
+}
+
+int
+main (int argc, char *argv[])
+{
+ extern int output_debug;
+ output_debug = 3;
+
+ // extern int __pthread_lock_trace;
+ // __pthread_lock_trace = 0;
+
+ int count = sizeof (modules) / sizeof (modules[0]);
+
+ struct storage activities[count];
+ addr_t thread[count];
+
+ /* Load modules. */
+ int i;
+ for (i = 0; i < count; i ++)
+ {
+ activities[i] = activity_alloc (ACTIVITY_POLICY_VOID);
+
+ const char *argv[] = { modules[i].name, modules[i].commandline, NULL };
+ const char *env[] = { NULL };
+ thread[i] = process_spawn (activities[i].addr,
+ modules[i].start, modules[i].end,
+ argv, env, false);
+
+ debug (0, "");
+
+ /* Free the memory used by the module's binary. */
+ /* XXX: This doesn't free folios or note pages that may be
+ partially freed. The latter is important because a page may
+ be used by two modules and after the second module is loaded,
+ it could be freed. */
+ int count = 0;
+ int j;
+ for (j = 0; j < __hurd_startup_data->desc_count; j ++)
+ {
+ struct hurd_object_desc *desc = &__hurd_startup_data->descs[j];
+
+ if ((desc->type == cap_page || desc->type == cap_rpage)
+ && ! ADDR_IS_VOID (desc->storage)
+ && addr_depth (desc->object) == ADDR_BITS - PAGESIZE_LOG2
+ && (uintptr_t) modules[i].start <= addr_prefix (desc->object)
+ && (addr_prefix (desc->object) + PAGESIZE - 1
+ <= (uintptr_t) modules[i].end))
+ {
+ debug (5, "Freeing " ADDR_FMT "(" ADDR_FMT "), a %s",
+ ADDR_PRINTF (desc->object), ADDR_PRINTF (desc->storage),
+ cap_type_string (desc->type));
+ count ++;
+ storage_free (desc->storage, true);
+ }
+ }
+ debug (0, "Freed %d pages", count);
+
+ thread_start (thread[i]);
+ }
+
+ /* Wait for all activities to die. */
+ for (i = 0; i < count; i ++)
+ {
+ uintptr_t rt = -1;
+ rm_thread_wait_object_destroyed (root_activity,
+ thread[i], &rt);
+
+ addr_t folio = addr_chop (activities[i].addr, FOLIO_OBJECTS_LOG2);
+ int index = addr_extract (activities[i].addr, FOLIO_OBJECTS_LOG2);
+
+ error_t err;
+ err = rm_folio_object_alloc (ADDR_VOID, folio, index,
+ cap_void, OBJECT_POLICY_VOID,
+ (uintptr_t) rt,
+ ADDR_VOID, ADDR_VOID);
+ if (err)
+ debug (0, "deallocating object: %d", err);
+
+ debug (0, "%s exited with %d", modules[i].name, (int) rt);
+ }
+
+ return 0;
+}
diff --git a/hieronymus/module.S b/hieronymus/module.S
new file mode 100644
index 0000000..c6fdc16
--- /dev/null
+++ b/hieronymus/module.S
@@ -0,0 +1,39 @@
+/* module.S - Binary packager.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ Written by Neal H. Walfield <neal@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef MODULE
+#error "Module not defined."
+#endif
+
+#define C_(a, b) a ## b
+#define C(a, b) C_(a, b)
+
+#define S_(id) #id
+#define S(id) S_(id)
+
+#define MODULE_BINARY MODULE
+
+ .data
+
+ /* Include the binary. Make it page aligned. */
+ .global C(MODULE, _start), C(MODULE, _end)
+C(MODULE, _start):
+ .incbin S(MODULE_BINARY)
+C(MODULE, _end):