ssssenai commented on code in PR #7762: URL: https://github.com/apache/nuttx/pull/7762#discussion_r1052949743
########## arch/xtensa/src/esp32/esp32_himem_chardev.c: ########## @@ -0,0 +1,414 @@ +/**************************************************************************** + * arch/xtensa/src/esp32/esp32_himem_chardev.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 <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <debug.h> +#include <sys/types.h> +#include <nuttx/list.h> +#include <nuttx/himem/himem.h> +#include <nuttx/semaphore.h> +#include <nuttx/fs/fs.h> +#include <arch/esp32/esp32_himem_chardev.h> +#include "esp32_himem.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define HIMEM_UNMAPPED (-1) + +struct himem_chardev +{ + struct list_node node; + size_t size; + esp_himem_handle_t mem_handle; + char name[32]; +}; + +struct himem_chardev_priv +{ + off_t offset; /* himem offset[byte]. update by seek(), read(), write(). */ +}; + +static struct list_node s_himem_chardev_list + = LIST_INITIAL_VALUE(s_himem_chardev_list); +static esp_himem_rangehandle_t s_range_handle; +static sem_t s_sem; +static size_t s_ram_offset; /* used by himem map/unmap */ + +static void *s_himem_ptr; /* mapped himem pointer */ + +static struct file *s_mapped_filep; /* for multi device */ + +/**************************************************************************** + * Priavte Functions + ****************************************************************************/ + +static int himem_chardev_open(struct file *filep) +{ + struct himem_chardev_priv *priv; + + priv = (struct himem_chardev_priv *)malloc( + sizeof(struct himem_chardev_priv)); + if (priv == NULL) + { + _err("Failed to malloc.\n"); Review Comment: I agree. I have revised it -- 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