| /**************************************************************************** |
| * arch/risc-v/src/bl602/bl602_allocateheap.c |
| * |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. The |
| * ASF licenses this file to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance with the |
| * License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| * License for the specific language governing permissions and limitations |
| * under the License. |
| * |
| ****************************************************************************/ |
| |
| /**************************************************************************** |
| * Included Files |
| ****************************************************************************/ |
| |
| #include <nuttx/config.h> |
| #include <nuttx/kmalloc.h> |
| |
| #include <nuttx/arch.h> |
| |
| #include "chip.h" |
| #include "riscv_internal.h" |
| |
| /**************************************************************************** |
| * Public Variables |
| ****************************************************************************/ |
| |
| extern uint8_t __heap_end[]; |
| extern uint8_t _heap_wifi_start[]; |
| extern uint8_t _heap_wifi_size[]; |
| |
| /**************************************************************************** |
| * Public Functions |
| ****************************************************************************/ |
| |
| /**************************************************************************** |
| * Name: up_allocate_heap |
| * |
| * Description: |
| * This function will be called to dynamically set aside the heap region. |
| * |
| * For the kernel build (CONFIG_BUILD_KERNEL=y) with both kernel- and |
| * user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the |
| * size of the unprotected, user-space heap. |
| * |
| * If a protected kernel-space heap is provided, the kernel heap must be |
| * allocated (and protected) by an analogous up_allocate_kheap(). |
| * |
| ****************************************************************************/ |
| |
| void up_allocate_heap(void **heap_start, size_t *heap_size) |
| { |
| *heap_start = (void *)g_idle_topstack; |
| *heap_size = (size_t)((uintptr_t)__heap_end - g_idle_topstack); |
| } |
| |
| /**************************************************************************** |
| * Name: riscv_addregion |
| * |
| * Description: |
| * RAM may be added in non-contiguous chunks. This routine adds all chunks |
| * that may be used for heap. |
| * |
| ****************************************************************************/ |
| |
| #if CONFIG_MM_REGIONS > 1 |
| void riscv_addregion(void) |
| { |
| kumm_addregion(_heap_wifi_start, (uint32_t)_heap_wifi_size); |
| } |
| #endif |
| |