[ECOS] [PATCH] shmat, shmget and shmdt syscalls for synth target
Andrew Lunn
andrew@lunn.ch
Wed Dec 15 14:05:00 GMT 2004
On Tue, Dec 14, 2004 at 11:01:48PM +0100, Alexander Neundorf wrote:
> 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.
I rearranged your patch a little bit. There is a new file
synth_syscalls.c which contains your small functions. I've also moved
the cyg_hal_sys_mmap() call from the flash driver into this file.
Attached is the patch i have committed.
Andrew
-------------- next part --------------
Index: devs/flash/synth/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/flash/synth/current/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- devs/flash/synth/current/ChangeLog 24 Nov 2003 11:21:28 -0000 1.4
+++ devs/flash/synth/current/ChangeLog 15 Dec 2004 13:59:02 -0000
@@ -1,3 +1,7 @@
+2004-12-15 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/synth.c: Moved cyg_hal_sys_mmap into the HAL.
+
2003-11-20 Jani Monoses <jani@iv.ro>
tests/flash1.c: Update flash_init() call to reflect
Index: devs/flash/synth/current/src/synth.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/flash/synth/current/src/synth.c,v
retrieving revision 1.3
diff -u -r1.3 synth.c
--- devs/flash/synth/current/src/synth.c 23 May 2002 23:01:06 -0000 1.3
+++ devs/flash/synth/current/src/synth.c 15 Dec 2004 13:59:03 -0000
@@ -68,25 +68,6 @@
/* Holds the base address of the mmap'd region */
flash_t *cyg_dev_flash_synth_base;
-/* Helper function. The Linux system call cannot pass 6 parameters. Instead
- a structure is filled in and passed as one parameter */
-static int
-cyg_hal_sys_do_mmap(void *addr, unsigned long length, unsigned long prot,
- unsigned long flags, unsigned long fd, unsigned long off)
-{
-
- struct cyg_hal_sys_mmap_args args;
-
- args.addr = (unsigned long) addr;
- args.len = length;
- args.prot = prot = prot;
- args.flags = flags;
- args.fd = fd;
- args.offset = off;
-
- return (cyg_hal_sys_mmap(&args));
-}
-
int
flash_hwr_init(void)
{
@@ -126,7 +107,7 @@
if ( cyg_dev_flash_synth_flashfd <= 0 ) {
return FLASH_ERR_HWR;
}
- cyg_dev_flash_synth_base = (flash_t *)cyg_hal_sys_do_mmap(
+ cyg_dev_flash_synth_base = (flash_t *)cyg_hal_sys_mmap(
#ifdef CYGMEM_FLASH_SYNTH_BASE
CYGMEM_FLASH_SYNTH_BASE,
#else
Index: hal/synth/arch/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/ChangeLog,v
retrieving revision 1.26
diff -u -r1.26 ChangeLog
--- hal/synth/arch/current/ChangeLog 9 Aug 2004 17:53:58 -0000 1.26
+++ hal/synth/arch/current/ChangeLog 15 Dec 2004 13:59:03 -0000
@@ -1,3 +1,12 @@
+2004-12-14 Alexander Neundorf <neundorf@kde.org>
+ Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * include/hal_io.h: Add cyg_hal_sys_shmget(), cyg_hal_sys_shmat()
+ and cyg_hal_sys_shmdt() system calls
+ * src/synth_syscalls.c: Implementations of cyg_hal_sys_shmget(),
+ cyg_hal_sys_shmat() and cyg_hal_sys_shmdt(). Moved
+ cyg_hal_sys_mmap() from the flash driver to here.
+
2004-08-09 Andrew Lunn <andrew.lunn@ascom.ch>
* include/hal_intr.h (HAL_PLATFORM_RESET): Added missing ;
Index: hal/synth/arch/current/cdl/hal_synth.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/arch/current/cdl/hal_synth.cdl,v
retrieving revision 1.6
diff -u -r1.6 hal_synth.cdl
--- hal/synth/arch/current/cdl/hal_synth.cdl 22 Apr 2004 15:26:55 -0000 1.6
+++ hal/synth/arch/current/cdl/hal_synth.cdl 15 Dec 2004 13:59:03 -0000
@@ -71,7 +71,7 @@
@echo >> $(notdir $@).deps
@rm target.tmp
}
- compile synth_entry.c synth_diag.c synth_intr.c
+ compile synth_entry.c synth_diag.c synth_intr.c synth_syscalls.c
define_proc {
puts $::cdl_system_header "#define CYGBLD_HAL_TARGET_H <pkgconf/hal_synth.h>"
Index: hal/synth/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 -u -r1.11 hal_io.h
--- hal/synth/arch/current/include/hal_io.h 4 Aug 2004 14:59:40 -0000 1.11
+++ hal/synth/arch/current/include/hal_io.h 15 Dec 2004 13:59:04 -0000
@@ -477,6 +477,33 @@
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. These may be unportable*/
+
+// Generic system call. Depending on the value of call, it will
+// perform the following functions.
+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*);
@@ -484,8 +511,18 @@
// not a char*.
externC int cyg_hal_sys_getcwd(char*, int);
-// mmap on the "host" system - this may be unportable.
-externC int cyg_hal_sys_mmap(struct cyg_hal_sys_mmap_args *);
+// mmap on the "host" system - this may be unportable. This is the
+// really system call into the kernel which passes one structure
+// containing all the arguments.
+externC int cyg_hal_sys_mmapx(struct cyg_hal_sys_mmap_args *);
+
+// This is the mmap call that users are used to.
+externC int cyg_hal_sys_mmap(void *addr,
+ unsigned long length,
+ unsigned long prot,
+ unsigned long flags,
+ unsigned long fd,
+ unsigned long off);
externC int cyg_hal_sys_readdir(unsigned int fd,
struct cyg_hal_sys_dirent *dp,
Index: hal/synth/arch/current/src/synth_syscalls.c
===================================================================
RCS file: hal/synth/arch/current/src/synth_syscalls.c
diff -N hal/synth/arch/current/src/synth_syscalls.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ hal/synth/arch/current/src/synth_syscalls.c 15 Dec 2004 13:59:05 -0000
@@ -0,0 +1,94 @@
+//=============================================================================
+//
+// synth_syscalls.c
+//
+// Synthetic target access to more complex system calls
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2004 Andrew Lunn
+// Copyright (C) 2004 eCosCentric Ltd
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos 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 General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew Lunn
+// Contributors:Alexander Neundorf
+// Date: 2004-12-15
+// Purpose: Access to more complex system calls which require marshalling.
+// Description:
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include <cyg/infra/cyg_type.h>
+#include <cyg/hal/hal_diag.h>
+#include <cyg/hal/hal_io.h>
+
+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);
+ 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);
+}
+
+int cyg_hal_sys_shmdt(const void* shmaddr)
+{
+ return cyg_hal_sys_ipc(CYG_HAL_SYS_IPCOP_shmdt, 0, 0, 0,
+ ((void *) shmaddr));
+}
+
+int
+cyg_hal_sys_mmap(void *addr, unsigned long length, unsigned long prot,
+ unsigned long flags, unsigned long fd, unsigned long off)
+{
+
+ struct cyg_hal_sys_mmap_args args;
+
+ args.addr = (unsigned long) addr;
+ args.len = length;
+ args.prot = prot = prot;
+ args.flags = flags;
+ args.fd = fd;
+ args.offset = off;
+
+ return (cyg_hal_sys_mmapx(&args));
+}
Index: hal/synth/i386linux/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/hal/synth/i386linux/current/ChangeLog,v
retrieving revision 1.11
diff -u -r1.11 ChangeLog
--- hal/synth/i386linux/current/ChangeLog 4 Aug 2004 15:00:28 -0000 1.11
+++ hal/synth/i386linux/current/ChangeLog 15 Dec 2004 13:59:05 -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: hal/synth/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 -u -r1.8 syscall-i386-linux-1.0.S
--- hal/synth/i386linux/current/src/syscall-i386-linux-1.0.S 4 Aug 2004 15:00:28 -0000 1.8
+++ hal/synth/i386linux/current/src/syscall-i386-linux-1.0.S 15 Dec 2004 13:59:06 -0000
@@ -140,7 +140,7 @@
#define SYS_swapon 87
#define SYS_reboot 88
#define SYS_readdir 89
-#define SYS_mmap 90
+#define SYS_mmapx 90
#define SYS_munmap 91
#define SYS_truncate 92
#define SYS_ftruncate 93
@@ -426,7 +426,7 @@
SYSCALL2(dup2)
SYSCALL3(sigaction)
SYSCALL2(gettimeofday)
-SYSCALL1(mmap)
+SYSCALL1(mmapx)
SYSCALL2(socketcall)
SYSCALL3(setitimer)
SYSCALL3(sigprocmask)
@@ -440,3 +440,4 @@
STATCALL2(lstat)
STATCALL2(fstat)
SYSCALL2(mkdir)
+SYSCALL5(ipc)
-------------- next part --------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss
mailing list