Beispiel #1
0
static void
removeIOSmem(void)
{
	smem_create(NULL, (char *) ioBase, 0, SM_DETACH);
	smem_remove("IOBASE");
	ioBase = MAP_FAILED;	
}
Beispiel #2
0
Bool
SDL_NAME(XF86DGADirectVideo)(
    Display *dis,
    int screen,
    int enable
){
    ScrPtr sp;
    MapPtr mp = NULL;

    if ((sp = FindScr(dis, screen)))
	mp = sp->map;

    if (enable & XF86DGADirectGraphics) {
#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
	&& !defined(__EMX__)
	if (mp && mp->vaddr)
	    mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ | PROT_WRITE);
#endif
    } else {
#if !defined(ISC) && !defined(HAS_SVR3_MMAP) && !defined(Lynx) \
	&& !defined(__EMX__)
	if (mp && mp->vaddr)
	    mprotect(mp->vaddr, mp->size + mp->delta, PROT_READ);
#elif defined(Lynx)
	/* XXX this doesn't allow enable after disable */
	smem_create(NULL, mp->vaddr, mp->size + mp->delta, SM_DETACH);
	smem_remove("XF86DGA");
#endif
    }

    SDL_NAME(XF86DGADirectVideoLL)(dis, screen, enable);
    return 1;
}
Beispiel #3
0
static void
UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
	int	i;

	xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n",
		Base, Size);
	for (i = 0; i < MAX_SMEMS; i++)
	{
		if (*smems[i].name && smems[i].ptr == Base 
			&& smems[i].Size == Size)
		{
			if (--smems[i].RefCnt > 0)
				return;

			(void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH);
			xf86MsgVerb(X_INFO, 3,
                           "UnMapVidMem: smem_create(%s, 0x%08x, ... "
                           "SM_DETACH)\n", smems[i].name, smems[i].ptr);
			(void)smem_remove(smems[i].name);
			*smems[i].name = '\0';
			smems[i].RefCnt = 0;
			return;
		}
	}
	xf86MsgVerb(X_WARNING, 2,
		"UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n",
	       	Base, Size);
}
Beispiel #4
0
static void
smemCleanup(void)
{
	int i;

	for (i = 0; i < MAX_SMEMS; i++) {
		if (*smems[i].name && smems[i].ptr) {
			(void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH);
			(void)smem_remove(smems[i].name);
			*smems[i].name = '\0';
			smems[i].ptr = NULL;
			smems[i].Base = 0;
			smems[i].Size = 0;
			smems[i].RefCnt = 0;
		}
	}
}
int main() {
   one = 1;

   if (!(mem24=(int)smem_create("MEM24",(char *)(CPUADDR&~0xFFF),0x4,
      SM_WRITE | SM_READ))){
      fprintf(stderr,"Unable to allocate MEM window for slave A24 memory");
      exit(0);
   }

   p = (long *)(mem24 | (CPUADDR&0xFFF));          /*Location for VMEjump*/

   dts=swap(*p);
   printf("Message box(4): VMEjump status was    : 0x%x \n",dts);
   *p = swap(1);
   dts=swap(*p);
   printf("Message box(4): VMEjump status is now : 0x%x \n",dts);
   printf("VME eventbuilder is leaving infinite eventloop...\n");

   smem_create("MEM24",(char *)mem24,0x4,SM_DETACH);
   smem_remove("MEM24"); 
  
   return;
}
Beispiel #6
0
static inline void disable_os_io(void)
{
    smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH);
    smem_remove("PCI-CONF");
    pciConfBase = NULL;
}
Beispiel #7
0
static pointer
MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
{
	static int once;
	int	free_slot = -1;
	int	i;

	if (!once)
	{
		atexit(smemCleanup);
		once = 1;
	}
	for (i = 0; i < MAX_SMEMS; i++)
	{
		if (!*smems[i].name && free_slot == -1)
			free_slot = i;
		if (smems[i].Base == Base && smems[i].Size == Size 
		    && *smems[i].name) {
			smems[i].RefCnt++;
			return smems[i].ptr;
		}
	}
	if (i == MAX_SMEMS && free_slot == -1)
	{
		FatalError("MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n",
			Base, Size);
	}

	i = free_slot;
	sprintf(smems[i].name, "Video-%d", i);
	smems[i].Base = Base;
	smems[i].Size = Size;
	
        xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n",
        	Base, Size);

#if defined(__powerpc__)
	if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) {
		Base = Base | PHYS_IO_MEM_START;
	}
#endif

	smems[i].ptr = smem_create(smems[i].name, (char *)Base, Size, SM_READ|SM_WRITE);
	smems[i].RefCnt = 1;
	if (smems[i].ptr == NULL)
	{
		/* check if there is a stale segment around */
		if (smem_remove(smems[i].name) == 0) {
	        	xf86Msg(X_INFO,
			    "MapVidMem: removed stale smem_ segment %s\n",
		            smems[i].name);
			smems[i].ptr = smem_create(smems[i].name, 
						(char *)Base, Size, SM_READ|SM_WRITE);
		}
	        if (smems[i].ptr == NULL) {
			*smems[i].name = '\0';
			FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n",
				Base, Size, strerror(errno));
		}
	}
        xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n",
        		 Base, Size, smems[i].ptr);
	return smems[i].ptr;
}