xref: /freebsd/sys/compat/linux/linux_vdso.h (revision 9931033bbfbe56a037723638cf3712366c6d943f)
1bdc37934SDmitry Chagin /*-
2bdc37934SDmitry Chagin  * Copyright (c) 2013 Dmitry Chagin
3bdc37934SDmitry Chagin  * All rights reserved.
4bdc37934SDmitry Chagin  *
5bdc37934SDmitry Chagin  * Redistribution and use in source and binary forms, with or without
6bdc37934SDmitry Chagin  * modification, are permitted provided that the following conditions
7bdc37934SDmitry Chagin  * are met:
8bdc37934SDmitry Chagin  * 1. Redistributions of source code must retain the above copyright
9bdc37934SDmitry Chagin  *    notice, this list of conditions and the following disclaimer
10bdc37934SDmitry Chagin  *    in this position and unchanged.
11bdc37934SDmitry Chagin  * 2. Redistributions in binary form must reproduce the above copyright
12bdc37934SDmitry Chagin  *    notice, this list of conditions and the following disclaimer in the
13bdc37934SDmitry Chagin  *    documentation and/or other materials provided with the distribution.
14bdc37934SDmitry Chagin  *
15bdc37934SDmitry Chagin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16bdc37934SDmitry Chagin  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17bdc37934SDmitry Chagin  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18bdc37934SDmitry Chagin  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19bdc37934SDmitry Chagin  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20bdc37934SDmitry Chagin  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21bdc37934SDmitry Chagin  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22bdc37934SDmitry Chagin  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23bdc37934SDmitry Chagin  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24bdc37934SDmitry Chagin  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25bdc37934SDmitry Chagin  *
26bdc37934SDmitry Chagin  * $FreeBSD$
27bdc37934SDmitry Chagin  */
28bdc37934SDmitry Chagin 
29bdc37934SDmitry Chagin #ifndef _LINUX_VDSO_H_
30bdc37934SDmitry Chagin #define	_LINUX_VDSO_H_
31bdc37934SDmitry Chagin 
32bdc37934SDmitry Chagin #include <sys/types.h>
33bdc37934SDmitry Chagin 
34bdc37934SDmitry Chagin struct linux_vdso_sym {
35bdc37934SDmitry Chagin 	SLIST_ENTRY(linux_vdso_sym) sym;
36bdc37934SDmitry Chagin 	uint32_t	size;
37bdc37934SDmitry Chagin 	uintptr_t *	ptr;
38bdc37934SDmitry Chagin 	char		symname[];
39bdc37934SDmitry Chagin };
40bdc37934SDmitry Chagin 
41*9931033bSDmitry Chagin vm_object_t __elfN(linux_shared_page_init)(char **, vm_size_t);
42*9931033bSDmitry Chagin void	__elfN(linux_shared_page_fini)(vm_object_t, void *, vm_size_t);
43*9931033bSDmitry Chagin void	__elfN(linux_vdso_fixup)(char *, vm_offset_t);
44bdc37934SDmitry Chagin void	__elfN(linux_vdso_sym_init)(struct linux_vdso_sym *);
45bdc37934SDmitry Chagin 
46*9931033bSDmitry Chagin int	linux_map_vdso(struct proc *, vm_object_t, vm_offset_t,
47*9931033bSDmitry Chagin 	    vm_offset_t, struct image_params *);
48*9931033bSDmitry Chagin 
49bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_INTPTR(name)				\
50bdc37934SDmitry Chagin uintptr_t name;							\
51bdc37934SDmitry Chagin LINUX_VDSO_SYM_DEFINE(name)
52bdc37934SDmitry Chagin 
53bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_CHAR(name)				\
54bdc37934SDmitry Chagin const char * name;						\
55bdc37934SDmitry Chagin LINUX_VDSO_SYM_DEFINE(name)
56bdc37934SDmitry Chagin 
57bdc37934SDmitry Chagin #define	LINUX_VDSO_SYM_DEFINE(name)				\
58bdc37934SDmitry Chagin static struct linux_vdso_sym name ## sym = {			\
59bdc37934SDmitry Chagin 	.symname	= #name,				\
60bdc37934SDmitry Chagin 	.size		= sizeof(#name),			\
61bdc37934SDmitry Chagin 	.ptr		= (uintptr_t *)&name			\
62bdc37934SDmitry Chagin };								\
63bdc37934SDmitry Chagin SYSINIT(__elfN(name ## _sym_init), SI_SUB_EXEC,			\
64bdc37934SDmitry Chagin     SI_ORDER_FIRST, __elfN(linux_vdso_sym_init), &name ## sym);	\
65bdc37934SDmitry Chagin struct __hack
66bdc37934SDmitry Chagin 
67bdc37934SDmitry Chagin #endif	/* _LINUX_VDSO_H_ */
68