blob: 3574cb665458744038dbc73690922dbeb75b51de [file] [log] [blame]
Russ Cox580ef3e2014-11-11 17:07:37 -05001package runtime
2
David du Colombiere9c57d82014-11-21 19:39:01 +01003const _PAGESIZE = 0x1000
4
Russ Cox580ef3e2014-11-11 17:07:37 -05005type ureg struct {
6 di uint32 /* general registers */
7 si uint32 /* ... */
8 bp uint32 /* ... */
9 nsp uint32
10 bx uint32 /* ... */
11 dx uint32 /* ... */
12 cx uint32 /* ... */
13 ax uint32 /* ... */
14 gs uint32 /* data segments */
15 fs uint32 /* ... */
16 es uint32 /* ... */
17 ds uint32 /* ... */
18 trap uint32 /* trap _type */
19 ecode uint32 /* error code (or zero) */
20 pc uint32 /* pc */
21 cs uint32 /* old context */
22 flags uint32 /* old flags */
23 sp uint32
24 ss uint32 /* old stack segment */
25}
Anthony Martin3d032d72014-12-18 05:05:44 -080026
27type sigctxt struct {
28 u *ureg
29}
30
31func (c *sigctxt) pc() uintptr { return uintptr(c.u.pc) }
32func (c *sigctxt) sp() uintptr { return uintptr(c.u.sp) }
33
34func (c *sigctxt) setpc(x uintptr) { c.u.pc = uint32(x) }
35func (c *sigctxt) setsp(x uintptr) { c.u.sp = uint32(x) }
36
37func dumpregs(u *ureg) {
38 print("ax ", hex(u.ax), "\n")
39 print("bx ", hex(u.bx), "\n")
40 print("cx ", hex(u.cx), "\n")
41 print("dx ", hex(u.dx), "\n")
42 print("di ", hex(u.di), "\n")
43 print("si ", hex(u.si), "\n")
44 print("bp ", hex(u.bp), "\n")
45 print("sp ", hex(u.sp), "\n")
46 print("pc ", hex(u.pc), "\n")
47 print("flags ", hex(u.flags), "\n")
48 print("cs ", hex(u.cs), "\n")
49 print("fs ", hex(u.fs), "\n")
50 print("gs ", hex(u.gs), "\n")
51}