You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/08/11 09:57:01 UTC

[GitHub] [incubator-nuttx] anjiahao1 commented on a diff in pull request #6829: drivers/mtd:init commit of power-loss resilient cfg

anjiahao1 commented on code in PR #6829:
URL: https://github.com/apache/incubator-nuttx/pull/6829#discussion_r943305478


##########
include/nuttx/mtd/nvs_priv.h:
##########
@@ -0,0 +1,103 @@
+/****************************************************************************
+ * include/nuttx/mtd/nvs_priv.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_MTD_NVS_PRIV_H_
+#define __INCLUDE_NUTTX_MTD_NVS_PRIV_H_
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+#include <assert.h>
+#include <nuttx/compiler.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* MASKS AND SHIFT FOR ADDRESSES
+ * an address in nvs is an uint32_t where:
+ *   high 2 bytes represent the sector number
+ *   low 2 bytes represent the offset in a sector
+ */
+#define ADDR_SECT_MASK           0xFFFF0000
+#define ADDR_SECT_SHIFT          16
+#define ADDR_OFFS_MASK           0x0000FFFF
+
+/* Status return values */
+
+#define NVS_STATUS_NOSPACE       1
+
+#define NVS_BLOCK_SIZE           32
+
+/**
+ * @brief Non-volatile Storage File system structure
+ *
+ * @param offset File system offset in flash
+ * @param ate_wra: Allocation table entry write address. Addresses are stored
+ * as uint32_t: high 2 bytes are sector, low 2 bytes are offset in sector,
+ * @param data_wra: Data write address.
+ * @param sector_size File system is divided into sectors each sector
+ * should be multiple of pagesize
+ * @param sector_count Amount of sectors in the file systems
+ * @param write_block_size Alignment size
+ * @param nvs_lock Mutex
+ * @param flash_device Flash Device
+ */
+
+struct nvs_fs
+{
+  struct   mtd_dev_s *mtd;   /* mtd device */
+  off_t    offset;           /* filesystem offset in flash */
+  uint32_t ate_wra;          /* next alloc table entry write address */
+  uint32_t data_wra;         /* next data write address */
+  uint16_t sector_size;      /* filesystem is divided into sectors,
+                              * sector size should be multiple of pagesize
+                              */
+  uint16_t page_size;        /* page size */
+  uint16_t sector_count;     /* amount of sectors in the filesystem */
+  bool     ready;            /* is the filesystem initialized ? */
+
+  uint32_t step_addr;        /* for traverse */
+  sem_t    nvs_lock;

Review Comment:
   mutex_t ?



-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org