summaryrefslogtreecommitdiff
path: root/viengoos/sigma0.c
diff options
context:
space:
mode:
authorneal <neal>2007-11-16 13:35:00 +0000
committerneal <neal>2007-11-16 13:35:00 +0000
commite46ff816c662bc8b47dfc00bbe5501dbeffd93bb (patch)
tree16603b813cf7301b85b58f28217aa188825513d8 /viengoos/sigma0.c
parent17b21c229fe9756a2e9ec158b6bdf5c2ca9869a5 (diff)
2007-11-16 Neal H. Walfield <neal@gnu.org>
* viengoos/Makefile.am: New file based on ../wortel/Makefile.am. * viengoos/headers.m4: New file. * viengoos/config.m4: New file based on ../wortel/config.m4. * viengoos/viengoos.h: New file. * viengoos/viengoos.c: New file. * viengoos/activity.h: Likewise. * viengoos/activity.c: Likewise. * viengoos/as.h: Likewise. * viengoos/as.c: Likewise. * viengoos/cap-lookup.c: Likewise. * viengoos/cap.h: Likewise. * viengoos/cap.c: Likewise. * viengoos/thread.h: New file. * viengoos/thread.c: New file. * viengoos/object.h: New file. * viengoos/object.c: New file. * viengoos/rm.h: New file. * viengoos/server.c: New file. * viengoos/server.h: New file. * viengoos/zalloc.h: Copied from ../physmem. * viengoos/zalloc.c: Copied from ../physmem. Don't include "output.h". Include <hurd/stddef.h>. Change uses of min_page_size to PAGESIZE. * viengoos/memory.h: New file. * viengoos/memory.c: New file. * viengoos/sigma0.c: Copy from ../wortel. * viengoos/sigma0.h: Copy from ../wortel. Don't include "shutdown.h". Include <hurd/stddef.h>. * viengoos/bits.h: Likewise. * viengoos/panic.c: New file. * viengoos/debug.c: Likewise. * viengoos/debug.h: Likewise. * viengoos/boot-modules.h: Likewise. * viengoos/boot-modules.c: Likewise. * viengoos/elf.h: Copied from ../wortel. * viengoos/loader.c: New file based on ../wortel/loader.c. * viengoos/loader.h: New file. * viengoos/multiboot.h: Copied from Grub. * viengoos/mmap.c: New file based on ../physmem/mmap.c. * viengoos/malloc-wrap.c: New file based on ../physmem/malloc-wrap.c. * viengoos/malloc.c: Version 2.8.3 of Doug Lea's malloc.c. * viengoos/malloc.h: Version 2.8.3 of Doug Lea's malloc.h. * viengoos/ia32-cmain.c: New file based on ../wortel/ia32-cmain.c. * viengoos/ia32-crt0.S: Copied from ../wortel. (STACK_SIZE): Use a 16 page stack. * viengoos/ia32-output.c: Copied from ../wortel. * viengoos/ia32-shutdown.c: Likewise. * viengoos/output.h: New file based on ../wortel/output.h. Include <stdarg.h>. (cprintf): New definition. (output_debug): Don't define. (debug): Don't define. * viengoos/output.c: New file based on ../wortel/output.c. Don't include <stdlib.h>. (vprintf): New function. (printf): Implement in terms of vprintf. * viengoos/output-none.c: Copied from ../wortel. * viengoos/output-serial.c: Likewise. * viengoos/output-stdio.c: New file. * viengoos/output-vga.c: Copied from ../wortel. * viengoos/shutdown.h: New file based on ../wortel/shutdown.h. Don't include "output.h". (panic): Don't define. (shutdown): Rename from this... (shutdown_machine): ... to this. * viengoos/shutdown.c: New file based on ../wortel/shutdown.c. (reset) [_L4_TEST_ENVIRONMENT]: Call abort. (halt) [_L4_TEST_ENVIRONMENT]: Call abort. (shutdown): Rename from this... (shutdown_machine): ... to this. * viengoos/t-environment.h: New file based on ../libl4/tests/environment.h. Protect from multiple inclusion. Include <hurd/stddef.h>. Include <string.h>. Include <l4/stubs.h>. (program_name): New declaration. (check_nr): Don't assume that val1 and val2 are _L4_word_t, use typeof instead. (main): Call output_init. * viengoos/t-as.c: New file.
Diffstat (limited to 'viengoos/sigma0.c')
-rw-r--r--viengoos/sigma0.c148
1 files changed, 148 insertions, 0 deletions
diff --git a/viengoos/sigma0.c b/viengoos/sigma0.c
new file mode 100644
index 0000000..2a1973d
--- /dev/null
+++ b/viengoos/sigma0.c
@@ -0,0 +1,148 @@
+/* Client code for sigma0.
+ Copyright (C) 2003 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 Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <l4.h>
+
+#include <hurd/stddef.h>
+
+/* The thread ID of sigma0. */
+#define SIGMA0_TID (l4_global_id (l4_thread_user_base (), 1))
+
+/* The message label for the sigma0 request page operation. This is
+ -6 in the upper 24 bits. */
+#define SIGMA0_RPC (0xffa0)
+
+/* The message label for undocumented sigma0 operations. This is
+ -1001 in the upper 24 bits. */
+#define SIGMA0_EXT (0xc170)
+
+/* For undocumented operations, this is the meaning of the first
+ untyped word in the message (MR1). */
+#define SIGMA0_EXT_SET_VERBOSITY 1
+#define SIGMA0_EXT_DUMP_MEMORY 2
+
+/* Set the verbosity level in sigma0. The only levels used currently
+ are 1 to 3. Returns 0 on success, otherwise an IPC error code. */
+void
+sigma0_set_verbosity (l4_word_t level)
+{
+ l4_msg_t msg;
+ l4_msg_tag_t tag;
+
+ l4_msg_clear (msg);
+ l4_set_msg_label (msg, SIGMA0_EXT);
+ l4_msg_append_word (msg, SIGMA0_EXT_SET_VERBOSITY);
+ l4_msg_append_word (msg, level);
+ l4_msg_load (msg);
+ tag = l4_send (SIGMA0_TID);
+ if (l4_ipc_failed (tag))
+ panic ("%s: request failed during %s: %u", __func__,
+ l4_error_code () & 1 ? "receive" : "send",
+ (l4_error_code () >> 1) & 0x7);
+}
+
+
+/* Request a memory dump from sigma0. If WAIT is true, wait until the
+ dump is completed before continuing. */
+void
+sigma0_dump_memory (int wait)
+{
+ l4_msg_t msg;
+ l4_msg_tag_t tag;
+
+ l4_msg_clear (msg);
+ l4_set_msg_label (msg, SIGMA0_EXT);
+ l4_msg_append_word (msg, SIGMA0_EXT_DUMP_MEMORY);
+ l4_msg_append_word (msg, wait);
+ l4_msg_load (msg);
+ if (wait)
+ tag = l4_call (SIGMA0_TID);
+ else
+ tag = l4_send (SIGMA0_TID);
+ if (l4_ipc_failed (tag))
+ panic ("%s: request failed during %s: %u", __func__,
+ l4_error_code () & 1 ? "receive" : "send",
+ (l4_error_code () >> 1) & 0x7);
+}
+
+
+/* Request the fpage FPAGE from sigma0. */
+void
+sigma0_get_fpage (l4_fpage_t fpage)
+{
+ l4_msg_t msg;
+ l4_msg_tag_t tag;
+ l4_map_item_t map_item;
+
+ l4_accept (l4_map_grant_items (L4_COMPLETE_ADDRESS_SPACE));
+ l4_msg_clear (msg);
+ l4_set_msg_label (msg, SIGMA0_RPC);
+ l4_msg_append_word (msg, fpage);
+ l4_msg_append_word (msg, L4_DEFAULT_MEMORY);
+ l4_msg_load (msg);
+ tag = l4_call (SIGMA0_TID);
+ if (l4_ipc_failed (tag))
+ panic ("%s: request failed during %s: %u", __func__,
+ l4_error_code () & 1 ? "receive" : "send",
+ (l4_error_code () >> 1) & 0x7);
+ if (l4_untyped_words (tag) != 0 || l4_typed_words (tag) != 2)
+ panic ("%s: invalid format of sigma0 reply", __func__);
+ l4_msg_store (tag, msg);
+ l4_msg_get_map_item (msg, 0, &map_item);
+ if (l4_is_nil_fpage (l4_map_item_snd_fpage (map_item)))
+ panic ("%s: sigma0 rejected mapping", __func__);
+ if (l4_address (fpage) != l4_address (l4_map_item_snd_fpage (map_item)))
+ panic ("%s: sigma0 returned wrong address 0x%x (expected 0x%x)",
+ __func__, l4_address (l4_map_item_snd_fpage (map_item)),
+ l4_address (fpage));
+}
+
+
+/* Request an fpage of the size 2^SIZE from sigma0. The fpage will be
+ fully accessible. */
+l4_fpage_t
+sigma0_get_any (unsigned int size)
+{
+ l4_msg_t msg;
+ l4_msg_tag_t tag;
+ l4_map_item_t map_item;
+ l4_fpage_t fpage = l4_fpage_log2 (-1, size);
+
+ l4_accept (l4_map_grant_items (L4_COMPLETE_ADDRESS_SPACE));
+ l4_msg_clear (msg);
+ l4_set_msg_label (msg, SIGMA0_RPC);
+ l4_msg_append_word (msg, fpage);
+ l4_msg_append_word (msg, L4_DEFAULT_MEMORY);
+ l4_msg_load (msg);
+ tag = l4_call (SIGMA0_TID);
+ if (l4_ipc_failed (tag))
+ panic ("%s: request failed during %s: %u", __func__,
+ l4_error_code () & 1 ? "receive" : "send",
+ (l4_error_code () >> 1) & 0x7);
+ if (l4_untyped_words (tag) != 0
+ || l4_typed_words (tag) != 2)
+ panic ("%s: invalid format of sigma0 reply", __func__);
+ l4_msg_store (tag, msg);
+ l4_msg_get_map_item (msg, 0, &map_item);
+ return l4_map_item_snd_fpage (map_item);
+}