| ... | ... | @@ -6,6 +6,7 @@ pub const Native = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "CpuCont |
| 6 | 6 | else switch (native_arch) { |
| 7 | 7 | .aarch64, .aarch64_be => Aarch64, |
| 8 | 8 | .arm, .armeb, .thumb, .thumbeb => Arm, |
| 9 | .csky => Csky, |
| 9 | 10 | .hexagon => Hexagon, |
| 10 | 11 | .lanai => Lanai, |
| 11 | 12 | .loongarch32, .loongarch64 => LoongArch, |
| ... | ... | @@ -74,6 +75,13 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { |
| 74 | 75 | .sp = uc.mcontext.sp, |
| 75 | 76 | .pc = uc.mcontext.pc, |
| 76 | 77 | }, |
| 78 | .csky => .{ |
| 79 | .r = uc.mcontext.r0_13 ++ |
| 80 | [_]u32{ uc.mcontext.r14, uc.mcontext.r15 } ++ |
| 81 | uc.mcontext.r16_30 ++ |
| 82 | [_]u32{uc.mcontext.r31}, |
| 83 | .pc = uc.mcontext.pc, |
| 84 | }, |
| 77 | 85 | .hexagon, .loongarch32, .loongarch64, .mips, .mipsel, .mips64, .mips64el, .or1k => .{ |
| 78 | 86 | .r = uc.mcontext.r, |
| 79 | 87 | .pc = uc.mcontext.pc, |
| ... | ... | @@ -433,6 +441,37 @@ const Aarch64 = extern struct { |
| 433 | 441 | } |
| 434 | 442 | }; |
| 435 | 443 | |
| 444 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 445 | const Csky = extern struct { |
| 446 | /// The numbered general-purpose registers r0 - r31. |
| 447 | r: [32]u32, |
| 448 | pc: u32, |
| 449 | |
| 450 | pub inline fn current() Csky { |
| 451 | var ctx: Csky = undefined; |
| 452 | asm volatile ( |
| 453 | \\ stm r0-r31, (t0) |
| 454 | \\ grs t1, 1f |
| 455 | \\1: |
| 456 | \\ st32.w t1, (t0, 128) |
| 457 | : |
| 458 | : [ctx] "{r12}" (&ctx), |
| 459 | : .{ .r13 = true, .memory = true }); |
| 460 | return ctx; |
| 461 | } |
| 462 | |
| 463 | pub fn dwarfRegisterBytes(ctx: *Csky, register_num: u16) DwarfRegisterError![]u8 { |
| 464 | switch (register_num) { |
| 465 | 0...31 => return @ptrCast(&ctx.r[register_num]), |
| 466 | 64 => return @ptrCast(&ctx.pc), |
| 467 | |
| 468 | 32...63 => return error.UnsupportedRegister, // f0 - f31 |
| 469 | |
| 470 | else => return error.InvalidRegister, |
| 471 | } |
| 472 | } |
| 473 | }; |
| 474 | |
| 436 | 475 | /// This is an `extern struct` so that inline assembly in `current` can use field offsets. |
| 437 | 476 | const Hexagon = extern struct { |
| 438 | 477 | /// The numbered general-purpose registers r0 - r31. |