1// Copyright 2014 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package runtime
6
7const _PAGESIZE = 0x1000
8
9type ureg struct {
10	di    uint32 /* general registers */
11	si    uint32 /* ... */
12	bp    uint32 /* ... */
13	nsp   uint32
14	bx    uint32 /* ... */
15	dx    uint32 /* ... */
16	cx    uint32 /* ... */
17	ax    uint32 /* ... */
18	gs    uint32 /* data segments */
19	fs    uint32 /* ... */
20	es    uint32 /* ... */
21	ds    uint32 /* ... */
22	trap  uint32 /* trap _type */
23	ecode uint32 /* error code (or zero) */
24	pc    uint32 /* pc */
25	cs    uint32 /* old context */
26	flags uint32 /* old flags */
27	sp    uint32
28	ss    uint32 /* old stack segment */
29}
30
31type sigctxt struct {
32	u *ureg
33}
34
35//go:nosplit
36//go:nowritebarrierrec
37func (c *sigctxt) pc() uintptr { return uintptr(c.u.pc) }
38
39func (c *sigctxt) sp() uintptr { return uintptr(c.u.sp) }
40func (c *sigctxt) lr() uintptr { return uintptr(0) }
41
42func (c *sigctxt) setpc(x uintptr) { c.u.pc = uint32(x) }
43func (c *sigctxt) setsp(x uintptr) { c.u.sp = uint32(x) }
44func (c *sigctxt) setlr(x uintptr) {}
45
46func (c *sigctxt) savelr(x uintptr) {}
47
48func dumpregs(u *ureg) {
49	print("ax    ", hex(u.ax), "\n")
50	print("bx    ", hex(u.bx), "\n")
51	print("cx    ", hex(u.cx), "\n")
52	print("dx    ", hex(u.dx), "\n")
53	print("di    ", hex(u.di), "\n")
54	print("si    ", hex(u.si), "\n")
55	print("bp    ", hex(u.bp), "\n")
56	print("sp    ", hex(u.sp), "\n")
57	print("pc    ", hex(u.pc), "\n")
58	print("flags ", hex(u.flags), "\n")
59	print("cs    ", hex(u.cs), "\n")
60	print("fs    ", hex(u.fs), "\n")
61	print("gs    ", hex(u.gs), "\n")
62}
63
64func sigpanictramp()
65