summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpager/Makefile2
-rw-r--r--libpager/chg-compl.c10
-rw-r--r--libpager/data-request.c10
-rw-r--r--libpager/data-return.c13
-rw-r--r--libpager/data-unlock.c8
-rw-r--r--libpager/lock-completed.c8
-rw-r--r--libpager/mig-decls.h42
-rw-r--r--libpager/mig-mutate.h22
-rw-r--r--libpager/object-init.c9
-rw-r--r--libpager/object-terminate.c9
-rw-r--r--libpager/priv.h1
-rw-r--r--libpager/seqnos.c14
-rw-r--r--libpager/stubs.c12
13 files changed, 108 insertions, 52 deletions
diff --git a/libpager/Makefile b/libpager/Makefile
index 7c4da38e..b6222950 100644
--- a/libpager/Makefile
+++ b/libpager/Makefile
@@ -31,7 +31,7 @@ HURDLIBS= ports
LDLIBS += -lpthread
OBJS = $(SRCS:.c=.o) memory_objectServer.o notifyServer.o
-MIGSFLAGS = -DSEQNOS
+MIGSFLAGS = -DSEQNOS -imacros $(srcdir)/mig-mutate.h
MIGCOMSFLAGS = -prefix _pager_
include ../Makeconf
diff --git a/libpager/chg-compl.c b/libpager/chg-compl.c
index 0b0c99c2..d77c46cf 100644
--- a/libpager/chg-compl.c
+++ b/libpager/chg-compl.c
@@ -22,16 +22,15 @@
when a memory_object_change_attributes call has completed. Read this
in combination with pager-attr.c. */
kern_return_t
-_pager_seqnos_memory_object_change_completed (mach_port_t obj,
+_pager_seqnos_memory_object_change_completed (struct pager *p,
mach_port_seqno_t seq,
boolean_t maycache,
memory_object_copy_strategy_t strat)
{
- struct pager *p;
struct attribute_request *ar;
-
- p = ports_lookup_port (0, obj, _pager_class);
- if (!p)
+
+ if (!p
+ || p->port.class != _pager_class)
{
printf ("Bad change completed\n");
return EOPNOTSUPP;
@@ -50,6 +49,5 @@ _pager_seqnos_memory_object_change_completed (mach_port_t obj,
_pager_release_seqno (p, seq);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
}
diff --git a/libpager/data-request.c b/libpager/data-request.c
index 34b8b438..82ce9041 100644
--- a/libpager/data-request.c
+++ b/libpager/data-request.c
@@ -22,22 +22,21 @@
/* Implement pagein callback as described in <mach/memory_object.defs>. */
kern_return_t
-_pager_seqnos_memory_object_data_request (mach_port_t object,
+_pager_seqnos_memory_object_data_request (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
vm_offset_t offset,
vm_size_t length,
vm_prot_t access)
{
- struct pager *p;
short *pm_entry;
int doread, doerror;
error_t err;
vm_address_t page;
int write_lock;
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
/* Acquire the right to meddle with the pagemap */
@@ -126,7 +125,6 @@ _pager_seqnos_memory_object_data_request (mach_port_t object,
_pager_mark_object_error (p, offset, length, 0);
_pager_allow_termination (p);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
error_read:
@@ -136,7 +134,6 @@ _pager_seqnos_memory_object_data_request (mach_port_t object,
pthread_mutex_lock (&p->interlock);
_pager_allow_termination (p);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
allow_release_out:
@@ -144,6 +141,5 @@ _pager_seqnos_memory_object_data_request (mach_port_t object,
release_out:
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
}
diff --git a/libpager/data-return.c b/libpager/data-return.c
index 6a3b9037..ee6c6e83 100644
--- a/libpager/data-return.c
+++ b/libpager/data-return.c
@@ -26,7 +26,7 @@
as for _pager_seqnos_memory_object_data_return; the additional
INITIALIZING arg identifies which function is calling us. */
kern_return_t
-_pager_do_write_request (mach_port_t object,
+_pager_do_write_request (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
vm_offset_t offset,
@@ -36,7 +36,6 @@ _pager_do_write_request (mach_port_t object,
int kcopy,
int initializing)
{
- struct pager *p;
short *pm_entries;
int npages, i;
char *notified;
@@ -47,8 +46,8 @@ _pager_do_write_request (mach_port_t object,
int wakeup;
int omitdata = 0;
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
/* Acquire the right to meddle with the pagemap */
@@ -249,19 +248,17 @@ _pager_do_write_request (mach_port_t object,
}
}
- ports_port_deref (p);
return 0;
release_out:
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
}
/* Implement pageout call back as described by <mach/memory_object.defs>. */
kern_return_t
-_pager_seqnos_memory_object_data_return (mach_port_t object,
+_pager_seqnos_memory_object_data_return (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
vm_offset_t offset,
@@ -270,6 +267,6 @@ _pager_seqnos_memory_object_data_return (mach_port_t object,
int dirty,
int kcopy)
{
- return _pager_do_write_request (object, seqno, control, offset, data,
+ return _pager_do_write_request (p, seqno, control, offset, data,
length, dirty, kcopy, 0);
}
diff --git a/libpager/data-unlock.c b/libpager/data-unlock.c
index 02339abb..599237c1 100644
--- a/libpager/data-unlock.c
+++ b/libpager/data-unlock.c
@@ -22,18 +22,17 @@
/* Implement kernel requests for access as described in
<mach/memory_object.defs>. */
kern_return_t
-_pager_seqnos_memory_object_data_unlock (mach_port_t object,
+_pager_seqnos_memory_object_data_unlock (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
vm_offset_t offset,
vm_size_t length,
vm_prot_t access)
{
- struct pager *p;
volatile int err;
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
pthread_mutex_lock (&p->interlock);
@@ -84,6 +83,5 @@ _pager_seqnos_memory_object_data_unlock (mach_port_t object,
_pager_mark_next_request_error (p, offset, length, err);
}
out:
- ports_port_deref (p);
return 0;
}
diff --git a/libpager/lock-completed.c b/libpager/lock-completed.c
index 9ab640fe..a3f3f168 100644
--- a/libpager/lock-completed.c
+++ b/libpager/lock-completed.c
@@ -23,18 +23,17 @@
when a memory_object_lock_request call has completed. Read this
in combination with lock-object.c. */
kern_return_t
-_pager_seqnos_memory_object_lock_completed (mach_port_t object,
+_pager_seqnos_memory_object_lock_completed (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
vm_offset_t offset,
vm_size_t length)
{
error_t err = 0;
- struct pager *p;
struct lock_request *lr;
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
pthread_mutex_lock (&p->interlock);
@@ -62,7 +61,6 @@ _pager_seqnos_memory_object_lock_completed (mach_port_t object,
out:
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return err;
}
diff --git a/libpager/mig-decls.h b/libpager/mig-decls.h
new file mode 100644
index 00000000..0c7b402f
--- /dev/null
+++ b/libpager/mig-decls.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ 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. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef __LIBPAGER_MIG_DECLS_H__
+#define __LIBPAGER_MIG_DECLS_H__
+
+#include "priv.h"
+
+typedef struct pager *pager_t;
+
+/* Called by server stub functions. */
+
+static inline struct pager * __attribute__ ((unused))
+begin_using_pager (mach_port_t port)
+{
+ return ports_lookup_port (0, port, _pager_class);
+}
+
+static inline void __attribute__ ((unused))
+end_using_pager (struct pager *p)
+{
+ if (p)
+ ports_port_deref (p);
+}
+
+#endif /* __LIBPAGER_MIG_DECLS_H__ */
diff --git a/libpager/mig-mutate.h b/libpager/mig-mutate.h
new file mode 100644
index 00000000..54f7de8b
--- /dev/null
+++ b/libpager/mig-mutate.h
@@ -0,0 +1,22 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ 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. If not, see <http://www.gnu.org/licenses/>. */
+
+#define MEMORY_OBJECT_INTRAN pager_t begin_using_pager (memory_object_t)
+#define MEMORY_OBJECT_DESTRUCTOR end_using_pager (pager_t)
+#define MEMORY_OBJECT_IMPORTS import "mig-decls.h";
diff --git a/libpager/object-init.c b/libpager/object-init.c
index 90ffc016..6683e24d 100644
--- a/libpager/object-init.c
+++ b/libpager/object-init.c
@@ -22,16 +22,14 @@
/* Implement the object initialiation call as described in
<mach/memory_object.defs>. */
kern_return_t
-_pager_seqnos_memory_object_init (mach_port_t object,
+_pager_seqnos_memory_object_init (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
mach_port_t name,
vm_size_t pagesize)
{
- struct pager *p;
-
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
pthread_mutex_lock (&p->interlock);
@@ -73,7 +71,6 @@ _pager_seqnos_memory_object_init (mach_port_t object,
out:
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
}
diff --git a/libpager/object-terminate.c b/libpager/object-terminate.c
index 896e2c20..365ba275 100644
--- a/libpager/object-terminate.c
+++ b/libpager/object-terminate.c
@@ -22,15 +22,13 @@
/* Implement the object termination call from the kernel as described
in <mach/memory_object.defs>. */
kern_return_t
-_pager_seqnos_memory_object_terminate (mach_port_t object,
+_pager_seqnos_memory_object_terminate (struct pager *p,
mach_port_seqno_t seqno,
mach_port_t control,
mach_port_t name)
{
- struct pager *p;
-
- p = ports_lookup_port (0, object, _pager_class);
- if (!p)
+ if (!p
+ || p->port.class != _pager_class)
return EOPNOTSUPP;
pthread_mutex_lock (&p->interlock);
@@ -79,7 +77,6 @@ _pager_seqnos_memory_object_terminate (mach_port_t object,
out:
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
- ports_port_deref (p);
return 0;
}
diff --git a/libpager/priv.h b/libpager/priv.h
index 7aa0fb44..d49cbb9d 100644
--- a/libpager/priv.h
+++ b/libpager/priv.h
@@ -139,6 +139,7 @@ struct port_class *_pager_class;
void _pager_wait_for_seqno (struct pager *, mach_port_seqno_t);
void _pager_release_seqno (struct pager *, mach_port_seqno_t);
void _pager_update_seqno (mach_port_t, mach_port_seqno_t);
+void _pager_update_seqno_p (struct pager *, mach_port_seqno_t);
void _pager_block_termination (struct pager *);
void _pager_allow_termination (struct pager *);
error_t _pager_pagemap_resize (struct pager *, vm_address_t);
diff --git a/libpager/seqnos.c b/libpager/seqnos.c
index 77bfbf21..cab2f33d 100644
--- a/libpager/seqnos.c
+++ b/libpager/seqnos.c
@@ -57,13 +57,23 @@ _pager_update_seqno (mach_port_t object,
struct pager *p;
p = ports_lookup_port (0, object, _pager_class);
+ _pager_update_seqno_p (p, seqno);
if (p)
+ ports_port_deref (p);
+}
+
+
+/* Just update the seqno, pointer version. */
+void
+_pager_update_seqno_p (struct pager *p,
+ mach_port_seqno_t seqno)
+{
+ if (p
+ && p->port.class == _pager_class)
{
pthread_mutex_lock (&p->interlock);
_pager_wait_for_seqno (p, seqno);
_pager_release_seqno (p, seqno);
pthread_mutex_unlock (&p->interlock);
-
- ports_port_deref (p);
}
}
diff --git a/libpager/stubs.c b/libpager/stubs.c
index 84782120..411f4839 100644
--- a/libpager/stubs.c
+++ b/libpager/stubs.c
@@ -21,7 +21,7 @@
#include <stdio.h>
kern_return_t
-_pager_seqnos_memory_object_copy (mach_port_t obj,
+_pager_seqnos_memory_object_copy (struct pager *p,
mach_port_seqno_t seq,
memory_object_control_t obj_ctl,
vm_offset_t off,
@@ -30,13 +30,13 @@ _pager_seqnos_memory_object_copy (mach_port_t obj,
{
printf ("m_o_copy called\n");
- _pager_update_seqno (obj, seq);
+ _pager_update_seqno_p (p, seq);
return EOPNOTSUPP;
}
kern_return_t
-_pager_seqnos_memory_object_data_write (mach_port_t obj,
+_pager_seqnos_memory_object_data_write (struct pager *p,
mach_port_seqno_t seq,
mach_port_t ctl,
vm_offset_t off,
@@ -45,13 +45,13 @@ _pager_seqnos_memory_object_data_write (mach_port_t obj,
{
printf ("m_o_data_write called\n");
- _pager_update_seqno (obj, seq);
+ _pager_update_seqno_p (p, seq);
return EOPNOTSUPP;
}
kern_return_t
-_pager_seqnos_memory_object_supply_completed (mach_port_t obj,
+_pager_seqnos_memory_object_supply_completed (struct pager *p,
mach_port_seqno_t seq,
mach_port_t ctl,
vm_offset_t off,
@@ -61,7 +61,7 @@ _pager_seqnos_memory_object_supply_completed (mach_port_t obj,
{
printf ("m_o_supply_completed called\n");
- _pager_update_seqno (obj, seq);
+ _pager_update_seqno_p (p, seq);
return EOPNOTSUPP;
}