Пример #1
0
void Destroy()
{
	ReleaseDevice(&quad);

	ReleaseDevice(&g_pInDevice);
	ReleaseDevice(&g_pDIN);

	ReleaseDevice(&g_pDevice);
	ReleaseDevice(&g_pD3D);

	delete[] map;
}
/****************************************************************************
Description:
   Clean up the module if unloaded.
Arguments:
   None.
Return Value:
   None.
Remarks:
   Called by the kernel.
****************************************************************************/
static void __exit duslic_module_exit(void)
{
    IFX_int32_t i;
#ifdef CONFIG_DEVFS_FS
    IFX_int32_t j;
#endif /* CONFIG_DEVFS_FS */

   for (i=0; i < DUSLIC_MAX_DEVICES; i++)
   {
#ifdef CONFIG_DEVFS_FS
      /* remove duslic devices from dev fs */
      for (j = 0; j <= DUSLIC_MAX_CHANNELS; j++ )
      {
         if (devfs_handle[i*DUSLIC_MAX_CHANNELS + j])
         {
	    //printk("unregister dus%d%d\n",i+1,j);
            devfs_unregister (devfs_handle[i*DUSLIC_MAX_CHANNELS + j]);
         }
      }
#else 
    unregister_chrdev (DUSLIC_MAJOR, DEV_NAME);
#endif /* CONFIG_DEVFS_FS */
   }
   
   for (i=0; i < DUSLIC_MAX_DEVICES; i++)
   {
      if (pDuslic_Devices[i] != NULL)
      {
         ReleaseDevice (pDuslic_Devices[i]);
      }
   }
   remove_proc_entry(DEV_NAME,NULL);
}
Пример #3
0
	void Shutdown()
	{
		Input::Shutdown();
		Sprites::Shutdown();
		
		ReleaseDevice();
	}
Пример #4
0
	bool SPDevice::ResetDevice( SPConfig config )
	{
		//SPTextureManager::GetSingleton().Unload();

		// Try to reset.
		if (d3dDevice)
		{
			if (D3D_OK == d3dDevice->Reset(&config.ToD3DParameters()))
			{
				return true;
			}
		}		

		// Force reload.
		SPLogHelper::WriteLog("[DirectX] WARNING: Force reseting D3D device!");

		ReleaseDevice();

		if( !CreateD3DDevice(config) )
		{
			return false;
		}

		return true;
	}
