Commit Graph

104 Commits

Author SHA1 Message Date
zhangshoukui d68fab125e FS_RAMMAP depends on FS_REFCOUNT and remove useless macro
Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-23 18:22:35 +08:00
guoshichao f01a2c70fd greenhills: fix the enumerated type mixed using warning
CC:  obstack/lib_obstack_printf.c "mmap/fs_rammap.c", line 126: warning #188-D: enumerated type mixed with
          another type
    enum mm_map_type_e type = (uintptr_t)entry->priv.p & 3;
                              ^

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-09-19 14:08:07 +08:00
zhangshoukui 3fb6b4c9ec fix mmap compile error.
mmap/fs_rammap.c:81:39: error: expected ‘)’ before ‘PRIdOFF’
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |                                       ^~~~~~~
mmap/fs_rammap.c:81:12: warning: spurious trailing ‘%’ in format [-Wformat=]
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:81:37: note: format string is defined here
   81 |       ferr("ERRORL Seek to position %"PRIdOFF" failed\n", fpos);
      |                                     ^
In file included from mmap/fs_rammap.c:30:
mmap/fs_rammap.c:98:51: error: expected ‘)’ before ‘PRIdOFF’
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
      |                                                   ^~~~~~~
mmap/fs_rammap.c:98:20: warning: spurious trailing ‘%’ in format [-Wformat=]
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mmap/fs_rammap.c:98:49: note: format string is defined here
   98 |               ferr("ERROR: Write failed: offset=%"PRIdOFF" nwrite=%zd\n",

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 250353240c rammap:Adjust the lower two bits to represent type
Summary:
  In rammap:
   1.0 - User
   2.1 - Kernel
   3.2 - XIP
  Therefore we need to use 2 bits to represent the type

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 c9148fbb0a fs_msync:Fix crash caused under the anonymous mapping
Summary:
 Limitations of using fs putfile

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
chenrun1 d04205aa3d fs/mmap/msync:support msync.
Summary:
  1.Added msync callback in struct mm_map_entry_s
  2.Added msync API in fs_msync.c
  3.Added static msync_rammap for rammap.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-19 01:43:50 +08:00
wanggang26 484600bd75 mmap: add xip mmap type support
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-19 01:43:50 +08:00
Shoukui Zhang 43223124ec vfs/file: add reference counting to prevent accidental close during reading writing...
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
ouyangxiangzhen 0451ead2c5 fs/mmap: Ensure anonymous pages are initialized to zero
According to the mmap(2) specification, anonymous pages should be initialized to zero unless the MAP_UNINITIALIZED is specified.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-09-13 09:10:21 +08:00
hujun5 198630a809 sched: use this_task replace nxsched_self
reason:
We can reduce a function call to improve performance.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-05 09:33:50 -03:00
pengyinjie cbc9b98075 [FS]:Fixed spacing and typo issues in code comment descriptions
[Desc]:as title

Signed-off-by: pengyinjie <pengyinjie@xiaomi.com>
2024-08-27 21:52:56 +08:00
cuiziwei 17a06ce2cd fs/mmap: Fix build warning with [-Wmaybe-uninitialized].
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-08-19 16:40:58 +08:00
Yanfeng Liu a5b5c963c7 fs/mmap: enable parameter checks always
These parameter checks should always be enabled.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-03-25 20:39:24 +08:00
raiden00pl 5b87fdfb9d Documentation: remove all migrated READMEs 2023-10-29 21:03:54 -03:00
cuiziwei a0206adcfa nuttx/fs:remove (flags & MAP_PRIVATE) == 0.
NuttX not support MAP_PRIVATE currently.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2023-08-04 04:20:06 -07:00
fangxinyong d1825a7acb fs/mmap: only MAP_SHARED mapping need file write permisson
If MAP_PRIVATE is specified, do not change the underlying object,
that is OK to open file with read-only permission. Change to pass:
testcases/open_posix_testsuite/conformance/interfaces/mmap/6-5.c

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong d892cda167 fs/mmap: fix mmap() wrong errno
As posix spec, mmap() function shall fail with ENODEV if fd refers
to a file whose type is not supported. Change to pass ltp open_posix test:
testcases/open_posix_testsuite/conformance/interfaces/mmap/23-1.c

https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:57:28 -07:00
fangxinyong dfa6a43744 fs/mmap: fix wrong return value check
while iterate throuh all mapping memory to munmap and release,
the last entry is NUlL.
We need differentiate the case with invald entry at the first.

The fix is to pass ltp shm related cases.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-07-28 08:05:39 -07:00
dongjiuzhu1 88161bfca5 fs/mmap: add sanity check
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-28 08:05:39 -07:00
Xiang Xiao e031a73aef Kconfig: Change some "default y" to "default !DEFAULT_SMALL"
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-07-16 14:39:20 -03:00
chao an f10b54a081 cmake: fix CMake build break
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-15 23:32:36 +08:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
chao an fb9b41221d semantic/parser: fix compile warning found by sparse
Reference:
https://linux.die.net/man/1/sparse

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
Ville Juven 53d4b9ed54 mm/mm_map: Give the mm_map as parameter to the mm_map functions
This way the mappings can be modified for any vm area, not only the
process that is running.

Why? This allows mapping pages to kernel dynamically, this functionality
will be presented later.
2023-04-22 00:40:37 +08:00
zhangyuan21 c239d19df0 nuttx: add more dependent header file
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-04-11 09:13:32 +03:00
dongjiuzhu1 f8b27d9fbe fs/mmap: try rammap when filesystem mmap don't support
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-03-10 10:43:33 +02:00
Xiang Xiao f8d33e40ac Fix mmap/fs_mmap.c:259:13: warning: 'mapped' may be used uninitialized in this function [-Wmaybe-uninitialized]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-18 08:40:33 +01:00
chao an 3d7629a02c fs/mmap: fix compile warning if set the optimize level to O3
| $ gcc -c "-O3" -Wall -isystem include -D__NuttX__ -D__KERNEL__ -I fs -I sched fs/mmap/fs_mmap.c -o fs_mmap.o
| include/sys/mman.h: In function ‘mmap’:
| fs/mmap/fs_mmap.c:259:13: warning: ‘mapped’ may be used uninitialized in this function [-Wmaybe-uninitialized]
|   259 |   FAR void *mapped;
|       |             ^~~~~~

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-17 21:56:37 +08:00
Xuxingliang 9166eeddf6 fs/mmap: update mapped var before exit
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-01-17 11:12:26 +08:00
Xuxingliang dce315005a fs/mmap: rammap should return buffer start address
Signed-off-by: Xuxingliang <xuxingliang@xiaomi.com>
2023-01-17 11:12:26 +08:00
Jukka Laitinen 6db295481b fs/mmap/fs_rammap.c: Remove void * arithmetic
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-13 23:08:58 +08:00
Jukka Laitinen 3577d2f055 fs/mmap/fs_anonmap.c: Remove void * arithmetic
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-13 23:08:58 +08:00
Xiang Xiao fd0195b0d8 fs/mmap: Suppor the partial unmap for anonymous mapping
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Xiang Xiao fcd4a421e3 fs/mmap: Support the no backing file for anonymous mapping
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Xiang Xiao ab67d6a75b fs/mmap: Remove the duplication rammap handling
and minor ifx for style and format

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-12 19:11:56 +02:00
Jukka Laitinen b8f23fc3f7 Move rammaps to use mm_map list
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
Jukka Laitinen a5ed8014e8 Move anonymous mapping emulation into own module under fs/mmap
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
Jukka Laitinen dd97900221 fs/mmap: Add mappings to mm_map list if CONFIG_MM_MAP is defined
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-10 18:34:25 +08:00
Xiang Xiao 1a59f4ed00 mm/map: Remove the unnessary map.h inclusion in various drivers
and Fix include/nuttx/mm/map.h:55:28: error: 'struct task_group_s' declared inside parameter list will not be visible outside of this definition or declaration

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-05 16:06:53 +02:00
Jukka Laitinen f33dc4df3f Change FIOC_MMAP into file operation call
- Add mmap into file_operations and remove it from ioctl definitions.
- Add mm_map structure definitions to support future unmapping
- Modify all drivers to initialize the operations struct accordingly

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-01-02 11:23:20 -03:00
anjiahao d1d46335df Replace nxsem API when used as a lock with nxmutex API
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-17 15:59:46 +09:00
Petro Karashchenko 8d3bf05fd2 include: fix double include pre-processor guards
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-16 11:11:14 -03:00
Alan C. Assis 9d79f82e24 mmap: Fix note: initialize the variable 'ret' 2021-08-10 09:08:25 -07:00
Xiang Xiao 1f3a8b5adf Fix mmap compiler error when CONFIG_FS_RAMMAP equals y
fs_munmap.c:122:15: error: ‘struct fs_rammap_s’ has no member named ‘kernel’
fs_rammap.c:110:52: error: expected ‘:’ before ‘;’ token

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-13 14:39:14 -03:00
Xiang Xiao 8612af4ae5 fs: Implement file_mmap and file_munmap API
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-06 11:18:13 +09:00
Xiang Xiao 2b0b298ab6 fs/mmap: Remove rammap_initialize declaration
Forget in patch:
commit ec30d6ef6b
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Thu Jun 24 01:42:11 2021 +0800

    fs: Initialize fs_allmaps_s::exclsem in declaration directly

    and then remove rammap_initialize and caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-06 11:18:13 +09:00
Xiang Xiao 06215be327 mmap: Implement the minial but reasonable mlock/munlock/mprotect
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I538e0d78ecd0680374a2e0f56adbc61d7a4e6d1f
2021-07-01 08:06:54 +09:00
Xiang Xiao ec30d6ef6b fs: Initialize fs_allmaps_s::exclsem in declaration directly
and then remove rammap_initialize and caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ife9f04d409b3a14a3be4bbb61c23da6e7a9f8a3d
2021-07-01 08:06:54 +09:00
Gustavo Henrique Nihei c80cdf06c2 fs/mmap: Return EACCES for incompatible file descriptors 2021-03-16 10:17:07 -07:00
Gustavo Henrique Nihei ecb9e03a7f fs/mmap: Update mmap documentation of possible return values 2021-03-15 20:02:52 -07:00