Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
47d106f
Merge pull request #1 from dotnet/main
shushanhf Apr 27, 2021
411b59e
Merge branch 'dotnet:main' into master
shushanhf Oct 25, 2021
7eed4eb
Merge branch 'dotnet:main' into master
shushanhf Dec 6, 2021
0d7c9e4
Merge branch 'dotnet:main' into master
shushanhf Dec 10, 2021
2c534c5
Merge branch 'dotnet:main' into master
shushanhf Dec 14, 2021
6e14d76
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
359875d
Merge branch 'dotnet:main' into master
shushanhf Dec 15, 2021
192b095
Merge branch 'dotnet:main' into main
shushanhf Dec 16, 2021
6117d07
[LoongArch64] add the coreclr/pal and libunwind directory. (#59561)
shushanhf Dec 16, 2021
4b1395d
[LoongArch64] delete the libunwind for LoongArch64.
Dec 18, 2021
f70f07a
[LoongArch64] add config files from #62889.
Dec 18, 2021
63cc4dd
[LoongArch64] revert some files when moved from #62889.
Dec 18, 2021
dbf71fc
[LoongArch64] compiling is sucessfully.
shushanhf Dec 21, 2021
c46968c
[LoongArch64] delete the define IMAGE_FILE_MACHINE_LOONGARCH64 for #6…
shushanhf Dec 21, 2021
d43f51b
[LoongArch64] exclude some files from pal directory.
Dec 22, 2021
80c2143
Merge branch 'main' into main_loongarch64_4
shushanhf Jan 13, 2022
80b233a
[LoongArch64] rename the `UNW_LOONGARCH_*` with `UNW_LOONGARCH64_*`
shushanhf Jan 13, 2022
422145b
[LoongArch64] update the version of the `LICENSE description`.
Jan 19, 2022
5647e5c
[LoongArch64] revert the `pal/inc/rt/ntimage.h`.
Feb 15, 2022
f6d3a93
[LoongArch64] delete unused assert and update the `DAC_CS_NATIVE_DATA…
shushanhf Feb 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/coreclr/inc/crosscomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ enum
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_LINUX) && defined(TARGET_S390X)
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_LINUX) && defined(TARGET_LOONGARCH64)
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_NETBSD) && defined(TARGET_AMD64)
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_NETBSD) && defined(TARGET_ARM)
Expand Down
155 changes: 155 additions & 0 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ typedef PVOID NATIVE_LIBRARY_HANDLE;
#define _M_ARM 7
#elif defined(__aarch64__) && !defined(_M_ARM64)
#define _M_ARM64 1
#elif defined(__loongarch64) && !defined(_M_LOONGARCH64)
#define _M_LOONGARCH64 1
#elif defined(__s390x__) && !defined(_M_S390X)
#define _M_S390X 1
#endif
Expand All @@ -106,6 +108,8 @@ typedef PVOID NATIVE_LIBRARY_HANDLE;
#define HOST_ARM
#elif defined(_M_ARM64) && !defined(HOST_ARM64)
#define HOST_ARM64
#elif defined(_M_LOONGARCH64) && !defined(HOST_LOONGARCH64)
#define HOST_LOONGARCH64
#elif defined(_M_S390X) && !defined(HOST_S390X)
#define HOST_S390X
#endif
Expand Down Expand Up @@ -2202,6 +2206,150 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {

} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;

#elif defined(HOST_LOONGARCH64)

//Please refence "src/pal/src/arch/loongarch64/asmconstants.h"
#define CONTEXT_LOONGARCH64 0x00800000

#define CONTEXT_CONTROL (CONTEXT_LOONGARCH64 | 0x1)
#define CONTEXT_INTEGER (CONTEXT_LOONGARCH64 | 0x2)
#define CONTEXT_FLOATING_POINT (CONTEXT_LOONGARCH64 | 0x4)
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_LOONGARCH64 | 0x8)

#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT)

#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS)

#define CONTEXT_EXCEPTION_ACTIVE 0x8000000
#define CONTEXT_SERVICE_ACTIVE 0x10000000
#define CONTEXT_EXCEPTION_REQUEST 0x40000000
#define CONTEXT_EXCEPTION_REPORTING 0x80000000

//
// This flag is set by the unwinder if it has unwound to a call
// site, and cleared whenever it unwinds through a trap frame.
// It is used by language-specific exception handlers to help
// differentiate exception scopes during dispatching.
//

#define CONTEXT_UNWOUND_TO_CALL 0x20000000

// begin_ntoshvp

//
// Specify the number of breakpoints and watchpoints that the OS
// will track. Architecturally, LOONGARCH64 supports up to 16. In practice,
// however, almost no one implements more than 4 of each.
//

#define LOONGARCH64_MAX_BREAKPOINTS 8
#define LOONGARCH64_MAX_WATCHPOINTS 2

//
// Context Frame
//
// This frame has a several purposes: 1) it is used as an argument to
// NtContinue, 2) it is used to constuct a call frame for APC delivery,
// and 3) it is used in the user level thread creation routines.
//
//
// The flags field within this record controls the contents of a CONTEXT
// record.
//
// If the context record is used as an input parameter, then for each
// portion of the context record controlled by a flag whose value is
// set, it is assumed that that portion of the context record contains
// valid context. If the context record is being used to modify a threads
// context, then only that portion of the threads context is modified.
//
// If the context record is used as an output parameter to capture the
// context of a thread, then only those portions of the thread's context
// corresponding to set flags will be returned.
//

typedef struct DECLSPEC_ALIGN(16) _CONTEXT {

//
// Control flags.
//

/* +0x000 */ DWORD ContextFlags;

//
// Integer registers, abi=N64.
//
DWORD64 R0;
DWORD64 Ra;
DWORD64 Tp;
DWORD64 Sp;
DWORD64 A0;//DWORD64 V0;
DWORD64 A1;//DWORD64 V1;
DWORD64 A2;
DWORD64 A3;
DWORD64 A4;
DWORD64 A5;
DWORD64 A6;
DWORD64 A7;
DWORD64 T0;
DWORD64 T1;
DWORD64 T2;
DWORD64 T3;
DWORD64 T4;
DWORD64 T5;
DWORD64 T6;
DWORD64 T7;
DWORD64 T8;
DWORD64 X0;
DWORD64 Fp;
DWORD64 S0;
DWORD64 S1;
DWORD64 S2;
DWORD64 S3;
DWORD64 S4;
DWORD64 S5;
DWORD64 S6;
DWORD64 S7;
DWORD64 S8;
DWORD64 Pc;

//
// Floating Point Registers
//
//TODO: support the SIMD.
DWORD64 F[32];
DWORD Fcsr;
} CONTEXT, *PCONTEXT, *LPCONTEXT;

//
// Nonvolatile context pointer record.
//

typedef struct _KNONVOLATILE_CONTEXT_POINTERS {

PDWORD64 S0;
PDWORD64 S1;
PDWORD64 S2;
PDWORD64 S3;
PDWORD64 S4;
PDWORD64 S5;
PDWORD64 S6;
PDWORD64 S7;
PDWORD64 S8;
PDWORD64 Fp;
PDWORD64 Tp;
PDWORD64 Ra;

PDWORD64 F24;
PDWORD64 F25;
PDWORD64 F26;
PDWORD64 F27;
PDWORD64 F28;
PDWORD64 F29;
PDWORD64 F30;
PDWORD64 F31;
} KNONVOLATILE_CONTEXT_POINTERS, *PKNONVOLATILE_CONTEXT_POINTERS;


#elif defined(HOST_S390X)

// There is no context for s390x defined in winnt.h,
Expand Down Expand Up @@ -2453,6 +2601,8 @@ PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_
#define PAL_CS_NATIVE_DATA_SIZE 56
#elif defined(__sun) && defined(__x86_64__)
#define PAL_CS_NATIVE_DATA_SIZE 48
#elif defined(__linux__) && defined(__loongarch64)
#define PAL_CS_NATIVE_DATA_SIZE 96
#else
#warning
#error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
Expand Down Expand Up @@ -3255,6 +3405,9 @@ FORCEINLINE void PAL_ArmInterlockedOperationBarrier()
// prevent that reordering. Code generated for arm32 includes a 'dmb' after 'cbnz', so no issue there at the moment.
__sync_synchronize();
#endif // HOST_ARM64
#ifdef HOST_LOONGARCH64
__sync_synchronize();
#endif
}

/*++
Expand Down Expand Up @@ -3653,6 +3806,8 @@ YieldProcessor()
"nop");
#elif defined(HOST_ARM) || defined(HOST_ARM64)
__asm__ __volatile__( "yield");
#elif defined(HOST_LOONGARCH64)
__asm__ volatile( "dbar 0; \n");
#else
return;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/inc/rt/intsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define LODWORD(_qw) ((ULONG)(_qw))

#if defined(MIDL_PASS) || defined(RC_INVOKED) || defined(_M_CEE_PURE) \
|| defined(_M_AMD64) || defined(__ARM_ARCH) || defined(_M_S390X)
|| defined(_M_AMD64) || defined(__ARM_ARCH) || defined(_M_S390X) || defined(_M_LOONGARCH64)

#ifndef UInt32x32To64
#define UInt32x32To64(a, b) ((unsigned __int64)((ULONG)(a)) * (unsigned __int64)((ULONG)(b)))
Expand Down
19 changes: 19 additions & 0 deletions src/coreclr/pal/inc/rt/palrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ typedef VOID (NTAPI *WAITORTIMERCALLBACK)(PVOID, BOOLEAN);
#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10
#define PROCESSOR_ARCHITECTURE_NEUTRAL 11
#define PROCESSOR_ARCHITECTURE_ARM64 12
#define PROCESSOR_ARCHITECTURE_LOONGARCH64 13

#define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF

Expand Down Expand Up @@ -1215,6 +1216,24 @@ typedef struct _DISPATCHER_CONTEXT {
BOOLEAN ControlPcIsUnwound;
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;

#elif defined(HOST_LOONGARCH64)

typedef struct _DISPATCHER_CONTEXT {
ULONG64 ControlPc;
ULONG64 ImageBase;
PRUNTIME_FUNCTION FunctionEntry;
ULONG64 EstablisherFrame;
ULONG64 TargetPc;
PCONTEXT ContextRecord;
PEXCEPTION_ROUTINE LanguageHandler;
PVOID HandlerData;
PVOID HistoryTable;
ULONG64 ScopeIndex;
BOOLEAN ControlPcIsUnwound;
PBYTE NonVolatileRegisters;
ULONG64 Reserved;
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;

#elif defined(HOST_S390X)

typedef struct _DISPATCHER_CONTEXT {
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/pal/inc/unixasmmacros.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@
#include "unixasmmacrosarm64.inc"
#elif defined(HOST_S390X)
#include "unixasmmacross390x.inc"
#elif defined(HOST_LOONGARCH64)
#include "unixasmmacrosloongarch64.inc"
#endif
Loading