Skip to contentSkip to conversation

arm support for klibc

PATCH In review H. Peter Anvin 1 participant 1 message Jun 26, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 22/43 arm support for klibc

The parts of klibc specific to the arm architecture.

---
commit 1eff7c685b36cd0120694fd4150b32a26168d926
tree 953dd1dbd2e994fc27c6cf5708fcbe06fe000d58
parent 5e5ce29210ac33a0b3704eb9ab5e5d5b55375575
author H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:16 -0700 committer H. Peter Anvin <[email protected]> Sun, 25 Jun 2006 16:58:16 -0700

 usr/include/arch/arm/klibc/archconfig.h |   14 ++++
 usr/include/arch/arm/klibc/archsetjmp.h |   14 ++++
 usr/include/arch/arm/klibc/archsignal.h |   14 ++++
 usr/include/arch/arm/klibc/archstat.h   |   40 ++++++++++++
 usr/include/arch/arm/klibc/archsys.h    |   12 ++++
 usr/include/arch/arm/klibc/asmmacros.h  |   30 +++++++++
 usr/klibc/arch/arm/MCONFIG              |   36 +++++++++++
 usr/klibc/arch/arm/Makefile.inc         |   23 +++++++
 usr/klibc/arch/arm/__muldi3.c           |   15 +++++
 usr/klibc/arch/arm/aeabi_nonsense.S     |    9 +++
 usr/klibc/arch/arm/crt0.S               |   23 +++++++
 usr/klibc/arch/arm/setjmp.S             |  102 +++++++++++++++++++++++++++++++
 usr/klibc/arch/arm/syscall.S            |   61 +++++++++++++++++++
 usr/klibc/arch/arm/sysstub.ph           |   58 ++++++++++++++++++
 usr/klibc/arch/arm/vfork.S              |   60 ++++++++++++++++++
 15 files changed, 511 insertions(+), 0 deletions(-)
