Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 287 → Rev 288

//SPARTAN/trunk/tools/amd64/gencontext.c
0,0 → 1,38
#include <stdio.h>
 
 
typedef long long __u64;
typedef __u64 pri_t;
 
#define __amd64_TYPES_H__
#include "../../arch/amd64/include/context.h"
 
#define FILENAME "../../arch/amd64/src/context_offset.h"
 
int main(void)
{
FILE *f;
struct context ctx;
struct context *pctx = &ctx;
 
f = fopen(FILENAME,"w");
if (!f) {
perror(FILENAME);
return 1;
}
 
fprintf(f, "/* This file is automatically generated by %s. */\n", __FILE__);
 
fprintf(f,"#define OFFSET_SP 0x%x\n",((int)&pctx->sp) - (int )pctx);
fprintf(f,"#define OFFSET_PC 0x%x\n",((int)&pctx->pc) - (int )pctx);
fprintf(f,"#define OFFSET_RBX 0x%x\n",((int)&pctx->rbx) - (int )pctx);
fprintf(f,"#define OFFSET_RBP 0x%x\n",((int)&pctx->rbp) - (int )pctx);
fprintf(f,"#define OFFSET_R12 0x%x\n",((int)&pctx->r12) - (int )pctx);
fprintf(f,"#define OFFSET_R13 0x%x\n",((int)&pctx->r13) - (int )pctx);
fprintf(f,"#define OFFSET_R14 0x%x\n",((int)&pctx->r14) - (int )pctx);
fprintf(f,"#define OFFSET_R15 0x%x\n",((int)&pctx->r15) - (int )pctx);
fprintf(f,"#define OFFSET_PRI 0x%x\n",((int)&pctx->pri) - (int )pctx);
fclose(f);
 
return 0;
}
//SPARTAN/trunk/tools/genmap.py
0,0 → 1,67
#!/usr/bin/env python
 
import sys
import struct
import re
 
symline = re.compile(r'(0x[a-f0-9]+)\s+([^\s]+)$')
fileline = re.compile(r'[^\s]+\s+0x[a-f0-9]+\s+0x[a-f0-9]+\s+([^\s]+\.o)$')
 
MAXSTRING=63
symtabfmt = "<Q%ds" % (MAXSTRING+1)
 
def read_symbols(inp):
while 1:
line = inp.readline()
if not line:
return
if 'memory map' in line:
break
 
symtable = {}
filename = ''
while 1:
line = inp.readline()
if not line.strip():
continue
if line[0] not in (' ','.'):
break
line = line.strip()
# Search for file name
res = fileline.match(line)
if res:
filename = res.group(1)
# Search for symbols
res = symline.match(line)
if res:
symtable[int(res.group(1),16)] = filename + ':' + res.group(2)
return symtable
def generate(inp, out):
symtab = read_symbols(inp)
if not symtab:
print "Bad kernel.map format, empty."
sys.exit(1)
addrs = symtab.keys()
addrs.sort()
for addr in addrs:
# Do not write address 0, it indicates end of data
if addr == 0:
continue
data = struct.pack(symtabfmt,addr,symtab[addr][:MAXSTRING])
out.write(data)
out.write(struct.pack(symtabfmt,0,''))
 
def main():
if len(sys.argv) != 3:
print "Usage: %s <kernel.map> <output.bin>" % sys.argv[0]
sys.exit(1)
 
inp = open(sys.argv[1],'r')
out = open(sys.argv[2],'w')
generate(inp,out)
inp.close()
out.close()
 
if __name__ == '__main__':
main()
Property changes:
Added: svn:executable
+*
\ No newline at end of property