1 // Inferno libmach/8.c
2 // http://code.google.com/p/inferno-os/source/browse/utils/libmach/8.c
3 //
4 // Copyright © 1994-1999 Lucent Technologies Inc.
5 // Power PC support Copyright © 1995-2004 C H Forsyth (forsyth@terzarima.net).
6 // Portions Copyright © 1997-1999 Vita Nuova Limited.
7 // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com).
8 // Revisions Copyright © 2000-2004 Lucent Technologies Inc. and others.
9 // Portions Copyright © 2009 The Go Authors. All rights reserved.
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a copy
12 // of this software and associated documentation files (the "Software"), to deal
13 // in the Software without restriction, including without limitation the rights
14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 // copies of the Software, and to permit persons to whom the Software is
16 // furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included in
19 // all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 // THE SOFTWARE.
28
29 /*
30 * 386 definition
31 */
32 #include <u.h>
33 #include <bio.h>
34 #include <ureg_x86.h>
35 #include <mach.h>
36
37 #define REGOFF(x) (uintptr)(&((struct Ureg *) 0)->x)
38
39 #define PC REGOFF(pc)
40 #define SP REGOFF(sp)
41 #define AX REGOFF(ax)
42
43 #define REGSIZE sizeof(struct Ureg)
44 #define FP_CTL(x) (REGSIZE+4*(x))
45 #define FP_REG(x) (FP_CTL(7)+10*(x))
46 #define FPREGSIZE (7*4+8*10)
47
48 Reglist i386reglist[] = {
49 {"DI", REGOFF(di), RINT, 'X'},
50 {"SI", REGOFF(si), RINT, 'X'},
51 {"BP", REGOFF(bp), RINT, 'X'},
52 {"BX", REGOFF(bx), RINT, 'X'},
53 {"DX", REGOFF(dx), RINT, 'X'},
54 {"CX", REGOFF(cx), RINT, 'X'},
55 {"AX", REGOFF(ax), RINT, 'X'},
56 {"GS", REGOFF(gs), RINT, 'X'},
57 {"FS", REGOFF(fs), RINT, 'X'},
58 {"ES", REGOFF(es), RINT, 'X'},
59 {"DS", REGOFF(ds), RINT, 'X'},
60 {"TRAP", REGOFF(trap), RINT, 'X'},
61 {"ECODE", REGOFF(ecode), RINT, 'X'},
62 {"PC", PC, RINT, 'X'},
63 {"CS", REGOFF(cs), RINT, 'X'},
64 {"EFLAGS", REGOFF(flags), RINT, 'X'},
65 {"SP", SP, RINT, 'X'},
66 {"SS", REGOFF(ss), RINT, 'X'},
67
68 {"E0", FP_CTL(0), RFLT, 'X'},
69 {"E1", FP_CTL(1), RFLT, 'X'},
70 {"E2", FP_CTL(2), RFLT, 'X'},
71 {"E3", FP_CTL(3), RFLT, 'X'},
72 {"E4", FP_CTL(4), RFLT, 'X'},
73 {"E5", FP_CTL(5), RFLT, 'X'},
74 {"E6", FP_CTL(6), RFLT, 'X'},
75 {"F0", FP_REG(0), RFLT, '3'},
76 {"F1", FP_REG(1), RFLT, '3'},
77 {"F2", FP_REG(2), RFLT, '3'},
78 {"F3", FP_REG(3), RFLT, '3'},
79 {"F4", FP_REG(4), RFLT, '3'},
80 {"F5", FP_REG(5), RFLT, '3'},
81 {"F6", FP_REG(6), RFLT, '3'},
82 {"F7", FP_REG(7), RFLT, '3'},
83 { 0 }
84 };
85
86 Mach mi386 =
87 {
88 "386",
89 MI386, /* machine type */
90 i386reglist, /* register list */
91 REGSIZE, /* size of registers in bytes */
92 FPREGSIZE, /* size of fp registers in bytes */
93 "PC", /* name of PC */
94 "SP", /* name of SP */
95 0, /* link register */
96 "setSB", /* static base register name (bogus anyways) */
97 0, /* static base register value */
98 0x1000, /* page size */
99 0x80100000ULL, /* kernel base */
100 0xF0000000ULL, /* kernel text mask */
101 0xFFFFFFFFULL, /* user stack top */
102 1, /* quantization of pc */
103 4, /* szaddr */
104 4, /* szreg */
105 4, /* szfloat */
106 8, /* szdouble */
107 };