usr/include/arch/arm/klibc/archconfig.h new file +14 -0
new file mode 100644
index 0000000..e34bdb7
@@ -0,0 +1,14 @@
+/*
+ * include/arch/arm/klibc/archconfig.h
+ *
+ * See include/klibc/sysconfig.h for the options that can be set in
+ * this file.
+ *
+ */
+
+#ifndef _KLIBC_ARCHCONFIG_H
+#define _KLIBC_ARCHCONFIG_H
+
+/* All defaults */
+
+#endif				/* _KLIBC_ARCHCONFIG_H */
usr/include/arch/arm/klibc/archsetjmp.h new file +14 -0
new file mode 100644
index 0000000..88db8a1
@@ -0,0 +1,14 @@
+/*
+ * arch/i386/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+	unsigned int regs[10];
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif				/* _SETJMP_H */
usr/include/arch/arm/klibc/archsignal.h new file +14 -0
new file mode 100644
index 0000000..a589527
@@ -0,0 +1,14 @@
+/*
+ * arch/arm/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#include <asm/signal.h>
+/* No special stuff for this architecture */
+
+#endif
usr/include/arch/arm/klibc/archstat.h new file +40 -0
new file mode 100644
index 0000000..95bbc9e
@@ -0,0 +1,40 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <klibc/stathelp.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ * Note: The kernel zero's the padded region because glibc might read them
+ * in the hope that the kernel has stretched to using larger sizes.
+ */
+
+struct stat {
+	__stdev64	(st_dev);
+	unsigned char   __pad0[4];
+
+	unsigned long	__st_ino;
+	unsigned int	st_mode;
+	unsigned int	st_nlink;
+
+	unsigned long	st_uid;
+	unsigned long	st_gid;
+
+	__stdev64	(st_rdev);
+	unsigned char   __pad3[4];
+
+	long long	st_size;
+	unsigned long	st_blksize;
+
+	unsigned long long  st_blocks;	/* Number 512-byte blocks allocated. */
+
+	struct timespec st_atim;
+	struct timespec st_mtim;
+	struct timespec st_ctim;
+
+	unsigned long long	st_ino;
+};
+
+#endif
usr/include/arch/arm/klibc/archsys.h new file +12 -0
new file mode 100644
index 0000000..e655680
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif				/* _KLIBC_ARCHSYS_H */
usr/include/arch/arm/klibc/asmmacros.h new file +30 -0
new file mode 100644
index 0000000..8a21c94
@@ -0,0 +1,30 @@
+/*
+ * usr/include/arch/arm/klibc/asmmacros.h
+ *
+ * Assembly macros used by ARM system call stubs
+ */
+
+#ifndef _KLIBC_ASMMACROS_H
+#define _KLIBC_ASMMACROS_H
+
+/* An immediate in ARM can be any 8-bit value rotated by an even number of bits */
+
+#define ARM_VALID_IMM(x)	\
+	((((x) & ~0x000000ff) == 0) || \
+	 (((x) & ~0x000003fc) == 0) || \
+	 (((x) & ~0x00000ff0) == 0) || \
+	 (((x) & ~0x00003fc0) == 0) || \
+	 (((x) & ~0x0000ff00) == 0) || \
+	 (((x) & ~0x0003fc00) == 0) || \
+	 (((x) & ~0x000ff000) == 0) || \
+	 (((x) & ~0x003fc000) == 0) || \
+	 (((x) & ~0x00ff0000) == 0) || \
+	 (((x) & ~0x03fc0000) == 0) || \
+	 (((x) & ~0x0ff00000) == 0) || \
+	 (((x) & ~0x3fc00000) == 0) || \
+	 (((x) & ~0xff000000) == 0) || \
+	 (((x) & ~0xfc000003) == 0) || \
+	 (((x) & ~0xf000000f) == 0) || \
+	 (((x) & ~0xc000003f) == 0))
+
+#endif /* _KLIBC_ASMMACROS_H */
usr/klibc/arch/arm/MCONFIG new file +36 -0
new file mode 100644
index 0000000..0023eee
@@ -0,0 +1,36 @@
+# -*- makefile -*-
+#
+# arch/arm/MCONFIG
+#
+# Special rules for this architecture.  Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+CPU_ARCH := armv4
+CPU_TUNE := strongarm
+
+KLIBCOPTFLAGS = -Os -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
+KLIBCBITSIZE  = 32
+KLIBCREQFLAGS = -fno-exceptions
+KLIBCSTRIPFLAGS += -R .ARM.exidx
+
+ifeq ($(CONFIG_KLIBC_THUMB),y)
+CPU_ARCH := $(CPU_ARCH)t
+KLIBCREQFLAGS += -mthumb
+KLIBCLDFLAGS  += --thumb-entry _start
+KLIBCEMAIN     = --thumb-entry _start
+KLIBCREQFLAGS += -mabi=aapcs-linux
+KLIBCSHAREDFLAGS = -Ttext 0x380200
+else
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+KLIBCSHAREDFLAGS = -Ttext 0x01800200
+ifeq ($(CONFIG_AEABI),y)
+KLIBCREQFLAGS += -mabi=aapcs-linux -mno-thumb-interwork
+else
+KLIBCREQFLAGS += -mabi=apcs-gnu -mno-thumb-interwork
+endif
+endif
+
usr/klibc/arch/arm/Makefile.inc new file +23 -0
new file mode 100644
index 0000000..9222918
@@ -0,0 +1,23 @@
+# -*- makefile -*-
+#
+# arch/arm/Makefile.inc
+#
+# Special rules for this architecture.  Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+KLIBCARCHOBJS = \
+	arch/arm/setjmp.o \
+	arch/arm/syscall.o \
+	arch/arm/vfork.o \
+	arch/arm/aeabi_nonsense.o \
+	libgcc/__udivmodsi4.o \
+	libgcc/__divdi3.o \
+	libgcc/__moddi3.o \
+	libgcc/__udivdi3.o \
+	libgcc/__umoddi3.o \
+	libgcc/__udivmoddi4.o \
+	libgcc/__clzsi2.o \
+	libgcc/__clzdi2.o \
+
usr/klibc/arch/arm/__muldi3.c new file +15 -0
new file mode 100644
index 0000000..3fdeb2b
@@ -0,0 +1,15 @@
+#include <stdint.h>
+
+uint64_t __muldi3(uint64_t a, uint64_t b)
+{
+	uint32_t al = (uint32_t)a;
+	uint32_t ah = (uint32_t)(a >> 32);
+	uint32_t bl = (uint32_t)b;
+	uint32_t bh = (uint32_t)(b >> 32);
+	uint64_t v;
+
+	v = (uint64_t)al * bl;
+	v += (uint64_t)(al*bh+ah*bl) << 32;
+
+	return v;
+}
usr/klibc/arch/arm/aeabi_nonsense.S new file +9 -0
new file mode 100644
index 0000000..c69eb11
@@ -0,0 +1,9 @@
+	.text
+	.globl	__aeabi_unwind_cpp_pr0
+__aeabi_unwind_cpp_pr0:
+	.globl	__aeabi_unwind_cpp_pr1
+__aeabi_unwind_cpp_pr1:
+	.globl	__aeabi_unwind_cpp_pr2
+__aeabi_unwind_cpp_pr2:
+	.globl	__aeabi_unwind_cpp_pr3
+__aeabi_unwind_cpp_pr3:
usr/klibc/arch/arm/crt0.S new file +23 -0
new file mode 100644
index 0000000..1e81f8e
@@ -0,0 +1,23 @@
+#
+# arch/arm/crt0.S
+#
+# void _start(void)
+# {
+#    __libc_init(elf_structure, atexit_ptr);
+# }
+#
+
+	.text
+	.balign 4
+	.type _start,#function
+	.globl _start
+
+#ifdef __thumb__
+	.thumb_func
+#endif
+
+_start:	mov	r0, sp
+	mov	r1, #0
+	bl	__libc_init
+
+	.size _start,.-_start
usr/klibc/arch/arm/setjmp.S new file +102 -0

102 lines not on this page · raw message

usr/klibc/arch/arm/syscall.S new file +61 -0

61 lines not on this page · raw message

usr/klibc/arch/arm/sysstub.ph new file +58 -0

58 lines not on this page · raw message

usr/klibc/arch/arm/vfork.S new file +60 -0

60 lines not on this page · raw message