This patch adds support for the ARM architecture to libhugetlbfs.

We do not add the xBT/xBDT style linker scripts as these have been deprecated
in favour of adjusting the page sizes via command line parameter to ld.

Signed-off-by: Steve Capper <steve.cap...@arm.com>
---
 Makefile                |  7 +++++++
 ld.hugetlbfs            | 12 ++++++++++++
 sys-armelf_linux_eabi.S | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 sys-armelf_linux_eabi.S

diff --git a/Makefile b/Makefile
index 796b063..48205af 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,12 @@ CC32 = gcc -m32
 ELF32 = elf32ppclinux
 TMPLIB32 = lib
 else
+ifeq ($(ARCH),armv7l)
+CC32 = gcc
+TMPLIB32 = lib
+ELF32 += armelf_linux_eabi
+CUSTOM_LDSCRIPTS = no
+else
 ifeq ($(ARCH),i386)
 CC32 = gcc
 ELF32 = elf_i386
@@ -93,6 +99,7 @@ endif
 endif
 endif
 endif
+endif
 
 ifdef CC32
 OBJDIRS += obj32
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index 199bf97..d6d12c4 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -79,6 +79,11 @@ if [ -n "$HTLB_LINK" ]; then
     HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
     LDSCRIPT="$EMU.x$HTLB_LINK"
     HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
+
+    if [ "$EMU" == "armelf_linux_eabi" ]; then
+        echo "Please use --hugetlbfs-align when targeting ARM."
+       exit -1
+    fi
 fi
 
 MB=$((1024*1024))
@@ -86,11 +91,18 @@ case "$EMU" in
 elf32ppclinux|elf64ppc)        HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) 
;;
 elf_i386|elf_x86_64)   HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
 elf_s390|elf64_s390)   HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
+armelf_linux_eabi)     HPAGE_SIZE=$((2*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
 esac
 
 if [ "$HTLB_ALIGN" == "slice" ]; then
        HTLBOPTS="-zcommon-page-size=$SLICE_SIZE -zmax-page-size=$SLICE_SIZE"
        HTLBOPTS="$HTLBOPTS -lhugetlbfs"
+
+       # targeting the ARM platform one needs to explicitly set the text 
segment offset
+       # otherwise it will be NULL.
+       if [ "$EMU" == "armelf_linux_eabi" ]; then
+               HTLBOPTS="$HTLBOPTS -Ttext-segment=$SLICE_SIZE"
+       fi
 fi
 
 ${LD} "${args[@]}" ${HTLBOPTS}
diff --git a/sys-armelf_linux_eabi.S b/sys-armelf_linux_eabi.S
new file mode 100644
index 0000000..983d28b
--- /dev/null
+++ b/sys-armelf_linux_eabi.S
@@ -0,0 +1,32 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 2012 ARM Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+        .text
+
+        .globl  direct_syscall
+direct_syscall:
+       mov     ip, sp
+       stmfd   sp!, {r4, r5, r6, r7}
+       mov     r7, r0
+       mov     r0, r1
+       mov     r1, r2
+       mov     r2, r3
+       ldmfd   ip, {r3, r4, r5, r6}
+       swi     0x0
+       ldmfd   sp!, {r4, r5, r6, r7}
+       bx      lr
-- 
1.8.0.2



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to