Rev 534 | Rev 1021 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
200 | palkovsky | 1 | #include <stdio.h> |
2 | |||
3 | |||
4 | typedef long long __u64; |
||
413 | jermar | 5 | typedef __u64 ipl_t; |
414 | jermar | 6 | typedef __u64 __address; |
200 | palkovsky | 7 | |
8 | #define __amd64_TYPES_H__ |
||
288 | jermar | 9 | #include "../../arch/amd64/include/context.h" |
200 | palkovsky | 10 | |
318 | jermar | 11 | #define FILENAME "../../arch/amd64/include/context_offset.h" |
200 | palkovsky | 12 | |
13 | int main(void) |
||
14 | { |
||
288 | jermar | 15 | FILE *f; |
16 | struct context ctx; |
||
17 | struct context *pctx = &ctx; |
||
200 | palkovsky | 18 | |
799 | palkovsky | 19 | struct interrupt_context ictx; |
20 | struct interrupt_context *ipctx = &ictx; |
||
21 | |||
288 | jermar | 22 | f = fopen(FILENAME,"w"); |
23 | if (!f) { |
||
24 | perror(FILENAME); |
||
25 | return 1; |
||
26 | } |
||
200 | palkovsky | 27 | |
288 | jermar | 28 | fprintf(f, "/* This file is automatically generated by %s. */\n", __FILE__); |
29 | |||
30 | fprintf(f,"#define OFFSET_SP 0x%x\n",((int)&pctx->sp) - (int )pctx); |
||
31 | fprintf(f,"#define OFFSET_PC 0x%x\n",((int)&pctx->pc) - (int )pctx); |
||
32 | fprintf(f,"#define OFFSET_RBX 0x%x\n",((int)&pctx->rbx) - (int )pctx); |
||
33 | fprintf(f,"#define OFFSET_RBP 0x%x\n",((int)&pctx->rbp) - (int )pctx); |
||
34 | fprintf(f,"#define OFFSET_R12 0x%x\n",((int)&pctx->r12) - (int )pctx); |
||
35 | fprintf(f,"#define OFFSET_R13 0x%x\n",((int)&pctx->r13) - (int )pctx); |
||
36 | fprintf(f,"#define OFFSET_R14 0x%x\n",((int)&pctx->r14) - (int )pctx); |
||
37 | fprintf(f,"#define OFFSET_R15 0x%x\n",((int)&pctx->r15) - (int )pctx); |
||
413 | jermar | 38 | fprintf(f,"#define OFFSET_IPL 0x%x\n",((int)&pctx->ipl) - (int )pctx); |
799 | palkovsky | 39 | |
40 | fprintf(f, "\n"); |
||
41 | |||
42 | #define ifpr(big,nm) fprintf(f, "#define IOFFSET_" #big " 0x%x\n", ((int)&ipctx->nm) - (int) ipctx) |
||
43 | |||
44 | ifpr(RAX, rax); |
||
45 | ifpr(RBX, rbx); |
||
46 | ifpr(RCX, rcx); |
||
47 | ifpr(RDX, rdx); |
||
48 | ifpr(RSI, rsi); |
||
49 | ifpr(RDI, rdi); |
||
50 | ifpr(R8, r8); |
||
51 | ifpr(R9, r9); |
||
52 | ifpr(R10, r10); |
||
53 | ifpr(R11, r11); |
||
54 | ifpr(R12, r12); |
||
55 | ifpr(R13, r13); |
||
56 | ifpr(R14, r14); |
||
57 | ifpr(R15, r15); |
||
58 | ifpr(RBP, rbp); |
||
59 | |||
60 | fprintf(f, "#define IREGISTER_SPACE %d\n", sizeof(ictx)); |
||
61 | |||
288 | jermar | 62 | fclose(f); |
63 | |||
64 | return 0; |
||
200 | palkovsky | 65 | } |