diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-03-05 21:48:24 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-03-05 21:48:24 +0000 |
commit | 5264247e94d08b60146c1b1ca9a1a89fb3a8bb6d (patch) | |
tree | 3311f51d27fe4450590ecd295e6b662b4fddde0e /sys | |
parent | bfd82ada45bbaa1265b4a6714224e7e0d6f01b60 (diff) |
Add pmap_prefer() for SH4, from NetBSD; ok drahn@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sh/include/cache.h | 4 | ||||
-rw-r--r-- | sys/arch/sh/include/pmap.h | 11 | ||||
-rw-r--r-- | sys/arch/sh/sh/cache.c | 3 | ||||
-rw-r--r-- | sys/arch/sh/sh/cache_sh4.c | 3 | ||||
-rw-r--r-- | sys/arch/sh/sh/pmap.c | 22 |
5 files changed, 38 insertions, 5 deletions
diff --git a/sys/arch/sh/include/cache.h b/sys/arch/sh/include/cache.h index 2e4fa50249a..0d70bfce04a 100644 --- a/sys/arch/sh/include/cache.h +++ b/sys/arch/sh/include/cache.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cache.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $OpenBSD: cache.h,v 1.2 2007/03/05 21:48:21 miod Exp $ */ /* $NetBSD: cache.h,v 1.7 2006/01/21 00:46:36 uwe Exp $ */ /*- @@ -157,6 +157,8 @@ extern int sh_cache_ram_mode; extern int sh_cache_index_mode_icache; extern int sh_cache_index_mode_dcache; +extern int sh_cache_prefer_mask; + extern struct sh_cache_ops sh_cache_ops; #define sh_icache_sync_all() \ diff --git a/sys/arch/sh/include/pmap.h b/sys/arch/sh/include/pmap.h index b26dd562137..bd70245409a 100644 --- a/sys/arch/sh/include/pmap.h +++ b/sys/arch/sh/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $OpenBSD: pmap.h,v 1.2 2007/03/05 21:48:21 miod Exp $ */ /* $NetBSD: pmap.h,v 1.28 2006/04/10 23:12:11 uwe Exp $ */ /*- @@ -80,6 +80,15 @@ pmap_remove_all(struct pmap *pmap) /* Nothing. */ } +/* + * pmap_prefer() helps to avoid virtual cache aliases on SH4 CPUs + * which have the virtually-indexed cache. + */ +#ifdef SH4 +#define PMAP_PREFER(pa, va) pmap_prefer((pa), (va)) +void pmap_prefer(vaddr_t, vaddr_t *); +#endif /* SH4 */ + #define __HAVE_PMAP_DIRECT #define pmap_map_direct(pg) SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg)) #define pmap_unmap_direct(va) PHYS_TO_VM_PAGE(SH3_P1SEG_TO_PHYS((va))) diff --git a/sys/arch/sh/sh/cache.c b/sys/arch/sh/sh/cache.c index 003b045e46d..4e2581e78b6 100644 --- a/sys/arch/sh/sh/cache.c +++ b/sys/arch/sh/sh/cache.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cache.c,v 1.2 2007/02/28 19:37:55 deraadt Exp $ */ +/* $OpenBSD: cache.c,v 1.3 2007/03/05 21:48:23 miod Exp $ */ /* $NetBSD: cache.c,v 1.11 2006/01/02 23:37:34 uwe Exp $ */ /*- @@ -73,6 +73,7 @@ int sh_cache_line_size; int sh_cache_ram_mode; int sh_cache_index_mode_icache; int sh_cache_index_mode_dcache; +int sh_cache_prefer_mask; void sh_cache_init() diff --git a/sys/arch/sh/sh/cache_sh4.c b/sys/arch/sh/sh/cache_sh4.c index 2f0a0fc9453..ace1e4317e0 100644 --- a/sys/arch/sh/sh/cache_sh4.c +++ b/sys/arch/sh/sh/cache_sh4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cache_sh4.c,v 1.1 2006/10/06 21:02:55 miod Exp $ */ +/* $OpenBSD: cache_sh4.c,v 1.2 2007/03/05 21:48:23 miod Exp $ */ /* $NetBSD: cache_sh4.c,v 1.15 2005/12/24 23:24:02 perry Exp $ */ /*- @@ -132,6 +132,7 @@ sh4_cache_config(void) sh_cache_enable_dcache = (r & SH4_CCR_OCE); sh_cache_ways = ways; sh_cache_line_size = SH4_CACHE_LINESZ; + sh_cache_prefer_mask = (dcache_size / ways - 1); sh_cache_write_through_p0_u0_p3 = (r & SH4_CCR_WT); sh_cache_write_through_p1 = !(r & SH4_CCR_CB); sh_cache_write_through = sh_cache_write_through_p0_u0_p3 && diff --git a/sys/arch/sh/sh/pmap.c b/sys/arch/sh/sh/pmap.c index d6ed6fbb750..05befe18f8d 100644 --- a/sys/arch/sh/sh/pmap.c +++ b/sys/arch/sh/sh/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.5 2007/03/05 21:47:55 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.6 2007/03/05 21:48:23 miod Exp $ */ /* $NetBSD: pmap.c,v 1.55 2006/08/07 23:19:36 tsutsui Exp $ */ /*- @@ -884,6 +884,26 @@ pmap_clear_modify(struct vm_page *pg) return (TRUE); } +#ifdef SH4 +/* + * pmap_prefer(vaddr_t foff, vaddr_t *vap) + * + * Find first virtual address >= *vap that doesn't cause + * a virtual cache alias against vaddr_t foff. + */ +void +pmap_prefer(vaddr_t foff, vaddr_t *vap) +{ + vaddr_t va; + + if (SH_HAS_VIRTUAL_ALIAS) { + va = *vap; + + *vap = va + ((foff - va) & sh_cache_prefer_mask); + } +} +#endif /* SH4 */ + /* * pv_entry pool allocator: * void *__pmap_pv_page_alloc(struct pool *pool, int flags): |