jlaitine commented on code in PR #8026: URL: https://github.com/apache/nuttx/pull/8026#discussion_r1064460918
########## include/nuttx/mm/map.h: ########## @@ -84,34 +84,34 @@ struct mm_map_s * Name: mm_map_lock * * Description: - * Get exclusive access to task_group's mm_map + * Get exclusive access current task_group's mm_map * * Input Parameters: - * mm - Pointer to the mm_map_s + * None * * Returned Value: * OK on success * A negated errno value on failure * ****************************************************************************/ -int mm_map_lock(FAR struct task_group_s *group); +int mm_map_lock(void); Review Comment: done ########## fs/mmap/fs_anonmap.c: ########## @@ -0,0 +1,96 @@ +/**************************************************************************** + * fs/mmap/fs_anonmap.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 <debug.h> + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: unmap_anonymous + ****************************************************************************/ + +static int unmap_anonymous(FAR struct task_group_s *group, + FAR struct mm_map_entry_s *map, + FAR void *start, + size_t length) +{ + int ret; + + /* De-allocate memory. + * NB: This is incomplete anounymous mapping implementation + * see file_mmap_ below + */ + + if (start == map->vaddr && length == map->length) + { + /* map->priv marks allocation from kernel heap */ + + if (map->priv.i) + { + kmm_free(start); + } + else + { + kumm_free(start); + } + + ret = mm_map_remove(group, &map); + } + else + { + ret = -EINVAL; + ferr("ERROR: Unknown map type\n"); + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int map_anonymous(FAR struct mm_map_entry_s *map, bool kernel) +{ + /* REVISIT: Should reside outside of the heap. That is really the + * only purpose of MAP_ANONYMOUS: To get non-heap memory. In KERNEL + * build, this could be accomplished using pgalloc(), provided that + * you had logic in place to assign a virtual address to the mapping. + */ + + map->vaddr = kernel ? kmm_zalloc(map->length) : kumm_zalloc(map->length); + if (map->vaddr == NULL) + { + ferr("ERROR: kumm_alloc() failed, enable DEBUG_MM for info!\n"); + return -ENOMEM; + } + + map->munmap = unmap_anonymous; + map->priv.i = kernel; + + return mm_map_add(map); Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org