/* System Control Register */
I32S Tcc353xSetRegSysEnable(Tcc353xHandle_t * _handle, I08U _value)
{
	I32S ret;
	ret = WriteProcess(_handle, TC3XREG_SYS_EN, &_value, 1, _LOCK_);
	_handle->sysEnValue = _value;
	return ret;
}
I32S Tcc353xSetRegRemapPc(Tcc353xHandle_t * _handle, I08U * _data,
			  I32S _size)
{
	/* TC3XREG_INIT_REMAP/TC3XREG_INIT_PC8/TC3XREG_INIT_PC0 */
	return (WriteProcess
		(_handle, TC3XREG_INIT_REMAP, _data, _size, _LOCK_));
}
I32S Tcc353xSetRegMailboxFifoWindow(Tcc353xHandle_t * _handle,
				    I08U * _data, I32S _size)
{
	return (WriteProcess
		(_handle, TC3XREG_MAIL_FIFO_WIND | Bit7, _data, _size,
		 _LOCK_));
}
Exemple #4
0
bool CMemoryPatcher::WriteProcessByte (DWORD pid, void * addr, BYTE value)
{
    BYTE buf[1];

    buf[0] = value;
    return (WriteProcess (pid, addr, buf, 1) == 1 ? true : false);
}
I32S Tcc353xSetRegSysReset(Tcc353xHandle_t * _handle, I08U _value, 
			   I08U _unlock)
{
	I32S ret;
	ret = WriteProcess(_handle, TC3XREG_SYS_RESET, &_value, 1, _LOCK_);
	return ret;
}
Exemple #6
0
    u64 enoFile::writeBytes(const void *bytes, u64 count)
    {
        u64 writeCount = 0;
        const c8* buf = static_cast<const c8*>(bytes);
        
        while (count != 0) {
            u64 writespace = write_end-write_offset;
            if (writespace == 0) {
                if (WriteProcess() != WRITE_BUFFER_SIZE) {
                    writeCount = 0;
                    break;
                }
            }

            if (writespace > count) {
                writespace = count;
            }
            
            memcpy(write_offset, buf+writeCount, writespace);
            write_offset += writespace;
            
            count -= writespace;
            writeCount += writespace;
        }
        
        if (autoflush) {
            flush();
        }

        return writeCount;
    }
I32S Tcc353xSetRegDataWindow(Tcc353xHandle_t * _handle, I08U * _data,
			     I32S _size, I08U _unlock)
{
	return (WriteProcess
		(_handle, TC3XREG_CMDDMA_DATA_WIND | Bit7, _data, _size,
		 _unlock));
}
I32S Tcc353xGetRegOpDebug(Tcc353xHandle_t * _handle, I08U * _data,
			  I08U _unlock)
{
	I08U tmp = 0x5e;
	WriteProcess(_handle, TC3XREG_OP_DEBUG0, &tmp, 1, _unlock);
	return (ReadProcess
		(_handle, TC3XREG_OP_DEBUG0, 3, _data, _unlock));
}
I32S Tcc353xGetRegOPStatus(Tcc353xHandle_t * _handle, I08U * _data, 
			   I32U _dataSize, I08U _unlock)
{
	I08U tmp = 1;
	WriteProcess (_handle, TC3XREG_OP_STATUS0, &tmp, 1, _unlock);
	return (ReadProcess
		(_handle, TC3XREG_OP_STATUS1| Bit7, _dataSize, _data, _unlock));
}
I32S Tcc353xGetRegMailboxFifoReadStatus(Tcc353xHandle_t * _handle,
					I08U * _data)
{
	I08U latchData = 0x5E;
	WriteProcess(_handle, TC3XREG_MAIL_FIFO_R, &latchData, 1, _LOCK_);
	return (ReadProcess
		(_handle, TC3XREG_MAIL_FIFO_R, 1, _data, _LOCK_));
}
I32S Tcc353xGetRegFifoAStatus(Tcc353xHandle_t * _handle, I08U * _data)
{
	I08U tmp = 0x10;
	WriteProcess (_handle, TC3XREG_OBUFF_INIT, &tmp, 1, _LOCK_);
	ReadProcess
		(_handle, TC3XREG_OBUFF_A_FIFO_STAT0, 1, &_data[0], _LOCK_);
	return (ReadProcess
		(_handle, TC3XREG_OBUFF_A_FIFO_STAT1, 1, &_data[1], _LOCK_));
}
I32S Tcc353xSetRegManual(Tcc353xHandle_t * _handle, I08U _addr,
			 I08U * _data, I32S _size)
{
	if (_addr == TC3XREG_SYS_EN) {
		TcpalPrintErr((I08S *)
			      "[TCC353X] Can't control System Register!!\n");
		return TCC353X_RETURN_FAIL;
	}
	return (WriteProcess(_handle, _addr, _data, _size, _LOCK_));
}
Exemple #13
0
 bool enoFile::flush()
 {
     if (mode & WRITE) {
         WriteProcess();
         if(fflush(file) != EOF) {
             return true;
         }
     }
     
     return false;
 }
I32S Tcc353xGetRegManual(Tcc353xHandle_t * _handle, I08U _addr, I32S _size,
			 I08U * _data)
{
	if (_addr == TC3XREG_STREAM_CFG2 || _addr == TC3XREG_STREAM_CFG1) {
		I08U latch = 0x20;
		if (_handle->options.useInterrupt)
			latch = 0x21;
		else
			latch = 0x20;
		WriteProcess(_handle, TC3XREG_STREAM_CFG3, &latch, 1,
			     _LOCK_);
	}
	return (ReadProcess(_handle, _addr, _size, _data, _LOCK_));
}
Exemple #15
0
    bool enoFile::writeByte(u8 byte)
    {
        if (write_offset == write_end) {
            if(WriteProcess() == 0) {
                return false;
            }
        }
        
        memcpy(write_offset++, &byte, 1);

        if (autoflush) {
            flush();
        }

        return true;
    }
