Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh3/sh3 Misc cosmetic fixes:
details: https://anonhg.NetBSD.org/src/rev/dcc3185868c7
branches: trunk
changeset: 985800:dcc3185868c7
user: rin <rin%NetBSD.org@localhost>
date: Wed Sep 08 00:35:56 2021 +0000
description:
Misc cosmetic fixes:
- Remove redundant parentheses/braces/comments.
- Improve uniformity of panic messages. Also, use __func__ instead of
hard-coded function names.
- Fix indents.
diffstat:
sys/arch/sh3/sh3/pmap.c | 120 ++++++++++++++++++++++-------------------------
1 files changed, 56 insertions(+), 64 deletions(-)
diffs (truncated from 417 to 300 lines):
diff -r 661ea90c85bd -r dcc3185868c7 sys/arch/sh3/sh3/pmap.c
--- a/sys/arch/sh3/sh3/pmap.c Wed Sep 08 00:24:29 2021 +0000
+++ b/sys/arch/sh3/sh3/pmap.c Wed Sep 08 00:35:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $ */
+/* $NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.88 2021/09/08 00:24:29 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.89 2021/09/08 00:35:56 rin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -153,7 +153,7 @@
va = SH3_PHYS_TO_P1SEG(pa);
memset((void *)va, 0, size);
- return (va);
+ return va;
}
vaddr_t
@@ -162,7 +162,7 @@
int i, n;
if (maxkvaddr <= __pmap_kve)
- return (__pmap_kve);
+ return __pmap_kve;
i = __PMAP_PTP_INDEX(__pmap_kve - VM_MIN_KERNEL_ADDRESS);
__pmap_kve = __PMAP_PTP_TRUNC(maxkvaddr);
@@ -190,9 +190,9 @@
}
}
- return (__pmap_kve);
+ return __pmap_kve;
error:
- panic("pmap_growkernel: out of memory.");
+ panic("%s: out of memory", __func__);
/* NOTREACHED */
}
@@ -248,7 +248,7 @@
uvm_pagealloc(NULL, 0, NULL,
UVM_PGA_USERESERVE | UVM_PGA_ZERO)));
- return (pmap);
+ return pmap;
}
void
@@ -271,7 +271,7 @@
for (j = 0; j < __PMAP_PTP_PG_N; j++, pte++)
KDASSERT(*pte == 0);
}
-#endif /* DEBUG */
+#endif
/* Purge cache entry for next use of this page. */
if (SH_HAS_VIRTUAL_ALIAS)
sh_dcache_inv_range(va, PAGE_SIZE);
@@ -323,7 +323,7 @@
struct vm_page *pg;
struct vm_page_md *pvh;
pt_entry_t entry, *pte;
- bool kva = (pmap == pmap_kernel());
+ bool kva = pmap == pmap_kernel();
/* "flags" never exceed "prot" */
KDASSERT(prot != 0 && ((flags & VM_PROT_ALL) & ~prot) == 0);
@@ -362,24 +362,23 @@
/* Check for existing mapping */
if (__pmap_map_change(pmap, va, pa, prot, entry))
- return (0);
+ return 0;
/* Add to physical-virtual map list of this page */
if (__pmap_pv_enter(pmap, pg, va)) {
if (flags & PMAP_CANFAIL)
return ENOMEM;
- panic("%s: __pmap_pv_enter failed", __func__);
+ panic("%s: cannot allocate pv", __func__);
}
} else { /* bus-space (always uncached map) */
- if (kva) {
+ if (kva)
entry |= PG_V | PG_SH |
- ((prot & VM_PROT_WRITE) ?
- (PG_PR_KRW | PG_D) : PG_PR_KRO);
- } else {
+ (prot & VM_PROT_WRITE) ?
+ (PG_PR_KRW | PG_D) : PG_PR_KRO;
+ else
entry |= PG_V |
- ((prot & VM_PROT_WRITE) ?
- (PG_PR_URW | PG_D) : PG_PR_URO);
- }
+ (prot & VM_PROT_WRITE) ?
+ (PG_PR_URW | PG_D) : PG_PR_URO;
}
/* Register to page table */
@@ -393,7 +392,7 @@
__pmap_pv_remove(pmap, pg, va);
return ENOMEM;
}
- panic("%s: __pmap_pte_alloc failed", __func__);
+ panic("%s: cannot allocate pte", __func__);
}
}
@@ -410,7 +409,7 @@
pmap->pm_stats.wired_count++;
pmap->pm_stats.resident_count++;
- return (0);
+ return 0;
}
/*
@@ -428,13 +427,13 @@
vaddr_t eva = va + PAGE_SIZE;
if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
- ((oentry = *pte) == 0))
- return (false); /* no mapping exists. */
+ (oentry = *pte) == 0)
+ return false; /* no mapping exists. */
if (pa != (oentry & PG_PPN)) {
/* Enter a mapping at a mapping to another physical page. */
pmap_remove(pmap, va, eva);
- return (false);
+ return false;
}
/* Pre-existing mapping */
@@ -454,10 +453,10 @@
} else if (entry & _PG_WIRED) {
/* unwired -> wired. make sure to reflect "flags" */
pmap_remove(pmap, va, eva);
- return (false);
+ return false;
}
- return (true); /* mapping was changed. */
+ return true; /* mapping was changed. */
}
/*
@@ -575,7 +574,7 @@
#ifdef DEBUG
/* Check duplicated map. */
SLIST_FOREACH(pv, &pvh->pvh_head, pv_link)
- KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
+ KDASSERT(!(pv->pv_pmap == pmap && pv->pv_va == vaddr));
#endif
splx(s);
}
@@ -638,17 +637,17 @@
if (pmap == pmap_kernel() && (va >> 30) == 2) {
if (pap != NULL)
*pap = va & SH3_PHYS_MASK;
- return (true);
+ return true;
}
pte = __pmap_pte_lookup(pmap, va);
if (pte == NULL || *pte == 0)
- return (false);
+ return false;
if (pap != NULL)
*pap = (*pte & PG_PPN) | (va & PGOFSET);
- return (true);
+ return true;
}
void
@@ -667,23 +666,20 @@
switch (prot) {
default:
- panic("pmap_protect: invalid protection mode %x", prot);
+ panic("%s: invalid protection mode %x", __func__, prot);
/* NOTREACHED */
case VM_PROT_READ:
- /* FALLTHROUGH */
case VM_PROT_READ | VM_PROT_EXECUTE:
protbits = kernel ? PG_PR_KRO : PG_PR_URO;
break;
case VM_PROT_READ | VM_PROT_WRITE:
- /* FALLTHROUGH */
case VM_PROT_ALL:
protbits = kernel ? PG_PR_KRW : PG_PR_URW;
break;
}
for (va = sva; va < eva; va += PAGE_SIZE) {
-
- if (((pte = __pmap_pte_lookup(pmap, va)) == NULL) ||
+ if ((pte = __pmap_pte_lookup(pmap, va)) == NULL ||
(entry = *pte) == 0)
continue;
@@ -713,12 +709,10 @@
switch (prot) {
case VM_PROT_READ | VM_PROT_WRITE:
- /* FALLTHROUGH */
case VM_PROT_ALL:
break;
case VM_PROT_READ:
- /* FALLTHROUGH */
case VM_PROT_READ | VM_PROT_EXECUTE:
s = splvm();
SLIST_FOREACH(pv, &pvh->pvh_head, pv_link) {
@@ -781,9 +775,8 @@
/* sync cache since we access via P2. */
sh_dcache_wbinv_all();
memset((void *)SH3_PHYS_TO_P2SEG(phys), 0, PAGE_SIZE);
- } else {
+ } else
memset((void *)SH3_PHYS_TO_P1SEG(phys), 0, PAGE_SIZE);
- }
}
void
@@ -795,10 +788,9 @@
sh_dcache_wbinv_all();
memcpy((void *)SH3_PHYS_TO_P2SEG(dst),
(void *)SH3_PHYS_TO_P2SEG(src), PAGE_SIZE);
- } else {
+ } else
memcpy((void *)SH3_PHYS_TO_P1SEG(dst),
(void *)SH3_PHYS_TO_P1SEG(src), PAGE_SIZE);
- }
}
bool
@@ -806,7 +798,7 @@
{
struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
- return ((pvh->pvh_flags & PVH_REFERENCED) ? true : false);
+ return (pvh->pvh_flags & PVH_REFERENCED) ? true : false;
}
bool
@@ -841,7 +833,7 @@
}
splx(s);
- return (true);
+ return true;
}
bool
@@ -849,7 +841,7 @@
{
struct vm_page_md *pvh = VM_PAGE_TO_MD(pg);
- return ((pvh->pvh_flags & PVH_MODIFIED) ? true : false);
+ return (pvh->pvh_flags & PVH_MODIFIED) ? true : false;
}
bool
@@ -865,14 +857,14 @@
modified = pvh->pvh_flags & PVH_MODIFIED;
if (!modified)
- return (false);
+ return false;
pvh->pvh_flags &= ~PVH_MODIFIED;
s = splvm();
if (SLIST_EMPTY(&pvh->pvh_head)) {/* no map on this page */
splx(s);
- return (true);
+ return true;
}
/* Write-back and invalidate TLB entry */
@@ -897,14 +889,14 @@
}
splx(s);
- return (true);
+ return true;
}
Home |
Main Index |
Thread Index |
Old Index