void CDirectInputDetail::Kill(void)
{
	szInstanceName.Kill();
	szProductName.Kill();
	szID.Kill();
	ReleaseDevice();
	CNativeDetail::Kill();
}
Пример #6
0
CAMARO_API void ReleaseDeviceList(HDevice *list, int num)
{
	if (list != nullptr)
	{
		for (auto i = 0; i < num; ++i)
			ReleaseDevice(list+i);
		delete[] list;
	}
}
Пример #7
0
int main(int argc, char *argv[])
{
	assert(argc == 2);
	char * outFileName = argv[1];
	FILE *outFile = fopen(outFileName, "w");
	
	
	int dtFlyPinitStatus = InitDevice(userIntHandler);
	assert(dtFlyPinitStatus == 0);	
	int status;
/*	
	uint32_t regData[1];
	uint32_t regAddress = 513;
	
	// Read, write, then read again register 0
	// ReadWriteConfigRegs(direction, registerNumber, registerDataBuffer, numberOfRegisters)
	status = ReadWriteConfigRegs(READ, regAddress, regData, 1);
	printf("Read status is %d, value is %08lx\n", status, regData[0]);

	regData[0] = 0x12345678;
	status = ReadWriteConfigRegs(WRITE, regAddress, regData, 1);
	printf("Write status is %d\n", status);

	status = ReadWriteConfigRegs(READ, regAddress, regData, 1);
	printf("Read status is %d, value is %08lx\n", status, regData[0]);

	*/
	
	/*
	 * Read and dump to file
	 */ 
	SBufferInit buffer;
	unsigned bufferIndex = 0;
	AllocateBuffer(bufferIndex, &buffer);
	
	for(int nReads = 0; nReads < 10; nReads += 1) {
		status = ReceiveDMAbyBufIndex(DMA1, bufferIndex, 1);
		if(status > 0) {
			uint64_t *wordBuffer = (uint64_t *)buffer.UserAddr;
			int nWords = status / sizeof(uint64_t);
			
			for(int i = 0; i < nWords; i++) {
				fprintf(outFile, "%016llx\n", wordBuffer[i]);
			}
		}
	}	
	ReleaseBuffer(bufferIndex);	
	
	
	
	ReleaseDevice();
	fclose(outFile);
	return 0;
}
Пример #8
0
bool OpenAL::CreateDevice()
{
    ReleaseDevice();

    m_Device = alcOpenDevice(NULL);

    if(m_Device)
        LogInfo("Opened OAL device");
 
    return m_Device != NULL;
}
Пример #9
0
void OpenAL::Release()
{
    LogInfo("Releasing OAL");
    
    if(m_ActiveBuffers != 0 || m_ActiveSources != 0)
    {
        LogError("Fatal OAL error: hanging references detected, %i buffers, %i sources", m_ActiveBuffers, m_ActiveSources);
    }

    ReleaseDevice();
}
Пример #10
0
// release our DirectInput effects and devices, our DirectInput handle, and then unload dinput library
void FreeDirectInput ()
{
	int i;
	// release effects
	for( i = 0; i < ARRAYSIZE( g_apdiEffect ); ++i )
		ReleaseEffect( g_apdiEffect[i] );
	ZeroMemory( g_apdiEffect, sizeof(g_apdiEffect) );

	// release FF devices
	for( i = 0; i << ARRAYSIZE(g_apFFDevice); ++i )
		ReleaseDevice( g_apFFDevice[i] );
	ZeroMemory( g_apFFDevice, sizeof(g_apFFDevice) );

	// release normal devices
	for( i = 0; i < g_nDevices; i++ )
		ReleaseDevice( g_devList[i].didHandle );
	ZeroMemory( g_devList, sizeof(g_devList) );
	g_nDevices = 0;

	// release mouse device
	ReleaseDevice( g_sysMouse.didHandle );
	ZeroMemory( &g_sysMouse, sizeof(g_sysMouse) );

    // Release any DirectInput handles.
	if( g_pDIHandle != NULL )
	{
		g_pDIHandle->Release();
		g_pDIHandle = NULL;
	}
	// Unload the library.
	if( g_hDirectInputDLL != NULL )
	{
		FreeLibrary( g_hDirectInputDLL );
		g_hDirectInputDLL = NULL;
	}
	return;
}
Пример #11
0
int main(int ac, char **av)
{
    int succp = 1;
	Progname = av[0];
	AlienFxHandle_t fx = {0,};  // relying on the compiler to obviate memset.
	int ai = 1;
	while(av[ai] && ('-' == av[ai][0]) && (1 < strlen(av[ai]))) {
		// a simple "-" is handled later
		if(      ! strcmp("-v", av[ai])) verbose = 1;
		else if( ! strcmp("-d", av[ai])) debug  = 1;
		else if( ! strcmp("-h", av[ai])) { Syntax(stdout); return 0; }
		else { Syntax(stderr); return -1; }
		++ai;
	}
	if(ai >= ac) { Syntax(stderr); return -1; } 
	if(InitDevice(AlienFxTypes, &fx))
	{
        int block = BLOCK_AC_POWER; // int block = BLOCK_LOAD_ON_BOOT;
        SetDelay(fx.usb_handle, MIN_SPEED);
        if(av[ai] && ! strcmp("-", av[ai])) // read from stdin
        {
            char *line = 0;
            while(line = Fgetstr(stdin, "\n")) {
                char **cmdv = 0;
                if(cmdv = Stoss(" \t", line)) {
                    succp = Command( & fx, cmdv);
                    free(cmdv);
                }
                free(line);
            }
            return succp;
        } else {              // r g b hex-region...
            succp = Command( & fx, & av[ai]);
        }
        ReleaseDevice( & fx);
	} else 
		fputs("No recognized AlienFX device found.\n", stderr);

    return succp ? 0 : -1;
}
Пример #12
0
	SPDevice::~SPDevice(void)
	{
		ReleaseDevice();
	}
Пример #13
0
	~Implementation()
	{
		ReleaseDevice();
	}
