--- QNX/src/hardware/devb/ram/sim.c 2008-08-13 18:02:12.000000000 -0400 +++ ./sim.c 2008-08-19 16:32:37.171875000 -0400 @@ -548,11 +548,42 @@ } } else { +#ifdef NOT_ARM_FCSE_LIMITED if( ( ext->ram = cam_calloc( ext->ram_capacity, ext->ram_blksize ) ) == NULL ) { ram_slogf( hba, _SLOGC_SIM_RAM, _SLOG_ERROR, 0, "ram_sim_attach: malloc size %d - %s", ext->ram_capacity * ext->ram_blksize, strerror( errno ) ); return( CAM_FAILURE ); } +#else + /* Create a new memory object */ + int fd = shm_open( "/dev/shmem/dos", O_RDWR | O_CREAT, 0700); + if( fd == -1 ) + { + ram_slogf( hba, _SLOGC_SIM_RAM, _SLOG_ERROR, 0, "ram_sim_attach: shmopen size %d - %s", + ext->ram_capacity * ext->ram_blksize, strerror( errno ) ); + return CAM_FAILURE; + } + + // ANON is zero-fill + // GLOBAL allows our process to use cache and have more than 32MB of it + // PRIV means that no screwing around for context switching + // if (shm_ctl( fd, SHMCTL_ANON|SHMCTL_GLOBAL|SHMCTL_PRIV, + if (shm_ctl( fd, SHMCTL_ANON | SHMCTL_PRIV | SHMCTL_GLOBAL, + (_uint64) 0, + (_uint64) ext->ram_capacity * ext->ram_blksize ) == -1) + { + // this fails for other than the first caller + // perror("dos ramdisk shmctl"); + } + + ext->ram = mmap( 0, ext->ram_capacity * ext->ram_blksize, + PROT_READ | PROT_WRITE | PROT_NOCACHE, + MAP_SHARED, fd, 0 ); + + // this will force the code to do an munmap rather than a bad free + ext->ram_phys = -1; + +#endif } #ifdef RAMDISK_QNX4_DINIT