Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cvmx-bootmem.h
Go to the documentation of this file.
1 /***********************license start***************
2  * Author: Cavium Networks
3  *
4  * Contact: [email protected]
5  * This file is part of the OCTEON SDK
6  *
7  * Copyright (c) 2003-2008 Cavium Networks
8  *
9  * This file is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License, Version 2, as
11  * published by the Free Software Foundation.
12  *
13  * This file is distributed in the hope that it will be useful, but
14  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16  * NONINFRINGEMENT. See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this file; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  * or visit http://www.gnu.org/licenses/.
23  *
24  * This file may also be available under a different license from Cavium.
25  * Contact Cavium Networks for more information
26  ***********************license end**************************************/
27 
28 /*
29  * Simple allocate only memory allocator. Used to allocate memory at
30  * application start time.
31  */
32 
33 #ifndef __CVMX_BOOTMEM_H__
34 #define __CVMX_BOOTMEM_H__
35 /* Must be multiple of 8, changing breaks ABI */
36 #define CVMX_BOOTMEM_NAME_LEN 128
37 
38 /* Can change without breaking ABI */
39 #define CVMX_BOOTMEM_NUM_NAMED_BLOCKS 64
40 
41 /* minimum alignment of bootmem alloced blocks */
42 #define CVMX_BOOTMEM_ALIGNMENT_SIZE (16ull)
43 
44 /* Flags for cvmx_bootmem_phy_mem* functions */
45 /* Allocate from end of block instead of beginning */
46 #define CVMX_BOOTMEM_FLAG_END_ALLOC (1 << 0)
47 
48 /* Don't do any locking. */
49 #define CVMX_BOOTMEM_FLAG_NO_LOCKING (1 << 1)
50 
51 /* First bytes of each free physical block of memory contain this structure,
52  * which is used to maintain the free memory list. Since the bootloader is
53  * only 32 bits, there is a union providing 64 and 32 bit versions. The
54  * application init code converts addresses to 64 bit addresses before the
55  * application starts.
56  */
58  /*
59  * Note: these are referenced from assembly routines in the
60  * bootloader, so this structure should not be changed
61  * without changing those routines as well.
62  */
65 
66 };
67 
68 /*
69  * Structure for named memory blocks. Number of descriptors available
70  * can be changed without affecting compatibility, but name length
71  * changes require a bump in the bootmem descriptor version Note: This
72  * structure must be naturally 64 bit aligned, as a single memory
73  * image will be used by both 32 and 64 bit programs.
74  */
76  /* Base address of named block */
78  /*
79  * Size actually allocated for named block (may differ from
80  * requested).
81  */
83  /* name of named block */
85 };
86 
87 /* Current descriptor versions */
88 /* CVMX bootmem descriptor major version */
89 #define CVMX_BOOTMEM_DESC_MAJ_VER 3
90 
91 /* CVMX bootmem descriptor minor version */
92 #define CVMX_BOOTMEM_DESC_MIN_VER 0
93 
94 /* First three members of cvmx_bootmem_desc_t are left in original
95  * positions for backwards compatibility.
96  */
98  /* spinlock to control access to list */
100  /* flags for indicating various conditions */
103 
104  /* Incremented when incompatible changes made */
106 
107  /*
108  * Incremented changed when compatible changes made, reset to
109  * zero when major incremented.
110  */
112 
115 
116  /* number of elements in named blocks array */
118 
119  /* length of name array in bootmem blocks */
121  /* address of named memory block descriptors */
123 
124 };
125 
132 extern int cvmx_bootmem_init(void *mem_desc_ptr);
133 
145 
161 
176  uint64_t min_addr, uint64_t max_addr);
177 
201  char *name);
202 
203 
204 
220  char *name);
221 
222 
223 
241  uint64_t max_addr, uint64_t align,
242  char *name);
243 
244 extern int cvmx_bootmem_free_named(char *name);
245 
255 
280 int64_t cvmx_bootmem_phy_alloc(uint64_t req_size, uint64_t address_min,
281  uint64_t address_max, uint64_t alignment,
282  uint32_t flags);
283 
307  uint64_t max_addr,
309  char *name, uint32_t flags);
310 
326 
337 
356 
363 void cvmx_bootmem_lock(void);
364 
371 void cvmx_bootmem_unlock(void);
372 
373 #endif /* __CVMX_BOOTMEM_H__ */