--- trunk/src/cpus/generate_head.c 2007/10/08 16:18:51 14 +++ trunk/src/cpus/generate_head.c 2007/10/08 16:20:26 28 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Anders Gavare. All rights reserved. + * Copyright (C) 2005-2006 Anders Gavare. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: generate_head.c,v 1.5 2005/09/18 19:54:14 debug Exp $ + * $Id: generate_head.c,v 1.18 2006/07/20 21:53:00 debug Exp $ */ #include @@ -33,10 +33,13 @@ #include +/* NOTE: Static return buffer, so calling it multiple times in the + same printf statement with the same argument works :-) but not + with different args. Hahaha. Really ugly. */ char *uppercase(char *l) { static char staticbuf[1000]; - int i = 0; + size_t i = 0; while (*l && i < sizeof(staticbuf)) { char u = *l++; @@ -65,18 +68,34 @@ a = argv[1]; b = argv[2]; + printf("\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n"); + printf("#include \n"); + printf("#include \"debugger.h\"\n"); + printf("#define DYNTRANS_MAX_VPH_TLB_ENTRIES " "%s_MAX_VPH_TLB_ENTRIES\n", uppercase(a)); printf("#define DYNTRANS_ARCH %s\n", a); printf("#define DYNTRANS_%s\n", uppercase(a)); - printf("#ifdef DYNTRANS_32\n" - "#define DYNTRANS_1LEVEL\n" - "#endif\n"); + + /* For 64-bit platforms, arch_L2N, and arch_L3N must be defined. */ + printf("#ifndef DYNTRANS_32\n"); + printf("#define DYNTRANS_L2N %s_L2N\n" + "#define DYNTRANS_L3N %s_L3N\n" + "#if !defined(%s_L2N) || !defined(%s_L3N)\n" + "#error arch_L2N, and arch_L3N must be defined for this arch!\n" + "#endif\n", + uppercase(a), uppercase(a), uppercase(a), uppercase(a)); + printf("#define DYNTRANS_L2_64_TABLE %s_l2_64_table\n" + "#define DYNTRANS_L3_64_TABLE %s_l3_64_table\n", a, a); + printf("#endif\n"); + + /* Default pagesize is 4KB. */ printf("#ifndef DYNTRANS_PAGESIZE\n" "#define DYNTRANS_PAGESIZE 4096\n" "#endif\n"); + printf("#define DYNTRANS_IC %s_instr_call\n", a); printf("#define DYNTRANS_IC_ENTRIES_PER_PAGE " "%s_IC_ENTRIES_PER_PAGE\n", uppercase(a)); @@ -112,10 +131,8 @@ "#define instr32(n) %s32_instr_ ## n\n\n", a); printf("#endif\n\n"); - printf("/* This is for marking a physical page as containing " - "translated or\n combined instructions, respectively: */\n"); - printf("#define translated (cpu->cd.%s.cur_physpage->flags " - "|= TRANSLATIONS)\n", a); + printf("/* This is for marking a physical page as containing" + "\n combined instructions: */\n"); printf("#define combined (cpu->cd.%s.cur_physpage->flags " "|= COMBINATIONS)\n", a); @@ -136,13 +153,14 @@ printf("\tcpu->cd.%s.next_ic --;\n", a); printf("}\n\n"); - /* TODO: solve this in a nicer way! */ - if (strcmp(a, "avr") == 0) + /* Ugly special hack for Transputer: */ + if (strcasecmp(argv[1], "transputer") == 0) { printf("static struct %s_instr_call nothing_call = { " - "instr(nothing), {0,0} };\n", a); - else + "instr(nothing), {0} };\n", a); + } else { printf("static struct %s_instr_call nothing_call = { " "instr(nothing), {0,0,0} };\n", a); + } printf("\n");