HRESULT Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::accept___STATIC__I4__OBJECT( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_NETWORK(); TINYCLR_HEADER(); CLR_RT_HeapBlock* socket = stack.Arg0().Dereference(); CLR_INT32 handle; CLR_INT32 ret; CLR_INT32 nonBlocking = 1; FAULT_ON_NULL(socket); handle = socket[ FIELD__m_Handle ].NumericByRef().s4; /* Because we could have been a rescheduled call due to a prior call that would have blocked, we need to see * if our handle has been shutdown before continuing. */ if (handle == DISPOSED_HANDLE) { ThrowError(stack, CLR_E_OBJECT_DISPOSED); TINYCLR_SET_AND_LEAVE (CLR_E_PROCESS_EXCEPTION); } ret = SOCK_accept( handle, NULL, NULL ); if(ret != SOCK_SOCKET_ERROR) { TINYCLR_CHECK_HRESULT(ThrowOnError( stack, SOCK_ioctl( ret, SOCK_FIONBIO, &nonBlocking ) )); } TINYCLR_CHECK_HRESULT(ThrowOnError( stack, ret )); stack.SetResult_I4( ret ); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_native_Microsoft_SPOT_Debug::GC___STATIC__U4__BOOLEAN( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); #if defined(TINYCLR_GC_VERBOSE) if(s_CLR_RT_fTrace_GC >= c_CLR_RT_Trace_Info) { CLR_Debug::Printf( " Memory: Debug.GC.\r\n" ); } #endif stack.SetResult_I4( g_CLR_RT_ExecutionEngine.PerformGarbageCollection() ); if(stack.Arg0().NumericByRefConst().u1) { // // Decrement the number of GC, otherwise the outer loop may request another compaction. // g_CLR_RT_GarbageCollector.m_numberOfGarbageCollections--; g_CLR_RT_ExecutionEngine.PerformHeapCompaction(); } TINYCLR_NOCLEANUP_NOLABEL(); }
// TODO: Make common functions for transformBlock for encrypt/decrypt when async logic is in place HRESULT Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_Decryptor::TransformBlockInternal___I4__SZARRAY_U1__I4__I4__SZARRAY_U1__I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_RT_HeapBlock* pThis = stack.This(); CLR_RT_HeapBlock_Array* pData = stack.Arg1().DereferenceArray(); CLR_INT32 dataOffset = stack.Arg2().NumericByRef().s4; CLR_INT32 dataLen = stack.Arg3().NumericByRef().s4; CLR_RT_HeapBlock_Array* pOutput = stack.Arg4().DereferenceArray(); CLR_INT32 outOffset = stack.Arg5().NumericByRef().s4; CLR_RT_HeapBlock* pSession = pThis[Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_SessionContainer::FIELD__m_session].Dereference(); CK_SESSION_HANDLE hSession; CLR_UINT32 decrSize; FAULT_ON_NULL_ARG(pData); FAULT_ON_NULL_ARG(pOutput); FAULT_ON_NULL_ARG(pSession); hSession = (CK_SESSION_HANDLE)pSession[Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_Session::FIELD__m_handle].NumericByRef().s4; if(hSession == CK_SESSION_HANDLE_INVALID) TINYCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); if((dataOffset + dataLen) > (CLR_INT32)pData->m_numOfElements ) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); if((outOffset ) > (CLR_INT32)pOutput->m_numOfElements) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); decrSize = pOutput->m_numOfElements - outOffset; CRYPTOKI_CHECK_RESULT(stack, C_DecryptUpdate(hSession, pData->GetElement(dataOffset), dataLen, pOutput->GetElement(outOffset), (CK_ULONG_PTR)&decrSize)); stack.SetResult_I4(decrSize); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_hardware_serial_native_System_IO_Ports_SerialPort::BytesInBuffer___I4__BOOLEAN( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_HARDWARE(); TINYCLR_HEADER(); CLR_RT_HeapBlock* pThis; BOOL fInput; CLR_RT_HeapBlock* config; CLR_UINT32 portId; CLR_INT32 numBytes; pThis = stack.This(); FAULT_ON_NULL(pThis); // check if the object was disposed if(pThis[ FIELD__m_fDisposed ].NumericByRef().s1 != 0) { TINYCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } config = pThis[ FIELD__m_config ].Dereference(); FAULT_ON_NULL(config); fInput = (TRUE == stack.Arg1().NumericByRef().u1); portId = config[ Library_spot_hardware_serial_native_System_IO_Ports_SerialPort__Configuration::FIELD__PortIndex ].NumericByRef().u4; numBytes = USART_BytesInBuffer( portId, fInput ); if(numBytes < 0) { TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } stack.SetResult_I4( numBytes ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_Text_UTF8Encoding::GetBytes___I4__STRING__I4__I4__SZARRAY_U1__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); size_t cMaxBytes; LPCSTR str = stack.Arg1().RecoverString(); CLR_INT32 strIdx = stack.Arg2().NumericByRef().s4; CLR_INT32 strCnt = stack.Arg3().NumericByRef().s4; CLR_RT_HeapBlock_Array* pArrayBytes = stack.Arg4().DereferenceArray(); CLR_INT32 byteIdx = stack.Arg5().NumericByRef().s4; FAULT_ON_NULL(str); FAULT_ON_NULL(pArrayBytes); cMaxBytes = hal_strlen_s(str); if((strIdx + strCnt) > (CLR_INT32)cMaxBytes ) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); if((byteIdx + strCnt) > (CLR_INT32)pArrayBytes->m_numOfElements) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); memcpy(pArrayBytes->GetElement(byteIdx), &str[strIdx], strCnt); stack.SetResult_I4(strCnt); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_hardware_usb_native_Microsoft_SPOT_Hardware_UsbClient_UsbStream::nativeWrite___I4__SZARRAY_U1__I4__I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_INT32 retVal = 0; CLR_INT32 controllerIndex, streamIndex, stream; CLR_UINT32 offset, count; CLR_RT_HeapBlock* pThis; CLR_RT_HeapBlock_Array* array; pThis = stack.This(); FAULT_ON_NULL(pThis); controllerIndex = pThis[ Library_spot_hardware_usb_native_Microsoft_SPOT_Hardware_UsbClient_UsbStream::FIELD__m_controllerIndex ].NumericByRef().s4; streamIndex = pThis[ Library_spot_hardware_usb_native_Microsoft_SPOT_Hardware_UsbClient_UsbStream::FIELD__m_streamIndex ].NumericByRef().s4; array = stack.Arg1().DereferenceArray(); FAULT_ON_NULL( array ); offset = stack.Arg2().NumericByRef().u4; count = stack.Arg3().NumericByRef().u4; stream = (controllerIndex << USB_CONTROLLER_SHIFT) + streamIndex; if( array->m_numOfElements < (offset + count) ) { TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } else { retVal = USB_Write( stream, (char*)array->GetFirstElement()+offset, count ); } stack.SetResult_I4( retVal ); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_hardware_usb_native_Microsoft_SPOT_Hardware_UsbClient_UsbStream::nativeOpen___I4__I4__I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_INT32 streamIndex, controllerIndex, writeEndpoint, readEndpoint; CLR_RT_HeapBlock* pThis; pThis = stack.This(); FAULT_ON_NULL(pThis); controllerIndex = pThis[ Library_spot_hardware_usb_native_Microsoft_SPOT_Hardware_UsbClient_UsbStream::FIELD__m_controllerIndex ].NumericByRef().s4; writeEndpoint = stack.Arg1().NumericByRef().s4; readEndpoint = stack.Arg2().NumericByRef().s4; for( streamIndex = 0; streamIndex < USB_MAX_QUEUES; streamIndex++ ) { CLR_INT32 stream = (controllerIndex << USB_CONTROLLER_SHIFT) + streamIndex; if( USB_OpenStream( stream, writeEndpoint, readEndpoint ) ) break; } if( streamIndex >= USB_MAX_QUEUES ) { TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); } stack.SetResult_I4( streamIndex ); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_Time_native_System_Environment::get_TickCount___STATIC__I4 ( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); stack.SetResult_I4( Time_GetTickCount() ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_Object::GetHashCode___I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); stack.SetResult_I4( CLR_RT_HeapBlock::GetHashCode( stack.This(), true, 0 ) ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_spot_net_native_Microsoft_SPOT_Net_NetworkInformation_NetworkInterface::GetNetworkInterfaceCount___STATIC__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_NETWORK(); TINYCLR_HEADER(); stack.SetResult_I4( SOCK_CONFIGURATION_GetAdapterCount() ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_spot_update_native_Microsoft_SPOT_MFUpdate_MFNativeUpdate::Open___STATIC__BOOLEAN__I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_INT32 handle = stack.Arg0().NumericByRef().s4; stack.SetResult_I4(MFUpdate_Open(handle)); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_DateTime::get_Millisecond___I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); SYSTEMTIME st; Expand( stack, st ); stack.SetResult_I4( st.wMilliseconds ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_Random::Next___I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_RT_Random* rand; TINYCLR_CHECK_HRESULT(GetRandom( stack, rand )); stack.SetResult_I4( rand->Next() ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_Double::CompareTo___STATIC__I4__R8__R8( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_INT64 left = stack.Arg0().NumericByRef().s8; CLR_INT64 right = stack.Arg1().NumericByRef().s8; stack.SetResult_I4((left < right) ? -1 : (left > right) ? 1 : 0); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_Threading_WaitHandle::WaitMultiple___STATIC__I4__SZARRAY_SystemThreadingWaitHandle__I4__BOOLEAN__BOOLEAN( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock_Array* arr = stack.Arg0().DereferenceArray(); FAULT_ON_NULL(arr); TINYCLR_CHECK_HRESULT(Wait( stack, stack.Arg1(), stack.Arg2(), (CLR_RT_HeapBlock*)arr->GetFirstElement(), arr->m_numOfElements, stack.Arg3().NumericByRef().s1 == 1 )); stack.SetResult_I4( stack.m_owningThread->m_waitForObject_Result ); TINYCLR_NOCLEANUP(); }
static HRESULT ComputeSinCos( CLR_RT_StackFrame& stack, bool fSin ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); int index = (stack.Arg0().NumericByRef().s4 % 360) / 6; if(index < 0) index += 60; const CLR_RADIAN& rec = c_CLR_radians[ index ]; stack.SetResult_I4( (int)(fSin ? rec.sin : rec.cos) ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_spot_net_security_native_Microsoft_SPOT_Net_Security_SslNative::ExitSecureContext___STATIC__I4__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_NETWORK(); TINYCLR_HEADER(); CLR_INT32 sslContext = stack.Arg0().NumericByRef().s4; int result = SSL_ExitContext( sslContext ) == TRUE ? 0 : -1; stack.SetResult_I4( result ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_spot_hardware_native_Microsoft_SPOT_Hardware_AnalogInput::ReadRaw___I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_HARDWARE(); TINYCLR_HEADER(); CLR_RT_HeapBlock* pThis = stack.This(); const ANALOG_CHANNEL channel = (ANALOG_CHANNEL)pThis[FIELD__m_channel].NumericByRef().s4; const CLR_INT32 raw = ::AD_Read(channel); stack.SetResult_I4(raw); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_DateTime::DaysInMonth___STATIC__I4__I4__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_INT32 year = stack.Arg0().NumericByRef().s4; CLR_INT32 month = stack.Arg1().NumericByRef().s4; CLR_INT32 days = 0; Time_DaysInMonth( year, month, &days ); stack.SetResult_I4( days ); TINYCLR_NOCLEANUP_NOLABEL(); }
HRESULT Library_corlib_native_System_Math::Sign___STATIC__I4__R8( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); double d = stack.Arg0().NumericByRefConst().r8; INT32 res; if (d < 0) res = -1; else if (d > 0) res = +1; else res = 0; stack.SetResult_I4( res ); TINYCLR_NOCLEANUP_NOLABEL();; }
HRESULT Library_corlib_native_System_DateTime::get_DayOfYear___I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); SYSTEMTIME st ; INT32 days; Expand( stack, st ); TINYCLR_CHECK_HRESULT(Time_AccDaysInMonth( st.wYear, st.wMonth, &days )); days += st.wDay; stack.SetResult_I4( days ); TINYCLR_NOCLEANUP(); }
HRESULT Library_windows_devices_native_Windows_Devices_Gpio_GpioPin::Read___WindowsDevicesGpioGpioPinValue( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); BOOL state; CLR_RT_HeapBlock* pThis = stack.This(); FAULT_ON_NULL(pThis); if (pThis[ FIELD__m_disposed ].NumericByRef().s1 != 0) { TINYCLR_SET_AND_LEAVE(CLR_E_OBJECT_DISPOSED); } state = ::CPU_GPIO_GetPinState( pThis[ FIELD__m_pinNumber ].NumericByRefConst().u4 ); stack.SetResult_I4( state ? GpioPinValue_High : GpioPinValue_Low ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_TimeSpan::CompareTo___I4__OBJECT( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock* pLeft = stack.This(); CLR_RT_HeapBlock* pRight = stack.Arg1().Dereference(); if(pRight) { TINYCLR_SET_AND_LEAVE(Compare___STATIC__I4__SystemTimeSpan__SystemTimeSpan( stack )); } stack.SetResult_I4( 1 ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_Random::Next___I4__I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_RT_Random* rand; CLR_INT32 maxValue; TINYCLR_CHECK_HRESULT(GetRandom( stack, rand )); maxValue = stack.Arg1().NumericByRef().s4; if(maxValue < 0) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); stack.SetResult_I4( rand->Next() % maxValue ); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_update_native_Microsoft_SPOT_MFUpdate_MFNativeUpdate::Initialize___STATIC__I4__MicrosoftSPOTMFUpdateMFUpdateBase( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_RT_HeapBlock* pUpdateBase = stack.Arg0().Dereference(); MFUpdateHeader header; LPCSTR szProvider; FAULT_ON_NULL(pUpdateBase); szProvider = pUpdateBase[Library_spot_update_native_Microsoft_SPOT_MFUpdate_MFUpdateBase::FIELD__m_provider].Dereference()->StringText(); MarshalStorageHeader(pUpdateBase, header); stack.SetResult_I4(MFUpdate_InitUpdate(szProvider, header)); TINYCLR_NOCLEANUP(); }
HRESULT Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_FindObjectEnum::get_Count___I4( CLR_RT_StackFrame& stack ) { TINYCLR_HEADER(); CLR_RT_HeapBlock* pThis = stack.This(); CLR_RT_HeapBlock* pSession = pThis[Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_FindObjectEnum::FIELD__m_session].Dereference(); CK_SESSION_HANDLE hSession; CK_ULONG cntObj = 0; FAULT_ON_NULL(pSession); hSession = pSession[Library_security_pkcs11_native_Microsoft_SPOT_Cryptoki_Session::FIELD__m_handle].NumericByRef().u4; CRYPTOKI_CHECK_RESULT(stack, C_FindObjects(hSession, NULL, 0xFFFF, &cntObj )); stack.SetResult_I4((CLR_INT32)cntObj); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_net_security_native_Microsoft_SPOT_Net_Security_SslNative::SecureCloseSocket___STATIC__I4__OBJECT( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_NETWORK(); TINYCLR_HEADER(); int result; CLR_INT32 handle; CLR_RT_HeapBlock* socket = stack.Arg0().Dereference(); FAULT_ON_NULL(socket); handle = socket[ Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::FIELD__m_Handle ].NumericByRef().s4; result = SSL_CloseSocket( handle ); stack.SetResult_I4( result ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_Resources_ResourceManager::FindResource___STATIC__I4__STRING__SystemReflectionAssembly( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_Assembly_Instance assm; CLR_INT32 resourceFileId; CLR_RT_HeapBlock* pArgs = &stack.Arg0(); LPCSTR szText = pArgs[ 0 ].RecoverString(); FAULT_ON_NULL(szText); TINYCLR_CHECK_HRESULT(Library_corlib_native_System_Reflection_Assembly::GetTypeDescriptor( *pArgs[ 1 ].Dereference(), assm )); TINYCLR_CHECK_HRESULT(g_CLR_RT_TypeSystem.LocateResourceFile( assm, szText, resourceFileId )); stack.SetResult_I4( resourceFileId ); TINYCLR_NOCLEANUP(); }
HRESULT Library_corlib_native_System_BitConverter::ToInt32___STATIC__I4__SZARRAY_U1__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_CORE(); TINYCLR_HEADER(); CLR_RT_HeapBlock_Array* pArray = stack.Arg0().DereferenceArray(); FAULT_ON_NULL_ARG(pArray); int index; index = stack.Arg1().NumericByRefConst().s4; if (index < 0 || (unsigned int)index >= pArray->m_numOfElements) TINYCLR_SET_AND_LEAVE(CLR_E_OUT_OF_RANGE); if ((unsigned int)index + 4 > pArray->m_numOfElements) TINYCLR_SET_AND_LEAVE(CLR_E_INVALID_PARAMETER); BYTE* p; p = pArray->GetFirstElement(); stack.SetResult_I4(*reinterpret_cast<int*>(p + index)); TINYCLR_NOCLEANUP(); }
HRESULT Library_spot_net_native_Microsoft_SPOT_Net_SocketNative::socket___STATIC__I4__I4__I4__I4( CLR_RT_StackFrame& stack ) { NATIVE_PROFILE_CLR_NETWORK(); TINYCLR_HEADER(); CLR_INT32 family = stack.Arg0().NumericByRef().s4; CLR_INT32 type = stack.Arg1().NumericByRef().s4; CLR_INT32 protocol = stack.Arg2().NumericByRef().s4; CLR_INT32 nonBlocking = 1; CLR_INT32 sock = SOCK_socket( family, type, protocol ); TINYCLR_CHECK_HRESULT(ThrowOnError( stack, sock )); TINYCLR_CHECK_HRESULT(ThrowOnError( stack, SOCK_ioctl( sock, SOCK_FIONBIO, &nonBlocking ) )); stack.SetResult_I4( sock ); TINYCLR_NOCLEANUP(); }