Thu Aug 31 17:19:57 1995 Alexandre Julliard <julliard@sunsite.unc.edu> * [Configure] Added compile-time option for IPC. * [configure.in] Added command-line options for language, IPC and malloc debugging. * [controls/menu.c] WM_MENUSELECT was sometimes sent to the wrong window. * [debugger/break.c] For the 'next' command, only step over instruction that require it. This allows 'next' to do the right thing with jmp and ret instructions. * [ipc/*.c] [memory/atom.c] [memory/global.c] IPC can now be configured out at compile-time. * [loader/task.c] Bug fix in TASK_Reschedule() that could cause a task to be deleted twice. * [miscemu/dosmem.c] (New file) Partial emulation of the BIOS data segment. * [miscemu/instr.c] Trap attempts to access selector 0x40 and remap the access to segment __0040H. * [tools/build.c] Fixed bug in CallTo32_LargeStack() that caused problems when compiling Wine with the -fomit-frame-pointer option. * [windows/message.c] Fixed bug in hardware event handling that could cause some events to get ignored. Sat Aug 26 13:12:59 IST 1995 Michael Veksler <mveksler@vnet.ibm.com> * [ipc/README] [ipc/dde.tex] LaTeX documentation for the ipc and DDE stuff. Wed Aug 23 22:01:23 GMT 1995 Michael Veksler <mveksler@vnet.ibm.com> * [ipc/Imakefile] [ipc/wine_test_stub.c] Fixed IPC testing. Now it can be compiled with "make tests" Wed Aug 23 21:04:14 1995 Fons Botman <botman@wab-tis.rabobank.nl> * [if1632/kernel.spec] [include/windows.h] [misc/main.c] Added GetWinDebugInfo/SetWinDebugInfo stub for player.exe Sun Aug 20 13:49:42 1995 Marcus Meissner <msmeissn@faui01.informatik.uni-erlangen.de> * [miscemu/int21.c] Misc fix to int21,ah=40 (write) to match _lwrite(). AX=0x440A (check if handle is remote) added. * [multimedia/mmsystem.c] Moved mciSendString to mcistring.c. * [multimedia/mcistring.c] New file, string interface for MCI (not complete, not thoroughly tested). * [multimedia/audio.c] IOCTL prints errors; one paranoid check disabled. * [misc/file.c] Misc operator precedence fixes. * [if1632/gdi.spec] [objects/bitblt.c] Stub for FastWindowFrame (parameters not correct). Sat Aug 19 01:31:23 1995 Graham Menhennitt <gfm@werple.mira.net.au> * [loader/ne_image.c] Preliminary support for iterated segments. Sat Aug 19 00:43:04 1995 Andrew Taylor (andrew@riscan.com) * [windows/mapping.c] In function MAPPING_FixIsotropic(), VportExt[XY] is multiplied by the absolute value of (ydim / xdim) or (xdim / ydim). Thu Aug 15 23:00:16 Gregory Trubetskoy <grisha@mira.com> * [objects/oembitmap.c] Added some includes for Windows 95. * [include/sysmetrics.h] Added some sysmetrics for Windows 95. * [include/bitmaps/*95] New files: obm_close_95, obm_closed_95, obm_reduce_95, obm_reduced_95 obm_zoom_95, obm_zoomd_95 - these are some pixmaps for Windows 95. Thu Aug 10 12:00:00 1995 Jan Willamowius (jan@janhh.shnet.org) * [misc/shell.c] [rc/sysres*.rc] The caption of the ShellAbout dialog box is language specific and should be defined in the resources.
195 lines
5.3 KiB
C
195 lines
5.3 KiB
C
/***************************************************************************
|
|
* Copyright 1995, Technion, Israel Institute of Technology
|
|
* Electrical Eng, Software Lab.
|
|
* Author: Michael Veksler.
|
|
***************************************************************************
|
|
* File: shm_block.c
|
|
* Purpose: Treat a shared memory block.
|
|
***************************************************************************
|
|
*/
|
|
#ifdef CONFIG_IPC
|
|
|
|
#define inline __inline__
|
|
#include <sys/types.h>
|
|
#include <sys/sem.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <stddebug.h>
|
|
#include <debug.h>
|
|
#include <global.h>
|
|
#include "selectors.h"
|
|
#include "shm_fragment.h"
|
|
#include "shm_block.h"
|
|
#include "shm_semaph.h"
|
|
#include "dde_proc.h"
|
|
|
|
/* How each shmid is maped to local pointer */
|
|
/* Only attached shm blocks are in this construct */
|
|
struct local_shm_map *shm_map=NULL;
|
|
|
|
/* setup a new shm block (construct a shm block object).
|
|
* block: The pointer to the memory block (local mapping)
|
|
* first: The first data byte (excluding header stuff),
|
|
* if 0 (zero) Use the default.
|
|
* size: The size of the memory block.
|
|
*/
|
|
void shm_setup_block(struct shm_block *block, int first, int size)
|
|
{
|
|
dprintf_shm(stddeb,"Setting up shm block at 0x%08x\n",(int )block);
|
|
/* setup block internal data structure */
|
|
if (first <= 0) {
|
|
first=sizeof(*block);
|
|
/* round up - so everything starts on cache line boundary
|
|
* (assume cache line=32 bytes, may be bigger/smaller for
|
|
* different processors and different L2 caches .)
|
|
*/
|
|
first=(first+0x1f) & ~0x1f;
|
|
}
|
|
block->free=size-first;
|
|
block->next_shm_id=-1; /* IPC shm ID (for initial linking) */
|
|
block->proc_idx= curr_proc_idx;
|
|
/* block->size is initialized in shm_FragmentInit */
|
|
shm_FragmentInit(block, first, size); /* first item in the free list */
|
|
|
|
dprintf_shm(stddeb,
|
|
"block was set up at 0x%08x, size=0x%04xKB, 1st usable=%02x\n",
|
|
(int )block,size/1024,first);
|
|
}
|
|
|
|
/* shm_attach_block: attach existing shm block, setup selectors
|
|
* shm_id - id of the block to attach.
|
|
* proc_idx - if not -1, puts this data into local mapping
|
|
* map - localy mapped info about this block.
|
|
*/
|
|
/* NOTE: there is no check if this block is already attached.
|
|
* Attaching the same block more than once - is possible
|
|
* In case of doubt use shm_locate_block.
|
|
*/
|
|
struct shm_block *shm_attach_block(int shm_id, int proc_idx,
|
|
struct local_shm_map *map)
|
|
{
|
|
struct shm_block *block;
|
|
struct shmid_ds ds;
|
|
struct local_shm_map *this;
|
|
|
|
shmctl(shm_id, IPC_STAT, &ds );
|
|
|
|
block=(struct shm_block*)shmat(shm_id, NULL, 0);
|
|
if (block==NULL || block == (struct shm_block*) -1) return NULL;
|
|
|
|
this=(struct local_shm_map *)malloc(sizeof(*this));
|
|
this->next= shm_map;
|
|
shm_map = this;
|
|
this->shm_id= shm_id;
|
|
this->ptr = block;
|
|
|
|
if (proc_idx < 0)
|
|
this->proc_idx=block->proc_idx;
|
|
else
|
|
this->proc_idx=proc_idx;
|
|
|
|
if (map != NULL) {
|
|
memcpy(map, this, sizeof(map));
|
|
map->next= NULL; /* don't pass private info */
|
|
}
|
|
|
|
return block;
|
|
}
|
|
|
|
struct shm_block *shm_create_block(int first, int size, int *shm_id)
|
|
{
|
|
struct shm_block *block;
|
|
|
|
if (size==0)
|
|
size=SHM_MINBLOCK;
|
|
else
|
|
/* round up size to a multiple of SHM_MINBLOCK */
|
|
size= (size+SHM_MINBLOCK-1) & ~(SHM_MINBLOCK-1);
|
|
*shm_id= shmget ( IPC_PRIVATE, size ,0700);
|
|
if (*shm_id==-1)
|
|
return NULL;
|
|
block=shm_attach_block(*shm_id, curr_proc_idx, NULL);
|
|
if (block!=NULL)
|
|
shm_setup_block(block, first, size);
|
|
|
|
return block;
|
|
}
|
|
|
|
/*
|
|
** Locate attached block. (return it, or NULL on failure)
|
|
** shm_id is the block we look for.
|
|
** *map - will get all the info related to this local map + proc_idx
|
|
** (may be NULL)
|
|
** *seg - will get the segment this block is attached to.
|
|
*/
|
|
struct shm_block *shm_locate_attached_block(int shm_id,
|
|
struct local_shm_map *map)
|
|
{
|
|
struct local_shm_map *curr;
|
|
|
|
for (curr= shm_map ; curr != NULL ; curr= curr->next) {
|
|
if (curr->shm_id == shm_id) {
|
|
if (map) {
|
|
memcpy(map, curr, sizeof(*curr) );
|
|
map->next = NULL; /* this is private info ! */
|
|
}
|
|
return curr->ptr;
|
|
}
|
|
}
|
|
|
|
/* block not found ! */
|
|
return 0;
|
|
}
|
|
|
|
/* shm_locate_block: see shm_attach_block.
|
|
In addition to shm_attach_block, make sure this
|
|
block is not already attached.
|
|
*/
|
|
struct shm_block *shm_locate_block(int shm_id, struct local_shm_map *map)
|
|
{
|
|
|
|
struct shm_block *ret;
|
|
ret= shm_locate_attached_block(shm_id, map);
|
|
if (ret!=NULL)
|
|
return ret;
|
|
/* block not found ! , try to attach */
|
|
return shm_attach_block(shm_id, -1, map);
|
|
}
|
|
|
|
static void forget_attached(int shmid)
|
|
{
|
|
struct local_shm_map *curr, **point_to_curr;
|
|
|
|
for (curr= shm_map, point_to_curr= &shm_map ;
|
|
curr != NULL ;
|
|
curr= curr->next, point_to_curr= &curr->next ) {
|
|
if (curr->shm_id == shmid) {
|
|
*point_to_curr= curr->next;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* delete chain of shm blocks (pointing to each other)
|
|
* Do it in reverse order. (This is what the recursion is for)
|
|
*/
|
|
void shm_delete_chain(int *shmid)
|
|
{
|
|
struct shm_block *block;
|
|
|
|
if (*shmid == -1)
|
|
return;
|
|
|
|
block= shm_locate_block(*shmid, NULL);
|
|
forget_attached( *shmid );
|
|
if (block == NULL)
|
|
return;
|
|
shm_delete_chain(&block->next_shm_id);
|
|
shmctl(*shmid, IPC_RMID, NULL);
|
|
*shmid=-1;
|
|
shmdt((char *)block);
|
|
}
|
|
|
|
#endif /* CONFIG_IPC */
|