Exemple #16
0
    s64 enoFile::seekcur(s64 offset)
    {
        WriteProcess();
                        
        fseek(file, offset, SEEK_CUR);
        s64 ret = tell();
        
        if ((read_buffer-read_offset) <= offset &&
            (read_end-read_offset) > offset) {
            read_offset += offset;
        } else {
            read_offset = read_end;
        }

        return ret;
    }
Exemple #17
0
 bool enoFile::close()
 {
     if (is_open()) {
         if (mode & WRITE) {
             WriteProcess();
         }
         
         if (fclose(file) == EOF) {
             file = nullptr;
             return false;
         }
     }
     
     file = nullptr;
     return true;
 }
Exemple #18
0
bool CMemoryPatcher::ReplaceByte (DWORD pid, void * addr, BYTE origvalue, BYTE newvalue)
{
    BYTE buf[1];

    if ( ReadProcess (pid, addr, buf, 1) != 1 )
        return false;

    if ( buf[0] != origvalue )
    {
        Error ("ReplaceByte: wrong original byte: %02X (%02X expected)", buf[0], origvalue);
        return false;
    }

    buf[0] = newvalue;
    return (WriteProcess (pid, addr, buf, 1) == 1 ? true : false);
}
int main()
{
	int fd[2];
	pid_t pid;

	if (pipe(fd)  < 0)		// check pipe
	{
		fprintf(stderr, "Create Pipe Error %s\n", strerror(errno));	
		exit(EXIT_FAILURE);
	}
	
	if( (pid = fork()) < 0)	// check fork 
	{
		fprintf(stderr, " Fork Error : %s \n",strerror(errno) );
		exit(EXIT_FAILURE);
	}
				
	if(pid == 0)		//child interprocess 1  ==> Write
	{
		WriteProcess(fd);
	}
	else			//father interprocess 
	{
				//create a new child interprocess: read 50
		if((pid = fork()) < 0) 
		{
			fprintf(stderr, " Fork Error : %s \n",strerror(errno) );
			exit(EXIT_FAILURE);
		}
		if(pid == 0)	// child interprocess 2 => Read
		{
			ReadProcess(fd);
		}
		else		//father interprocess
		{
			wait(0);
			wait(0);
			printf("-------------End of Program-----------\n");
			return 0;
		}

	}

}
I32S Tcc353xSetRegPll7(Tcc353xHandle_t * _handle, I08U _value, I08U _unlock)
{
	return (WriteProcess(_handle, TC3XREG_PLL_7, &_value, 1, _unlock));
}
I32S Tcc353xSetRegOutBufferEndAddressD(Tcc353xHandle_t * _handle,
				       I08U * _data)
{
	return (WriteProcess
		(_handle, TC3XREG_OBUFF_D_EADDR0, _data, 2, _LOCK_));
}
I32S Tcc353xSetRegIrqEnable(Tcc353xHandle_t * _handle, I08U _value)
{
	return (WriteProcess(_handle, TC3XREG_IRQ_EN, &_value, 1, _LOCK_));
}
I32S Tcc353xSetRegIrqErrorClear(Tcc353xHandle_t * _handle, I08U _value)
{
	return (WriteProcess(_handle, TC3XREG_IRQ_ERROR, &_value, 1, _LOCK_));
}
I32S Tcc353xSetRegOutBufferStartAddressC(Tcc353xHandle_t * _handle,
					 I08U * _data)
{
	return (WriteProcess
		(_handle, TC3XREG_OBUFF_C_SADDR0, _data, 2, _LOCK_));
}
I32S Tcc353xSetRegOutBufferInit(Tcc353xHandle_t * _handle, I08U _value)
{
	return (WriteProcess
		(_handle, TC3XREG_OBUFF_INIT, &_value, 1, _LOCK_));
}
I32S Tcc353xSetRegMiscData(Tcc353xHandle_t * _handle, I08U * _data,
			   I08U _unlock)
{
	return (WriteProcess
		(_handle, TC3XREG_MISC_CFG3, _data, 4, _unlock));
}
I32S Tcc353xSetRegMiscAddress(Tcc353xHandle_t * _handle, I08U _value,
			      I08U _unlock)
{
	return (WriteProcess
		(_handle, TC3XREG_MISC_CFG2, &_value, 1, _unlock));
}
I32S Tcc353xSetRegOutBufferDFifoThr(Tcc353xHandle_t * _handle,
				    I08U * _data)
{
	return (WriteProcess
		(_handle, TC3XREG_OBUFF_D_FIFO_THR0, _data, 2, _LOCK_));
}
I32S Tcc353xSetRegLdoConfig(Tcc353xHandle_t * _handle, I08U _value)
{
	return (WriteProcess
		(_handle, TC3XREG_OP_LDO_CONFIG, &_value, 1, _LOCK_));
}
I32S Tcc353xSetRegXtalBiasKey(Tcc353xHandle_t * _handle, I08U _value)
{
	return (WriteProcess
		(_handle, TC3XREG_OP_XTAL_BIAS_KEY, &_value, 1, _LOCK_));
}