Patchwork xtensa: add support for the configurable Xtensa architecture

login
register
mail settings
Submitter Baruch Siach
Date Jan. 20, 2014, 1:11 p.m.
Message ID <31c1d29cb2be4fe089bc.1390223487@tarshish.tkos.co.il>
Download mbox | patch
Permalink /patch/312522/
State New
Headers show

Comments

Baruch Siach - Jan. 20, 2014, 1:11 p.m.
# HG changeset patch
# User Baruch Siach <baruch@tkos.co.il>
# Date 1390222464 -7200
#      Mon Jan 20 14:54:24 2014 +0200
# Node ID 31c1d29cb2be4fe089bcd40833ebb46501cfad33
# Parent  c95c1ccf5b77d4108b6cccec76fbb3d5f4b80490
xtensa: add support for the configurable Xtensa architecture.

The Xtensa processor architecture is a configurable, extensible,
and synthesizable 32-bit RISC processor core. Processor and SOC vendors
can select from various processor options and even create customized
instructions in addition to a base ISA to tailor the processor for
a particular application.

Because of the configurability, the build process requires one additional
step for gcc, binutils, and gdb to update the default configuration.
These configurations are packed into an 'overlay' tar image, and are
simply untarred on top of the default configuration during the build.

This patch was originally authored by Chris Zankel. This version fixes a few
issues raised by Yann E. MORIN, and tested on latest tip.


--
For unsubscribe information see http://sourceware.org/lists.html#faq

Patch

diff -r c95c1ccf5b77 -r 31c1d29cb2be config/arch/xtensa.in
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/arch/xtensa.in	Mon Jan 20 14:54:24 2014 +0200
@@ -0,0 +1,20 @@ 
+# xtensa specific configuration file
+
+## select ARCH_SUPPORTS_32
+## select ARCH_SUPPORTS_BOTH_MMU
+## select ARCH_DEFAULT_HAS_MMU
+##
+## help The xtensa architecture
+## help
+## help    Xtensa is a configurable and extensible processor architecture.
+## help    Supporting a specific configuration typically requires minor 
+## help    modifications to a small set of configuration files in various
+## help    development tools. This process is automated and only requires
+## help    a configuration specific 'overlay' file.
+## help
+## help    For a custom configuration, select the XTENSA_CUSTOM option and
+## help    provide the name of the overlay file through the
+## help    CT_ARCH_XTENSA_CUSTOM_OVERLAY_FILE option.
+## help
+## help    The default option (ARCH_xtensa_fsf) uses a built-in configuration,
+## help    which may or may not work for a particular Xtensa processor.
diff -r c95c1ccf5b77 -r 31c1d29cb2be config/arch/xtensa.in.2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/arch/xtensa.in.2	Mon Jan 20 14:54:24 2014 +0200
@@ -0,0 +1,30 @@ 
+choice
+	prompt "Target Architecture Variant"
+	default ARCH_xtensa_fsf
+config XTENSA_CUSTOM
+	bool "Custom Xtensa processor configuration"
+
+config ARCH_xtensa_fsf
+	bool "fsf - Default configuration"
+
+endchoice
+
+config ARCH_XTENSA_CUSTOM_OVERLAY_FILE
+	string "Custom Xtensa process configuration file name"
+	depends on XTENSA_CUSTOM
+	default ""
+	help
+	  Enter the name of the custom processor configuration
+	  overlay file or leave blank to use the default 'xtensa-overlay.tar'.
+	  For more information about this option, please also consult
+	  the 'help' section of the 'Target Architecture Variant'
+	  option above.
+	  
+config ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION
+	string "Full path to custom Xtensa processor configurations"
+	depends on XTENSA_CUSTOM
+	default ""
+	help
+	  Enter the path to the directory for the custom processor
+	  configuration file or leave blank to use the default location:
+	  CT_CUSTOM_LOCATION_ROOT_DIR
diff -r c95c1ccf5b77 -r 31c1d29cb2be scripts/build/arch/xtensa.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/build/arch/xtensa.sh	Mon Jan 20 14:54:24 2014 +0200
@@ -0,0 +1,51 @@ 
+CT_DoArchTupleValues() {
+    :
+}
+
+# This function updates the specified component (binutils, gcc, gdb, etc.)
+# with the processor specific configuration.
+CT_ConfigureXtensa() {
+    local component="${1}"
+    local version="${2}"
+    local custom_config="${CT_ARCH_XTENSA_CUSTOM_OVERLAY_FILE}"
+    local custom_location="${CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION}"
+
+    local full_file="${CT_TARBALLS_DIR}/${custom_config}"
+    local basename="${component}-${version}"
+
+    CT_TestAndAbort "${custom_config}: CT_CUSTOM_LOCATION_ROOT_DIR or CT_ARCH_XTENSA_CUSTOM_OVERLAY_LOCATION must be set." \
+        -z "${CT_CUSTOM_LOCATION_ROOT_DIR}" -a -z "${custom_location}"
+
+    if [ -n "${CT_CUSTOM_LOCATION_ROOT_DIR}" -a -z "${custom_location}" ]; then
+        custom_location="${CT_CUSTOM_LOCATION_ROOT_DIR}"
+    fi
+
+    if [ -e "${CT_SRC_DIR}/.${basename}.configuring" ]; then
+        CT_DoLog ERROR "The '${basename}' source were partially configured."
+        CT_DoLog ERROR "Please remove first:"
+        CT_DoLog ERROR " - the source dir for '${basename}', in '${CT_SRC_DIR}'"
+        CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.extracted'"
+        CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.patch'"
+        CT_DoLog ERROR " - the file '${CT_SRC_DIR}/.${basename}.configuring'"
+        CT_Abort
+    fi
+
+    CT_DoLog DEBUG "Using '${custom_config}' from ${custom_location}"
+    CT_DoExecLog INFO ln -sf "${custom_location}/${custom_config}" \
+        "${CT_TARBALLS_DIR}/${custom_config}"
+
+    CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configuring"
+
+    CT_Pushd "${CT_SRC_DIR}/${basename}"
+
+    tar_opts=( "--strip-components=1" )
+    tar_opts+=( "-xv" )
+
+    CT_DoLog DEBUG "Extracting ${full_file} for ${component}"
+    CT_DoExecLog FILE tar "${tar_opts[@]}" -f "${full_file}" "${component}"
+
+    CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.${basename}.configured"
+    CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/.${basename}.configuring"
+
+    CT_Popd
+}
diff -r c95c1ccf5b77 -r 31c1d29cb2be scripts/build/binutils/binutils.sh
--- a/scripts/build/binutils/binutils.sh	Sat Jan 04 20:16:18 2014 +0100
+++ b/scripts/build/binutils/binutils.sh	Mon Jan 20 14:54:24 2014 +0200
@@ -37,6 +37,10 @@ 
         CT_Extract "elf2flt-${CT_ELF2FLT_VERSION}"
         CT_Patch "elf2flt" "${CT_ELF2FLT_VERSION}"
     fi
