git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: nearly complete POSIX.1-2008 compliant terminal interface implementation
[lunaix-os.git]
/
lunaix-os
/
arch
/
i386
/
mm
/
pfault.c
diff --git
a/lunaix-os/arch/i386/mm/pfault.c
b/lunaix-os/arch/i386/mm/pfault.c
index b028d844d9d64b4ee72a3b2d8faa111ec981e7e5..faf7da066d30a3cba019c1775b9af66c4fca2a86 100644
(file)
--- a/
lunaix-os/arch/i386/mm/pfault.c
+++ b/
lunaix-os/arch/i386/mm/pfault.c
@@
-1,4
+1,3
@@
-#include <lunaix/common.h>
#include <lunaix/mm/mm.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/region.h>
#include <lunaix/mm/mm.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/region.h>
@@
-13,6
+12,8
@@
#include <klibc/string.h>
#include <klibc/string.h>
+LOG_MODULE("pf")
+
static u32_t
get_ptattr(struct mm_region* vmr)
{
static u32_t
get_ptattr(struct mm_region* vmr)
{
@@
-26,15
+27,6
@@
get_ptattr(struct mm_region* vmr)
return ptattr & 0xfff;
}
return ptattr & 0xfff;
}
-static void
-kprintf(const char* fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- __kprintf("PFAULT", fmt, args);
- va_end(args);
-}
-
#define COW_MASK (REGION_RSHARED | REGION_READ | REGION_WRITE)
extern void
#define COW_MASK (REGION_RSHARED | REGION_READ | REGION_WRITE)
extern void
@@
-68,10
+60,10
@@
intr_routine_page_fault(const isr_param* param)
if (PG_IS_PRESENT(*pte)) {
if (((errcode ^ mapping.flags) & PG_ALLOW_USER)) {
// invalid access
if (PG_IS_PRESENT(*pte)) {
if (((errcode ^ mapping.flags) & PG_ALLOW_USER)) {
// invalid access
-
kprintf(KDEBUG "invalid user access. (%p->%p, attr:0x%x)\n
",
-
mapping.va,
-
mapping.pa,
-
mapping.flags);
+
DEBUG("invalid user access. (%p->%p, attr:0x%x)
",
+ mapping.va,
+ mapping.pa,
+ mapping.flags);
goto segv_term;
}
if ((hit_region->attr & COW_MASK) == COW_MASK) {
goto segv_term;
}
if ((hit_region->attr & COW_MASK) == COW_MASK) {
@@
-100,7
+92,7
@@
intr_routine_page_fault(const isr_param* param)
goto oom;
}
goto oom;
}
- *pte =
*pte |
pa | get_ptattr(hit_region);
+ *pte = pa | get_ptattr(hit_region);
memset((void*)PG_ALIGN(ptr), 0, PG_SIZE);
goto resolved;
}
memset((void*)PG_ALIGN(ptr), 0, PG_SIZE);
goto resolved;
}
@@
-123,18
+115,14
@@
intr_routine_page_fault(const isr_param* param)
}
cpu_flush_page((ptr_t)pte);
}
cpu_flush_page((ptr_t)pte);
- *pte =
(*pte & 0xFFF) |
pa | get_ptattr(hit_region);
+ *pte = pa | get_ptattr(hit_region);
memset((void*)ptr, 0, PG_SIZE);
memset((void*)ptr, 0, PG_SIZE);
- int errno = 0;
- if (mseg_off < hit_region->flen) {
- errno =
- file->ops->read_page(file->inode, (void*)ptr, PG_SIZE, mfile_off);
- }
+ int errno = file->ops->read_page(file->inode, (void*)ptr, mfile_off);
if (errno < 0) {
if (errno < 0) {
-
kprintf(KERROR "fail to populate page (%d)\n
", errno);
+
ERROR("fail to populate page (%d)
", errno);
goto segv_term;
}
goto segv_term;
}
@@
-149,15
+137,15
@@
intr_routine_page_fault(const isr_param* param)
;
oom:
;
oom:
-
kprintf(KERROR "out of memory\n
");
+
ERROR("out of memory
");
segv_term:
segv_term:
-
kprintf(KERROR "(pid: %d) Segmentation fault on %p (%p:%p,e=0x%x)\n
",
-
__current->pid,
-
ptr,
-
param->execp->cs,
-
param->execp->eip,
-
param->execp->err_code);
+
ERROR("(pid: %d) Segmentation fault on %p (%p:%p,e=0x%x)
",
+ __current->pid,
+ ptr,
+ param->execp->cs,
+ param->execp->eip,
+ param->execp->err_code);
sigset_add(__current->sigctx.sig_pending, _SIGSEGV);
sigset_add(__current->sigctx.sig_pending, _SIGSEGV);