函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\nommu.c Create Date:2022-07-27 16:03:45
Last Modify:2020-03-17 21:26:27 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:handle mapping creation for uClinux

函数原型:unsigned long do_mmap(struct file *file, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, vm_flags_t vm_flags, unsigned long pgoff, unsigned long *populate, struct list_head *uf)

返回类型:unsigned long

参数:

类型参数名称
struct file *file
unsigned longaddr
unsigned longlen
unsigned longprot
unsigned longflags
vm_flags_tvm_flags
unsigned longpgoff
unsigned long *populate
struct list_head *uf
1115  populate等于0
1119  ret等于determine whether a mapping should be permitted and, if so, what sort of* mapping we're capable of supporting
1121  如果ret小于0则返回:ret
1125  addr等于0
1126  len等于 align the pointer to the (next) page boundary (len)
1130  vm_flags或等于we've determined that we can make the mapping, now translate what we* now know into VMA flags
1133  region等于Shortcuts
1134  如果非region则转到:error_getting_region
1137  vma等于vm_area_alloc(mm)
1138  如果非vma则转到:error_getting_vma
1141  gion usage count (access under nommu_region_sem) 等于1
1142  VMA vm_flags 等于vm_flags
1143  he offset in vm_file corresponding to vm_start 等于pgoff
1145  Flags, see mm.h. 等于vm_flags
1146  Offset (within vm_file) in PAGE_SIZEunits 等于pgoff
1148  如果file
1149  he backing file or NULL 等于get_file(file)
1150  File we map to (can be NULL). 等于get_file(file)
1153  lock for writing
1163  如果vm_flags按位与VM_MAYSHARE
1167  pglen等于lenPAGE_SIZE减1右移PAGE_SHIFT determines the page size
1168  pgend等于pgoffpglen
1170 rb循环
1171  pregion等于rb_entry(rb, structvm_region, vm_rb)
1173  如果非VMA vm_flags 按位与VM_MAYSHARE的值则继续下一循环
1177  如果file_inode(he backing file or NULL )不等于file_inode(file)则继续下一循环
1181  如果he offset in vm_file corresponding to vm_start 大于等于pgend则继续下一循环
1187  如果pgoff大于等于rpgend则继续下一循环
1192  如果he offset in vm_file corresponding to vm_start 不等于pgoffrpglen不等于pglen的值且非pgoff大于等于he offset in vm_file corresponding to vm_start pgend小于等于rpgend的值则
1195  如果非capabilities按位与NOMMU_MAP_DIRECT的值则转到:sharing_violation
1197  继续下一循环
1202  vm_region等于pregion
1210  否则
1223  region等于pregion
1224  result等于start
1225  转到:share
1232  如果capabilities按位与NOMMU_MAP_DIRECT
1235  如果IS_ERR_VALUE(addr)则
1248  否则
1255  vm_region等于region
1260  如果fileFlags, see mm.h. 按位与VM_SHAREDret等于set up a shared mapping on a file (the driver or filesystem provides and* pins the storage)
1262  否则ret等于set up a private mapping or an anonymous shared mapping
1264  如果ret小于0则转到:error_just_free
1266  add a region into the global tree
1269  如果非File we map to (can be NULL). 且非IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_MMAP_ALLOW_UNINITIALIZED)或非flags按位与For anonymous mmap, memory could be* uninitialized 的值的值则memset((void * )start address of region , 0, gion initialised to here - start address of region )
1276  result等于Our start address within vm_mm.
1278  total_vm加等于len右移PAGE_SHIFT determines the page size
1280  share :
1281  add a VMA into a process's mm_struct in the appropriate place in the list* and tree and add to the address space's page tree also if not an anonymous* page* - should be called with mm->mmap_sem held writelocked
1285  如果Flags, see mm.h. 按位与VM_EXEC且非rue if the icache has been flushed for* this region
1286  flush_icache_range(start address of region , gion initialised to here )
1287  rue if the icache has been flushed for* this region = true
1290  lease a write lock
1292  返回:result
1294  error_just_free :
1295  lease a write lock
1296  error :
1297  如果he backing file or NULL fput(he backing file or NULL )
1299  kmem_cache_free(list of mapped, potentially shareable regions , region)
1300  如果File we map to (can be NULL). fput(File we map to (can be NULL). )
1302  vm_area_free(vma)
1303  返回:ret
1305  sharing_violation :
1306  lease a write lock
1307  打印警告信息("Attempt to share mismatched mappings\n")
1308  ret等于负EINVAL
1309  转到:error
1311  error_getting_vma :
1312  kmem_cache_free(list of mapped, potentially shareable regions , region)
1313  打印警告信息("Allocation of vma for %lu byte allocation from process %d failed\n", len, pid)
1315  Show free area list (used inside shift_scroll-lock stuff)* We also calculate the percentage fragmentation
1316  返回:负ENOMEM
1318  error_getting_region :
1319  打印警告信息("Allocation of vm region for %lu byte allocation from process %d failed\n", len, pid)
1321  Show free area list (used inside shift_scroll-lock stuff)* We also calculate the percentage fragmentation
1322  返回:负ENOMEM