Пример #14
0
/**
Handle incomming frames from the serial port.
*/
void rxhandler(void) {
    switch (serRxBuf.header.type) {
        case ACK:
        case NACK:
            break;

        case T_CONNECT:                         //connect JTAG to the target
            InitTarget();
            if (GetDevice() == STATUS_OK) {
                txACK();
                //printf("Device type: %04x\n", DEVICE);
            } else{
                txNACKstr("no target");
            }
            break;
        case T_RELEASE:                         //release JTAG from target
            ClrTCLK();
            IR_Shift(IR_CNTRL_SIG_16BIT);
            DR_Shift16(0x3001);         //lch
            IR_Shift(IR_CNTRL_SIG_RELEASE);
            SetTCLK();
            ReleaseTarget();
            txACK();
            break;
        case T_RESET:                           //reset the target and release JTAG
            ReleaseDevice(V_RESET);
            ReleaseTarget();
            txACK();
            break;
        case T_PUC:                             //reset the target through JTAG, keep connection
            ExecutePUC();
            txACK();
            break;

        case T_MEMREAD:                         //ream memory from target
            {                                   //use a new block for local vars
                word size = serRxBuf.data.memread.size;
                word address = serRxBuf.data.memread.address;
                word offset;
    
                txACK();
                HaltCPU();
                if (size > sizeof(serTxBuf.data.memdata.data)) {
                   size = sizeof(serTxBuf.data.memdata.data);
                }
                if (address <= 0xff) {          //peripherals in bytemode
                    for (offset = 0; offset < size; offset++) {
                        serTxBuf.data.memdata.data[offset] = ReadMem(F_BYTE, address+offset);
                    }
                } else {                        //peripherals in wordmode as well as RAM and Flash
                    address = address & 0xfffe; //startaddress has to be even!
                    for (offset = 0; offset < size/2; offset++) {
                        ((word *)serTxBuf.data.memdata.data)[offset] = ReadMem(F_WORD, address+offset*2);
                    }
                    if (size & 1) {
                        //odd size, read last byte separate
                        //odd sizes on word-mode peripherals yield  wrong results
                        //in the last word!!
                        serTxBuf.data.memdata.data[size-1] = ReadMem(F_BYTE, address+size-1);
                    }
                }
                serTxBuf.data.memdata.address = address;
                serTxBuf.header.type = T_MEMDATA;
                serTxBuf.header.size = 2+size;
                sendMessage(&serTxBuf);
            }
            break;
        case T_MEMWRITE:                        //write target memory (Peripherals, RAM, Flash)
            {
                word offset;
                word size = serRxBuf.header.size - 2;
                HaltCPU();
                if ((serRxBuf.data.memwrite.address >= 0x100) &&
                    (serRxBuf.data.memwrite.address <= 0x1ff)) { //peripherals in wordmode
                    for (offset = 0; offset < size; offset+=2) {
                        WriteMem(F_WORD,
                                 serRxBuf.data.memwrite.address+offset,
                                 ((word*)serRxBuf.data.memwrite.data)[offset/2]
                        );
                    }
                } else if (serRxBuf.data.memwrite.address < 0x1000) {  //ram + peripherals, bytemode
                    for (offset = 0; offset < size; offset++) {
                        WriteMem(F_BYTE,
                                 serRxBuf.data.memwrite.address+offset,
                                 serRxBuf.data.memwrite.data[offset]
                        );
                    }
                } else {                        //flash memory, wordmode
                    WriteFLASH(serRxBuf.data.memwrite.address,
                               size/2,
                               (word *)serRxBuf.data.memwrite.data
                    );
                }
                txACK();
            }
            break;
        case T_EXEC:                            //execute target program located at given address
            ReleaseDevice(serRxBuf.data.exec.address);
            txACK();
            break;
        case T_MEMERASE:                        //erase target flash (Segment, Main or All)
            HaltCPU();
            EraseFLASH(
                serRxBuf.data.memerase.mode,
                serRxBuf.data.memerase.address
            );
            txACK();
            break;
        case T_MCLK:                            //provide MCLKs, allows sort of single stepping
            ClrTCLK();
            IR_Shift(IR_CNTRL_SIG_16BIT);
            DR_Shift16(0x3401);         //lch
            while (serRxBuf.data.step.numsteps--) {
                SetTCLK();
                ClrTCLK();
            }
            SetTCLK();
            txACK();
            break;

        case MEMREAD:                           //host memory read
            {
                word size = serRxBuf.data.memread.size;
                byte *address = (byte*)serRxBuf.data.memread.address;
                word offset;
                txACK();
                if (size > sizeof(serTxBuf.data.memdata.data)) {
                   size = sizeof(serTxBuf.data.memdata.data);
                }
                if (address <= (byte *)0xff) {      //bytemode
                    for (offset = 0; offset < size; offset++) {
                        serTxBuf.data.memdata.data[offset] = address[offset];
                    }
                } else {                            //wordmode
                    address = (byte *)((word)address & 0xfffe);    //startaddress has to be even!
                    size &= 0xfffe;                     //size has to be even
                    for (offset = 0; offset < size/2; offset++) {
                        ((word *)serTxBuf.data.memdata.data)[offset] = ((word *)address)[offset];
                    }
                }
                serTxBuf.data.memdata.address = (word)address;
                serTxBuf.header.type = MEMDATA;
                serTxBuf.header.size = 2+size;
                sendMessage(&serTxBuf);
            }
            break;
        case MEMWRITE:                          //host memory write, used to download user programs
            {
                void *adr = (byte *)serRxBuf.data.memwrite.address;
                word offset;
                word size = serRxBuf.header.size - 2;
                if ((adr >= (void *)0x100) && (adr <= (void *)0x1ff)) { //peripherals, wordmode
                    for (offset = 0; offset < size/2; offset++) {
                        ((word *)adr)[offset] = ((word *)serRxBuf.data.memwrite.data)[offset];
                    }
                    txACK();
                    return;
                }
                if (adr < (void *)0x1000) {     //ram + peripherals, bytemode
                    for (offset = 0; offset < size; offset++) {
                        ((byte *)adr)[offset] = serRxBuf.data.memwrite.data[offset];
                    }
                } else {                        //flash
                    flashWriteBlock(
                        serRxBuf.data.memwrite.data,
                        (void *)serRxBuf.data.memwrite.address,
                        size);
                }
                txACK();
            }
            break;
        case MEMERASE:                          //erase one segemnt on host
            flashErase((void *)serRxBuf.data.memerase.address);
            txACK();
            break;
        //~ case MEMEXEC:                       //exec code on host
                //~ serRxBuf.memexec.function(
                    //~ serRxBuf.memexec.arg1,
                    //~ serRxBuf.memexec.arg2
                //~ );
            //~ txACK();
            //~ break;
        case STARTBSL:                          //start BSL for firmware upgrade
            txACK();
            while((UTCTL0 & TXEPT) == 0) {}     //wait until last byte is sent
            FCTL3 = 0;                          //generate a flash key violation -> POR reset, see main()
            break;
        default:
            txNACKstr("unknown command");       //serialComm error: unknown command
    }
}
Пример #15
0
/****************************************************************************
Description:
   Open the device.
   - allocating internal memory for each new device
   - allocating io memory
   - initialize the device
   - set up the interrupt
Arguments:
   inode - pointer to the inode
   filp  - file pointer to be opened
Return Value:
   IFX_SUCCESS or error code
Remarks:
   None.
****************************************************************************/
static int DUSLIC_Open (struct inode *inode, struct file *filp)
{
   DUSLIC_DEVICE *pDev  = NULL;
   DUSLIC_CHANNEL *pCh  = NULL;
  
   IFX_int32_t dev_num = 0;
   IFX_int32_t ret = IFX_SUCCESS;
   IFX_int32_t num = MINOR(inode->i_rdev);
   IFX_char_t nCh  = 0;

   /* get device number */
   dev_num = (num / DUSLIC_MINOR_BASE) - 1;

   if ((dev_num >= DUSLIC_MAX_DEVICES) || (dev_num < 0))
   {
      printk("Warning: Driver only supports %d DUSLIC(s)\n\r",
             DUSLIC_MAX_DEVICES);
      ret = -ENODEV;
      goto OPEN_ERROR;
   }

   /* check if first open on this device */
   if (pDuslic_Devices[dev_num] == NULL)
   {
     /* Now allocate and initialize all data. */
      if (Board_DevOpen (dev_num) == IFX_ERR)
      {
         ret = -ENODEV;
         goto OPEN_ERROR;
      }
   }

   //IFXOS_MutexLock (SemDrvIF);
   pDev = pDuslic_Devices[dev_num];
   /* increase in use count */
   pDev->nInUse++;
   nCh = num % DUSLIC_MINOR_BASE;
  

   if (nCh == 0)
   {
      /* Save the device pointer */
      filp->private_data = pDev;
   }

   else if (nCh > 0 && nCh <= 2)
   {
      /* Save the channel pointer */
      pCh = filp->private_data = &pDev->pChannel [nCh - 1];
      pCh->nChannel = nCh-1;
      /* Check if the device is opened as a non-blocking one */
      if (! (filp->f_flags & O_NONBLOCK))
      {
         /* set the CF_NONBLOCK channel specific flag for reading without
            blocking */
         /* writing to the device is implemented as non-blocking */
         pCh->nFlags |= CF_NONBLOCK;
      }
      pCh->nFlags |= CF_NONBLOCK;
      if (pCh->nInUse == 0)
      {
         ResetChMember (pCh);
      }
      pCh->nInUse++;
   }
   MOD_INC_USE_COUNT;
   //IFXOS_MutexUnlock (SemDrvIF);
   return IFX_SUCCESS;
OPEN_ERROR:
   if (pDev != NULL)
   {
      printk("open error!\n");
      ReleaseDevice(pDev);
      TRACE (DUSLIC,DBG_LEVEL_HIGH, ("Open Error 0x%lX\n", pDev->err));
   }
    return ret;
   
}
Пример #16
0
/**
   Open the device from kernel mode.
\param
   nDev - index of the DUSLIC device
\param
   nCh - index of the DUSLIC channel (1 = channel 0, ...)
\return
   handle to device/channel or ERR on error
\remarks
  If not already done this will
   - allocate internal memory for each new device
   - allocate io memory
   - initialize the device
   - set up the interrupt
*/
INT DUSLIC_OpenKernel(INT nDev, INT nCh)
{
   DUSLIC_DEVICE *pDev = NULL;
   DUSLIC_CHANNEL *pCh = NULL;
   INT ret = ERR;
   /* check the device number for the type 0 */
   if ((nDev >= DUSLIC_MAX_DEVICES) || (nDev < 0))
   {
      TRACE (DUSLIC, DBG_LEVEL_NORMAL,
  	         ("Warning: Driver only supports %d DUSLIC(s)\n\r",
             DUSLIC_MAX_DEVICES));
      ret = -ENODEV;
      goto OPEN_ERROR;
   }
   /* check if first open on this device */
   if (pDuslic_Devices[nDev] == NULL)
   {
      /* Now allocate and initialize all data. This function will call
         OS_InitDevice at first  */
      if (Board_DevOpen(nDev) == ERR)
      {
         ret = -ENODEV;
         goto OPEN_ERROR;
      }
   }
   //Sem_Lock(SemDrvIF);
   pDev = pDuslic_Devices[nDev];
   /* increase in use count */
   pDev->nInUse++;

   if (nCh == 0)
   {
      /* return the device pointer */
      ret = (INT)pDev;
   }
   else
   {
      /* return the channel pointer */
      pCh = &pDev->pChannel [nCh - 1];
      pCh->nChannel = nCh-1;
      if (pCh->nInUse == 0)
      {
         ResetChMember (pCh);
      }
      pCh->nInUse++;
      ret = (INT)pCh;
   }

   /* increment module use counter */
   MOD_INC_USE_COUNT;

   TRACE (VINETIC, DBG_LEVEL_LOW,
         ("Open Kernel VINETIC device Nr. %d, channel %d\n\r", nDev, nCh));

   //Sem_Unlock (SemDrvIF);
   return ret;

OPEN_ERROR:
   if (pDev != NULL)
   {
      ReleaseDevice(pDev);
      TRACE (DUSLIC,DBG_LEVEL_HIGH, ("Open Kernel Error 0x%X\n", pDev->err));
   }
   Board_ResetPlatform();
   return ret;
}
Пример #17
0
// **if passed an existing DirectInputDevice which matches gGuid
//		unacquires it, and sets its cooperative level (reinitialize)
// **if the existing device does not match the passed gGuid, the existing device is released
// **if no device was passed or gGuid did not match
//		searches for the controller matching gGuid in connected and available devices
//		creates a DirectInputDevice
//		sets its data format
//		sets its cooperative level
//		for joysticks, calls EnumSetObjectsAxis for each axis
// GetInputDevice always leaves the returned device in an UNACQUIRED state.
bool GetInputDevice( HWND hWnd, LPDIRECTINPUTDEVICE8 &lpDirectInputDevice, GUID gGuid, DWORD dwDevType, DWORD dwCooperativeLevel )
{
	DebugWriteA("GetInputDevice: gGuid is {%08.8lX-%04.4hX-%04.4hX-%02.2X%02.2X-%02.2X%02.2X%02.2X%02.2X%02.2X%02.2X}\n", gGuid.Data1, gGuid.Data2, gGuid.Data3, gGuid.Data4[0], gGuid.Data4[1], gGuid.Data4[2], gGuid.Data4[3], gGuid.Data4[4], gGuid.Data4[5], gGuid.Data4[6], gGuid.Data4[7]);
	if( lpDirectInputDevice != NULL)
	{
		DIDEVICEINSTANCE didDev;
		didDev.dwSize = sizeof(DIDEVICEINSTANCE);
		lpDirectInputDevice->GetDeviceInfo( &didDev );

		if( didDev.guidInstance == gGuid )
		{	// we've already gotten this device; unacquire it and initialize
			DebugWriteA("GetInputDevice: already created, attempting to reinit\n");
			lpDirectInputDevice->Unacquire();
			lpDirectInputDevice->SetCooperativeLevel( hWnd, dwCooperativeLevel );
			return true;
		}
		else
			ReleaseDevice( lpDirectInputDevice );
	}

	HRESULT hResult;
	
	LPCDIDATAFORMAT ppDiDataFormat = NULL;
	bool Success = false;

	switch( LOBYTE(dwDevType) )
	{
	case DI8DEVTYPE_KEYBOARD:
		ppDiDataFormat = &c_dfDIKeyboard;
		break;

	case DI8DEVTYPE_MOUSE:
		ppDiDataFormat = &c_dfDIMouse2;
		break;

	//case DI8DEVTYPE_GAMEPAD:
	//case DI8DEVTYPE_JOYSTICK:
	//case DI8DEVTYPE_DRIVING:
	//case DI8DEVTYPE_1STPERSON:
	//case DI8DEVTYPE_FLIGHT:
	default: // assume everything else is a gamepad; probably not the best idea but it works
		ppDiDataFormat = &c_dfDIJoystick;
		break;
	}

	bool bDeviceAvailable = false;
		
	VOID* aRef[2] = { &gGuid, &bDeviceAvailable };
		
	// for each available device in our dwDevType category, run EnumIsDeviceAvailable with params "aRef"
	g_pDIHandle->EnumDevices( DI8DEVCLASS_ALL, EnumIsDeviceAvailable, (LPVOID)aRef, DIEDFL_ATTACHEDONLY );
		
	if( !bDeviceAvailable )
	{
		DebugWriteA("GetInputDevice: Device does not appear available\n");
		return false;
	}
		
	hResult = g_pDIHandle->CreateDevice( gGuid, &lpDirectInputDevice, NULL );
	
	if( SUCCEEDED( hResult ))
	{
		hResult = lpDirectInputDevice->SetDataFormat( ppDiDataFormat );
		hResult = lpDirectInputDevice->SetCooperativeLevel( hWnd, dwCooperativeLevel );
		
		Success = SUCCEEDED( hResult );
		if (!Success)
		{
			DebugWriteA("GetInputDevice: SetCooperativeLevel failed\n");
		}
	}
	else
		DebugWriteA("GetInputDevice: CreateDevice failed\n");

	if( Success && ( ppDiDataFormat == &c_dfDIJoystick ))
		lpDirectInputDevice->EnumObjects( EnumSetObjectsAxis, lpDirectInputDevice, DIDFT_AXIS );

	return Success;
}