Hi Robert,

On Thu, 2008-06-05 at 16:00 -0500, Robert Hildinger wrote:
> multi-app code within DirectFB itself. The problem comes at runtime
> with the execution of the mmap() command during shared memory pool
> creation, which fails everytime. The fact that the mmap() calls
> request a fixed address starting at 0x20000000 appears to be the heart
> of the problem, although perhaps it is the actual memory map of the
> platform that is at issue. At any rate, I have tried fixed address of
> all types in the format 0xX0000000 to no avail. 

this may be unrelated to your problem, but in addition to the base
address that must be changed, many embedded architectures have certain
restrictions on mmap() because of cache aliasing issues.
Please see the two attached patches as a guide (don't know if this
applies to DirectFB-1.1, though)

HTH,
Andre'

- Default base address of shared memory is not suitable for SH4,
  since that's in shared library address space.
- SH4 has some D-Cache aliasing issues, so we need to get around
  those.

Signed-off by: André Draszik <[EMAIL PROTECTED]>

Index: linux-fusion-3.2.4/linux/drivers/char/fusion/shmpool.c
===================================================================
--- linux-fusion-3.2.4.orig/linux/drivers/char/fusion/shmpool.c	2008-01-17 17:09:25.517236000 +0000
+++ linux-fusion-3.2.4/linux/drivers/char/fusion/shmpool.c	2008-01-18 12:57:09.361721000 +0000
@@ -29,7 +29,11 @@
 #include "shmpool.h"
 
 
+#ifdef CONFIG_CPU_SH4
+#define SHM_BASE    0x30010000     /* virtual base address */
+#else
 #define SHM_BASE    0x20010000     /* virtual base address */
+#endif
 #define SHM_SIZE    0x1FFEF000     /* size of virtual address space */
 
 
@@ -119,6 +123,12 @@ fusion_shmpool_construct( FusionEntry *e
      shmpool->addr_base = poolnew->addr_base = (void*) addr_base;
 
      addr_base += PAGE_ALIGN(poolnew->max_size) + PAGE_SIZE; /* fence page */
+#ifdef CONFIG_CPU_SH4
+     /* a generic kernel api for retrieving information about mmap
+        restrictions would be nice! On sh4, shm_align_mask is 0x3fff */
+     /* beware! other CPU have similar requirements, but we don't care */
+     addr_base = (addr_base + shm_align_mask) & ~shm_align_mask;
+#endif
 
      shmpool->addr_entry = add_addr_entry( addr_base );
 
- SH4 (and several architectures) have special requirements on the alignment
  of mmap()ed MAP_FIXED | MAP_SHARED memory (D-Cache aliasing issues). However,
  this patch cares about SH4 only and leaves other arches untouched!

Signed-off by: André Draszik <[EMAIL PROTECTED]>

Index: DirectFB-1.0.1/lib/fusion/fusion.c
===================================================================
--- DirectFB-1.0.1.orig/lib/fusion/fusion.c	2008-01-22 12:52:51.489485000 +0000
+++ DirectFB-1.0.1/lib/fusion/fusion.c	2008-01-22 13:53:01.268090000 +0000
@@ -334,6 +334,7 @@ fusion_enter( int               world_in
      FusionEnter        enter;
      char               buf1[20];
      char               buf2[20];
+     unsigned long      base, offset;
 
      D_DEBUG_AT( Fusion_Main, "%s( %d, %d, %p )\n", __FUNCTION__, world_index, abi_version, ret_world );
 
@@ -492,7 +493,14 @@ fusion_enter( int               world_in
      }
 
      /* Map shared area. */
-     shared = mmap( (void*) 0x20000000 + 0x2000 * world_index, sizeof(FusionWorldShared),
+#ifdef __SH4__
+     base   = 0x20000000;
+     offset = 0x4000 * world_index;
+#else
+     base   = 0x20000000;
+     offset = 0x2000 * world_index;
+#endif
+     shared = mmap( (void*) (base + offset), sizeof(FusionWorldShared),
                     PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, 0 );
      if (shared == MAP_FAILED) {
           D_PERROR( "Fusion/Init: Mapping shared area failed!\n" );
_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to