github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/libmach/8.c (about) 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 <libc.h> 34 #include <bio.h> 35 #include <ureg_x86.h> 36 #include <mach.h> 37 38 #define REGOFF(x) (uintptr)(&((struct Ureg *) 0)->x) 39 40 #define PC REGOFF(pc) 41 #define SP REGOFF(sp) 42 #define AX REGOFF(ax) 43 44 #define REGSIZE sizeof(struct Ureg) 45 #define FP_CTL(x) (REGSIZE+4*(x)) 46 #define FP_REG(x) (FP_CTL(7)+10*(x)) 47 #define FPREGSIZE (7*4+8*10) 48 49 Reglist i386reglist[] = { 50 {"DI", REGOFF(di), RINT, 'X'}, 51 {"SI", REGOFF(si), RINT, 'X'}, 52 {"BP", REGOFF(bp), RINT, 'X'}, 53 {"BX", REGOFF(bx), RINT, 'X'}, 54 {"DX", REGOFF(dx), RINT, 'X'}, 55 {"CX", REGOFF(cx), RINT, 'X'}, 56 {"AX", REGOFF(ax), RINT, 'X'}, 57 {"GS", REGOFF(gs), RINT, 'X'}, 58 {"FS", REGOFF(fs), RINT, 'X'}, 59 {"ES", REGOFF(es), RINT, 'X'}, 60 {"DS", REGOFF(ds), RINT, 'X'}, 61 {"TRAP", REGOFF(trap), RINT, 'X'}, 62 {"ECODE", REGOFF(ecode), RINT, 'X'}, 63 {"PC", PC, RINT, 'X'}, 64 {"CS", REGOFF(cs), RINT, 'X'}, 65 {"EFLAGS", REGOFF(flags), RINT, 'X'}, 66 {"SP", SP, RINT, 'X'}, 67 {"SS", REGOFF(ss), RINT, 'X'}, 68 69 {"E0", FP_CTL(0), RFLT, 'X'}, 70 {"E1", FP_CTL(1), RFLT, 'X'}, 71 {"E2", FP_CTL(2), RFLT, 'X'}, 72 {"E3", FP_CTL(3), RFLT, 'X'}, 73 {"E4", FP_CTL(4), RFLT, 'X'}, 74 {"E5", FP_CTL(5), RFLT, 'X'}, 75 {"E6", FP_CTL(6), RFLT, 'X'}, 76 {"F0", FP_REG(0), RFLT, '3'}, 77 {"F1", FP_REG(1), RFLT, '3'}, 78 {"F2", FP_REG(2), RFLT, '3'}, 79 {"F3", FP_REG(3), RFLT, '3'}, 80 {"F4", FP_REG(4), RFLT, '3'}, 81 {"F5", FP_REG(5), RFLT, '3'}, 82 {"F6", FP_REG(6), RFLT, '3'}, 83 {"F7", FP_REG(7), RFLT, '3'}, 84 { 0 } 85 }; 86 87 Mach mi386 = 88 { 89 "386", 90 MI386, /* machine type */ 91 i386reglist, /* register list */ 92 REGSIZE, /* size of registers in bytes */ 93 FPREGSIZE, /* size of fp registers in bytes */ 94 "PC", /* name of PC */ 95 "SP", /* name of SP */ 96 0, /* link register */ 97 "setSB", /* static base register name (bogus anyways) */ 98 0, /* static base register value */ 99 0x1000, /* page size */ 100 0x80100000ULL, /* kernel base */ 101 0xF0000000ULL, /* kernel text mask */ 102 0xFFFFFFFFULL, /* user stack top */ 103 1, /* quantization of pc */ 104 4, /* szaddr */ 105 4, /* szreg */ 106 4, /* szfloat */ 107 8, /* szdouble */ 108 };