1 /***********************license start***************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2008 Cavium Networks
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.
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
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/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
29 * Simple allocate only memory allocator. Used to allocate memory at
30 * application start time.
33 #include <linux/export.h>
34 #include <linux/kernel.h>
36 #include <asm/octeon/cvmx.h>
37 #include <asm/octeon/cvmx-spinlock.h>
38 #include <asm/octeon/cvmx-bootmem.h>
43 static struct cvmx_bootmem_desc *cvmx_bootmem_desc;
45 /* See header file for descriptions of functions */
48 * This macro returns the size of a member of a structure.
49 * Logically it is the same as "sizeof(s::field)" in C++, but
50 * C lacks the "::" operator.
52 #define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field)
55 * This macro returns a member of the
56 * cvmx_bootmem_named_block_desc_t structure. These members can't
57 * be directly addressed as they might be in memory not directly
58 * reachable. In the case where bootmem is compiled with
59 * LINUX_HOST, the structure itself might be located on a remote
60 * Octeon. The argument "field" is the member name of the
61 * cvmx_bootmem_named_block_desc_t to read. Regardless of the type
62 * of the field, the return type is always a uint64_t. The "addr"
63 * parameter is the physical address of the structure.
65 #define CVMX_BOOTMEM_NAMED_GET_FIELD(addr, field) \
66 __cvmx_bootmem_desc_get(addr, \
67 offsetof(struct cvmx_bootmem_named_block_desc, field), \
68 SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field))
71 * This function is the implementation of the get macros defined
72 * for individual structure members. The argument are generated
73 * by the macros inorder to read only the needed memory.
75 * @param base 64bit physical address of the complete structure
76 * @param offset Offset from the beginning of the structure to the member being
78 * @param size Size of the structure member.
80 * @return Value of the structure member promoted into a uint64_t.
82 static inline uint64_t __cvmx_bootmem_desc_get(uint64_t base, int offset,
85 base = (1ull << 63) | (base + offset);
88 return cvmx_read64_uint32(base);
90 return cvmx_read64_uint64(base);
97 * Wrapper functions are provided for reading/writing the size and
98 * next block values as these may not be directly addressible (in 32
99 * bit applications, for instance.) Offsets of data elements in
100 * bootmem list, must match cvmx_bootmem_block_header_t.
102 #define NEXT_OFFSET 0
103 #define SIZE_OFFSET 8
105 static void cvmx_bootmem_phy_set_size(uint64_t addr, uint64_t size)
107 cvmx_write64_uint64((addr + SIZE_OFFSET) | (1ull << 63), size);
110 static void cvmx_bootmem_phy_set_next(uint64_t addr, uint64_t next)
112 cvmx_write64_uint64((addr + NEXT_OFFSET) | (1ull << 63), next);
115 static uint64_t cvmx_bootmem_phy_get_size(uint64_t addr)
117 return cvmx_read64_uint64((addr + SIZE_OFFSET) | (1ull << 63));
120 static uint64_t cvmx_bootmem_phy_get_next(uint64_t addr)
122 return cvmx_read64_uint64((addr + NEXT_OFFSET) | (1ull << 63));
126 * Allocate a block of memory from the free list that was
127 * passed to the application by the bootloader within a specified
128 * address range. This is an allocate-only algorithm, so
129 * freeing memory is not possible. Allocation will fail if
130 * memory cannot be allocated in the requested range.
132 * @size: Size in bytes of block to allocate
133 * @min_addr: defines the minimum address of the range
134 * @max_addr: defines the maximum address of the range
135 * @alignment: Alignment required - must be power of 2
136 * Returns pointer to block of memory, NULL on error
138 static void *cvmx_bootmem_alloc_range(uint64_t size, uint64_t alignment,
139 uint64_t min_addr, uint64_t max_addr)
143 cvmx_bootmem_phy_alloc(size, min_addr, max_addr, alignment, 0);
146 return cvmx_phys_to_ptr(address);
151 void *cvmx_bootmem_alloc_address(uint64_t size, uint64_t address,
154 return cvmx_bootmem_alloc_range(size, alignment, address,
158 void *cvmx_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr,
159 uint64_t max_addr, uint64_t align,
164 addr = cvmx_bootmem_phy_named_block_alloc(size, min_addr, max_addr,
167 return cvmx_phys_to_ptr(addr);
172 void *cvmx_bootmem_alloc_named(uint64_t size, uint64_t alignment, char *name)
174 return cvmx_bootmem_alloc_named_range(size, 0, 0, alignment, name);
176 EXPORT_SYMBOL(cvmx_bootmem_alloc_named);
178 void cvmx_bootmem_lock(void)
180 cvmx_spinlock_lock((cvmx_spinlock_t *) &(cvmx_bootmem_desc->lock));
183 void cvmx_bootmem_unlock(void)
185 cvmx_spinlock_unlock((cvmx_spinlock_t *) &(cvmx_bootmem_desc->lock));
188 int cvmx_bootmem_init(void *mem_desc_ptr)
190 /* Here we set the global pointer to the bootmem descriptor
191 * block. This pointer will be used directly, so we will set
192 * it up to be directly usable by the application. It is set
193 * up as follows for the various runtime/ABI combinations:
195 * Linux 64 bit: Set XKPHYS bit
196 * Linux 32 bit: use mmap to create mapping, use virtual address
197 * CVMX 64 bit: use physical address directly
198 * CVMX 32 bit: use physical address directly
200 * Note that the CVMX environment assumes the use of 1-1 TLB
201 * mappings so that the physical addresses can be used
204 if (!cvmx_bootmem_desc) {
205 #if defined(CVMX_ABI_64)
207 cvmx_bootmem_desc = cvmx_phys_to_ptr(CAST64(mem_desc_ptr));
209 cvmx_bootmem_desc = (struct cvmx_bootmem_desc *) mem_desc_ptr;
217 * The cvmx_bootmem_phy* functions below return 64 bit physical
218 * addresses, and expose more features that the cvmx_bootmem_functions
219 * above. These are required for full memory space access in 32 bit
220 * applications, as well as for using some advance features. Most
221 * applications should not need to use these.
224 int64_t cvmx_bootmem_phy_alloc(uint64_t req_size, uint64_t address_min,
225 uint64_t address_max, uint64_t alignment,
231 /* points to previous list entry, NULL current entry is head of list */
232 uint64_t prev_addr = 0;
233 uint64_t new_ent_addr = 0;
234 uint64_t desired_min_addr;
237 cvmx_dprintf("cvmx_bootmem_phy_alloc: req_size: 0x%llx, "
238 "min_addr: 0x%llx, max_addr: 0x%llx, align: 0x%llx\n",
239 (unsigned long long)req_size,
240 (unsigned long long)address_min,
241 (unsigned long long)address_max,
242 (unsigned long long)alignment);
245 if (cvmx_bootmem_desc->major_version > 3) {
246 cvmx_dprintf("ERROR: Incompatible bootmem descriptor "
247 "version: %d.%d at addr: %p\n",
248 (int)cvmx_bootmem_desc->major_version,
249 (int)cvmx_bootmem_desc->minor_version,
255 * Do a variety of checks to validate the arguments. The
256 * allocator code will later assume that these checks have
257 * been made. We validate that the requested constraints are
258 * not self-contradictory before we look through the list of
262 /* 0 is not a valid req_size for this allocator */
266 /* Round req_size up to mult of minimum alignment bytes */
267 req_size = (req_size + (CVMX_BOOTMEM_ALIGNMENT_SIZE - 1)) &
268 ~(CVMX_BOOTMEM_ALIGNMENT_SIZE - 1);
271 * Convert !0 address_min and 0 address_max to special case of
272 * range that specifies an exact memory block to allocate. Do
273 * this before other checks and adjustments so that this
274 * tranformation will be validated.
276 if (address_min && !address_max)
277 address_max = address_min + req_size;
278 else if (!address_min && !address_max)
279 address_max = ~0ull; /* If no limits given, use max limits */
283 * Enforce minimum alignment (this also keeps the minimum free block
284 * req_size the same as the alignment req_size.
286 if (alignment < CVMX_BOOTMEM_ALIGNMENT_SIZE)
287 alignment = CVMX_BOOTMEM_ALIGNMENT_SIZE;
290 * Adjust address minimum based on requested alignment (round
291 * up to meet alignment). Do this here so we can reject
292 * impossible requests up front. (NOP for address_min == 0)
295 address_min = ALIGN(address_min, alignment);
298 * Reject inconsistent args. We have adjusted these, so this
299 * may fail due to our internal changes even if this check
300 * would pass for the values the user supplied.
302 if (req_size > address_max - address_min)
305 /* Walk through the list entries - first fit found is returned */
307 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
309 head_addr = cvmx_bootmem_desc->head_addr;
310 ent_addr = head_addr;
312 prev_addr = ent_addr,
313 ent_addr = cvmx_bootmem_phy_get_next(ent_addr)) {
314 uint64_t usable_base, usable_max;
315 uint64_t ent_size = cvmx_bootmem_phy_get_size(ent_addr);
317 if (cvmx_bootmem_phy_get_next(ent_addr)
318 && ent_addr > cvmx_bootmem_phy_get_next(ent_addr)) {
319 cvmx_dprintf("Internal bootmem_alloc() error: ent: "
320 "0x%llx, next: 0x%llx\n",
321 (unsigned long long)ent_addr,
323 cvmx_bootmem_phy_get_next(ent_addr));
328 * Determine if this is an entry that can satisify the
329 * request Check to make sure entry is large enough to
333 ALIGN(max(address_min, ent_addr), alignment);
334 usable_max = min(address_max, ent_addr + ent_size);
336 * We should be able to allocate block at address
340 desired_min_addr = usable_base;
342 * Determine if request can be satisfied from the
345 if (!((ent_addr + ent_size) > usable_base
346 && ent_addr < address_max
347 && req_size <= usable_max - usable_base))
350 * We have found an entry that has room to satisfy the
351 * request, so allocate it from this entry. If end
352 * CVMX_BOOTMEM_FLAG_END_ALLOC set, then allocate from
353 * the end of this block rather than the beginning.
355 if (flags & CVMX_BOOTMEM_FLAG_END_ALLOC) {
356 desired_min_addr = usable_max - req_size;
358 * Align desired address down to required
361 desired_min_addr &= ~(alignment - 1);
364 /* Match at start of entry */
365 if (desired_min_addr == ent_addr) {
366 if (req_size < ent_size) {
368 * big enough to create a new block
369 * from top portion of block.
371 new_ent_addr = ent_addr + req_size;
372 cvmx_bootmem_phy_set_next(new_ent_addr,
373 cvmx_bootmem_phy_get_next(ent_addr));
374 cvmx_bootmem_phy_set_size(new_ent_addr,
379 * Adjust next pointer as following
382 cvmx_bootmem_phy_set_next(ent_addr,
387 * adjust prev ptr or head to remove this
391 cvmx_bootmem_phy_set_next(prev_addr,
392 cvmx_bootmem_phy_get_next(ent_addr));
395 * head of list being returned, so
398 cvmx_bootmem_desc->head_addr =
399 cvmx_bootmem_phy_get_next(ent_addr);
401 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
402 cvmx_bootmem_unlock();
403 return desired_min_addr;
406 * block returned doesn't start at beginning of entry,
407 * so we know that we will be splitting a block off
408 * the front of this one. Create a new block from the
409 * beginning, add to list, and go to top of loop
412 * create new block from high portion of
413 * block, so that top block starts at desired
416 new_ent_addr = desired_min_addr;
417 cvmx_bootmem_phy_set_next(new_ent_addr,
418 cvmx_bootmem_phy_get_next
420 cvmx_bootmem_phy_set_size(new_ent_addr,
421 cvmx_bootmem_phy_get_size
425 cvmx_bootmem_phy_set_size(ent_addr,
426 desired_min_addr - ent_addr);
427 cvmx_bootmem_phy_set_next(ent_addr, new_ent_addr);
428 /* Loop again to handle actual alloc from new block */
431 /* We didn't find anything, so return error */
432 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
433 cvmx_bootmem_unlock();
437 int __cvmx_bootmem_phy_free(uint64_t phy_addr, uint64_t size, uint32_t flags)
440 uint64_t prev_addr = 0; /* zero is invalid */
444 cvmx_dprintf("__cvmx_bootmem_phy_free addr: 0x%llx, size: 0x%llx\n",
445 (unsigned long long)phy_addr, (unsigned long long)size);
447 if (cvmx_bootmem_desc->major_version > 3) {
448 cvmx_dprintf("ERROR: Incompatible bootmem descriptor "
449 "version: %d.%d at addr: %p\n",
450 (int)cvmx_bootmem_desc->major_version,
451 (int)cvmx_bootmem_desc->minor_version,
456 /* 0 is not a valid size for this allocator */
460 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
462 cur_addr = cvmx_bootmem_desc->head_addr;
463 if (cur_addr == 0 || phy_addr < cur_addr) {
464 /* add at front of list - special case with changing head ptr */
465 if (cur_addr && phy_addr + size > cur_addr)
466 goto bootmem_free_done; /* error, overlapping section */
467 else if (phy_addr + size == cur_addr) {
468 /* Add to front of existing first block */
469 cvmx_bootmem_phy_set_next(phy_addr,
470 cvmx_bootmem_phy_get_next
472 cvmx_bootmem_phy_set_size(phy_addr,
473 cvmx_bootmem_phy_get_size
475 cvmx_bootmem_desc->head_addr = phy_addr;
478 /* New block before first block. OK if cur_addr is 0 */
479 cvmx_bootmem_phy_set_next(phy_addr, cur_addr);
480 cvmx_bootmem_phy_set_size(phy_addr, size);
481 cvmx_bootmem_desc->head_addr = phy_addr;
484 goto bootmem_free_done;
487 /* Find place in list to add block */
488 while (cur_addr && phy_addr > cur_addr) {
489 prev_addr = cur_addr;
490 cur_addr = cvmx_bootmem_phy_get_next(cur_addr);
495 * We have reached the end of the list, add on to end,
496 * checking to see if we need to combine with last
499 if (prev_addr + cvmx_bootmem_phy_get_size(prev_addr) ==
501 cvmx_bootmem_phy_set_size(prev_addr,
502 cvmx_bootmem_phy_get_size
505 cvmx_bootmem_phy_set_next(prev_addr, phy_addr);
506 cvmx_bootmem_phy_set_size(phy_addr, size);
507 cvmx_bootmem_phy_set_next(phy_addr, 0);
510 goto bootmem_free_done;
513 * insert between prev and cur nodes, checking for
514 * merge with either/both.
516 if (prev_addr + cvmx_bootmem_phy_get_size(prev_addr) ==
518 /* Merge with previous */
519 cvmx_bootmem_phy_set_size(prev_addr,
520 cvmx_bootmem_phy_get_size
522 if (phy_addr + size == cur_addr) {
523 /* Also merge with current */
524 cvmx_bootmem_phy_set_size(prev_addr,
525 cvmx_bootmem_phy_get_size(cur_addr) +
526 cvmx_bootmem_phy_get_size(prev_addr));
527 cvmx_bootmem_phy_set_next(prev_addr,
528 cvmx_bootmem_phy_get_next(cur_addr));
531 goto bootmem_free_done;
532 } else if (phy_addr + size == cur_addr) {
533 /* Merge with current */
534 cvmx_bootmem_phy_set_size(phy_addr,
535 cvmx_bootmem_phy_get_size
537 cvmx_bootmem_phy_set_next(phy_addr,
538 cvmx_bootmem_phy_get_next
540 cvmx_bootmem_phy_set_next(prev_addr, phy_addr);
542 goto bootmem_free_done;
545 /* It is a standalone block, add in between prev and cur */
546 cvmx_bootmem_phy_set_size(phy_addr, size);
547 cvmx_bootmem_phy_set_next(phy_addr, cur_addr);
548 cvmx_bootmem_phy_set_next(prev_addr, phy_addr);
554 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
555 cvmx_bootmem_unlock();
561 * Finds a named memory block by name.
562 * Also used for finding an unused entry in the named block table.
564 * @name: Name of memory block to find. If NULL pointer given, then
565 * finds unused descriptor, if available.
567 * @flags: Flags to control options for the allocation.
569 * Returns Pointer to memory block descriptor, NULL if not found.
570 * If NULL returned when name parameter is NULL, then no memory
571 * block descriptors are available.
573 static struct cvmx_bootmem_named_block_desc *
574 cvmx_bootmem_phy_named_block_find(char *name, uint32_t flags)
577 struct cvmx_bootmem_named_block_desc *named_block_array_ptr;
580 cvmx_dprintf("cvmx_bootmem_phy_named_block_find: %s\n", name);
583 * Lock the structure to make sure that it is not being
584 * changed while we are examining it.
586 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
589 /* Use XKPHYS for 64 bit linux */
590 named_block_array_ptr = (struct cvmx_bootmem_named_block_desc *)
591 cvmx_phys_to_ptr(cvmx_bootmem_desc->named_block_array_addr);
595 ("cvmx_bootmem_phy_named_block_find: named_block_array_ptr: %p\n",
596 named_block_array_ptr);
598 if (cvmx_bootmem_desc->major_version == 3) {
600 i < cvmx_bootmem_desc->named_block_num_blocks; i++) {
601 if ((name && named_block_array_ptr[i].size
602 && !strncmp(name, named_block_array_ptr[i].name,
603 cvmx_bootmem_desc->named_block_name_len
605 || (!name && !named_block_array_ptr[i].size)) {
606 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
607 cvmx_bootmem_unlock();
609 return &(named_block_array_ptr[i]);
613 cvmx_dprintf("ERROR: Incompatible bootmem descriptor "
614 "version: %d.%d at addr: %p\n",
615 (int)cvmx_bootmem_desc->major_version,
616 (int)cvmx_bootmem_desc->minor_version,
619 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
620 cvmx_bootmem_unlock();
625 void *cvmx_bootmem_alloc_named_range_once(uint64_t size, uint64_t min_addr,
626 uint64_t max_addr, uint64_t align,
628 void (*init) (void *))
632 uint64_t named_block_desc_addr;
634 named_block_desc_addr = (uint64_t)
635 cvmx_bootmem_phy_named_block_find(name,
636 (uint32_t)CVMX_BOOTMEM_FLAG_NO_LOCKING);
638 if (named_block_desc_addr) {
639 addr = CVMX_BOOTMEM_NAMED_GET_FIELD(named_block_desc_addr,
641 return cvmx_phys_to_ptr(addr);
644 addr = cvmx_bootmem_phy_named_block_alloc(size, min_addr, max_addr,
646 (uint32_t)CVMX_BOOTMEM_FLAG_NO_LOCKING);
650 ptr = cvmx_phys_to_ptr(addr);
655 memset(ptr, 0, size);
659 EXPORT_SYMBOL(cvmx_bootmem_alloc_named_range_once);
661 struct cvmx_bootmem_named_block_desc *cvmx_bootmem_find_named_block(char *name)
663 return cvmx_bootmem_phy_named_block_find(name, 0);
665 EXPORT_SYMBOL(cvmx_bootmem_find_named_block);
668 * Frees a named block.
670 * @name: name of block to free
671 * @flags: flags for passing options
673 * Returns 0 on failure
676 static int cvmx_bootmem_phy_named_block_free(char *name, uint32_t flags)
678 struct cvmx_bootmem_named_block_desc *named_block_ptr;
680 if (cvmx_bootmem_desc->major_version != 3) {
681 cvmx_dprintf("ERROR: Incompatible bootmem descriptor version: "
682 "%d.%d at addr: %p\n",
683 (int)cvmx_bootmem_desc->major_version,
684 (int)cvmx_bootmem_desc->minor_version,
689 cvmx_dprintf("cvmx_bootmem_phy_named_block_free: %s\n", name);
693 * Take lock here, as name lookup/block free/name free need to
699 cvmx_bootmem_phy_named_block_find(name,
700 CVMX_BOOTMEM_FLAG_NO_LOCKING);
701 if (named_block_ptr) {
703 cvmx_dprintf("cvmx_bootmem_phy_named_block_free: "
704 "%s, base: 0x%llx, size: 0x%llx\n",
706 (unsigned long long)named_block_ptr->base_addr,
707 (unsigned long long)named_block_ptr->size);
709 __cvmx_bootmem_phy_free(named_block_ptr->base_addr,
710 named_block_ptr->size,
711 CVMX_BOOTMEM_FLAG_NO_LOCKING);
712 named_block_ptr->size = 0;
713 /* Set size to zero to indicate block not used. */
716 cvmx_bootmem_unlock();
717 return named_block_ptr != NULL; /* 0 on failure, 1 on success */
720 int cvmx_bootmem_free_named(char *name)
722 return cvmx_bootmem_phy_named_block_free(name, 0);
725 int64_t cvmx_bootmem_phy_named_block_alloc(uint64_t size, uint64_t min_addr,
731 int64_t addr_allocated;
732 struct cvmx_bootmem_named_block_desc *named_block_desc_ptr;
735 cvmx_dprintf("cvmx_bootmem_phy_named_block_alloc: size: 0x%llx, min: "
736 "0x%llx, max: 0x%llx, align: 0x%llx, name: %s\n",
737 (unsigned long long)size,
738 (unsigned long long)min_addr,
739 (unsigned long long)max_addr,
740 (unsigned long long)alignment,
743 if (cvmx_bootmem_desc->major_version != 3) {
744 cvmx_dprintf("ERROR: Incompatible bootmem descriptor version: "
745 "%d.%d at addr: %p\n",
746 (int)cvmx_bootmem_desc->major_version,
747 (int)cvmx_bootmem_desc->minor_version,
753 * Take lock here, as name lookup/block alloc/name add need to
756 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
757 cvmx_spinlock_lock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
759 /* Get pointer to first available named block descriptor */
760 named_block_desc_ptr =
761 cvmx_bootmem_phy_named_block_find(NULL,
762 flags | CVMX_BOOTMEM_FLAG_NO_LOCKING);
765 * Check to see if name already in use, return error if name
766 * not available or no more room for blocks.
768 if (cvmx_bootmem_phy_named_block_find(name,
769 flags | CVMX_BOOTMEM_FLAG_NO_LOCKING) || !named_block_desc_ptr) {
770 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
771 cvmx_spinlock_unlock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
777 * Round size up to mult of minimum alignment bytes We need
778 * the actual size allocated to allow for blocks to be
779 * coalesced when they are freed. The alloc routine does the
780 * same rounding up on all allocations.
782 size = ALIGN(size, CVMX_BOOTMEM_ALIGNMENT_SIZE);
784 addr_allocated = cvmx_bootmem_phy_alloc(size, min_addr, max_addr,
786 flags | CVMX_BOOTMEM_FLAG_NO_LOCKING);
787 if (addr_allocated >= 0) {
788 named_block_desc_ptr->base_addr = addr_allocated;
789 named_block_desc_ptr->size = size;
790 strncpy(named_block_desc_ptr->name, name,
791 cvmx_bootmem_desc->named_block_name_len);
792 named_block_desc_ptr->name[cvmx_bootmem_desc->named_block_name_len - 1] = 0;
795 if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
796 cvmx_spinlock_unlock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
797 return addr_allocated;
800 struct cvmx_bootmem_desc *cvmx_bootmem_get_desc(void)
802 return cvmx_bootmem_desc;