@@ -1494,6 +1494,25 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
14941494
14951495} KNONVOLATILE_CONTEXT_POINTERS , *PKNONVOLATILE_CONTEXT_POINTERS ;
14961496
1497+
1498+ //
1499+ // Context Frame
1500+ //
1501+ //
1502+ // The flags field within this record controls the contents of a CONTEXT
1503+ // record.
1504+ //
1505+ // If the context record is used as an input parameter, then for each
1506+ // portion of the context record controlled by a flag whose value is
1507+ // set, it is assumed that such portion of the context record contains
1508+ // valid context. If the context record is being used to modify a threads
1509+ // context, then only that portion of the threads context is modified.
1510+ //
1511+ // If the context record is used as an output parameter to capture the
1512+ // context of a thread, then only those portions of the thread's context
1513+ // corresponding to set flags will be returned.
1514+ //
1515+
14971516#elif defined(HOST_AMD64)
14981517// copied from winnt.h
14991518
@@ -1540,39 +1559,6 @@ typedef struct _XMM_SAVE_AREA32 {
15401559 BYTE Reserved4[96 ];
15411560} XMM_SAVE_AREA32 , *PXMM_SAVE_AREA32 ;
15421561
1543- //
1544- // Context Frame
1545- //
1546- // This frame has a several purposes: 1) it is used as an argument to
1547- // NtContinue, 2) it is used to construct a call frame for APC delivery,
1548- // and 3) it is used in the user level thread creation routines.
1549- //
1550- //
1551- // The flags field within this record controls the contents of a CONTEXT
1552- // record.
1553- //
1554- // If the context record is used as an input parameter, then for each
1555- // portion of the context record controlled by a flag whose value is
1556- // set, it is assumed that such portion of the context record contains
1557- // valid context. If the context record is being used to modify a threads
1558- // context, then only that portion of the threads context is modified.
1559- //
1560- // If the context record is used as an output parameter to capture the
1561- // context of a thread, then only those portions of the thread's context
1562- // corresponding to set flags will be returned.
1563- //
1564- // CONTEXT_CONTROL specifies SegSs, Rsp, SegCs, Rip, and EFlags.
1565- //
1566- // CONTEXT_INTEGER specifies Rax, Rcx, Rdx, Rbx, Rbp, Rsi, Rdi, and R8-R15.
1567- //
1568- // CONTEXT_SEGMENTS specifies SegDs, SegEs, SegFs, and SegGs.
1569- //
1570- // CONTEXT_DEBUG_REGISTERS specifies Dr0-Dr3 and Dr6-Dr7.
1571- //
1572- // CONTEXT_MMX_REGISTERS specifies the floating point and extended registers
1573- // Mm0/St0-Mm7/St7 and Xmm0-Xmm15).
1574- //
1575-
15761562typedef struct DECLSPEC_ALIGN (16 ) _CONTEXT {
15771563
15781564 //
@@ -1786,37 +1772,6 @@ typedef struct _NEON128 {
17861772 LONGLONG High;
17871773} NEON128 , *PNEON128 ;
17881774
1789- //
1790- // Context Frame
1791- //
1792- // This frame has a several purposes: 1) it is used as an argument to
1793- // NtContinue, 2) it is used to construct a call frame for APC delivery,
1794- // and 3) it is used in the user level thread creation routines.
1795- //
1796- //
1797- // The flags field within this record controls the contents of a CONTEXT
1798- // record.
1799- //
1800- // If the context record is used as an input parameter, then for each
1801- // portion of the context record controlled by a flag whose value is
1802- // set, it is assumed that such portion of the context record contains
1803- // valid context. If the context record is being used to modify a threads
1804- // context, then only that portion of the threads context is modified.
1805- //
1806- // If the context record is used as an output parameter to capture the
1807- // context of a thread, then only those portions of the thread's context
1808- // corresponding to set flags will be returned.
1809- //
1810- // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
1811- //
1812- // CONTEXT_INTEGER specifies R0-R12
1813- //
1814- // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
1815- //
1816- // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
1817- // DBGWCR.
1818- //
1819-
18201775typedef struct DECLSPEC_ALIGN (8 ) _CONTEXT {
18211776
18221777 //
@@ -1968,37 +1923,6 @@ typedef struct _IMAGE_ARM_RUNTIME_FUNCTION_ENTRY {
19681923#define ARM64_MAX_BREAKPOINTS 8
19691924#define ARM64_MAX_WATCHPOINTS 2
19701925
1971- //
1972- // Context Frame
1973- //
1974- // This frame has a several purposes: 1) it is used as an argument to
1975- // NtContinue, 2) it is used to construct a call frame for APC delivery,
1976- // and 3) it is used in the user level thread creation routines.
1977- //
1978- //
1979- // The flags field within this record controls the contents of a CONTEXT
1980- // record.
1981- //
1982- // If the context record is used as an input parameter, then for each
1983- // portion of the context record controlled by a flag whose value is
1984- // set, it is assumed that such portion of the context record contains
1985- // valid context. If the context record is being used to modify a threads
1986- // context, then only that portion of the threads context is modified.
1987- //
1988- // If the context record is used as an output parameter to capture the
1989- // context of a thread, then only those portions of the thread's context
1990- // corresponding to set flags will be returned.
1991- //
1992- // CONTEXT_CONTROL specifies Sp, Lr, Pc, and Cpsr
1993- //
1994- // CONTEXT_INTEGER specifies R0-R12
1995- //
1996- // CONTEXT_FLOATING_POINT specifies Q0-Q15 / D0-D31 / S0-S31
1997- //
1998- // CONTEXT_DEBUG_REGISTERS specifies up to 16 of DBGBVR, DBGBCR, DBGWVR,
1999- // DBGWCR.
2000- //
2001-
20021926typedef struct _NEON128 {
20031927 ULONGLONG Low;
20041928 LONGLONG High;
@@ -2145,28 +2069,6 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
21452069#define LOONGARCH64_MAX_BREAKPOINTS 8
21462070#define LOONGARCH64_MAX_WATCHPOINTS 2
21472071
2148- //
2149- // Context Frame
2150- //
2151- // This frame has a several purposes: 1) it is used as an argument to
2152- // NtContinue, 2) it is used to construct a call frame for APC delivery,
2153- // and 3) it is used in the user level thread creation routines.
2154- //
2155- //
2156- // The flags field within this record controls the contents of a CONTEXT
2157- // record.
2158- //
2159- // If the context record is used as an input parameter, then for each
2160- // portion of the context record controlled by a flag whose value is
2161- // set, it is assumed that such portion of the context record contains
2162- // valid context. If the context record is being used to modify a threads
2163- // context, then only that portion of the threads context is modified.
2164- //
2165- // If the context record is used as an output parameter to capture the
2166- // context of a thread, then only those portions of the thread's context
2167- // corresponding to set flags will be returned.
2168- //
2169-
21702072typedef struct DECLSPEC_ALIGN (16 ) _CONTEXT {
21712073
21722074 //
@@ -2249,6 +2151,155 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
22492151 PDWORD64 F31 ;
22502152} KNONVOLATILE_CONTEXT_POINTERS , *PKNONVOLATILE_CONTEXT_POINTERS ;
22512153
2154+ #elif defined(HOST_RISCV64)
2155+
2156+ #error "TODO-RISCV64: review this when src/coreclr/pal/src/arch/riscv64/asmconstants.h is ported"
2157+
2158+ // Please refer to src/coreclr/pal/src/arch/riscv64/asmconstants.h
2159+ #define CONTEXT_RISCV64 0x04000000L
2160+
2161+ #define CONTEXT_CONTROL (CONTEXT_RISCV64 | 0x1 )
2162+ #define CONTEXT_INTEGER (CONTEXT_RISCV64 | 0x2 )
2163+ #define CONTEXT_FLOATING_POINT (CONTEXT_RISCV64 | 0x4 )
2164+ #define CONTEXT_DEBUG_REGISTERS (CONTEXT_RISCV64 | 0x8 )
2165+
2166+ #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT )
2167+
2168+ #define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS )
2169+
2170+ #define CONTEXT_EXCEPTION_ACTIVE 0x8000000
2171+ #define CONTEXT_SERVICE_ACTIVE 0x10000000
2172+ #define CONTEXT_EXCEPTION_REQUEST 0x40000000
2173+ #define CONTEXT_EXCEPTION_REPORTING 0x80000000
2174+
2175+ //
2176+ // This flag is set by the unwinder if it has unwound to a call
2177+ // site, and cleared whenever it unwinds through a trap frame.
2178+ // It is used by language-specific exception handlers to help
2179+ // differentiate exception scopes during dispatching.
2180+ //
2181+
2182+ #define CONTEXT_UNWOUND_TO_CALL 0x20000000
2183+
2184+ // begin_ntoshvp
2185+
2186+ //
2187+ // Specify the number of breakpoints and watchpoints that the OS
2188+ // will track. Architecturally, RISCV64 supports up to 16. In practice,
2189+ // however, almost no one implements more than 4 of each.
2190+ //
2191+
2192+ #define RISCV64_MAX_BREAKPOINTS 8
2193+ #define RISCV64_MAX_WATCHPOINTS 2
2194+
2195+ typedef struct DECLSPEC_ALIGN (16 ) _CONTEXT {
2196+
2197+ //
2198+ // Control flags.
2199+ //
2200+
2201+ /* +0x000 */ DWORD ContextFlags;
2202+
2203+ //
2204+ // Integer registers.
2205+ //
2206+ DWORD64 Ra;
2207+ DWORD64 Sp;
2208+ DWORD64 Gp;
2209+ DWORD64 Tp;
2210+ DWORD64 T0 ;
2211+ DWORD64 T1 ;
2212+ DWORD64 T2 ;
2213+ DWORD64 S0 ;
2214+ DWORD64 S1 ;
2215+ DWORD64 A0 ;
2216+ DWORD64 A1 ;
2217+ DWORD64 A2 ;
2218+ DWORD64 A3 ;
2219+ DWORD64 A4 ;
2220+ DWORD64 A5 ;
2221+ DWORD64 A6 ;
2222+ DWORD64 A7 ;
2223+ DWORD64 S2 ;
2224+ DWORD64 S3 ;
2225+ DWORD64 S4 ;
2226+ DWORD64 S5 ;
2227+ DWORD64 S6 ;
2228+ DWORD64 S7 ;
2229+ DWORD64 S8 ;
2230+ DWORD64 S9 ;
2231+ DWORD64 S10 ;
2232+ DWORD64 S11 ;
2233+ DWORD64 T3 ;
2234+ DWORD64 T4 ;
2235+ DWORD64 T5 ;
2236+ DWORD64 T6 ;
2237+ DWORD64 Pc;
2238+
2239+ //
2240+ // Floating Point Registers
2241+ //
2242+ // TODO-RISCV64: support the SIMD.
2243+ ULONGLONG F[32 ];
2244+ DWORD Fcsr;
2245+ } CONTEXT , *PCONTEXT , *LPCONTEXT ;
2246+
2247+ //
2248+ // Nonvolatile context pointer record.
2249+ //
2250+
2251+ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
2252+
2253+ PDWORD64 Ra;
2254+ PDWORD64 Tp;
2255+ PDWORD64 T0 ;
2256+ PDWORD64 T1 ;
2257+ PDWORD64 S0 ;
2258+ PDWORD64 S1 ;
2259+ PDWORD64 A0 ;
2260+ PDWORD64 A1 ;
2261+ PDWORD64 A2 ;
2262+ PDWORD64 A3 ;
2263+ PDWORD64 A4 ;
2264+ PDWORD64 A5 ;
2265+ PDWORD64 A6 ;
2266+ PDWORD64 A7 ;
2267+ PDWORD64 S2 ;
2268+ PDWORD64 S3 ;
2269+ PDWORD64 S4 ;
2270+ PDWORD64 S5 ;
2271+ PDWORD64 S6 ;
2272+ PDWORD64 S7 ;
2273+ PDWORD64 S8 ;
2274+ PDWORD64 S9 ;
2275+ PDWORD64 S10 ;
2276+ PDWORD64 S11 ;
2277+ PDWORD64 T3 ;
2278+ PDWORD64 T4 ;
2279+ PDWORD64 T5 ;
2280+ PDWORD64 T6 ;
2281+
2282+ PDWORD64 FS0 ;
2283+ PDWORD64 FS1 ;
2284+ PDWORD64 FA0 ;
2285+ PDWORD64 FA1 ;
2286+ PDWORD64 FA2 ;
2287+ PDWORD64 FA3 ;
2288+ PDWORD64 FA4 ;
2289+ PDWORD64 FA5 ;
2290+ PDWORD64 FA6 ;
2291+ PDWORD64 FA7 ;
2292+ PDWORD64 FS2 ;
2293+ PDWORD64 FS3 ;
2294+ PDWORD64 FS4 ;
2295+ PDWORD64 FS5 ;
2296+ PDWORD64 FS6 ;
2297+ PDWORD64 FS7 ;
2298+ PDWORD64 FS8 ;
2299+ PDWORD64 FS9 ;
2300+ PDWORD64 FS10 ;
2301+ PDWORD64 FS11 ;
2302+ } KNONVOLATILE_CONTEXT_POINTERS , *PKNONVOLATILE_CONTEXT_POINTERS ;
22522303
22532304#elif defined(HOST_S390X)
22542305
0 commit comments