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_P2SEG_FUNC(f) - get a P2 address of a funct...
details: https://anonhg.NetBSD.org/src/rev/fe4bf4e8338c
branches: trunk
changeset: 936988:fe4bf4e8338c
user: uwe <uwe%NetBSD.org@localhost>
date: Mon Aug 03 21:53:25 2020 +0000
description:
SH3_P2SEG_FUNC(f) - get a P2 address of a function.
Just SH3_P1SEG_TO_P2SEG + cast, but we now define SH3_P1SEG_TO_P2SEG
and SH3_P2SEG_TO_P1SEG to use arithmetic, not bitwise ops. That gives
the same result for the correct P1/P2 input values, but addition can
be done at link time with addends. Thus SH3_P2SEG_FUNC compiles to a
constant P2 address.
diffstat:
sys/arch/sh3/include/cpu.h | 12 +++++++++---
sys/arch/sh3/sh3/db_interface.c | 12 ++++++------
2 files changed, 15 insertions(+), 9 deletions(-)
diffs (69 lines):
diff -r 69f80438b0a9 -r fe4bf4e8338c sys/arch/sh3/include/cpu.h
--- a/sys/arch/sh3/include/cpu.h Mon Aug 03 21:44:43 2020 +0000
+++ b/sys/arch/sh3/include/cpu.h Mon Aug 03 21:53:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.59 2019/12/01 15:34:45 ad Exp $ */
+/* $NetBSD: cpu.h,v 1.60 2020/08/03 21:53:25 uwe Exp $ */
/*-
* Copyright (c) 2002, 2019 The NetBSD Foundation, Inc. All rights reserved.
@@ -151,8 +151,14 @@
#define SH3_P2SEG_TO_PHYS(x) ((uint32_t)(x) & SH3_PHYS_MASK)
#define SH3_PHYS_TO_P1SEG(x) ((uint32_t)(x) | SH3_P1SEG_BASE)
#define SH3_PHYS_TO_P2SEG(x) ((uint32_t)(x) | SH3_P2SEG_BASE)
-#define SH3_P1SEG_TO_P2SEG(x) ((uint32_t)(x) | 0x20000000)
-#define SH3_P2SEG_TO_P1SEG(x) ((uint32_t)(x) & ~0x20000000)
+#define SH3_P1SEG_TO_P2SEG(x) ((uint32_t)(x) + 0x20000000u)
+#define SH3_P2SEG_TO_P1SEG(x) ((uint32_t)(x) - 0x20000000u)
+
+#ifdef __GNUC__
+#define SH3_P2SEG_FUNC(f) ((__typeof__(f) *)SH3_P1SEG_TO_P2SEG(f))
+#else
+#define SH3_P2SEG_FUNC(f) ((void *)SH3_P1SEG_TO_P2SEG(f))
+#endif
#ifndef __lint__
diff -r 69f80438b0a9 -r fe4bf4e8338c sys/arch/sh3/sh3/db_interface.c
--- a/sys/arch/sh3/sh3/db_interface.c Mon Aug 03 21:44:43 2020 +0000
+++ b/sys/arch/sh3/sh3/db_interface.c Mon Aug 03 21:53:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $ */
+/* $NetBSD: db_interface.c,v 1.65 2020/08/03 21:53:25 uwe Exp $ */
/*-
* Copyright (C) 2002 UCHIYAMA Yasushi. All rights reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.65 2020/08/03 21:53:25 uwe Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -331,8 +331,8 @@
void (*get_utlb_p2)(uint32_t, uint32_t *, uint32_t *, uint32_t *);
uint32_t aa, da1, da2;
- get_itlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_itlb_sh4);
- get_utlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_utlb_sh4);
+ get_itlb_p2 = SH3_P2SEG_FUNC(__db_get_itlb_sh4);
+ get_utlb_p2 = SH3_P2SEG_FUNC(__db_get_utlb_sh4);
/* MMU configuration */
r = _reg_read_4(SH4_MMUCR);
@@ -478,11 +478,11 @@
#ifdef SH3
if (CPU_IS_SH3)
- cachedump_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_cachedump_sh3);
+ cachedump_p2 = SH3_P2SEG_FUNC(__db_cachedump_sh3);
#endif
#ifdef SH4
if (CPU_IS_SH4)
- cachedump_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_cachedump_sh4);
+ cachedump_p2 = SH3_P2SEG_FUNC(__db_cachedump_sh4);
#endif
(*cachedump_p2)(have_addr ? addr : 0);
}
Home |
Main Index |
Thread Index |
Old Index