Deleted Added
full compact
cvmx-bootmem.h (210286) cvmx-bootmem.h (215990)
1/***********************license start***************
1/***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3 * reserved.
2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights
3 * reserved.
4 *
5 *
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22 *
23 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33 *
34 *
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
36 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
26 * countries.
27
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
37 ***********************license end**************************************/
38
39
40
41
42
38 ***********************license end**************************************/
39
40
41
42
43
44
43/**
44 * @file
45 * Simple allocate only memory allocator. Used to allocate memory at application
46 * start time.
47 *
45/**
46 * @file
47 * Simple allocate only memory allocator. Used to allocate memory at application
48 * start time.
49 *
48 * <hr>$Revision: 41586 $<hr>
50 * <hr>$Revision: 49448 $<hr>
49 *
50 */
51
52#ifndef __CVMX_BOOTMEM_H__
53#define __CVMX_BOOTMEM_H__
54
55#ifdef __cplusplus
56extern "C" {

--- 27 unchanged lines hidden (view full) ---

84/* Structure for named memory blocks
85** Number of descriptors
86** available can be changed without affecting compatiblity,
87** but name length changes require a bump in the bootmem
88** descriptor version
89** Note: This structure must be naturally 64 bit aligned, as a single
90** memory image will be used by both 32 and 64 bit programs.
91*/
51 *
52 */
53
54#ifndef __CVMX_BOOTMEM_H__
55#define __CVMX_BOOTMEM_H__
56
57#ifdef __cplusplus
58extern "C" {

--- 27 unchanged lines hidden (view full) ---

86/* Structure for named memory blocks
87** Number of descriptors
88** available can be changed without affecting compatiblity,
89** but name length changes require a bump in the bootmem
90** descriptor version
91** Note: This structure must be naturally 64 bit aligned, as a single
92** memory image will be used by both 32 and 64 bit programs.
93*/
92typedef struct
94struct cvmx_bootmem_named_block_desc
93{
94 uint64_t base_addr; /**< Base address of named block */
95 uint64_t size; /**< Size actually allocated for named block (may differ from requested) */
96 char name[CVMX_BOOTMEM_NAME_LEN]; /**< name of named block */
95{
96 uint64_t base_addr; /**< Base address of named block */
97 uint64_t size; /**< Size actually allocated for named block (may differ from requested) */
98 char name[CVMX_BOOTMEM_NAME_LEN]; /**< name of named block */
97} cvmx_bootmem_named_block_desc_t;
99};
98
100
101typedef struct cvmx_bootmem_named_block_desc cvmx_bootmem_named_block_desc_t;
99
102
100
101/* Current descriptor versions */
102#define CVMX_BOOTMEM_DESC_MAJ_VER 3 /* CVMX bootmem descriptor major version */
103#define CVMX_BOOTMEM_DESC_MIN_VER 0 /* CVMX bootmem descriptor minor version */
104
105/* First three members of cvmx_bootmem_desc_t are left in original
106** positions for backwards compatibility.
107*/
108typedef struct

--- 13 unchanged lines hidden (view full) ---

122
123} cvmx_bootmem_desc_t;
124
125
126/**
127 * Initialize the boot alloc memory structures. This is
128 * normally called inside of cvmx_user_app_init()
129 *
103/* Current descriptor versions */
104#define CVMX_BOOTMEM_DESC_MAJ_VER 3 /* CVMX bootmem descriptor major version */
105#define CVMX_BOOTMEM_DESC_MIN_VER 0 /* CVMX bootmem descriptor minor version */
106
107/* First three members of cvmx_bootmem_desc_t are left in original
108** positions for backwards compatibility.
109*/
110typedef struct

--- 13 unchanged lines hidden (view full) ---

124
125} cvmx_bootmem_desc_t;
126
127
128/**
129 * Initialize the boot alloc memory structures. This is
130 * normally called inside of cvmx_user_app_init()
131 *
130 * @param mem_desc_ptr Address of the free memory list
132 * @param mem_desc_addr Address of the free memory list
131 * @return
132 */
133 * @return
134 */
133extern int cvmx_bootmem_init(void *mem_desc_ptr);
135extern int cvmx_bootmem_init(uint64_t mem_desc_addr);
134
135
136/**
137 * Allocate a block of memory from the free list that was passed
138 * to the application by the bootloader.
139 * This is an allocate-only algorithm, so freeing memory is not possible.
140 *
141 * @param size Size in bytes of block to allocate

--- 43 unchanged lines hidden (view full) ---

185 * Named blocks can later be freed.
186 *
187 * @param size Size in bytes of block to allocate
188 * @param alignment Alignment required - must be power of 2
189 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
190 *
191 * @return pointer to block of memory, NULL on error
192 */
136
137
138/**
139 * Allocate a block of memory from the free list that was passed
140 * to the application by the bootloader.
141 * This is an allocate-only algorithm, so freeing memory is not possible.
142 *
143 * @param size Size in bytes of block to allocate

--- 43 unchanged lines hidden (view full) ---

187 * Named blocks can later be freed.
188 *
189 * @param size Size in bytes of block to allocate
190 * @param alignment Alignment required - must be power of 2
191 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
192 *
193 * @return pointer to block of memory, NULL on error
194 */
193extern void *cvmx_bootmem_alloc_named(uint64_t size, uint64_t alignment, char *name);
195extern void *cvmx_bootmem_alloc_named(uint64_t size, uint64_t alignment, const char *name);
194
195
196
197/**
198 * Allocate a block of memory from the free list that was passed
199 * to the application by the bootloader, and assign it a name in the
200 * global named block table. (part of the cvmx_bootmem_descriptor_t structure)
201 * Named blocks can later be freed.
202 *
203 * @param size Size in bytes of block to allocate
204 * @param address Physical address to allocate memory at. If this memory is not
205 * available, the allocation fails.
206 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
207 *
208 * @return pointer to block of memory, NULL on error
209 */
196
197
198
199/**
200 * Allocate a block of memory from the free list that was passed
201 * to the application by the bootloader, and assign it a name in the
202 * global named block table. (part of the cvmx_bootmem_descriptor_t structure)
203 * Named blocks can later be freed.
204 *
205 * @param size Size in bytes of block to allocate
206 * @param address Physical address to allocate memory at. If this memory is not
207 * available, the allocation fails.
208 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
209 *
210 * @return pointer to block of memory, NULL on error
211 */
210extern void *cvmx_bootmem_alloc_named_address(uint64_t size, uint64_t address, char *name);
212extern void *cvmx_bootmem_alloc_named_address(uint64_t size, uint64_t address, const char *name);
211
212
213
214/**
215 * Allocate a block of memory from a specific range of the free list that was passed
216 * to the application by the bootloader, and assign it a name in the
217 * global named block table. (part of the cvmx_bootmem_descriptor_t structure)
218 * Named blocks can later be freed.
219 * If request cannot be satisfied within the address range specified, NULL is returned
220 *
221 * @param size Size in bytes of block to allocate
222 * @param min_addr minimum address of range
223 * @param max_addr maximum address of range
224 * @param align Alignment of memory to be allocated. (must be a power of 2)
225 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
226 *
227 * @return pointer to block of memory, NULL on error
228 */
213
214
215
216/**
217 * Allocate a block of memory from a specific range of the free list that was passed
218 * to the application by the bootloader, and assign it a name in the
219 * global named block table. (part of the cvmx_bootmem_descriptor_t structure)
220 * Named blocks can later be freed.
221 * If request cannot be satisfied within the address range specified, NULL is returned
222 *
223 * @param size Size in bytes of block to allocate
224 * @param min_addr minimum address of range
225 * @param max_addr maximum address of range
226 * @param align Alignment of memory to be allocated. (must be a power of 2)
227 * @param name name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
228 *
229 * @return pointer to block of memory, NULL on error
230 */
229extern void *cvmx_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t align, char *name);
231extern void *cvmx_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t align, const char *name);
230
231/**
232 * Frees a previously allocated named bootmem block.
233 *
234 * @param name name of block to free
235 *
236 * @return 0 on failure,
237 * !0 on success
238 */
232
233/**
234 * Frees a previously allocated named bootmem block.
235 *
236 * @param name name of block to free
237 *
238 * @return 0 on failure,
239 * !0 on success
240 */
239extern int cvmx_bootmem_free_named(char *name);
241extern int cvmx_bootmem_free_named(const char *name);
240
241
242/**
243 * Finds a named bootmem block by name.
244 *
245 * @param name name of block to free
246 *
247 * @return pointer to named block descriptor on success
248 * 0 on failure
249 */
242
243
244/**
245 * Finds a named bootmem block by name.
246 *
247 * @param name name of block to free
248 *
249 * @return pointer to named block descriptor on success
250 * 0 on failure
251 */
250cvmx_bootmem_named_block_desc_t * cvmx_bootmem_find_named_block(char *name);
252const cvmx_bootmem_named_block_desc_t *cvmx_bootmem_find_named_block(const char *name);
251
252
253
254/**
255 * Returns the size of available memory in bytes, only
256 * counting blocks that are at least as big as the minimum block
257 * size.
258 *

--- 46 unchanged lines hidden (view full) ---

305 * This must be a power of 2.
306 * (Note: Alignment of CVMX_BOOTMEM_ALIGNMENT_SIZE bytes is required, and internally enforced. Requested alignments of
307 * less than CVMX_BOOTMEM_ALIGNMENT_SIZE are set to CVMX_BOOTMEM_ALIGNMENT_SIZE.)
308 * @param name name to assign to named block
309 * @param flags Flags to control options for the allocation.
310 *
311 * @return physical address of block allocated, or -1 on failure
312 */
253
254
255
256/**
257 * Returns the size of available memory in bytes, only
258 * counting blocks that are at least as big as the minimum block
259 * size.
260 *

--- 46 unchanged lines hidden (view full) ---

307 * This must be a power of 2.
308 * (Note: Alignment of CVMX_BOOTMEM_ALIGNMENT_SIZE bytes is required, and internally enforced. Requested alignments of
309 * less than CVMX_BOOTMEM_ALIGNMENT_SIZE are set to CVMX_BOOTMEM_ALIGNMENT_SIZE.)
310 * @param name name to assign to named block
311 * @param flags Flags to control options for the allocation.
312 *
313 * @return physical address of block allocated, or -1 on failure
314 */
313int64_t cvmx_bootmem_phy_named_block_alloc(uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t alignment, char *name, uint32_t flags);
315int64_t cvmx_bootmem_phy_named_block_alloc(uint64_t size, uint64_t min_addr, uint64_t max_addr, uint64_t alignment, const char *name, uint32_t flags);
314
315
316/**
317 * Finds a named memory block by name.
318 * Also used for finding an unused entry in the named block table.
319 *
320 * @param name Name of memory block to find.
321 * If NULL pointer given, then finds unused descriptor, if available.
316
317
318/**
319 * Finds a named memory block by name.
320 * Also used for finding an unused entry in the named block table.
321 *
322 * @param name Name of memory block to find.
323 * If NULL pointer given, then finds unused descriptor, if available.
322 * @param flags Flags to control options for the allocation.
324 * @param flags Flags to control options for the allocation.
323 *
325 *
324 * @return Pointer to memory block descriptor, NULL if not found.
325 * If NULL returned when name parameter is NULL, then no memory
326 * block descriptors are available.
326 * @return Physical address of the memory block descriptor, zero if not
327 * found. If zero returned when name parameter is NULL, then no
328 * memory block descriptors are available.
327 */
329 */
328cvmx_bootmem_named_block_desc_t * cvmx_bootmem_phy_named_block_find(char *name, uint32_t flags);
330uint64_t cvmx_bootmem_phy_named_block_find(const char *name, uint32_t flags);
329
330
331/**
332 * Returns the size of available memory in bytes, only
333 * counting blocks that are at least as big as the minimum block
334 * size.
335 *
336 * @param min_block_size

--- 7 unchanged lines hidden (view full) ---

344 * Frees a named block.
345 *
346 * @param name name of block to free
347 * @param flags flags for passing options
348 *
349 * @return 0 on failure
350 * 1 on success
351 */
331
332
333/**
334 * Returns the size of available memory in bytes, only
335 * counting blocks that are at least as big as the minimum block
336 * size.
337 *
338 * @param min_block_size

--- 7 unchanged lines hidden (view full) ---

346 * Frees a named block.
347 *
348 * @param name name of block to free
349 * @param flags flags for passing options
350 *
351 * @return 0 on failure
352 * 1 on success
353 */
352int cvmx_bootmem_phy_named_block_free(char *name, uint32_t flags);
354int cvmx_bootmem_phy_named_block_free(const char *name, uint32_t flags);
353
354/**
355 * Frees a block to the bootmem allocator list. This must
356 * be used with care, as the size provided must match the size
357 * of the block that was allocated, or the list will become
358 * corrupted.
359 *
360 * IMPORTANT: This is only intended to be used as part of named block

--- 69 unchanged lines hidden ---
355
356/**
357 * Frees a block to the bootmem allocator list. This must
358 * be used with care, as the size provided must match the size
359 * of the block that was allocated, or the list will become
360 * corrupted.
361 *
362 * IMPORTANT: This is only intended to be used as part of named block

--- 69 unchanged lines hidden ---