+
+    if [ -n "${CT_ARCH_XTENSA_CUSTOM_OVERLAY_FILE}" ]; then
+        CT_ConfigureXtensa "binutils" "${CT_BINUTILS_VERSION}"
+    fi
 }
 
 # Build binutils for build -> target
diff -r c95c1ccf5b77 -r 31c1d29cb2be scripts/build/cc/gcc.sh
--- a/scripts/build/cc/gcc.sh	Sat Jan 04 20:16:18 2014 +0100
+++ b/scripts/build/cc/gcc.sh	Mon Jan 20 14:54:24 2014 +0200
@@ -58,6 +58,10 @@ 
        ]; then
         CT_DoExecLog ALL cp -v "${CT_TARBALLS_DIR}/ecj-latest.jar" "${CT_SRC_DIR}/gcc-${CT_CC_VERSION}/ecj.jar"
     fi
+
+    if [ -n "${CT_ARCH_XTENSA_CUSTOM_OVERLAY_FILE}" ]; then
+        CT_ConfigureXtensa "gcc" "${CT_CC_VERSION}"
+    fi
 }
 
 #------------------------------------------------------------------------------
diff -r c95c1ccf5b77 -r 31c1d29cb2be scripts/build/debug/300-gdb.sh
--- a/scripts/build/debug/300-gdb.sh	Sat Jan 04 20:16:18 2014 +0100
+++ b/scripts/build/debug/300-gdb.sh	Mon Jan 20 14:54:24 2014 +0200
@@ -93,6 +93,10 @@ 
         CT_Extract "expat-${CT_DEBUG_GDB_EXPAT_VERSION}"
         CT_Patch "expat" "${CT_DEBUG_GDB_EXPAT_VERSION}"
     fi
+
+    if [ -n "${CT_ARCH_XTENSA_CUSTOM_OVERLAY_FILE}" ]; then
+        CT_ConfigureXtensa "gdb" "${CT_GDB_VERSION}"
+    fi
 }
 
 do_debug_gdb_build() {