summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-08-17 04:47:47 +0000
committerRoland McGrath <roland@gnu.org>2001-08-17 04:47:47 +0000
commit16bc4b4cfed8959345574d8389c1aa1f24ecfa95 (patch)
treea8f6c4eddb303ed827c450c586b36e036855e8ba
parentcc94c82e35667c170c5a0640c073195ec83fe79f (diff)
2001-08-16 Roland McGrath <roland@frob.com>
* boot_script.h (struct cmd): Change `task' member type to `task_t'. (boot_script_task_create, boot_script_task_resume, boot_script_prompt_task_resume, boot_script_free_task): Declare new functions that callers must define. * userland-boot.c: Define those. * boot_script.c (create_task, resume_task, prompt_resume_task): Use those instead of direct Mach calls. (free_cmd): Likewise. (read_file): Function removed. (builtin_symbols): Remove the "read-file" element. * boot_script.h (boot_script_malloc, boot_script_free): Declare new functions that callers must define. * boot_script.c: All uses of malloc/free changed to use those instead. * userland-boot.c: New file. Defines them using malloc/free. * Makefile (SRCS, OBJS): Add it. * boot.c (boot_script_malloc, boot_script_free): Old cruft functions removed.
-rw-r--r--boot/userland-boot.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/boot/userland-boot.c b/boot/userland-boot.c
new file mode 100644
index 00000000..ed14d36a
--- /dev/null
+++ b/boot/userland-boot.c
@@ -0,0 +1,82 @@
+/* boot_script.c support functions for running in a Mach user task.
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ 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 2, 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <mach.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include "boot_script.h"
+
+void *
+boot_script_malloc (size_t size)
+{
+ return malloc (size);
+}
+
+void
+boot_script_free (void *ptr, size_t size)
+{
+ free (ptr);
+}
+
+
+int
+boot_script_task_create (struct cmd *cmd)
+{
+ error_t err = task_create (mach_task_self (), 0, &cmd->task);
+ if (err)
+ {
+ error (0, err, "%s: task_create", cmd->path);
+ return BOOT_SCRIPT_MACH_ERROR;
+ }
+ return 0;
+}
+
+int
+boot_script_task_resume (struct cmd *cmd)
+{
+ error_t err = task_resume (cmd->task);
+ if (err)
+ {
+ error (0, err, "%s: task_resume", cmd->path);
+ return BOOT_SCRIPT_MACH_ERROR;
+ }
+ return 0;
+}
+
+int
+boot_script_prompt_task_resume (struct cmd *cmd)
+{
+ char xx[5];
+
+ printf ("Hit return to resume %s...", cmd->path);
+ fgets (xx, sizeof xx, stdin);
+
+ return boot_script_task_resume (cmd);
+}
+
+void
+boot_script_free_task (task_t task, int aborting)
+{
+ if (aborting)
+ task_terminate (task);
+ else
+ mach_port_deallocate (mach_task_self (), task);
+}