[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] sysv ipc support on microblaze
Hi Jim,
I've implemented this for the next cut - here's a patch to apply from
petalinux-dist/software that should get you going.
I've tested this with simple test apps, but will be interested to hear
your experiences.
Regards,
John
Jim Van Vorst wrote:
Hi all,
I added sysv ipc support to the 2.6 kernel and I can see
/proc/sysvipc/msg,sem,shm but when I call msgget() I get "Function not
implemented."
Are message queues (and semaphores and shared memory) implemented on the
microblaze 2.6 kernel?
Thanks,
Jim
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive :
http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/
Index: linux-2.6.x-petalogix/arch/microblaze/kernel/syscall_table.S
===================================================================
--- linux-2.6.x-petalogix/arch/microblaze/kernel/syscall_table.S (revision 3032)
+++ linux-2.6.x-petalogix/arch/microblaze/kernel/syscall_table.S (revision 3033)
@@ -116,7 +116,7 @@
.long sys_wait4
.long sys_swapoff /* 115 */
.long sys_sysinfo
- .long sys_ni_syscall /* ipc */
+ .long sys_ipc
.long sys_fsync
.long sys_sigreturn_wrapper
.long sys_clone_wrapper /* 120 */
Index: linux-2.6.x-petalogix/arch/microblaze/kernel/sys_microblaze.c
===================================================================
--- linux-2.6.x-petalogix/arch/microblaze/kernel/sys_microblaze.c (revision 3032)
+++ linux-2.6.x-petalogix/arch/microblaze/kernel/sys_microblaze.c (revision 3033)
@@ -6,17 +6,19 @@
* for more details.
*
* Copyright (C) 2006 Atmark Techno, Inc.
+ * (C) 2007 PetaLogix
*
* Authors:
+ * John Williams <john.williams@xxxxxxxxxxxxx>
* Yasushi SHOJI <yashi@xxxxxxxxxxxxxxxxx>
* Tetsuya OHKAWA <tetsuya@xxxxxxxxxxxxxxxxx>
*/
#include <linux/errno.h>
-#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
+#include <linux/syscalls.h>
#include <linux/sem.h>
#include <linux/msg.h>
#include <linux/shm.h>
@@ -26,17 +28,114 @@
#include <linux/ipc.h>
#include <linux/utsname.h>
#include <linux/file.h>
-
+#include <linux/module.h>
+
#include <asm/uaccess.h>
#include <asm/ipc.h>
#include <asm/semaphore.h>
-
-#include <linux/module.h>
-#include <linux/ptrace.h>
-#include <linux/fs.h>
-#include <asm/uaccess.h>
#include <asm/unistd.h>
+
+/*
+ * sys_ipc() is the de-multiplexer for the SysV IPC calls..
+ *
+ * This is really horribly ugly.
+ */
+int
+sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
+{
+ int version, ret;
+
+ version = call >> 16; /* hack for backward compatibility */
+ call &= 0xffff;
+
+ ret = -EINVAL;
+ switch (call) {
+ case SEMOP:
+ ret = sys_semop (first, (struct sembuf *)ptr, second);
+ break;
+ case SEMGET:
+ ret = sys_semget (first, second, third);
+ break;
+ case SEMCTL:
+ {
+ union semun fourth;
+
+ if (!ptr)
+ break;
+ if ((ret = access_ok(VERIFY_READ, ptr, sizeof(long)) ? 0 : -EFAULT)
+ || (ret = get_user(fourth.__pad, (void **)ptr)))
+ break;
+ ret = sys_semctl (first, second, third, fourth);
+ break;
+ }
+ case MSGSND:
+ ret = sys_msgsnd (first, (struct msgbuf *) ptr, second, third);
+ break;
+ case MSGRCV:
+ switch (version) {
+ case 0: {
+ struct ipc_kludge tmp;
+
+ if (!ptr)
+ break;
+ if ((ret = access_ok(VERIFY_READ, ptr, sizeof(tmp)) ? 0 : -EFAULT)
+ || (ret = copy_from_user(&tmp,
+ (struct ipc_kludge *) ptr,
+ sizeof (tmp))))
+ break;
+ ret = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp,
+ third);
+ break;
+ }
+ default:
+ ret = sys_msgrcv (first, (struct msgbuf *) ptr,
+ second, fifth, third);
+ break;
+ }
+ break;
+ case MSGGET:
+ ret = sys_msgget ((key_t) first, second);
+ break;
+ case MSGCTL:
+ ret = sys_msgctl (first, second, (struct msqid_ds *) ptr);
+ break;
+ case SHMAT:
+ switch (version) {
+ default: {
+ ulong raddr;
+
+ if ((ret = access_ok(VERIFY_WRITE, (ulong*) third,
+ sizeof(ulong)) ? 0 : -EFAULT))
+ break;
+ ret = do_shmat (first, (char *) ptr, second, &raddr);
+ if (ret)
+ break;
+ ret = put_user (raddr, (ulong *) third);
+ break;
+ }
+ case 1: /* iBCS2 emulator entry point */
+ if (!segment_eq(get_fs(), get_ds()))
+ break;
+ ret = do_shmat (first, (char *) ptr, second,
+ (ulong *) third);
+ break;
+ }
+ break;
+ case SHMDT:
+ ret = sys_shmdt ((char *)ptr);
+ break;
+ case SHMGET:
+ ret = sys_shmget (first, second, third);
+ break;
+ case SHMCTL:
+ ret = sys_shmctl (first, second, (struct shmid_ds *) ptr);
+ break;
+ }
+
+ return ret;
+}
+
long execve(const char *filename, char **argv, char **envp)
{
struct pt_regs regs;