diff options
author | neal <neal> | 2005-01-11 18:15:26 +0000 |
---|---|---|
committer | neal <neal> | 2005-01-11 18:15:26 +0000 |
commit | fbb89a288be9c833121e8688f7f78788b8261e44 (patch) | |
tree | 1077de6e34905777233545d9ba456be413b98d60 /libhurd-mm/mm-init.c | |
parent | 06128810fef55354f16ad628bac03acac4f964f8 (diff) |
/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* libhurd-mm: New directory.
* Makefile.am (SUBDIRS): Add libhurd-mm.
* configure.ac: Add include for libhurd-mm/headers.m4.
(AC_CONFIG_FILES): Add libhurd-mm/Makefile.
deva/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* Makefile.am (deva_SOURCES): Remove physmem-user.h and
physmem-user.c.
(deva_LDADD): Add ../libhurd-btree/libhurd-btree.a and
../libhurd-mm/libhurd-mm.a.
* ia32-cmain.c: Include <hurd/mm.h>.
(pager_tid): New global variable.
(cmain): Allocate a thread that the memory management subsystem
can use as the pager thread. Call hurd_mm_init. Set the
PAGER_TID as the current thread's pager.
* mmap.c: Rewrite to use new interfaces.
* physmem-user.h: Remove obsolete file.
* physmem-user.c: Likewise.
libhurd-mm/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* Makefile.am: Initial check in.
* README: Likewise.
* frame.c: Likewise.
* headers.m4: Likewise.
* map.c: Likewise.
* mm-init.c: Likewise.
* mm.h: Likewise.
* pager.c: Likewise.
* physmem-user.c: Likewise.
* physmem-user.h: Likewise.
* priv.h: Likewise.
* vm.c: Likewise.
* vm.h: Likewise.
physmem/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* Makefile.am (physmem_SOURCES): Add frame-entry.c and frame.c
(physmem_LDADD): Add ../libhurd-btree/libhurd-btree.a.
* frame-entry.c: New file.
* frame.c: New file.
* README: Rewrite.
* container.c: Likewise.
* physmem.h: Likewise.
* physmem.c (create_bootstrap_caps): Change container_t to struct
container *.
task/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* Makefile.am (task_SOURCES): Remove physmem-user.h and
physmem-user.c.
(task_LDADD): Add ../libhurd-btree/libhurd-btree.a and
../libhurd-mm/libhurd-mm.a.
* ia32-cmain.c: Include <hurd/mm.h>.
(pager_tid): New global variable.
(cmain): Allocate a thread that the memory management subsystem
can use as the pager thread. Call hurd_mm_init. Set the
PAGER_TID as the current thread's pager.
* mmap.c: Rewrite to use new interfaces.
* physmem-user.h: Remove obsolete file.
* physmem-user.c: Likewise.
wortel/
2005-01-11 Neal H. Walfield <neal@gnu.org>
* startup.c (physmem_map): Rename . . .
(allocate): . . . to this. Rewrite it.
(map): New function.
(cmain): Call map, not physmem_map.
* wortel.c (setup_components): Allocate an extra thread for the
task server.
(start_elf): Update assert.
Diffstat (limited to 'libhurd-mm/mm-init.c')
-rw-r--r-- | libhurd-mm/mm-init.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/libhurd-mm/mm-init.c b/libhurd-mm/mm-init.c new file mode 100644 index 0000000..7abac2e --- /dev/null +++ b/libhurd-mm/mm-init.c @@ -0,0 +1,94 @@ +/* mm-init.h - Memory management initialization. + Copyright (C) 2004, 2005 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 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 the GNU Hurd; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, + USA. */ + +#if HAVE_CONFIG_H +#include <config.h> +#endif + +#include <assert.h> +#include <errno.h> +#include <stdbool.h> +#include <l4.h> +#include <hurd/startup.h> + +#include "mm.h" +#include "vm.h" + +#include "priv.h" + +/* Physmem's server thread. */ +l4_thread_id_t physmem; + +/* By default, we allocate all anonymous memory in this container. */ +hurd_pm_container_t default_container; + +/* True once the MM is up and running. */ +int mm_init_done; + +/* Initialized by the machine-specific startup-code. */ +extern struct hurd_startup_data *__hurd_startup_data; + +/* Initialize the memory management subsystem. */ +void +hurd_mm_init (l4_thread_id_t pager_tid) +{ + error_t err; + uintptr_t stack; + + /* FIXME: The image server may not be (and will likely not be) + physmem. */ + physmem = __hurd_startup_data->image.server; + + /* Create the primary anonymous memory container. */ + /* FIXME: We use the image cap handle as the memory control object. + This is wrong. */ + err = hurd_pm_container_create (__hurd_startup_data->image.cap_handle, + &default_container); + assert_perror (err); + + swap_store.server = physmem; + swap_store.handle = default_container; + hurd_btree_frame_tree_init (&swap_store.frames); + + /* Initialize the mapping database. */ + map_init (); + + /* The mapping database is now bootstrapped. */ + mm_init_done = 1; + + /* Allocate a stack for the pager thread. */ + err = hurd_vm_allocate (&stack, getpagesize (), 0, 1); + if (err) + panic ("Unable to allocate a stack for the pager thread.\n"); + + /* Start it up. */ + l4_start_sp_ip (pager_tid, stack + getpagesize (), (l4_word_t) pager); + + /* XXX: EVIL. If a thread causes a page fault before its pager is + waiting for faults, the pager will not get the correct message + contents. This is an evil work around to make sure that the + pager is up before we return. */ + int i; + for (i = 0; i < 100; i ++) + l4_yield (); + + l4_set_pager (pager_tid); +} |