xref: /freebsd/sys/kern/subr_early.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
1*c9964045SMateusz Guzik /*-
2*c9964045SMateusz Guzik  * Copyright (c) 2018 The FreeBSD Foundation
3*c9964045SMateusz Guzik  *
4*c9964045SMateusz Guzik  * This software was developed by Mateusz Guzik <mjg@FreeBSD.org>
5*c9964045SMateusz Guzik  * under sponsorship from the FreeBSD Foundation.
6*c9964045SMateusz Guzik  *
7*c9964045SMateusz Guzik  * Redistribution and use in source and binary forms, with or without
8*c9964045SMateusz Guzik  * modification, are permitted provided that the following conditions
9*c9964045SMateusz Guzik  * are met:
10*c9964045SMateusz Guzik  * 1. Redistributions of source code must retain the above copyright
11*c9964045SMateusz Guzik  *    notice, this list of conditions and the following disclaimer.
12*c9964045SMateusz Guzik  * 2. Redistributions in binary form must reproduce the above copyright
13*c9964045SMateusz Guzik  *    notice, this list of conditions and the following disclaimer in the
14*c9964045SMateusz Guzik  *    documentation and/or other materials provided with the distribution.
15*c9964045SMateusz Guzik  *
16*c9964045SMateusz Guzik  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*c9964045SMateusz Guzik  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*c9964045SMateusz Guzik  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*c9964045SMateusz Guzik  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*c9964045SMateusz Guzik  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*c9964045SMateusz Guzik  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*c9964045SMateusz Guzik  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*c9964045SMateusz Guzik  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*c9964045SMateusz Guzik  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*c9964045SMateusz Guzik  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*c9964045SMateusz Guzik  * SUCH DAMAGE.
27*c9964045SMateusz Guzik  */
28*c9964045SMateusz Guzik 
29*c9964045SMateusz Guzik #include <sys/param.h>
30*c9964045SMateusz Guzik #include <sys/types.h>
31*c9964045SMateusz Guzik #include <sys/systm.h>
32*c9964045SMateusz Guzik #include <machine/cpu.h>
33*c9964045SMateusz Guzik 
34*c9964045SMateusz Guzik #ifndef	MEMSET_EARLY_FUNC
35*c9964045SMateusz Guzik #define	MEMSET_EARLY_FUNC	memset
36*c9964045SMateusz Guzik #else
37*c9964045SMateusz Guzik void *MEMSET_EARLY_FUNC(void *, int, size_t);
38*c9964045SMateusz Guzik #endif
39*c9964045SMateusz Guzik 
40*c9964045SMateusz Guzik void *
memset_early(void * buf,int c,size_t len)41*c9964045SMateusz Guzik memset_early(void *buf, int c, size_t len)
42*c9964045SMateusz Guzik {
43*c9964045SMateusz Guzik 
44*c9964045SMateusz Guzik 	return (MEMSET_EARLY_FUNC(buf, c, len));
45*c9964045SMateusz Guzik }
46*c9964045SMateusz Guzik 
47*c9964045SMateusz Guzik #ifndef	MEMCPY_EARLY_FUNC
48*c9964045SMateusz Guzik #define	MEMCPY_EARLY_FUNC	memcpy
49*c9964045SMateusz Guzik #else
50*c9964045SMateusz Guzik void *MEMCPY_EARLY_FUNC(void *, const void *, size_t);
51*c9964045SMateusz Guzik #endif
52*c9964045SMateusz Guzik 
53*c9964045SMateusz Guzik void *
memcpy_early(void * to,const void * from,size_t len)54*c9964045SMateusz Guzik memcpy_early(void *to, const void *from, size_t len)
55*c9964045SMateusz Guzik {
56*c9964045SMateusz Guzik 
57*c9964045SMateusz Guzik 	return (MEMCPY_EARLY_FUNC(to, from, len));
58*c9964045SMateusz Guzik }
59*c9964045SMateusz Guzik 
60*c9964045SMateusz Guzik #ifndef	MEMMOVE_EARLY_FUNC
61*c9964045SMateusz Guzik #define	MEMMOVE_EARLY_FUNC	memmove
62*c9964045SMateusz Guzik #else
63*c9964045SMateusz Guzik void *MEMMOVE_EARLY_FUNC(void *, const void *, size_t);
64*c9964045SMateusz Guzik #endif
65*c9964045SMateusz Guzik 
66*c9964045SMateusz Guzik void *
memmove_early(void * to,const void * from,size_t len)67*c9964045SMateusz Guzik memmove_early(void *to, const void *from, size_t len)
68*c9964045SMateusz Guzik {
69*c9964045SMateusz Guzik 
70*c9964045SMateusz Guzik 	return (MEMMOVE_EARLY_FUNC(to, from, len));
71*c9964045SMateusz Guzik }
72