/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 |
/SPARTAN/trunk/src/debug/genmap.py |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/SPARTAN/trunk/src/clean.amd64 |
---|
5,4 → 5,4 |
find ../arch/amd64 -type l | xargs rm |
rm ../arch/amd64/src/context_offset.h |
rm ../arch/amd64/src/gencontext |
rm ../tools/amd64/gencontext |
/SPARTAN/trunk/src/build.amd64 |
---|
2,7 → 2,7 |
set -e |
# Generate context_offset.h |
(cd ../arch/amd64/src;make gencontext;./gencontext) |
(cd ../tools/amd64/;make gencontext;./gencontext) |
# Create links to ia32 architecture |
( |
/SPARTAN/trunk/src/Makefile |
---|
76,7 → 76,7 |
kernel.bin: $(arch_objects) $(objects) $(test_objects) |
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile debug/empty_map.o |
$(LD) $(LFLAGS) $(arch_objects) $(objects) $(test_objects) debug/empty_map.o -o $@ -Map kernel.map.pre |
debug/genmap.py kernel.map.pre debug/real_map.bin |
../tools/genmap.py kernel.map.pre debug/real_map.bin |
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab debug/real_map.bin debug/real_map.o |
$(LD) $(LFLAGS) $(arch_objects) $(objects) $(test_objects) debug/real_map.o -o $@ -Map kernel.map |
/SPARTAN/trunk/arch/amd64/src/gencontext.c |
---|
File deleted |
/SPARTAN/trunk/arch/amd64/src/boot/boot.S |
---|
1,5 → 1,5 |
# |
# Copyright (C) 2001-2004 Ondrej Palkovsky |
# Copyright (C) 2005 Ondrej Palkovsky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |