Skip to content

Commit 0505823

Browse files
ranj063lrgirdwo
authored andcommitted
build: add library build support for host platform
This patch provides library build support for host platform architecture. It enables creating separate libraries for each SOF audio component. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent f7beb51 commit 0505823

34 files changed

+2004
-41
lines changed

Makefile.am

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,29 @@ EXTRA_DIST = version.sh
66

77
SRC_DIR = $(abs_top_builddir)/src
88

9+
if BUILD_HOST
10+
export ARCH_INCDIR = \
11+
-I $(SRC_DIR)/arch/$(ARCH)/include
12+
13+
export REEF_INCDIR = \
14+
-I $(SRC_DIR)/include
15+
16+
if BUILD_LIB
17+
export PLATFORM_INCDIR = \
18+
-I $(SRC_DIR)/library/include
19+
endif
20+
21+
else
922
export REEF_INCDIR = \
1023
-I $(SRC_DIR)/include \
1124
-I $(ROOT_DIR)/include
1225

1326
export ARCH_INCDIR = \
1427
-I $(SRC_DIR)/arch/$(ARCH)/include \
1528
-I $(SRC_DIR)/arch/$(ARCH)/xtos
16-
1729
export PLATFORM_INCDIR = \
1830
-I $(SRC_DIR)/platform/$(PLATFORM)/include
31+
endif
1932

2033
dist-hook:
2134
./version.sh $(top_srcdir)

README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ Cherrytrail :-
1313

1414
./configure --with-arch=xtensa --with-platform=cherrytrail --with-root-dir=$PWD/../xtensa-root/xtensa-byt-elf --host=xtensa-byt-elf
1515

16+
Library for Host Platform :-
17+
If building library for host platform, run the following configure. Please modify
18+
the --prefix option to choose the directory for installing the library files and
19+
headers
20+
21+
./configure --with-arch=host --enable-library=yes --host=x86_64-unknown-linux-gnu --prefix=$pwd/../host-root/
22+
1623
3) make
1724

1825
4) make bin

build-all.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ make clean
3333
make
3434
make bin
3535

36+
# Build library for host platform architecture
37+
./configure --with-arch=host --enable-library=yes --host=x86_64-unknown-linux-gnu --prefix=$pwd/../host-root/
38+
make
39+
make install
3640

