From 4dc998596f0ed8c9f1da6dc57a5640e3928cc12b Mon Sep 17 00:00:00 2001 From: "Steven J. Magnani" Date: Wed, 10 Nov 2010 19:23:45 +0100 Subject: microblaze: Fix setjmp/longjmp Some state and registers are missing from setjmp/longjmp handling. Signed-off-by: Steven J. Magnani Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/microblaze/bits/setjmp.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libc/sysdeps/linux/microblaze/bits') diff --git a/libc/sysdeps/linux/microblaze/bits/setjmp.h b/libc/sysdeps/linux/microblaze/bits/setjmp.h index d966efd2b..0c0573cd7 100644 --- a/libc/sysdeps/linux/microblaze/bits/setjmp.h +++ b/libc/sysdeps/linux/microblaze/bits/setjmp.h @@ -28,12 +28,16 @@ typedef struct /* Link pointer. */ void *__lp; - /* Callee-saved registers r18-r30. */ - int __regs[13]; + /* SDA pointers */ + void *__SDA; + void *__SDA2; + + /* Callee-saved registers r18-r31. */ + int __regs[14]; } __jmp_buf[1]; #endif -#define JB_SIZE (4 * 15) +#define JB_SIZE (4 * 18) /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ -- cgit v1.2.3 From 54f73a98f6b841f05484e2275c860ae61d49aae2 Mon Sep 17 00:00:00 2001 From: "Steven J. Magnani" Date: Wed, 10 Nov 2010 19:27:57 +0100 Subject: microblaze: syscall interface Fix the microblaze syscall interface. Recent mainline kernels no longer carry userland code to invoke syscalls and microblaze can use the uClibc generic code. Signed-off-by: Steven J. Magnani Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/microblaze/bits/syscalls.h | 54 ++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'libc/sysdeps/linux/microblaze/bits') diff --git a/libc/sysdeps/linux/microblaze/bits/syscalls.h b/libc/sysdeps/linux/microblaze/bits/syscalls.h index b21851333..f4bdc4522 100644 --- a/libc/sysdeps/linux/microblaze/bits/syscalls.h +++ b/libc/sysdeps/linux/microblaze/bits/syscalls.h @@ -4,12 +4,54 @@ # error "Never use directly; include instead." #endif -#include -/* Do something very evil for now. Until we create our own syscall - * macros, short circuit bits/sysnum.h and use asm/unistd.h instead */ -#warning "fixme -- add arch specific syscall macros.h" -#include +#ifndef __ASSEMBLER__ -#endif /* _BITS_SYSCALLS_H */ +#include + +#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ + ({ \ + register int __ret __asm__("r3"); \ + register int _scno __asm__("r12") = name; \ + LOAD_ARGS_##nr (args); \ + __asm__ __volatile__("brki r14, 0x8" \ + : "=r" (__ret) \ + : "r"(_scno) ASM_ARGS_##nr \ + : __SYSCALL_CLOBBERS ); \ + __ret; \ + }) + +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned int)(val) >= 0xfffff001U) +#define LOAD_ARGS_0() do { } while(0) +#define ASM_ARGS_0 +#define LOAD_ARGS_1(a1) \ + register int _a1 __asm__("r5") = (int)(a1); \ + LOAD_ARGS_0() +#define ASM_ARGS_1 ASM_ARGS_0, "r"(_a1) +#define LOAD_ARGS_2(a1, a2) \ + register int _a2 __asm__("r6") = (int)(a2); \ + LOAD_ARGS_1(a1) +#define ASM_ARGS_2 ASM_ARGS_1, "r"(_a2) +#define LOAD_ARGS_3(a1, a2, a3) \ + register int _a3 __asm__("r7") = (int)(a3); \ + LOAD_ARGS_2(a1, a2) +#define ASM_ARGS_3 ASM_ARGS_2, "r"(_a3) +#define LOAD_ARGS_4(a1, a2, a3, a4) \ + register int _a4 __asm__("r8") = (int)(a4); \ + LOAD_ARGS_3(a1, a2, a3) +#define ASM_ARGS_4 ASM_ARGS_3, "r"(_a4) +#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ + register int _a5 __asm__("r9") = (int)(a5); \ + LOAD_ARGS_4(a1, a2, a3, a4) +#define ASM_ARGS_5 ASM_ARGS_4, "r"(_a5) +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ + register int _a6 __asm__("r10") = (int)(a6); \ + LOAD_ARGS_5(a1, a2, a3, a4, a5) +#define ASM_ARGS_6 ASM_ARGS_5, "r"(_a6) + +#define __SYSCALL_CLOBBERS "r4", "r14", "cc", "memory" + +#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ -- cgit v1.2.3 From bc71df2efbf1a007365b7c3841da781bdfdafce2 Mon Sep 17 00:00:00 2001 From: "Steven J. Magnani" Date: Wed, 10 Nov 2010 19:32:13 +0100 Subject: microblaze: kernel headers Sync kernel header definitions with those used in recent mainline kernels. Signed-off-by: Steven J. Magnani Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/microblaze/bits/fcntl.h | 17 ++++-- libc/sysdeps/linux/microblaze/bits/kernel_stat.h | 74 +++++++++++------------ libc/sysdeps/linux/microblaze/bits/kernel_types.h | 29 +++++---- libc/sysdeps/linux/microblaze/bits/poll.h | 8 +-- 4 files changed, 66 insertions(+), 62 deletions(-) (limited to 'libc/sysdeps/linux/microblaze/bits') diff --git a/libc/sysdeps/linux/microblaze/bits/fcntl.h b/libc/sysdeps/linux/microblaze/bits/fcntl.h index bb6727ad8..44e8f3f5b 100644 --- a/libc/sysdeps/linux/microblaze/bits/fcntl.h +++ b/libc/sysdeps/linux/microblaze/bits/fcntl.h @@ -23,6 +23,9 @@ #include +#ifdef __USE_GNU +# include +#endif /* open/fcntl - O_SYNC is only implemented on blocks devices and on files located on an ext2 file system */ @@ -42,11 +45,11 @@ #define O_ASYNC 020000 #ifdef __USE_GNU -# define O_DIRECTORY 040000 /* Must be a directory. */ -# define O_NOFOLLOW 0100000 /* Do not follow links. */ -# define O_DIRECT 0200000 /* Direct disk access. */ -# define O_NOATIME 01000000 /* Do not set atime. */ -# define O_CLOEXEC 02000000 /* set close_on_exec */ +# define O_DIRECTORY 0200000 /* Must be a directory. */ +# define O_NOFOLLOW 0400000 /* Do not follow links. */ +# define O_DIRECT 040000 /* Direct disk access. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +# define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* For now Linux has synchronisity options for data and read operations. @@ -58,7 +61,7 @@ #endif #ifdef __USE_LARGEFILE64 -# define O_LARGEFILE 0400000 +# define O_LARGEFILE 0100000 #endif /* Values for the second argument to `fcntl'. */ @@ -96,6 +99,8 @@ # define F_NOTIFY 1026 /* Request notfications on a directory. */ # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with close-on-exit set on new fd. */ +# define F_SETPIPE_SZ 1031 /* Set of pipe page size array */ +# define F_GETPIPE_SZ 1032 /* Get of pipe page size array */ #endif /* For F_[GET|SET]FL. */ diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h index de35488bd..2c5eb28af 100644 --- a/libc/sysdeps/linux/microblaze/bits/kernel_stat.h +++ b/libc/sysdeps/linux/microblaze/bits/kernel_stat.h @@ -9,50 +9,44 @@ struct kernel_stat { - __kernel_dev_t st_dev; - __kernel_ino_t st_ino; - __kernel_mode_t st_mode; - __kernel_nlink_t st_nlink; - __kernel_uid_t st_uid; - __kernel_gid_t st_gid; - __kernel_dev_t st_rdev; - __kernel_off_t st_size; - unsigned long st_blksize; - unsigned long st_blocks; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; - unsigned long __unused4; - unsigned long __unused5; + unsigned long st_dev; /* Device. */ + unsigned long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long st_rdev; /* Device number, if device. */ + unsigned long __pad1; + long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long st_blocks; /* Number 512-byte blocks allocated. */ + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + unsigned int __unused4; + unsigned int __unused5; }; struct kernel_stat64 { - __kernel_dev_t st_dev; - unsigned long __unused0; - unsigned long __unused1; - - __kernel_ino64_t st_ino; - - __kernel_mode_t st_mode; - __kernel_nlink_t st_nlink; - - __kernel_uid_t st_uid; - __kernel_gid_t st_gid; - - __kernel_dev_t st_rdev; - unsigned long __unused2; - unsigned long __unused3; - - __kernel_loff_t st_size; - unsigned long st_blksize; - - unsigned long __unused4; /* future possible st_blocks high bits */ - unsigned long st_blocks; /* Number 512-byte blocks allocated. */ - - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; + unsigned long long st_dev; /* Device. */ + unsigned long long st_ino; /* File serial number. */ + unsigned int st_mode; /* File mode. */ + unsigned int st_nlink; /* Link count. */ + unsigned int st_uid; /* User ID of the file's owner. */ + unsigned int st_gid; /* Group ID of the file's group. */ + unsigned long long st_rdev; /* Device number, if device. */ + unsigned long long __pad1; + long long st_size; /* Size of file, in bytes. */ + int st_blksize; /* Optimal block size for I/O. */ + int __pad2; + long long st_blocks; /* Number 512-byte blocks allocated. */ + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + unsigned int __unused4; + unsigned int __unused5; }; #endif /* _BITS_STAT_STRUCT_H */ diff --git a/libc/sysdeps/linux/microblaze/bits/kernel_types.h b/libc/sysdeps/linux/microblaze/bits/kernel_types.h index 1ca2dae30..2a7057502 100644 --- a/libc/sysdeps/linux/microblaze/bits/kernel_types.h +++ b/libc/sysdeps/linux/microblaze/bits/kernel_types.h @@ -13,18 +13,17 @@ * Microblaze port by John Williams */ -#ifndef __MICROBLAZE_POSIX_TYPES_H__ -#define __MICROBLAZE_POSIX_TYPES_H__ +#ifndef _ASM_MICROBLAZE_POSIX_TYPES_H +#define _ASM_MICROBLAZE_POSIX_TYPES_H -typedef unsigned int __kernel_dev_t; +typedef unsigned long __kernel_dev_t; typedef unsigned long __kernel_ino_t; -typedef unsigned long long __kernel_ino64_t; -typedef unsigned int __kernel_mode_t; -typedef unsigned int __kernel_nlink_t; +//typedef unsigned long long __kernel_ino64_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned long __kernel_nlink_t; typedef long __kernel_off_t; -typedef long long __kernel_loff_t; typedef int __kernel_pid_t; -typedef unsigned short __kernel_ipc_pid_t; +typedef int __kernel_ipc_pid_t; typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; typedef unsigned int __kernel_size_t; @@ -33,6 +32,8 @@ typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; @@ -40,9 +41,13 @@ typedef unsigned short __kernel_gid16_t; typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; -typedef unsigned short __kernel_old_uid_t; -typedef unsigned short __kernel_old_gid_t; -typedef __kernel_dev_t __kernel_old_dev_t; +typedef unsigned int __kernel_old_uid_t; +typedef unsigned int __kernel_old_gid_t; +typedef unsigned int __kernel_old_dev_t; + +#ifdef __GNUC__ +typedef long long __kernel_loff_t; +#endif typedef struct { #ifdef __USE_ALL @@ -52,4 +57,4 @@ typedef struct { #endif } __kernel_fsid_t; -#endif /* __MICROBLAZE_POSIX_TYPES_H__ */ +#endif /* _ASM_MICROBLAZE_POSIX_TYPES_H */ diff --git a/libc/sysdeps/linux/microblaze/bits/poll.h b/libc/sysdeps/linux/microblaze/bits/poll.h index f7a739315..78ee877c0 100644 --- a/libc/sysdeps/linux/microblaze/bits/poll.h +++ b/libc/sysdeps/linux/microblaze/bits/poll.h @@ -29,10 +29,10 @@ #ifdef __USE_XOPEN /* These values are defined in XPG4.2. */ -# define POLLRDNORM 0x040 /* Normal data may be read. */ -# define POLLRDBAND 0x080 /* Priority data may be read. */ -# define POLLWRNORM POLLOUT /* Writing now will not block. */ -# define POLLWRBAND 0x100 /* Priority data may be written. */ +# define POLLRDNORM 0x0040 /* Normal data may be read. */ +# define POLLRDBAND 0x0080 /* Priority data may be read. */ +# define POLLWRNORM 0x0100 /* Writing now will not block. */ +# define POLLWRBAND 0x0200 /* Priority data may be written. */ #endif /* Event types always implicitly polled for. These bits need not be set in -- cgit v1.2.3 From dd8572189cde0425a9c09b57d1d05f53a24c0365 Mon Sep 17 00:00:00 2001 From: "Steven J. Magnani" Date: Wed, 10 Nov 2010 19:32:27 +0100 Subject: microblaze: misc headers Other header files for uClibc compilation. Signed-off-by: Steven J. Magnani Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/microblaze/bits/stackinfo.h | 28 +++++++++++++++ .../linux/microblaze/bits/uClibc_arch_features.h | 4 +-- libc/sysdeps/linux/microblaze/bits/uClibc_page.h | 41 ++++++++++++++++++++++ 3 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 libc/sysdeps/linux/microblaze/bits/stackinfo.h create mode 100644 libc/sysdeps/linux/microblaze/bits/uClibc_page.h (limited to 'libc/sysdeps/linux/microblaze/bits') diff --git a/libc/sysdeps/linux/microblaze/bits/stackinfo.h b/libc/sysdeps/linux/microblaze/bits/stackinfo.h new file mode 100644 index 000000000..819e81974 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/bits/stackinfo.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This file contains a bit of information about the stack allocation + of the processor. */ + +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +/* On microblaze the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +#endif /* stackinfo.h */ diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h index 2a9422e23..86d00084c 100644 --- a/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h +++ b/libc/sysdeps/linux/microblaze/bits/uClibc_arch_features.h @@ -10,7 +10,7 @@ #undef __UCLIBC_ABORT_INSTRUCTION__ /* can your target use syscall6() for mmap ? */ -#undef __UCLIBC_MMAP_HAS_6_ARGS__ +#define __UCLIBC_MMAP_HAS_6_ARGS__ /* does your target use syscall4() for truncate64 ? (32bit arches only) */ #undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ @@ -22,7 +22,7 @@ #undef __UCLIBC_HANDLE_OLDER_RLIMIT__ /* does your target have an asm .set ? */ -#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ +#undef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ /* define if target doesn't like .global */ #undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ diff --git a/libc/sysdeps/linux/microblaze/bits/uClibc_page.h b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h new file mode 100644 index 000000000..8fc81ae32 --- /dev/null +++ b/libc/sysdeps/linux/microblaze/bits/uClibc_page.h @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 Erik Andersen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Supply an architecture specific value for PAGE_SIZE and friends. */ + +#ifndef _UCLIBC_PAGE_H +#define _UCLIBC_PAGE_H + +#include + +#if defined(CONFIG_MICROBLAZE_32K_PAGES) +#define PAGE_SHIFT 15 +#elif defined(CONFIG_MICROBLAZE_16K_PAGES) +#define PAGE_SHIFT 14 +#elif defined(CONFIG_MICROBLAZE_8K_PAGES) +#define PAGE_SHIFT 13 +#elif defined(CONFIG_MICROBLAZE_4K_PAGES) +#define PAGE_SHIFT 12 +#else +#warning Missing CONFIG_MICROBLAZE_nnK_PAGES, assuming 4K +#define PAGE_SHIFT 12 +#endif + +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#endif /* _UCLIBC_PAGE_H */ -- cgit v1.2.3