• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef FS_PAGE_FAULT_H
13 #define FS_PAGE_FAULT_H
14 
15 #include <errno.h>
16 #include <string.h>
17 #include <assert.h>
18 #include <pthread.h>
19 #include <sys/mman.h>
20 #include <chcore/ipc.h>
21 #include <chcore/proc.h>
22 #include <chcore/syscall.h>
23 #include <chcore/memory.h>
24 #include <chcore/container/list.h>
25 
26 #include "fs_vnode.h"
27 
28 /* Same structure in kernel, item of user-level ring buffer */
29 struct user_fault_msg {
30     badge_t fault_badge;
31     vaddr_t fault_va;
32 };
33 
34 /* Mapping from client mmap area to server vnode structure */
35 struct fmap_area_mapping {
36     badge_t client_badge;
37     vaddr_t client_va_start;
38     size_t length;
39 
40     struct fs_vnode *vnode;
41     off_t file_offset;
42     u64 flags;
43     vmr_prop_t prot;
44 
45     struct list_head node;
46 };
47 
48 extern struct list_head fmap_area_mappings;
49 extern pthread_rwlock_t fmap_area_lock;
50 
51 int fs_page_fault_init(void);
52 
53 int fmap_area_insert(badge_t client_badge, vaddr_t client_va_start,
54                      size_t length, struct fs_vnode *vnode, off_t file_offset,
55                      u64 flags, vmr_prop_t prot);
56 int fmap_area_find(badge_t client_badge, vaddr_t client_va, size_t *area_off,
57                    struct fs_vnode **vnode, off_t *file_offset, u64 *flags,
58                    vmr_prop_t *prot);
59 int fmap_area_remove(badge_t client_badge, vaddr_t client_va_start,
60                      size_t length);
61 void fmap_area_recycle(badge_t client_badge);
62 
63 #endif /* FS_PAGE_FAULT_H */