3741
# list all the images
3842
ls -l src/arch/xtensa/*.ri

configure.ac

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ AC_SUBST(ASFLAGS)
2929
AC_ARG_WITH([root-dir],
3030
AS_HELP_STRING([--with-root-dir], [Specify location of cross gcc libraries and headers]),
3131
[], [with_root_dir=no])
32-
AS_IF([test "x$with_root_dir" = xno],
33-
AC_MSG_ERROR([Please specify cross compiler root header directory]),
34-
[ROOT_DIR=$with_root_dir])
35-
AC_SUBST(ROOT_DIR)
32+
33+
# check if we are building FW image or library
34+
AC_ARG_ENABLE(library, [AS_HELP_STRING([--enable-library],[build library])], have_library=$enableval, have_library=no)
35+
if test "$have_library" = "yes"; then
36+
AC_DEFINE([CONFIG_LIB], [1], [Configure for Shared Library])
37+
fi
38+
AM_CONDITIONAL(BUILD_LIB, test "$have_library" = "yes")
3639

3740
# Architecture support
3841
AC_ARG_WITH([arch],
@@ -57,14 +60,31 @@ case "$with_arch" in
5760

5861
ARCH="xtensa"
5962
AC_SUBST(ARCH)
63+
64+
AS_IF([test "x$with_root_dir" = xno],
65+
AC_MSG_ERROR([Please specify cross compiler root header directory]),
66+
[ROOT_DIR=$with_root_dir])
67+
AC_SUBST(ROOT_DIR)
68+
;;
69+
host*)
70+
71+
ARCH_CFLAGS="-g"
72+
AC_SUBST(ARCH_CFLAGS)
73+
74+
# extra CFLAGS defined here otherwise configure working gcc tests fails.
75+
CFLAGS="${CFLAGS:+$CFLAGS } -O3"
76+
LDFLAGS="${LDFLAGS:+$LDFLAGS }-lpthread"
77+
78+
ARCH="host"
79+
AC_SUBST(ARCH)
6080
;;
6181
*)
6282
AC_MSG_ERROR([DSP architecture not specified])
6383
;;
6484
esac
6585

6686
AM_CONDITIONAL(BUILD_XTENSA, test "$ARCH" = "xtensa")
67-
87+
AM_CONDITIONAL(BUILD_HOST, test "$ARCH" = "host")
6888

6989
# Platform support
7090
AC_ARG_WITH([platform],
@@ -175,7 +195,12 @@ case "$with_platform" in
175195
AC_DEFINE([CONFIG_IRQ_MAP], [1], [Configure IRQ maps])
176196
;;
177197
*)
178-
AC_MSG_ERROR([Host platform not specified])
198+
if test "$ARCH" = "host"; then
199+
PLATFORM="host"
200+
AC_SUBST(PLATFORM)
201+
else
202+
AC_MSG_ERROR([Host platform not specified])
203+
fi
179204
;;
180205
esac
181206

@@ -215,6 +240,70 @@ AM_CONDITIONAL(BUILD_DMA_TRACE, test "x$enable_dma_trace" != "xno")
215240
PLATFORM_BOOT_LDR_LDSCRIPT="boot_ldr.x"
216241
AC_SUBST(PLATFORM_BOOT_LDR_LDSCRIPT)
217242

243+
# Optimisation settings and checks
244+
245+
# SSE4_2 support
246+
AC_ARG_ENABLE(sse42, [AS_HELP_STRING([--enable-sse42],[enable SSE42 optimizations])], have_sse42=$enableval, have_sse42=yes)
247+
AX_CHECK_COMPILE_FLAG(-msse4.2, [SSE42_CFLAGS="-DOPS_SSE42 -msse4.2 -ffast-math -ftree-vectorizer-verbose=0"],
248+
[have_sse42=no])
249+
if test "$have_sse42" = "yes"; then
250+
AC_DEFINE(HAVE_SSE42,1,[Define to enable SSE42 optimizations.])
251+
fi
252+
AM_CONDITIONAL(HAVE_SSE42, test "$have_sse42" = "yes")
253+
AC_SUBST(SSE42_CFLAGS)
254+
255+
# AVX support
256+
AC_ARG_ENABLE(avx, [AS_HELP_STRING([--enable-avx],[enable AVX optimizations])], have_avx=$enableval, have_avx=yes)
257+
AX_CHECK_COMPILE_FLAG(-mavx, [AVX_CFLAGS="-DOPS_AVX -mavx -ffast-math -ftree-vectorizer-verbose=0"],
258+
[have_avx=no])
259+
if test "$have_avx" = "yes"; then
260+
AC_DEFINE(HAVE_AVX,1,[Define to enable AVX optimizations.])
261+
fi
262+
AM_CONDITIONAL(HAVE_AVX, test "$have_avx" = "yes")
263+
AC_SUBST(AVX_CFLAGS)
264+
265+
266+
# AVX2 support
267+
AC_ARG_ENABLE(avx2, [AS_HELP_STRING([--enable-avx2],[enable AVX2 optimizations])], have_avx2=$enableval, have_avx2=yes)
268+
AX_CHECK_COMPILE_FLAG(-mavx2, [AVX2_CFLAGS="-DOPS_AVX2 -mavx2 -ffast-math -ftree-vectorizer-verbose=0"],
269+
[have_avx2=no])
270+
if test "$have_avx2" = "yes"; then
271+
AC_DEFINE(HAVE_AVX2,1,[Define to enable AVX2 optimizations.])
272+
fi
273+
AM_CONDITIONAL(HAVE_AVX2, test "$have_avx2" = "yes")
274+
AC_SUBST(AVX2_CFLAGS)
275+
276+
277+
# FMA support
278+
AC_ARG_ENABLE(fma, [AS_HELP_STRING([--enable-fma],[enable FMA optimizations])], have_fma=$enableval, have_fma=yes)
279+
AX_CHECK_COMPILE_FLAG(-mfma, [FMA_CFLAGS="-DOPS_FMA -mfma -ffast-math -ftree-vectorizer-verbose=0"],
280+
[have_fma=no])
281+
if test "$have_fma" = "yes"; then
282+
AC_DEFINE(HAVE_FMA,1,[Define to enable FMA optimizations.])
283+
fi
284+
AM_CONDITIONAL(HAVE_FMA, test "$have_fma" = "yes")
285+
AC_SUBST(FMA_CFLAGS)
286+
287+
# Hifi2EP
288+
AC_ARG_ENABLE(hifi2ep, [AS_HELP_STRING([--enable-hifi2ep],[enable HiFi2EP optimizations])], have_hifi2ep=$enableval, have_hifi2ep=yes)
289+
AX_CHECK_COMPILE_FLAG(-mhifi2ep, [FMA_CFLAGS="-DOPS_HIFI2EP -mhifi2ep -ffast-math -ftree-vectorizer-verbose=0"],
290+
[have_hifi2ep=no])
291+
if test "$have_hifi2ep" = "yes"; then
292+
AC_DEFINE(HAVE_HIFI2EP,1,[Define to enable Hifi2 EP optimizations.])
293+
fi
294+
AM_CONDITIONAL(HAVE_HIFI2EP, test "$have_hifi2ep" = "yes")
295+
AC_SUBST(HIFI2EP_CFLAGS)
296+
297+
# Hifi3
298+
AC_ARG_ENABLE(hifi3, [AS_HELP_STRING([--enable-hifi3],[enable HiFi3 optimizations])], have_hifi3=$enableval, have_hifi3=yes)
299+
AX_CHECK_COMPILE_FLAG(-mhihi3, [FMA_CFLAGS="-DOPS_HIFI3 -mhifi3 -ffast-math -ftree-vectorizer-verbose=0"],
300+
[have_hifi3=no])
301+
if test "$have_hifi3" = "yes"; then
302+
AC_DEFINE(HAVE_HIFI3,1,[Define to enable Hifi3 optimizations.])
303+
fi
304+
AM_CONDITIONAL(HAVE_HIFI3, test "$have_hifi3" = "yes")
305+
AC_SUBST(HIFI3_CFLAGS)
306+
218307
# Test after CFLAGS set othewise test of cross compiler fails.
219308
AM_PROG_AS
220309
AM_PROG_AR
@@ -240,6 +329,9 @@ AC_CONFIG_FILES([
240329
src/arch/xtensa/include/xtensa/config/Makefile
241330
src/arch/xtensa/hal/Makefile
242331
src/arch/xtensa/xtos/Makefile
332+
src/arch/host/Makefile
333+
src/arch/host/include/Makefile
334+
src/arch/host/include/arch/Makefile
243335
src/audio/Makefile
244336
src/math/Makefile
245337
src/drivers/Makefile
@@ -251,6 +343,9 @@ AC_CONFIG_FILES([
251343
src/include/reef/math/Makefile
252344
src/include/uapi/Makefile
253345
src/ipc/Makefile
346+
src/library/Makefile
347+
src/library/include/Makefile
348+
src/library/include/platform/Makefile
254349
src/lib/Makefile
255350
src/platform/Makefile
256351
src/platform/baytrail/Makefile

src/Makefile.am

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1+
export COMMON_INCDIR = \
2+
$(REEF_INCDIR) \
3+
$(ARCH_INCDIR) \
4+
$(PLATFORM_INCDIR)
5+
6+
if BUILD_LIB
7+
SUBDIRS = ipc math audio arch include library
8+
endif
9+
10+
if BUILD_XTENSA
111
SUBDIRS = include init math audio platform tasks drivers ipc lib arch
12+
endif

src/arch/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
if BUILD_XTENSA
22
SUBDIRS = xtensa
33
endif
4+
5+
if BUILD_HOST
6+
SUBDIRS = host
7+
endif

src/arch/host/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SUBDIRS = include

src/arch/host/include/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SUBDIRS = arch
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
includedir = $(prefix)/include/sof/arch
2+
3+
include_HEADERS = \
4+
cache.h \
5+
interrupt.h \
6+
reef.h \
7+
spinlock.h \
8+
timer.h \
9+
wait.h

src/arch/host/include/arch/cache.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2017, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
29+
*/
30+
31+
#ifndef __INCLUDE_ARCH_CACHE__
32+
#define __INCLUDE_ARCH_CACHE__
33+
34+
#include <stdint.h>
35+
#include <stddef.h>
36+
37+
static inline void dcache_writeback_region(void *addr, size_t size) {}
38+
static inline void dcache_invalidate_region(void *addr, size_t size) {}
39+
static inline void icache_invalidate_region(void *addr, size_t size) {}
40+
static inline void dcache_writeback_invalidate_region(void *addr,
41+
size_t size) {}
42+
43+
#endif

0 commit comments

Comments
 (0)