summaryrefslogtreecommitdiff
path: root/config/coreboot/fam15h_udimm/patches
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-04 02:36:41 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-04 02:47:25 +0100
commitda3c9bb3c5c3b1f2e6e67a3695ce39b17bf68d5b (patch)
treeb81cdd418a4906c846800a8c5094b312e74f57df /config/coreboot/fam15h_udimm/patches
parenta05010503f9a748943033d1fc40e36625e72dcbb (diff)
merge config/ and resources/
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'config/coreboot/fam15h_udimm/patches')
-rw-r--r--config/coreboot/fam15h_udimm/patches/0001-Revert-Revert-nb-amd-mct_ddr3-Fix-RDIMM-training-fai.patch31
-rw-r--r--config/coreboot/fam15h_udimm/patches/0003-Tweak-cmos-defaults-for-KCMA-D8-for-a-little-speed-b.patch38
-rw-r--r--config/coreboot/fam15h_udimm/patches/0006-asus-kgpe-d16-enable-lc_cache_partitioning-and-exper.patch32
-rw-r--r--config/coreboot/fam15h_udimm/patches/0007-util-cbfstool-Makefile-support-distclean.patch41
-rw-r--r--config/coreboot/fam15h_udimm/patches/0008-crossgcc-patch-binutils-2.32-for-newer-hostcc.patch37
-rw-r--r--config/coreboot/fam15h_udimm/patches/0009-fix-crossgcc-acpica-build-on-newer-hostcc.patch108
-rw-r--r--config/coreboot/fam15h_udimm/patches/0010-coreboot-fam15h-use-new-upstream-for-acpica.patch38
-rw-r--r--config/coreboot/fam15h_udimm/patches/0011-gcc-8.3.0_gnat_eh_new.patch232
8 files changed, 557 insertions, 0 deletions
diff --git a/config/coreboot/fam15h_udimm/patches/0001-Revert-Revert-nb-amd-mct_ddr3-Fix-RDIMM-training-fai.patch b/config/coreboot/fam15h_udimm/patches/0001-Revert-Revert-nb-amd-mct_ddr3-Fix-RDIMM-training-fai.patch
new file mode 100644
index 00000000..3c131a86
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0001-Revert-Revert-nb-amd-mct_ddr3-Fix-RDIMM-training-fai.patch
@@ -0,0 +1,31 @@
+From 8f2988cba4fffef1bd4f65e123c76bf4b7a18672 Mon Sep 17 00:00:00 2001
+From: "D.d.P.F. Lombard" <lombard@lombards.xyz>
+Date: Sun, 7 Feb 2021 15:29:40 +0100
+Subject: [PATCH 1/6] Revert "Revert "nb/amd/mct_ddr3: Fix RDIMM training
+ failure on Fam15h" (fixes a bug that prevent certain RAM modules from
+ booting)
+
+This reverts commit 610d1c67b2298a9840681c2b4492b6d3fdf44a46.
+
+After 610d1c67b2298a9840681c2b4492b6d3fdf44a46 many RAM modules wouldn't work and you couldn't even see any output on the screen.
+---
+ src/northbridge/amd/amdmct/mct_ddr3/mctproc.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/northbridge/amd/amdmct/mct_ddr3/mctproc.c b/src/northbridge/amd/amdmct/mct_ddr3/mctproc.c
+index ddaaaab8d5..3b07786b91 100644
+--- a/src/northbridge/amd/amdmct/mct_ddr3/mctproc.c
++++ b/src/northbridge/amd/amdmct/mct_ddr3/mctproc.c
+@@ -71,6 +71,9 @@ u32 mct_SetDramConfigMisc2(struct DCTStatStruc *pDCTstat,
+ misc2 |= ((cs_mux_67 & 0x1) << 27);
+ misc2 &= ~(0x1 << 26); /* CsMux45 = cs_mux_45 */
+ misc2 |= ((cs_mux_45 & 0x1) << 26);
++
++ if (pDCTstat->Status & (1 << SB_Registered))
++ misc2 |= 1 << SubMemclkRegDly;
+ } else if (pDCTstat->LogicalCPUID & (AMD_DR_Dx | AMD_DR_Cx)) {
+ if (pDCTstat->Status & (1 << SB_Registered)) {
+ misc2 |= 1 << SubMemclkRegDly;
+--
+2.25.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0003-Tweak-cmos-defaults-for-KCMA-D8-for-a-little-speed-b.patch b/config/coreboot/fam15h_udimm/patches/0003-Tweak-cmos-defaults-for-KCMA-D8-for-a-little-speed-b.patch
new file mode 100644
index 00000000..5a39bd69
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0003-Tweak-cmos-defaults-for-KCMA-D8-for-a-little-speed-b.patch
@@ -0,0 +1,38 @@
+From 7a00638cea41ad939a59fc0e5996959435fbdb7f Mon Sep 17 00:00:00 2001
+From: "D.d.P.F. Lombard" <lombard@lombards.xyz>
+Date: Sun, 7 Feb 2021 16:40:05 +0100
+Subject: [PATCH 3/6] Tweak cmos defaults for KCMA-D8 (for a little speed
+ boost)
+
+63xx CPUs have the option to use a reduced latency value inside the crossbar.
+Setting "experimental_memory_speed_boost=Enable" aparently only has an effect
+on 63xx CPUs and may, in certain cases, yield a slight memory bandwidth
+increase (according to Timothy Pearson), but maybe it also works for
+43xx CPUs.
+
+Setting "l3_cache_partitioning=Enable" will increase performance in certain
+situations. See:
+https://developer.arm.com/documentation/100453/0401/functional-description/l3-cache/l3-cache-partitioning?lang=en
+---
+ src/mainboard/asus/kcma-d8/cmos.default | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/mainboard/asus/kcma-d8/cmos.default b/src/mainboard/asus/kcma-d8/cmos.default
+index 306687157f..4e033d756f 100644
+--- a/src/mainboard/asus/kcma-d8/cmos.default
++++ b/src/mainboard/asus/kcma-d8/cmos.default
+@@ -21,9 +21,9 @@ sata_ahci_mode=Enable
+ sata_alpm=Disable
+ maximum_p_state_limit=0xf
+ probe_filter=Auto
+-l3_cache_partitioning=Disable
++l3_cache_partitioning=Enable
+ gart=Enable
+ ehci_async_data_cache=Enable
+-experimental_memory_speed_boost=Disable
++experimental_memory_speed_boost=Enable
+ power_on_after_fail=On
+ boot_option=Fallback
+--
+2.25.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0006-asus-kgpe-d16-enable-lc_cache_partitioning-and-exper.patch b/config/coreboot/fam15h_udimm/patches/0006-asus-kgpe-d16-enable-lc_cache_partitioning-and-exper.patch
new file mode 100644
index 00000000..5ada0dff
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0006-asus-kgpe-d16-enable-lc_cache_partitioning-and-exper.patch
@@ -0,0 +1,32 @@
+From f0aac7261e16adc8e61eca7a506ff2de5112be47 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Fri, 7 May 2021 19:43:32 +0100
+Subject: [PATCH 6/6] asus/kgpe-d16: enable lc_cache_partitioning and
+ experimental_memory_speed_boost
+
+This really only benefits 63xx opterons which are less reliable in libreboot due
+to lack of CPU microcode updates, but we might aswell enable this anyway.
+---
+ src/mainboard/asus/kgpe-d16/cmos.default | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/mainboard/asus/kgpe-d16/cmos.default b/src/mainboard/asus/kgpe-d16/cmos.default
+index 7c496a50d7..8a25620e1d 100644
+--- a/src/mainboard/asus/kgpe-d16/cmos.default
++++ b/src/mainboard/asus/kgpe-d16/cmos.default
+@@ -21,10 +21,10 @@ sata_ahci_mode=Enable
+ sata_alpm=Disable
+ maximum_p_state_limit=0xf
+ probe_filter=Auto
+-l3_cache_partitioning=Disable
++l3_cache_partitioning=Enable
+ ieee1394_controller=Enable
+ gart=Enable
+ ehci_async_data_cache=Enable
+-experimental_memory_speed_boost=Disable
++experimental_memory_speed_boost=Enable
+ power_on_after_fail=On
+ boot_option=Fallback
+--
+2.25.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0007-util-cbfstool-Makefile-support-distclean.patch b/config/coreboot/fam15h_udimm/patches/0007-util-cbfstool-Makefile-support-distclean.patch
new file mode 100644
index 00000000..87db312c
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0007-util-cbfstool-Makefile-support-distclean.patch
@@ -0,0 +1,41 @@
+From d5dc3f23eb546cf328fdfe1e918afa028fb9cd8c Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 9 Jul 2023 04:13:52 +0100
+Subject: [PATCH 1/1] util/cbfstool Makefile: support distclean
+
+it just does make-clean
+
+this is so that this super-old coreboot revision
+interfaces well with lbmk, which runs distclean
+on cbfstool (which is supported, on modern cbfstool)
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ util/cbfstool/Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile
+index d5321f6959..b8424d7d87 100644
+--- a/util/cbfstool/Makefile
++++ b/util/cbfstool/Makefile
+@@ -26,7 +26,7 @@ ifittool: $(objutil)/cbfstool/ifittool
+
+ cbfs-compression-tool: $(objutil)/cbfstool/cbfs-compression-tool
+
+-.PHONY: clean cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
++.PHONY: distclean clean cbfstool ifittool fmaptool rmodtool ifwitool cbfs-compression-tool
+ clean:
+ $(RM) fmd_parser.c fmd_parser.h fmd_scanner.c fmd_scanner.h
+ $(RM) $(objutil)/cbfstool/cbfstool $(cbfsobj)
+@@ -55,6 +55,8 @@ install: all
+ $(INSTALL) ifittool $(DESTDIR)$(BINDIR)
+ $(INSTALL) cbfs-compression-tool $(DESTDIR)$(BINDIR)
+
++distclean: clean
++
+ ifneq ($(V),1)
+ .SILENT:
+ endif
+--
+2.40.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0008-crossgcc-patch-binutils-2.32-for-newer-hostcc.patch b/config/coreboot/fam15h_udimm/patches/0008-crossgcc-patch-binutils-2.32-for-newer-hostcc.patch
new file mode 100644
index 00000000..72681490
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0008-crossgcc-patch-binutils-2.32-for-newer-hostcc.patch
@@ -0,0 +1,37 @@
+From 4b4b2bdc2cedb3e219c6f90809e5684441b1dafa Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 9 Jul 2023 04:54:19 +0100
+Subject: [PATCH 1/1] crossgcc: patch binutils 2.32 for newer hostcc
+
+tested on debian sid as of 9 July 2023
+
+implicit string declaration
+
+easy peasy
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ util/crossgcc/patches/binutils-2.32_stringfix.patch | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+ create mode 100644 util/crossgcc/patches/binutils-2.32_stringfix.patch
+
+diff --git a/util/crossgcc/patches/binutils-2.32_stringfix.patch b/util/crossgcc/patches/binutils-2.32_stringfix.patch
+new file mode 100644
+index 0000000000..de27a2752a
+--- /dev/null
++++ b/util/crossgcc/patches/binutils-2.32_stringfix.patch
+@@ -0,0 +1,11 @@
++diff -u binutils-2.32/gold/errors.h binutils-2.32.patched/gold/errors.h
++--- binutils-2.32/gold/errors.h
+++++ binutils-2.32.patched/gold/errors.h
++@@ -24,6 +24,7 @@
++ #define GOLD_ERRORS_H
++
++ #include <cstdarg>
+++#include <string>
++
++ #include "gold-threads.h"
++
+--
+2.40.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0009-fix-crossgcc-acpica-build-on-newer-hostcc.patch b/config/coreboot/fam15h_udimm/patches/0009-fix-crossgcc-acpica-build-on-newer-hostcc.patch
new file mode 100644
index 00000000..ecc06d00
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0009-fix-crossgcc-acpica-build-on-newer-hostcc.patch
@@ -0,0 +1,108 @@
+From 373dd351e374f391c9e2048e5f3e535267a04719 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 9 Jul 2023 19:37:39 +0100
+Subject: [PATCH 1/1] fix crossgcc/acpica build on newer hostcc
+
+Changes made to acpica/iasl:
+
+remove superfluous YYSTYPE declaration
+
+make LuxBuffer variables static, to avoid warnings
+treated as errors about multiple definitions
+
+AcpiGbl_DbOpt_NoRegionSupport - remove this definition
+in source/tools/acpiexec/aemain.c because it's already
+re-defined by acpiexec. otherwise the linker complains
+about multiple definitions
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ .../acpica-unix2-20190703_mitigategcc.patch | 76 +++++++++++++++++++
+ 1 file changed, 76 insertions(+)
+ create mode 100644 util/crossgcc/patches/acpica-unix2-20190703_mitigategcc.patch
+
+diff --git a/util/crossgcc/patches/acpica-unix2-20190703_mitigategcc.patch b/util/crossgcc/patches/acpica-unix2-20190703_mitigategcc.patch
+new file mode 100644
+index 0000000000..8de47245bd
+--- /dev/null
++++ b/util/crossgcc/patches/acpica-unix2-20190703_mitigategcc.patch
+@@ -0,0 +1,76 @@
++From 66b927d923183ff62c9a757fafdeca9d1ac3fa87 Mon Sep 17 00:00:00 2001
++From: Leah Rowe <leah@libreboot.org>
++Date: Sun, 9 Jul 2023 18:58:11 +0100
++Subject: [PATCH 1/1] fix building on newer hostcc (debian sid tested)
++
++remove superfluous YYSTYPE declaration
++
++make LuxBuffer variables static, to avoid warnings
++treated as errors about multiple definitions
++
++AcpiGbl_DbOpt_NoRegionSupport - remove this definition
++in source/tools/acpiexec/aemain.c because it's already
++re-defined by acpiexec. otherwise the linker complains
++about multiple definitions
++
++Signed-off-by: Leah Rowe <leah@libreboot.org>
++---
++ source/compiler/aslcompiler.l | 1 -
++ source/compiler/dtparser.l | 2 +-
++ source/compiler/prparser.l | 2 +-
++ source/tools/acpiexec/aemain.c | 1 -
++ 4 files changed, 2 insertions(+), 4 deletions(-)
++
++diff --git a/source/compiler/aslcompiler.l b/source/compiler/aslcompiler.l
++index 1949b32..a24f028 100644
++--- a/source/compiler/aslcompiler.l
+++++ b/source/compiler/aslcompiler.l
++@@ -48,7 +48,6 @@
++
++ #include <stdlib.h>
++ #include <string.h>
++-YYSTYPE AslCompilerlval;
++
++ /*
++ * Generation: Use the following command line:
++diff --git a/source/compiler/dtparser.l b/source/compiler/dtparser.l
++index 6517e52..d35181c 100644
++--- a/source/compiler/dtparser.l
+++++ b/source/compiler/dtparser.l
++@@ -100,7 +100,7 @@ NewLine [\n]
++ /*
++ * Local support functions
++ */
++-YY_BUFFER_STATE LexBuffer;
+++static YY_BUFFER_STATE LexBuffer;
++
++ /******************************************************************************
++ *
++diff --git a/source/compiler/prparser.l b/source/compiler/prparser.l
++index bcdef14..5a1b848 100644
++--- a/source/compiler/prparser.l
+++++ b/source/compiler/prparser.l
++@@ -116,7 +116,7 @@ Identifier [a-zA-Z][0-9a-zA-Z]*
++ /*
++ * Local support functions
++ */
++-YY_BUFFER_STATE LexBuffer;
+++static YY_BUFFER_STATE LexBuffer;
++
++
++ /******************************************************************************
++diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c
++index 58640dd..cd0add6 100644
++--- a/source/tools/acpiexec/aemain.c
+++++ b/source/tools/acpiexec/aemain.c
++@@ -84,7 +84,6 @@ BOOLEAN AcpiGbl_VerboseHandlers = FALSE;
++ UINT8 AcpiGbl_RegionFillValue = 0;
++ BOOLEAN AcpiGbl_IgnoreErrors = FALSE;
++ BOOLEAN AcpiGbl_AbortLoopOnTimeout = FALSE;
++-BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE;
++ UINT8 AcpiGbl_UseHwReducedFadt = FALSE;
++ BOOLEAN AcpiGbl_DoInterfaceTests = FALSE;
++ BOOLEAN AcpiGbl_LoadTestTables = FALSE;
++--
++2.40.1
++
+--
+2.40.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0010-coreboot-fam15h-use-new-upstream-for-acpica.patch b/config/coreboot/fam15h_udimm/patches/0010-coreboot-fam15h-use-new-upstream-for-acpica.patch
new file mode 100644
index 00000000..6b7e6de0
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0010-coreboot-fam15h-use-new-upstream-for-acpica.patch
@@ -0,0 +1,38 @@
+From ba94a3f27a26d181291b5908bdd627be375eb606 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Sun, 16 Jul 2023 00:44:22 +0100
+Subject: [PATCH 1/1] coreboot/fam15h: use new upstream for acpica
+
+the original upstream died
+
+i decided to host it myself, on libreboot rsync,
+for use by mirrors.
+
+this is also useful for GNU Boot, when downloading
+acpica on coreboot 4.11_branch, for fam15h boards
+
+this change is not necessary on other coreboot trees,
+which adhere to new coreboot policy (newer coreboot
+pulls acpica from github, which is fairly reliable)
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ util/crossgcc/buildgcc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
+index b75b90a877..e3efa722f1 100755
+--- a/util/crossgcc/buildgcc
++++ b/util/crossgcc/buildgcc
+@@ -73,7 +73,7 @@ MPC_ARCHIVE="https://ftpmirror.gnu.org/mpc/mpc-${MPC_VERSION}.tar.gz"
+ GCC_ARCHIVE="https://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz"
+ BINUTILS_ARCHIVE="https://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.xz"
+ GDB_ARCHIVE="https://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.xz"
+-IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix2-${IASL_VERSION}.tar.gz"
++IASL_ARCHIVE="https://mirror.math.princeton.edu/pub/libreboot/misc/acpica/acpica-unix2-${IASL_VERSION}.tar.gz"
+ PYTHON_ARCHIVE="https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz"
+ EXPAT_ARCHIVE="https://downloads.sourceforge.net/sourceforge/expat/expat-${EXPAT_VERSION}.tar.bz2"
+ # CLANG toolchain archive locations
+--
+2.40.1
+
diff --git a/config/coreboot/fam15h_udimm/patches/0011-gcc-8.3.0_gnat_eh_new.patch b/config/coreboot/fam15h_udimm/patches/0011-gcc-8.3.0_gnat_eh_new.patch
new file mode 100644
index 00000000..443d8512
--- /dev/null
+++ b/config/coreboot/fam15h_udimm/patches/0011-gcc-8.3.0_gnat_eh_new.patch
@@ -0,0 +1,232 @@
+From c5a03de594d6bb6ea5012a6549404e4631c903c8 Mon Sep 17 00:00:00 2001
+From: Alexandre Oliva <oliva@adacore.com>
+Date: Wed, 9 Aug 2023 16:57:31 +0200
+Subject: [PATCH] crossgcc: Backport GNAT exception handler v1 patch
+
+Signed-off-by: Adrien Bourmault <neox@gnu.org>
+---
+ .../patches/gcc-8.3.0_gnat_eh_new.patch | 212 ++++++++++++++++++
+ 1 file changed, 212 insertions(+)
+ create mode 100644 util/crossgcc/patches/gcc-8.3.0_gnat_eh_new.patch
+
+diff --git a/util/crossgcc/patches/gcc-8.3.0_gnat_eh_new.patch b/util/crossgcc/patches/gcc-8.3.0_gnat_eh_new.patch
+new file mode 100644
+index 00000000..75e4f18d
+--- /dev/null
++++ b/util/crossgcc/patches/gcc-8.3.0_gnat_eh_new.patch
+@@ -0,0 +1,212 @@
++diff --git a/gcc/ada/libgnat/a-exexpr.adb b/gcc/ada/libgnat/a-exexpr.adb
++index b1aa1c6e6ba..5e72fd6e3f2 100644
++--- a/gcc/ada/libgnat/a-exexpr.adb
+++++ b/gcc/ada/libgnat/a-exexpr.adb
++@@ -197,15 +197,75 @@ package body Exception_Propagation is
++ -- whose machine occurrence is Mo. The message is empty, the backtrace
++ -- is empty too and the exception identity is Foreign_Exception.
++
++- -- Hooks called when entering/leaving an exception handler for a given
++- -- occurrence, aimed at handling the stack of active occurrences. The
++- -- calls are generated by gigi in tree_transform/N_Exception_Handler.
+++ -- Hooks called when entering/leaving an exception handler for a
+++ -- given occurrence. The calls are generated by gigi in
+++ -- Exception_Handler_to_gnu_gcc.
+++
+++ -- Begin_Handler_v1, called when entering an exception handler,
+++ -- claims responsibility for the handler to release the
+++ -- GCC_Exception occurrence. End_Handler_v1, called when
+++ -- leaving the handler, releases the occurrence, unless the
+++ -- occurrence is propagating further up, or the handler is
+++ -- dynamically nested in the context of another handler that
+++ -- claimed responsibility for releasing that occurrence.
+++
+++ -- Responsibility is claimed by changing the Cleanup field to
+++ -- Claimed_Cleanup, which enables claimed exceptions to be
+++ -- recognized, and avoids accidental releases even by foreign
+++ -- handlers.
+++
+++ function Begin_Handler_v1
+++ (GCC_Exception : not null GCC_Exception_Access)
+++ return System.Address;
+++ pragma Export (C, Begin_Handler_v1, "__gnat_begin_handler_v1");
+++ -- Called when entering an exception handler. Claim
+++ -- responsibility for releasing GCC_Exception, by setting the
+++ -- cleanup/release function to Claimed_Cleanup, and return the
+++ -- address of the previous cleanup/release function.
+++
+++ procedure End_Handler_v1
+++ (GCC_Exception : not null GCC_Exception_Access;
+++ Saved_Cleanup : System.Address;
+++ Propagating_Exception : GCC_Exception_Access);
+++ pragma Export (C, End_Handler_v1, "__gnat_end_handler_v1");
+++ -- Called when leaving an exception handler. Restore the
+++ -- Saved_Cleanup in the GCC_Exception occurrence, and then release
+++ -- it, unless it remains claimed by an enclosing handler, or
+++ -- GCC_Exception and Propagating_Exception are the same
+++ -- occurrence. Propagating_Exception could be either an
+++ -- occurrence (re)raised within the handler of GCC_Exception, when
+++ -- we're executing as an exceptional cleanup, or null, if we're
+++ -- completing the handler of GCC_Exception normally.
+++
+++ procedure Claimed_Cleanup
+++ (Reason : Unwind_Reason_Code;
+++ GCC_Exception : not null GCC_Exception_Access);
+++ pragma Export (C, Claimed_Cleanup, "__gnat_claimed_cleanup");
+++ -- A do-nothing placeholder installed as GCC_Exception.Cleanup
+++ -- while handling GCC_Exception, to claim responsibility for
+++ -- releasing it, and to stop it from being accidentally released.
+++
+++ -- The following are version 0 implementations of the version 1
+++ -- hooks above. They remain in place for compatibility with the
+++ -- output of compilers that still use version 0, such as those
+++ -- used during bootstrap. They are interoperable with the v1
+++ -- hooks, except that the older versions may malfunction when
+++ -- handling foreign exceptions passed to Reraise_Occurrence.
++
++ procedure Begin_Handler (GCC_Exception : not null GCC_Exception_Access);
++ pragma Export (C, Begin_Handler, "__gnat_begin_handler");
+++ -- Called when entering an exception handler translated by an old
+++ -- compiler. It does nothing.
++
++ procedure End_Handler (GCC_Exception : GCC_Exception_Access);
++ pragma Export (C, End_Handler, "__gnat_end_handler");
+++ -- Called when leaving an exception handler translated by an old
+++ -- compiler. It releases GCC_Exception, unless it is null. It is
+++ -- only ever null when the handler has a 'raise;' translated by a
+++ -- v0-using compiler. The artificial handler variable passed to
+++ -- End_Handler was set to null to tell End_Handler to refrain from
+++ -- releasing the reraised exception. In v1 safer ways are used to
+++ -- accomplish that.
++
++ --------------------------------------------------------------------
++ -- Accessors to Basic Components of a GNAT Exception Data Pointer --
++@@ -352,6 +412,128 @@ package body Exception_Propagation is
++ end if;
++ end Setup_Current_Excep;
++
+++ ----------------------
+++ -- Begin_Handler_v1 --
+++ ----------------------
+++
+++ function Begin_Handler_v1
+++ (GCC_Exception : not null GCC_Exception_Access)
+++ return System.Address is
+++ Saved_Cleanup : constant System.Address := GCC_Exception.Cleanup;
+++ begin
+++ -- Claim responsibility for releasing this exception, and stop
+++ -- others from releasing it.
+++ GCC_Exception.Cleanup := Claimed_Cleanup'Address;
+++ return Saved_Cleanup;
+++ end Begin_Handler_v1;
+++
+++ --------------------
+++ -- End_Handler_v1 --
+++ --------------------
+++
+++ procedure End_Handler_v1
+++ (GCC_Exception : not null GCC_Exception_Access;
+++ Saved_Cleanup : System.Address;
+++ Propagating_Exception : GCC_Exception_Access) is
+++ begin
+++ GCC_Exception.Cleanup := Saved_Cleanup;
+++ -- Restore the Saved_Cleanup, so that it is either used to
+++ -- release GCC_Exception below, or transferred to the next
+++ -- handler of the Propagating_Exception occurrence. The
+++ -- following test ensures that an occurrence is only released
+++ -- once, even after reraises.
+++ --
+++ -- The idea is that the GCC_Exception is not to be released
+++ -- unless it had an unclaimed Cleanup when the handler started
+++ -- (see Begin_Handler_v1 above), but if we propagate across its
+++ -- handler a reraise of the same exception, we transfer to the
+++ -- Propagating_Exception the responsibility for running the
+++ -- Saved_Cleanup when its handler completes.
+++ --
+++ -- This ownership transfer mechanism ensures safety, as in
+++ -- single release and no dangling pointers, because there is no
+++ -- way to hold on to the Machine_Occurrence of an
+++ -- Exception_Occurrence: the only situations in which another
+++ -- Exception_Occurrence gets the same Machine_Occurrence are
+++ -- through Reraise_Occurrence, and plain reraise, and so we
+++ -- have the following possibilities:
+++ --
+++ -- - Reraise_Occurrence is handled within the running handler,
+++ -- and so when completing the dynamically nested handler, we
+++ -- must NOT release the exception. A Claimed_Cleanup upon
+++ -- entry of the nested handler, installed when entering the
+++ -- enclosing handler, ensures the exception will not be
+++ -- released by the nested handler, but rather by the enclosing
+++ -- handler.
+++ --
+++ -- - Reraise_Occurrence/reraise escapes the running handler,
+++ -- and we run as an exceptional cleanup for GCC_Exception. The
+++ -- Saved_Cleanup was reinstalled, but since we're propagating
+++ -- the same machine occurrence, we do not release it. Instead,
+++ -- we transfer responsibility for releasing it to the eventual
+++ -- handler of the propagating exception.
+++ --
+++ -- - An unrelated exception propagates through the running
+++ -- handler. We restored GCC_Exception.Saved_Cleanup above.
+++ -- Since we're propagating a different exception, we proceed to
+++ -- release GCC_Exception, unless Saved_Cleanup was
+++ -- Claimed_Cleanup, because then we know we're not in the
+++ -- outermost handler for GCC_Exception.
+++ --
+++ -- - The handler completes normally, so it reinstalls the
+++ -- Saved_Cleanup and runs it, unless it was Claimed_Cleanup.
+++ -- If Saved_Cleanup is null, Unwind_DeleteException (currently)
+++ -- has no effect, so we could skip it, but if it is ever
+++ -- changed to do more in this case, we're ready for that,
+++ -- calling it exactly once.
+++ if Saved_Cleanup /= Claimed_Cleanup'Address
+++ and then
+++ Propagating_Exception /= GCC_Exception
+++ then
+++ declare
+++ Current : constant EOA := Get_Current_Excep.all;
+++ Cur_Occ : constant GCC_Exception_Access
+++ := To_GCC_Exception (Current.Machine_Occurrence);
+++ begin
+++ -- If we are releasing the Machine_Occurrence of the current
+++ -- exception, reset the access to it, so that it is no
+++ -- longer accessible.
+++ if Cur_Occ = GCC_Exception then
+++ Current.Machine_Occurrence := System.Null_Address;
+++ end if;
+++ end;
+++ Unwind_DeleteException (GCC_Exception);
+++ end if;
+++ end End_Handler_v1;
+++
+++ ---------------------
+++ -- Claimed_Cleanup --
+++ ---------------------
+++
+++ procedure Claimed_Cleanup
+++ (Reason : Unwind_Reason_Code;
+++ GCC_Exception : not null GCC_Exception_Access) is
+++ pragma Unreferenced (Reason);
+++ pragma Unreferenced (GCC_Exception);
+++ begin
+++ -- This procedure should never run. If it does, it's either a
+++ -- version 0 handler or a foreign handler, attempting to
+++ -- release an exception while a version 1 handler that claimed
+++ -- responsibility for releasing the exception remains still
+++ -- active. This placeholder stops GCC_Exception from being
+++ -- released by them.
+++
+++ -- We could get away with just Null_Address instead, with
+++ -- nearly the same effect, but with this placeholder we can
+++ -- detect and report unexpected releases, and we can tell apart
+++ -- a GCC_Exception without a Cleanup, from one with another
+++ -- active handler, so as to still call Unwind_DeleteException
+++ -- exactly once: currently, Unwind_DeleteException does nothing
+++ -- when the Cleanup is null, but should it ever be changed to
+++ -- do more, we'll still be safe.
+++ null;
+++ end Claimed_Cleanup;
+++
++ -------------------
++ -- Begin_Handler --
++ -------------------
+--
+2.30.2
+