From 14013f679d0bb9def0afff3a6cf041828c13dcf4 Mon Sep 17 00:00:00 2001 From: scw Date: Thu, 11 Jul 2002 21:21:58 +0000 Subject: [PATCH] Add a macro which verifies that a 64-bit value is a valid effective address as defined by the cpu's Implemented Effective Address bits. --- sys/arch/sh5/include/cpu.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/arch/sh5/include/cpu.h b/sys/arch/sh5/include/cpu.h index ecce9888c84a..cf72a820509c 100644 --- a/sys/arch/sh5/include/cpu.h +++ b/sys/arch/sh5/include/cpu.h @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.2 2002/07/11 14:10:39 scw Exp $ */ +/* $NetBSD: cpu.h,v 1.3 2002/07/11 21:21:58 scw Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -104,11 +104,26 @@ #define SH5_KSEG0_SIZE 0x20000000 #define SH5_KSEG1_SIZE 0x20000000 - +/* + * Default to NEFF == 32 if port-specific code doesn't define it + */ #ifndef SH5_NEFF_BITS #define SH5_NEFF_BITS 32 #endif +/* + * This hairy macro evaluates true if (register_t)`eff' is a valid + * effective address for the CPU's Implemented Effective Address space. + */ +#if SH5_NEFF_BITS < 64 +#define SH5_EFF_IS_VALID(eff) (((((eff) & (1ULL << 63)) ? \ + ((eff) ^ 0xffffffff00000000ULL) : (eff)) & \ + ~((1ULL << SH5_NEFF_BITS) - 1)) == 0) +#else +#define SH5_EFF_IS_VALID(eff) 1 /* Everything's valid in this case */ +#endif + + #ifndef SH5_ASID_BITS #define SH5_ASID_BITS 8 #endif