Skip to content

Commit 69513f9

Browse files
author
Frank Robijn
committed
Merge
2 parents 894c168 + 65eb7b2 commit 69513f9

File tree

1 file changed

+0
-225
lines changed

1 file changed

+0
-225
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,225 +0,0 @@
1-
//
2-
// Copyright (c) .NET Foundation and Contributors
3-
// See LICENSE file in the project root for full license information.
4-
//
5-
6-
#include "stdafx.h"
7-
8-
#include "nanoCLR_native.h"
9-
#include <nanoCLR_Application.h>
10-
#include <target_common.h>
11-
#include <iostream>
12-
#include <format>
13-
14-
//
15-
// UNDONE: Feature configuration
16-
//
17-
18-
#define NF_CLR_FEATURE_ALL
19-
20-
#if defined(NF_CLR_FEATURE_ALL)
21-
22-
#pragma comment(lib, "WireProtocol.lib")
23-
24-
#pragma comment(lib, "Debugger.lib")
25-
#pragma comment(lib, "Diagnostics.lib")
26-
#pragma comment(lib, "Hardware.lib")
27-
#pragma comment(lib, "InterruptHandler.lib")
28-
#pragma comment(lib, "Messaging.lib")
29-
#pragma comment(lib, "RPC.lib")
30-
#pragma comment(lib, "Serialization.lib")
31-
32-
#else
33-
34-
#pragma comment(lib, "WireProtocol.lib")
35-
36-
#pragma comment(lib, "Debugger_stub.lib")
37-
#pragma comment(lib, "Diagnostics_stub.lib")
38-
#pragma comment(lib, "Hardware_stub.lib")
39-
#pragma comment(lib, "InterruptHandler_stub.lib")
40-
#pragma comment(lib, "IOPort_stub.lib")
41-
#pragma comment(lib, "Messaging_stub.lib")
42-
#pragma comment(lib, "RPC_stub.lib")
43-
#pragma comment(lib, "Serialization_stub.lib")
44-
45-
#endif
46-
47-
DebugPrintCallback gDebugPrintCallback = NULL;
48-
49-
WireTransmitCallback WireProtocolTransmitCallback = NULL;
50-
WireReceiveCallback WireProtocolReceiveCallback = NULL;
51-
52-
// flag requesting stopping of WP processing
53-
bool _wireProtocolStopProcess;
54-
55-
/////////////////////////////////////////////////////////////////////////////
56-
57-
// All solutions are expected to provide an implementation of this
58-
bool Target_GetReleaseInfo(NFReleaseInfo &releaseInfo)
59-
{
60-
NFReleaseInfo::Init(
61-
releaseInfo,
62-
VERSION_MAJOR,
63-
VERSION_MINOR,
64-
VERSION_BUILD,
65-
VERSION_REVISION,
66-
OEMSYSTEMINFOSTRING,
67-
hal_strlen_s(OEMSYSTEMINFOSTRING),
68-
TARGETNAMESTRING,
69-
hal_strlen_s(TARGETNAMESTRING),
70-
PLATFORMNAMESTRING,
71-
hal_strlen_s(PLATFORMNAMESTRING));
72-
73-
return true; // alternatively, return false if you didn't initialize the releaseInfo structure.
74-
}
75-
76-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
77-
// The following functions are exposed in the DLL and
78-
// meant to be called by the C# host application.
79-
// Keep their names in sync with the managed code declaration @ nanoFramework.nanoCLR.Host\Interop\Native.cs
80-
// and the declarations @ nanoCLR_native.h
81-
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
82-
83-
void nanoCLR_Run(NANO_CLR_SETTINGS nanoClrSettings)
84-
{
85-
86-
#if _DEBUG
87-
// only show this in debug build
88-
DWORD pid = GetCurrentProcessId();
89-
CLR_Debug::Printf("Process ID: %d\r\n", pid);
90-
#endif
91-
92-
CLR_Debug::Printf(
93-
"\r\nLoading nanoCLR v%d.%d.%d.%d\r\n...",
94-
VERSION_MAJOR,
95-
VERSION_MINOR,
96-
VERSION_BUILD,
97-
VERSION_REVISION);
98-
99-
// initialize nanoHAL
100-
nanoHAL_Initialize();
101-
102-
// take care of block storage here as we are RAM based
103-
BlockStorageList_Initialize();
104-
BlockStorage_AddDevices();
105-
BlockStorageList_InitializeDevices();
106-
107-
CLR_SETTINGS clrSettings;
108-
ZeroMemory(&clrSettings, sizeof(CLR_SETTINGS));
109-
110-
clrSettings.MaxContextSwitches = nanoClrSettings.MaxContextSwitches;
111-
clrSettings.WaitForDebugger = nanoClrSettings.WaitForDebugger;
112-
clrSettings.EnterDebuggerLoopAfterExit = nanoClrSettings.EnterDebuggerLoopAfterExit;
113-
clrSettings.PerformGarbageCollection = nanoClrSettings.PerformGarbageCollection;
114-
clrSettings.PerformHeapCompaction = nanoClrSettings.PerformHeapCompaction;
115-
116-
ClrStartup(clrSettings);
117-
118-
#if !defined(BUILD_RTM)
119-
CLR_Debug::Printf("Exiting.\r\n");
120-
#endif
121-
}
122-
123-
void nanoCLR_SetDebugPrintCallback(DebugPrintCallback debugPrintCallback)
124-
{
125-
gDebugPrintCallback = debugPrintCallback;
126-
}
127-
128-
void nanoCLR_SetWireProtocolReceiveCallback(WireReceiveCallback receiveCallback)
129-
{
130-
WireProtocolReceiveCallback = receiveCallback;
131-
}
132-
133-
void nanoCLR_SetWireProtocolTransmitCallback(WireTransmitCallback transmitCallback)
134-
{
135-
WireProtocolTransmitCallback = transmitCallback;
136-
}
137-
138-
void nanoCLR_WireProtocolProcess()
139-
{
140-
while (!_wireProtocolStopProcess)
141-
{
142-
WP_Message_Process();
143-
}
144-
}
145-
146-
void nanoCLR_WireProtocolOpen()
147-
{
148-
WP_Message_PrepareReception();
149-
150-
_wireProtocolStopProcess = false;
151-
}
152-
153-
void nanoCLR_WireProtocolClose()
154-
{
155-
// request to stop
156-
_wireProtocolStopProcess = true;
157-
}
158-
159-
const char *nanoCLR_GetVersion()
160-
{
161-
char buffer[128];
162-
163-
char *pszVersion = nullptr;
164-
pszVersion = (char *)CoTaskMemAlloc(std::size(buffer));
165-
166-
if (pszVersion != nullptr)
167-
{
168-
const auto result = std::format_to_n(
169-
buffer,
170-
std::size(buffer) - 1,
171-
"{}.{}.{}.{}",
172-
VERSION_MAJOR,
173-
VERSION_MINOR,
174-
VERSION_BUILD,
175-
VERSION_REVISION);
176-
*result.out = '\0';
177-
178-
const std::string_view str{buffer, result.out};
179-
180-
std::memcpy(pszVersion, buffer, result.size);
181-
}
182-
183-
return pszVersion;
184-
}
185-
186-
uint16_t nanoCLR_GetNativeAssemblyCount()
187-
{
188-
return g_CLR_InteropAssembliesCount;
189-
}
190-
191-
bool nanoCLR_GetNativeAssemblyInformation(const CLR_UINT8 *data, size_t size)
192-
{
193-
const size_t requiredSize = g_CLR_InteropAssembliesCount * (sizeof(uint32_t) + 4 * sizeof(CLR_UINT16) + 128);
194-
if (size < requiredSize)
195-
{
196-
return false; // Buffer too small
197-
}
198-
199-
// clear buffer memory
200-
memset((void *)data, 0, size);
201-
202-
// fill the array
203-
for (uint32_t i = 0; i < g_CLR_InteropAssembliesCount; i++)
204-
{
205-
memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_checkSum, sizeof(uint32_t));
206-
data += sizeof(uint32_t);
207-
208-
memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iMajorVersion, sizeof(CLR_UINT16));
209-
data += sizeof(CLR_UINT16);
210-
211-
memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iMinorVersion, sizeof(CLR_UINT16));
212-
data += sizeof(CLR_UINT16);
213-
214-
memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iBuildNumber, sizeof(CLR_UINT16));
215-
data += sizeof(CLR_UINT16);
216-
217-
memcpy((void *)data, &g_CLR_InteropAssembliesNativeData[i]->m_Version.iRevisionNumber, sizeof(CLR_UINT16));
218-
data += sizeof(CLR_UINT16);
219-
220-
hal_strcpy_s((char *)data, 128, g_CLR_InteropAssembliesNativeData[i]->m_szAssemblyName);
221-
data += 128;
222-
}
223-
224-
return true; // Success
225-
}

0 commit comments

Comments
 (0)