1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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 "anonymous.h"
#include "vm.h"
#include "priv.h"
/* Physmem's server thread. */
l4_thread_id_t physmem;
/* 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;
#define INIT(service) \
do \
{ \
void service##_system_init (void); \
service##_system_init (); \
} \
while (0)
/* Initialize the core. */
INIT (memory);
/* Initialize the system pagers. */
INIT (core);
INIT (hurd_anonymous);
/* Initialize the mapping database. */
INIT (map);
/* The mapping database is now bootstrapped. */
mm_init_done = 1;
/* Allocate a stack for the pager thread. */
err = core_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);
}
|