Function report |
Source Code:mm\nommu.c |
Create Date:2022-07-28 14:37:31 |
| Last Modify:2020-03-17 21:26:27 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:handle mapping creation for uClinux
Proto: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)
Type:unsigned long
Parameter:
| Type | Parameter | Name |
|---|---|---|
| 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 |
| 1115 | populate = 0 |
| 1119 | ret = determine whether a mapping should be permitted and, if so, what sort of* mapping we're capable of supporting |
| 1125 | addr = 0 |
| 1130 | vm_flags |= we've determined that we can make the mapping, now translate what we* now know into VMA flags |
| 1134 | If Not region Then Go to error_getting_region |
| 1137 | vma = vm_area_alloc(mm) |
| 1138 | If Not vma Then Go to error_getting_vma |
| 1142 | VMA vm_flags = vm_flags |
| 1145 | Flags, see mm.h. = vm_flags |
| 1148 | If file Then |
| 1149 | he backing file or NULL = get_file(file) |
| 1153 | lock for writing |
| 1163 | If vm_flags & VM_MAYSHARE Then |
| 1167 | pglen = len + PAGE_SIZE - 1 >> PAGE_SHIFT determines the page size |
| 1173 | If Not (VMA vm_flags & VM_MAYSHARE) Then Continue |
| 1177 | If file_inode(he backing file or NULL ) != file_inode(file) Then Continue |
| 1181 | If he offset in vm_file corresponding to vm_start >= pgend Then Continue |
| 1185 | rpglen = rpglen + PAGE_SIZE - 1 >> PAGE_SHIFT determines the page size |
| 1192 | If ( he offset in vm_file corresponding to vm_start != pgoff || rpglen != pglen ) && Not ( pgoff >= he offset in vm_file corresponding to vm_start && pgend <= rpgend ) Then |
| 1195 | If Not (capabilities & Can be mapped directly (MAP_SHARED)) Then Go to sharing_violation |
| 1197 | Continue |
| 1203 | start = start address of region |
| 1204 | start += pgoff - he offset in vm_file corresponding to vm_start << PAGE_SHIFT determines the page size |
| 1208 | If VMA vm_flags & VM_MAPPED_COPY Then Flags, see mm.h. |= VM_MAPPED_COPY |
| 1210 | Else |
| 1211 | ret = set up a shared mapping on a file (the driver or filesystem provides and* pins the storage) |
| 1212 | If ret < 0 Then |
| 1213 | vm_region = NULL |
| 1214 | Our start address within vm_mm. = 0 |
| 1217 | pregion = NULL |
| 1218 | Go to error_just_free |
| 1221 | fput(he backing file or NULL ) |
| 1225 | Go to share |
| 1232 | If capabilities & Can be mapped directly (MAP_SHARED) Then |
| 1235 | If IS_ERR_VALUE(addr) Then |
| 1237 | If ret != -ENOSYS Then Go to error_just_free |
| 1244 | If Not (capabilities & Copy can be mapped (MAP_PRIVATE)) Then Go to error_just_free |
| 1248 | Else |
| 1260 | If file && Flags, see mm.h. & VM_SHARED Then ret = set up a shared mapping on a file (the driver or filesystem provides and* pins the storage) |
| 1264 | If ret < 0 Then Go to error_just_free |
| 1278 | total_vm += len >> PAGE_SHIFT determines the page size |
| 1280 | share : |
| 1285 | If Flags, see mm.h. & VM_EXEC && Not rue if the icache has been flushed for* this region Then |
| 1290 | lease a write lock |
| 1292 | Return result |
| 1294 | error_just_free : |
| 1295 | lease a write lock |
| 1296 | error : |
| 1297 | If he backing file or NULL Then fput(he backing file or NULL ) |
| 1300 | If File we map to (can be NULL). Then fput(File we map to (can be NULL). ) |
| 1302 | vm_area_free(vma) |
| 1303 | Return ret |
| 1305 | sharing_violation : |
| 1306 | lease a write lock |
| 1307 | pr_warn("Attempt to share mismatched mappings\n") |
| 1309 | Go to error |
| 1311 | error_getting_vma : |
| 1316 | Return -ENOMEM |
| 1318 | error_getting_region : |
| 1322 | Return -ENOMEM |
| Source code conversion tool public plug-in interface | X |
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |