This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] shmat, shmget and shmdt syscalls for synth target


Hi,

attached is a patch against current cvs which adds support for the shmat(), 
shmget() and shmid() system calls for the synth. target. This is useful e.g. 
for connecting to the Qt/E qvfb framebuffer simulator.

Please apply.
(I know the shmat, shmget and shmdt implementations would live better in maybe 
synth_ipc.c, but are these three tiny functions really worth their own 
file ? )


Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net
Index: arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/ChangeLog,v
retrieving revision 1.26
diff -b -u -p -r1.26 ChangeLog
--- arch/current/ChangeLog	9 Aug 2004 17:53:58 -0000	1.26
+++ arch/current/ChangeLog	14 Dec 2004 21:56:56 -0000
@@ -1,3 +1,10 @@
+2004-12-14  Alexander Neundorf <neundorf@kde.org>
+
+	* include/hal_io.h: Add cyg_hal_sys_ipc(), cyg_hal_sys_shmget(), 
+        cyg_hal_sys_shmat() and cyg_hal_sys_shmdt() system calls
+	* src/synth_diag.c_ Implementations of cyg_hal_sys_shmget(), 
+        cyg_hal_sys_shmat() and cyg_hal_sys_shmdt()
+
 2004-08-09  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* include/hal_intr.h (HAL_PLATFORM_RESET): Added missing ;
Index: arch/current/include/hal_io.h
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/include/hal_io.h,v
retrieving revision 1.11
diff -b -u -p -r1.11 hal_io.h
--- arch/current/include/hal_io.h	4 Aug 2004 14:59:40 -0000	1.11
+++ arch/current/include/hal_io.h	14 Dec 2004 21:56:57 -0000
@@ -477,6 +477,29 @@ externC int             cyg_hal_sys_pipe
 externC int             cyg_hal_sys_close(int);
 externC int             cyg_hal_sys_dup2(int, int);
  
+#define CYG_HAL_SYS_IPCOP_semop          1
+#define CYG_HAL_SYS_IPCOP_semget         2
+#define CYG_HAL_SYS_IPCOP_semctl	 3
+#define CYG_HAL_SYS_IPCOP_msgsnd	11
+#define CYG_HAL_SYS_IPCOP_msgrcv	12
+#define CYG_HAL_SYS_IPCOP_msgget	13
+#define CYG_HAL_SYS_IPCOP_msgctl	14
+#define CYG_HAL_SYS_IPCOP_shmat         21
+#define CYG_HAL_SYS_IPCOP_shmdt         22
+#define CYG_HAL_SYS_IPCOP_shmget	23
+#define CYG_HAL_SYS_IPCOP_shmctl	24
+
+/*The ipc system call, which is used by the following shmem functions.
+ It takes only 5 arguments, as opposed to some man pages, which add a "long fifth" argument at the end.*/
+externC int             cyg_hal_sys_ipc(int call, int first, int second, int third, void* ptr);
+//get an identifier for a shared memory segment
+externC int             cyg_hal_sys_shmget (int key, int size, int shmflg);
+//attach to an shared memory segment
+externC void *          cyg_hal_sys_shmat (int shmid, const void* shmaddr, int shmflg);
+//detach from it again
+externC int             cyg_hal_sys_shmdt (const void* shmaddr);
+
+
 // The actual implementation appears to return the new brk() value.
 externC void*           cyg_hal_sys_brk(void*);
 
Index: arch/current/src/synth_diag.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/src/synth_diag.c,v
retrieving revision 1.4
diff -b -u -p -r1.4 synth_diag.c
--- arch/current/src/synth_diag.c	15 Sep 2002 17:53:27 -0000	1.4
+++ arch/current/src/synth_diag.c	14 Dec 2004 21:56:57 -0000
@@ -151,5 +151,26 @@ void hal_diag_read_char(char *c)
     } while ((-CYG_HAL_SYS_EINTR == rc) || (-CYG_HAL_SYS_EAGAIN == rc));
 }
 
+//the shmat, shmget and shmdt functions
+//actually they would live better in their own file, but they are so short...
+void * cyg_hal_sys_shmat (int shmid, const void* shmaddr, int shmflg)
+{
+   void * result;
+   void * raddr;
+   result = (void *) cyg_hal_sys_ipc(CYG_HAL_SYS_IPCOP_shmat, shmid, shmflg, (int) (&raddr), (void*)shmaddr/*, 0*/);
+   return raddr;
+}
+
+int cyg_hal_sys_shmget (int key, int size, int shmflg)
+{
+   return cyg_hal_sys_ipc(CYG_HAL_SYS_IPCOP_shmget, key, size, shmflg, NULL/*, 0*/);
+}
+
+int cyg_hal_sys_shmdt (const void* shmaddr)
+{
+   return cyg_hal_sys_ipc(CYG_HAL_SYS_IPCOP_shmdt, 0, 0, 0, ((void *) shmaddr)/*, 0*/);
+}
+
+
 //-----------------------------------------------------------------------------
 // End of hal_diag.c
Index: i386linux/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/i386linux/current/ChangeLog,v
retrieving revision 1.11
diff -b -u -p -r1.11 ChangeLog
--- i386linux/current/ChangeLog	4 Aug 2004 15:00:28 -0000	1.11
+++ i386linux/current/ChangeLog	14 Dec 2004 21:56:57 -0000
@@ -1,3 +1,7 @@
+2004-12-14  Alexander Neundorf <neundorf@kde.org>
+
+	* src/syscall-i386-linux-1.0.S:	Add ipc system call
+
 2004-08-04  Alexander Neundorf <alexander.neundorf@jenoptik.com>
 
 	* src/syscall-i386-linux-1.0.S:	Add mkdir system call
Index: i386linux/current/src/syscall-i386-linux-1.0.S
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/i386linux/current/src/syscall-i386-linux-1.0.S,v
retrieving revision 1.8
diff -b -u -p -r1.8 syscall-i386-linux-1.0.S
--- i386linux/current/src/syscall-i386-linux-1.0.S	4 Aug 2004 15:00:28 -0000	1.8
+++ i386linux/current/src/syscall-i386-linux-1.0.S	14 Dec 2004 21:56:57 -0000
@@ -440,3 +440,4 @@ SYSCALL3(readdir)
 STATCALL2(lstat)
 STATCALL2(fstat)
 SYSCALL2(mkdir)
+SYSCALL5(ipc)

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]