xref: /titanic_51/usr/src/boot/lib/libstand/zalloc_defs.h (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1*4a5d661aSToomas Soome /*
2*4a5d661aSToomas Soome  * This module derived from code donated to the FreeBSD Project by
3*4a5d661aSToomas Soome  * Matthew Dillon <dillon@backplane.com>
4*4a5d661aSToomas Soome  *
5*4a5d661aSToomas Soome  * Copyright (c) 1998 The FreeBSD Project
6*4a5d661aSToomas Soome  * All rights reserved.
7*4a5d661aSToomas Soome  *
8*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
9*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
10*4a5d661aSToomas Soome  * are met:
11*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
12*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
13*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
14*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
15*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
16*4a5d661aSToomas Soome  *
17*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*4a5d661aSToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*4a5d661aSToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*4a5d661aSToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*4a5d661aSToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*4a5d661aSToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*4a5d661aSToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*4a5d661aSToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*4a5d661aSToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*4a5d661aSToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*4a5d661aSToomas Soome  * SUCH DAMAGE.
28*4a5d661aSToomas Soome  *
29*4a5d661aSToomas Soome  * $FreeBSD$
30*4a5d661aSToomas Soome  */
31*4a5d661aSToomas Soome 
32*4a5d661aSToomas Soome /*
33*4a5d661aSToomas Soome  * DEFS.H
34*4a5d661aSToomas Soome  */
35*4a5d661aSToomas Soome 
36*4a5d661aSToomas Soome #define USEGUARD		/* use stard/end guard bytes */
37*4a5d661aSToomas Soome #define USEENDGUARD
38*4a5d661aSToomas Soome #define DMALLOCDEBUG		/* add debugging code to gather stats */
39*4a5d661aSToomas Soome #define ZALLOCDEBUG
40*4a5d661aSToomas Soome 
41*4a5d661aSToomas Soome #include <sys/stdint.h>
42*4a5d661aSToomas Soome #include "stand.h"
43*4a5d661aSToomas Soome #include "zalloc_mem.h"
44*4a5d661aSToomas Soome 
45*4a5d661aSToomas Soome #define Library extern
46*4a5d661aSToomas Soome 
47*4a5d661aSToomas Soome /*
48*4a5d661aSToomas Soome  * block extension for sbrk()
49*4a5d661aSToomas Soome  */
50*4a5d661aSToomas Soome 
51*4a5d661aSToomas Soome #define BLKEXTEND	(4 * 1024)
52*4a5d661aSToomas Soome #define BLKEXTENDMASK	(BLKEXTEND - 1)
53*4a5d661aSToomas Soome 
54*4a5d661aSToomas Soome /*
55*4a5d661aSToomas Soome  * Required malloc alignment.
56*4a5d661aSToomas Soome  *
57*4a5d661aSToomas Soome  * Embedded platforms using the u-boot API drivers require that all I/O buffers
58*4a5d661aSToomas Soome  * be on a cache line sized boundary.  The worst case size for that is 64 bytes.
59*4a5d661aSToomas Soome  * For other platforms, 16 bytes works fine.  The alignment also must be at
60*4a5d661aSToomas Soome  * least sizeof(struct MemNode); this is asserted in zalloc.c.
61*4a5d661aSToomas Soome  */
62*4a5d661aSToomas Soome 
63*4a5d661aSToomas Soome #if defined(__arm__) || defined(__mips__) || defined(__powerpc__)
64*4a5d661aSToomas Soome #define	MALLOCALIGN		64
65*4a5d661aSToomas Soome #else
66*4a5d661aSToomas Soome #define	MALLOCALIGN		16
67*4a5d661aSToomas Soome #endif
68*4a5d661aSToomas Soome #define	MALLOCALIGN_MASK	(MALLOCALIGN - 1)
69*4a5d661aSToomas Soome 
70*4a5d661aSToomas Soome typedef struct Guard {
71*4a5d661aSToomas Soome     size_t	ga_Bytes;
72*4a5d661aSToomas Soome     size_t	ga_Magic;	/* must be at least 32 bits */
73*4a5d661aSToomas Soome } Guard;
74*4a5d661aSToomas Soome 
75*4a5d661aSToomas Soome #define GAMAGIC		0x55FF44FD
76*4a5d661aSToomas Soome #define GAFREE		0x5F54F4DF
77*4a5d661aSToomas Soome 
78*4a5d661aSToomas Soome #include "zalloc_protos.h"
79