aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ar71xx
Commit message (Collapse)AuthorAgeFilesLines
...
* ar71xx: add support for the embeddedwireless Dorin board (based on patch by ↵Felix Fietkau2012-06-198-0/+185
| | | | | | embeddedwireless.de) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32447 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add support for reading the MAC address from OTP ROM on AR933xFelix Fietkau2012-06-191-0/+166
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32446 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: swap the PHY address of the ethernet port of TL-MR3040/TL-MR11U ↵Felix Fietkau2012-06-131-0/+3
| | | | | | similar to TL-MR3020 to fix ethernet link detection git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32336 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix LZMA loader build regression from r32090 (thx, juhosg)Felix Fietkau2012-06-061-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32095 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix PHY setup on TL-MR3020 (fixes #11572)Felix Fietkau2012-06-061-0/+4
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32093 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add a helper function for setting up PHY4 swapping on ar933xFelix Fietkau2012-06-063-15/+21
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32092 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: only build all loader images if the image builder is enabled - saves ↵Felix Fietkau2012-06-061-1/+1
| | | | | | some time on make target/install git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32090 3c298f89-4303-0410-b956-a3cf2f4a3e73
* [kernel] bump to 3.3.8John Crispin2012-06-051-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32055 3c298f89-4303-0410-b956-a3cf2f4a3e73
* uboot-envtools: update to 2012.04.01Luka Perkov2012-06-041-37/+0
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32051 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add default LED setup for the DB120 boardGabor Juhos2012-05-291-0/+5
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31997 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: use the generic uci-default functions for initial LED setupGabor Juhos2012-05-291-152/+60
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31992 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: do not override the mdio clock for ar9330. the override value ↵Felix Fietkau2012-05-281-2/+0
| | | | | | (obtained from an atheros driver) seems to break ethernet functionality git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31956 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: improve rx performance of the ethernet driver by using build_skb to ↵Felix Fietkau2012-05-282-41/+49
| | | | | | deliver a cache-hot skb to the network stack git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31934 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix MII clock settings for various chips, improves ethernet ↵Felix Fietkau2012-05-274-5/+30
| | | | | | stability on AR934x git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31925 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix TL-WR1041 image sizeGabor Juhos2012-05-271-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31923 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.7Gabor Juhos2012-05-231-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31848 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix an insignificant typoGabor Juhos2012-05-232-2/+2
| | | | | | Patch from #11485. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31847 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix WLAN led for RB751U-2HnD and RB751G-2HnDGabor Juhos2012-05-231-0/+2
| | | | | | Patch by Kamil Trzciński <ayufan@osk-net.pl> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31846 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add support for TP-Link TL-MR3040Gabor Juhos2012-05-233-0/+20
| | | | | | | | | Support for TP-Link TL-MR3040. Power LED not working - always on red, after start should be green. Signed-off-by: Cezary Jackiewicz <cezary.jackiewicz@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31845 3c298f89-4303-0410-b956-a3cf2f4a3e73
* linux: move certain disabled symbols to the generic configsGabor Juhos2012-05-151-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * CONFIG_ARCH_DMA_ADDR_T_64BIT * CONFIG_ARCH_HAS_ILOG2_U32 * CONFIG_ARCH_HAS_ILOG2_U64 * CONFIG_ARCH_PHYS_ADDR_T_64BIT * CONFIG_ARCH_SUPPORTS_MSI * CONFIG_GENERIC_CPU_DEVICES * CONFIG_HWMON_DEBUG_CHIP * CONFIG_I2C_PXA_PCI * CONFIG_LEDS_GPIO * CONFIG_MINIX_FS_NATIVE_ENDIAN * CONFIG_MLX4_CORE * CONFIG_POWER_SUPPLY * CONFIG_POWER_SUPPLY_DEBUG * CONFIG_QUOTACTL * CONFIG_SDIO_UART * CONFIG_SENSORS_K10TEMP * CONFIG_SENSORS_SCH56XX_COMMON * CONFIG_SENSORS_VIA_CPUTEMP * CONFIG_SERIO_AMBAKMI * CONFIG_SERIO_I8042 * CONFIG_SERIO_LIBPS2 * CONFIG_SERIO_PCIPS2 * CONFIG_SERIO_RAW * CONFIG_SERIO_SERPORT * CONFIG_SPI_BITBANG * CONFIG_SPI_GPIO git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31737 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: remove AG71XX_RX_PKT_RESERVE, it is no longer necessary (found by ↵Felix Fietkau2012-05-151-2/+1
| | | | | | Eric Dumazet) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31736 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.6Gabor Juhos2012-05-141-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31709 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix build error if PCI is disabledGabor Juhos2012-05-071-0/+11
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31646 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.5Gabor Juhos2012-05-072-32/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31645 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: rewrite the phy packet hook, put it in the network stack to avoid ↵Felix Fietkau2012-05-062-26/+15
| | | | | | having to keep non-upstream ethernet driver changes git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31637 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add profile and build image for the TL-WR1041N v2 boardGabor Juhos2012-05-052-0/+17
| | | | | | Patch-by: Vince Huang <axishero@foxmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31610 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add support for the TP-Link TL-WR1041N v2 boardGabor Juhos2012-05-058-1/+212
| | | | | | Patch-by: Vince Huang <axishero@foxmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31608 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: update 3.3 patchesGabor Juhos2012-05-0562-738/+1920
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31602 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: fix a typo in the db120 mach fileGabor Juhos2012-05-051-1/+1
| | | | | | Reported-by: Sven Eckelmann <sven@narfation.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31601 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.4Gabor Juhos2012-04-301-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31541 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: allow to disable link polling on unused PHYsGabor Juhos2012-04-293-4/+16
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31533 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: enable MIB counters in the built-in switch of the AR934xGabor Juhos2012-04-251-2/+11
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31476 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: TL-WR741NDv4: add WLAN LED configGabor Juhos2012-04-241-0/+1
| | | | | | | | On TP-Link TL-WR741ND version 4, the WLAN LED must be configured to work. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31461 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.3Jonas Gorski2012-04-241-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31460 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: remove duplicated AP121 Kconfig entryGabor Juhos2012-04-201-19/+7
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31382 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: nuke 3.2 supportGabor Juhos2012-04-19134-12668/+0
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31360 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: switch to 3.3.2Gabor Juhos2012-04-191-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31359 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: sync 3.3 configGabor Juhos2012-04-191-1/+0
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31358 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: merge/reorganize 3.3 patchesGabor Juhos2012-04-196-101/+38
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31357 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: use ap91_pci_init for RB751{,G}Gabor Juhos2012-04-193-32/+20
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31356 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: move USB device registration directly into rb751{,g}_setupGabor Juhos2012-04-191-5/+5
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31355 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add ap9x_pci_get_wmac_data helperGabor Juhos2012-04-192-0/+19
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31354 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add sanity checks to decode_rleGabor Juhos2012-04-191-2/+7
| | | | | | Also use -EINVAL instead of -1. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31353 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: also update the targets to use 3.2.15Jonas Gorski2012-04-171-1/+1
| | | | | | Thanks Gabor for spotting it. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31337 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.3 to 3.3.2Jonas Gorski2012-04-171-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31336 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.2 to 3.2.14Jonas Gorski2012-04-091-1/+1
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31222 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: image: build initramfs images for the WHR boardsGabor Juhos2012-04-061-0/+4
| | | | git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31209 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: initial support for Mikrotik RB751G-2HnD and RB751U-2HnDGabor Juhos2012-04-065-0/+142
| | | | | | | | | | | | | | | | | Great collaboration on these two fantastic routers on the openwrt forum: https://forum.openwrt.org/viewtopic.php?id=32320 Above all kudos to aryufan. Well done and thank you everyone else who contributed. To-Do: LED for wlan is not yet activated To-Do: TxPower over 20dBm (RB751U) or 22dBm (RB751G) are not accepted by the router Signed-off-by: Hanno Schupp <hanno.schupp@gmail.com> [juhosg: fix line wrapped patch, fix checkpatch errors, add missing kernel patches] git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31208 3c298f89-4303-0410-b956-a3cf2f4a3e73
* ar71xx: add rb750 to diag.shGabor Juhos2012-04-061-0/+3
| | | | | | | | Support status led in diag.sh for RB750 Patch from: Evangelos Arkalis <arkalis.e@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31207 3c298f89-4303-0410-b956-a3cf2f4a3e73
* kernel: update linux 3.2 to 3.2.13 and refresh patchesJonas Gorski2012-04-012-2/+2
| | | | | | Also remove a duplicate patch from lantiq (already in generic). git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31158 3c298f89-4303-0410-b956-a3cf2f4a3e73
ebug; extern int mm_flex_debug; extern int yydebug; extern int mmdebug; #endif extern FILE *yyin; extern int yyparse(void); int main(int argc, char *argv[]); int main(int argc, char *argv[]) { extern char *optarg; extern int optind; int ch; int retval; char *inputfilename; scope_t *sentinal; STAILQ_INIT(&patches); SLIST_INIT(&search_path); STAILQ_INIT(&seq_program); TAILQ_INIT(&cs_tailq); SLIST_INIT(&scope_stack); /* Set Sentinal scope node */ sentinal = scope_alloc(); sentinal->type = SCOPE_ROOT; includes_search_curdir = 1; appname = *argv; regfile = NULL; listfile = NULL; #if DEBUG yy_flex_debug = 0; mm_flex_debug = 0; yydebug = 0; mmdebug = 0; #endif while ((ch = getopt(argc, argv, "d:i:l:n:o:p:r:I:")) != -1) { switch(ch) { case 'd': #if DEBUG if (strcmp(optarg, "s") == 0) { yy_flex_debug = 1; mm_flex_debug = 1; } else if (strcmp(optarg, "p") == 0) { yydebug = 1; mmdebug = 1; } else { fprintf(stderr, "%s: -d Requires either an " "'s' or 'p' argument\n", appname); usage(); } #else stop("-d: Assembler not built with debugging " "information", EX_SOFTWARE); #endif break; case 'i': stock_include_file = optarg; break; case 'l': /* Create a program listing */ if ((listfile = fopen(optarg, "w")) == NULL) { perror(optarg); stop(NULL, EX_CANTCREAT); } listfilename = optarg; break; case 'n': /* Don't complain about the -nostdinc directrive */ if (strcmp(optarg, "ostdinc")) { fprintf(stderr, "%s: Unknown option -%c%s\n", appname, ch, optarg); usage(); /* NOTREACHED */ } break; case 'o': if ((ofile = fopen(optarg, "w")) == NULL) { perror(optarg); stop(NULL, EX_CANTCREAT); } ofilename = optarg; break; case 'p': /* Create Register Diagnostic "printing" Functions */ if ((regdiagfile = fopen(optarg, "w")) == NULL) { perror(optarg); stop(NULL, EX_CANTCREAT); } regdiagfilename = optarg; break; case 'r': if ((regfile = fopen(optarg, "w")) == NULL) { perror(optarg); stop(NULL, EX_CANTCREAT); } regfilename = optarg; break; case 'I': { path_entry_t include_dir; if (strcmp(optarg, "-") == 0) { if (includes_search_curdir == 0) { fprintf(stderr, "%s: Warning - '-I-' " "specified multiple " "times\n", appname); } includes_search_curdir = 0; for (include_dir = SLIST_FIRST(&search_path); include_dir != NULL; include_dir = SLIST_NEXT(include_dir, links)) /* * All entries before a '-I-' only * apply to includes specified with * quotes instead of "<>". */ include_dir->quoted_includes_only = 1; } else { include_dir = (path_entry_t)malloc(sizeof(*include_dir)); if (include_dir == NULL) { perror(optarg); stop(NULL, EX_OSERR); } include_dir->directory = strdup(optarg); if (include_dir->directory == NULL) { perror(optarg); stop(NULL, EX_OSERR); } include_dir->quoted_includes_only = 0; SLIST_INSERT_HEAD(&search_path, include_dir, links); } break; } case '?': default: usage(); /* NOTREACHED */ } } argc -= optind; argv += optind; if (argc != 1) { fprintf(stderr, "%s: No input file specifiled\n", appname); usage(); /* NOTREACHED */ } if (regdiagfile != NULL && (regfile == NULL || stock_include_file == NULL)) { fprintf(stderr, "%s: The -p option requires the -r and -i options.\n", appname); usage(); /* NOTREACHED */ } symtable_open(); inputfilename = *argv; include_file(*argv, SOURCE_FILE); retval = yyparse(); if (retval == 0) { if (SLIST_FIRST(&scope_stack) == NULL || SLIST_FIRST(&scope_stack)->type != SCOPE_ROOT) { stop("Unterminated conditional expression", EX_DATAERR); /* NOTREACHED */ } /* Process outmost scope */ process_scope(SLIST_FIRST(&scope_stack)); /* * Decend the tree of scopes and insert/emit * patches as appropriate. We perform a depth first * tranversal, recursively handling each scope. */ /* start at the root scope */ dump_scope(SLIST_FIRST(&scope_stack)); /* Patch up forward jump addresses */ back_patch(); if (ofile != NULL) output_code(); if (regfile != NULL) symtable_dump(regfile, regdiagfile); if (listfile != NULL) output_listing(inputfilename); } stop(NULL, 0); /* NOTREACHED */ return (0); } static void usage() { (void)fprintf(stderr, "usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]\n" " [-r register_output_file [-p register_diag_file -i includefile]]\n" " [-l program_list_file]\n" " input_file\n", appname); exit(EX_USAGE); } static void back_patch() { struct instruction *cur_instr; for (cur_instr = STAILQ_FIRST(&seq_program); cur_instr != NULL; cur_instr = STAILQ_NEXT(cur_instr, links)) { if (cur_instr->patch_label != NULL) { struct ins_format3 *f3_instr; u_int address; if (cur_instr->patch_label->type != LABEL) { char buf[255]; snprintf(buf, sizeof(buf), "Undefined label %s", cur_instr->patch_label->name); stop(buf, EX_DATAERR); /* NOTREACHED */ } f3_instr = &cur_instr->format.format3; address = f3_instr->address; address += cur_instr->patch_label->info.linfo->address; f3_instr->address = address; } } } static void output_code() { struct instruction *cur_instr; patch_t *cur_patch; critical_section_t *cs; symbol_node_t *cur_node; int instrcount; instrcount = 0; fprintf(ofile, "/*\n" " * DO NOT EDIT - This file is automatically generated\n" " * from the following source files:\n" " *\n" "%s */\n", versions); fprintf(ofile, "static const uint8_t seqprog[] = {\n"); for (cur_instr = STAILQ_FIRST(&seq_program); cur_instr != NULL; cur_instr = STAILQ_NEXT(cur_instr, links)) { fprintf(ofile, "%s\t0x%02x, 0x%02x, 0x%02x, 0x%02x", cur_instr == STAILQ_FIRST(&seq_program) ? "" : ",\n", #ifdef __LITTLE_ENDIAN cur_instr->format.bytes[0], cur_instr->format.bytes[1], cur_instr->format.bytes[2], cur_instr->format.bytes[3]); #else cur_instr->format.bytes[3], cur_instr->format.bytes[2], cur_instr->format.bytes[1], cur_instr->format.bytes[0]); #endif instrcount++; } fprintf(ofile, "\n};\n\n"); if (patch_arg_list == NULL) stop("Patch argument list not defined", EX_DATAERR); /* * Output patch information. Patch functions first. */ fprintf(ofile, "typedef int %spatch_func_t (%s);\n", prefix, patch_arg_list); for (cur_node = SLIST_FIRST(&patch_functions); cur_node != NULL; cur_node = SLIST_NEXT(cur_node,links)) { fprintf(ofile, "static %spatch_func_t %spatch%d_func;\n" "\n" "static int\n" "%spatch%d_func(%s)\n" "{\n" " return (%s);\n" "}\n\n", prefix, prefix, cur_node->symbol->info.condinfo->func_num, prefix, cur_node->symbol->info.condinfo->func_num, patch_arg_list, cur_node->symbol->name); } fprintf(ofile, "static const struct patch {\n" " %spatch_func_t *patch_func;\n" " uint32_t begin :10,\n" " skip_instr :10,\n" " skip_patch :12;\n" "} patches[] = {\n", prefix); for (cur_patch = STAILQ_FIRST(&patches); cur_patch != NULL; cur_patch = STAILQ_NEXT(cur_patch,links)) { fprintf(ofile, "%s\t{ %spatch%d_func, %d, %d, %d }", cur_patch == STAILQ_FIRST(&patches) ? "" : ",\n", prefix, cur_patch->patch_func, cur_patch->begin, cur_patch->skip_instr, cur_patch->skip_patch); } fprintf(ofile, "\n};\n\n"); fprintf(ofile, "static const struct cs {\n" " uint16_t begin;\n" " uint16_t end;\n" "} critical_sections[] = {\n"); for (cs = TAILQ_FIRST(&cs_tailq); cs != NULL; cs = TAILQ_NEXT(cs, links)) { fprintf(ofile, "%s\t{ %d, %d }", cs == TAILQ_FIRST(&cs_tailq) ? "" : ",\n", cs->begin_addr, cs->end_addr); } fprintf(ofile, "\n};\n\n"); fprintf(ofile, "static const int num_critical_sections = sizeof(critical_sections)\n" " / sizeof(*critical_sections);\n"); fprintf(stderr, "%s: %d instructions used\n", appname, instrcount); } static void dump_scope(scope_t *scope) { scope_t *cur_scope; /* * Emit the first patch for this scope */ emit_patch(scope, 0); /* * Dump each scope within this one. */ cur_scope = TAILQ_FIRST(&scope->inner_scope); while (cur_scope != NULL) { dump_scope(cur_scope); cur_scope = TAILQ_NEXT(cur_scope, scope_links); } /* * Emit the second, closing, patch for this scope */ emit_patch(scope, 1); } void emit_patch(scope_t *scope, int patch) { patch_info_t *pinfo; patch_t *new_patch; pinfo = &scope->patches[patch]; if (pinfo->skip_instr == 0) /* No-Op patch */ return; new_patch = (patch_t *)malloc(sizeof(*new_patch)); if (new_patch == NULL) stop("Could not malloc patch structure", EX_OSERR); memset(new_patch, 0, sizeof(*new_patch)); if (patch == 0) { new_patch->patch_func = scope->func_num; new_patch->begin = scope->begin_addr; } else { new_patch->patch_func = 0; new_patch->begin = scope->end_addr; } new_patch->skip_instr = pinfo->skip_instr; new_patch->skip_patch = pinfo->skip_patch; STAILQ_INSERT_TAIL(&patches, new_patch, links); } void output_listing(char *ifilename) { char buf[1024]; FILE *ifile; struct instruction *cur_instr; patch_t *cur_patch; symbol_node_t *cur_func; int *func_values; int instrcount; int instrptr; int line; int func_count; int skip_addr; instrcount = 0; instrptr = 0; line = 1; skip_addr = 0; if ((ifile = fopen(ifilename, "r")) == NULL) { perror(ifilename); stop(NULL, EX_DATAERR); } /* * Determine which options to apply to this listing. */ for (func_count = 0, cur_func = SLIST_FIRST(&patch_functions); cur_func != NULL; cur_func = SLIST_NEXT(cur_func, links)) func_count++; func_values = NULL; if (func_count != 0) { func_values = (int *)malloc(func_count * sizeof(int)); if (func_values == NULL) stop("Could not malloc", EX_OSERR); func_values[0] = 0; /* FALSE func */ func_count--; /* * Ask the user to fill in the return values for * the rest of the functions. */ for (cur_func = SLIST_FIRST(&patch_functions); cur_func != NULL && SLIST_NEXT(cur_func, links) != NULL; cur_func = SLIST_NEXT(cur_func, links), func_count--) { int input; fprintf(stdout, "\n(%s)\n", cur_func->symbol->name); fprintf(stdout, "Enter the return value for " "this expression[T/F]:"); while (1) { input = getchar(); input = toupper(input); if (input == 'T') { func_values[func_count] = 1; break; } else if (input == 'F') { func_values[func_count] = 0; break; } } if (isatty(fileno(stdin)) == 0) putchar(input); } fprintf(stdout, "\nThanks!\n"); } /* Now output the listing */ cur_patch = STAILQ_FIRST(&patches); for (cur_instr = STAILQ_FIRST(&seq_program); cur_instr != NULL; cur_instr = STAILQ_NEXT(cur_instr, links), instrcount++) { if (check_patch(&cur_patch, instrcount, &skip_addr, func_values) == 0) { /* Don't count this instruction as it is in a patch * that was removed. */ continue; } while (line < cur_instr->srcline) { fgets(buf, sizeof(buf), ifile); fprintf(listfile, " \t%s", buf); line++; } fprintf(listfile, "%04x %02x%02x%02x%02x", instrptr, #ifdef __LITTLE_ENDIAN cur_instr->format.bytes[0], cur_instr->format.bytes[1], cur_instr->format.bytes[2], cur_instr->format.bytes[3]); #else cur_instr->format.bytes[3], cur_instr->format.bytes[2], cur_instr->format.bytes[1], cur_instr->format.bytes[0]); #endif /* * Macro expansions can cause several instructions * to be output for a single source line. Only * advance the line once in these cases. */ if (line == cur_instr->srcline) { fgets(buf, sizeof(buf), ifile); fprintf(listfile, "\t%s", buf); line++; } else { fprintf(listfile, "\n"); } instrptr++; } /* Dump the remainder of the file */ while(fgets(buf, sizeof(buf), ifile) != NULL) fprintf(listfile, " %s", buf); fclose(ifile); } static int check_patch(patch_t **start_patch, int start_instr, int *skip_addr, int *func_vals) { patch_t *cur_patch; cur_patch = *start_patch; while (cur_patch != NULL && start_instr == cur_patch->begin) { if (func_vals[cur_patch->patch_func] == 0) { int skip; /* Start rejecting code */ *skip_addr = start_instr + cur_patch->skip_instr; for (skip = cur_patch->skip_patch; skip > 0 && cur_patch != NULL; skip--) cur_patch = STAILQ_NEXT(cur_patch, links); } else { /* Accepted this patch. Advance to the next * one and wait for our intruction pointer to * hit this point. */ cur_patch = STAILQ_NEXT(cur_patch, links); } } *start_patch = cur_patch; if (start_instr < *skip_addr) /* Still skipping */ return (0); return (1); } /* * Print out error information if appropriate, and clean up before * terminating the program. */ void stop(const char *string, int err_code) { if (string != NULL) { fprintf(stderr, "%s: ", appname); if (yyfilename != NULL) { fprintf(stderr, "Stopped at file %s, line %d - ", yyfilename, yylineno); } fprintf(stderr, "%s\n", string); } if (ofile != NULL) { fclose(ofile); if (err_code != 0) { fprintf(stderr, "%s: Removing %s due to error\n", appname, ofilename); unlink(ofilename); } } if (regfile != NULL) { fclose(regfile); if (err_code != 0) { fprintf(stderr, "%s: Removing %s due to error\n", appname, regfilename); unlink(regfilename); } } if (listfile != NULL) { fclose(listfile); if (err_code != 0) { fprintf(stderr, "%s: Removing %s due to error\n", appname, listfilename); unlink(listfilename); } } symlist_free(&patch_functions); symtable_close(); exit(err_code); } struct instruction * seq_alloc() { struct instruction *new_instr; new_instr = (struct instruction *)malloc(sizeof(struct instruction)); if (new_instr == NULL) stop("Unable to malloc instruction object", EX_SOFTWARE); memset(new_instr, 0, sizeof(*new_instr)); STAILQ_INSERT_TAIL(&seq_program, new_instr, links); new_instr->srcline = yylineno; return new_instr; } critical_section_t * cs_alloc() { critical_section_t *new_cs; new_cs= (critical_section_t *)malloc(sizeof(critical_section_t)); if (new_cs == NULL) stop("Unable to malloc critical_section object", EX_SOFTWARE); memset(new_cs, 0, sizeof(*new_cs)); TAILQ_INSERT_TAIL(&cs_tailq, new_cs, links); return new_cs; } scope_t * scope_alloc() { scope_t *new_scope; new_scope = (scope_t *)malloc(sizeof(scope_t)); if (new_scope == NULL) stop("Unable to malloc scope object", EX_SOFTWARE); memset(new_scope, 0, sizeof(*new_scope)); TAILQ_INIT(&new_scope->inner_scope); if (SLIST_FIRST(&scope_stack) != NULL) { TAILQ_INSERT_TAIL(&SLIST_FIRST(&scope_stack)->inner_scope, new_scope, scope_links); } /* This patch is now the current scope */ SLIST_INSERT_HEAD(&scope_stack, new_scope, scope_stack_links); return new_scope; } void process_scope(scope_t *scope) { /* * We are "leaving" this scope. We should now have * enough information to process the lists of scopes * we encapsulate. */ scope_t *cur_scope; u_int skip_patch_count; u_int skip_instr_count; cur_scope = TAILQ_LAST(&scope->inner_scope, scope_tailq); skip_patch_count = 0; skip_instr_count = 0; while (cur_scope != NULL) { u_int patch0_patch_skip; patch0_patch_skip = 0; switch (cur_scope->type) { case SCOPE_IF: case SCOPE_ELSE_IF: if (skip_instr_count != 0) { /* Create a tail patch */ patch0_patch_skip++; cur_scope->patches[1].skip_patch = skip_patch_count + 1; cur_scope->patches[1].skip_instr = skip_instr_count; } /* Count Head patch */ patch0_patch_skip++; /* Count any patches contained in our inner scope */ patch0_patch_skip += cur_scope->inner_scope_patches; cur_scope->patches[0].skip_patch = patch0_patch_skip; cur_scope->patches[0].skip_instr = cur_scope->end_addr - cur_scope->begin_addr; skip_instr_count += cur_scope->patches[0].skip_instr; skip_patch_count += patch0_patch_skip; if (cur_scope->type == SCOPE_IF) { scope->inner_scope_patches += skip_patch_count; skip_patch_count = 0; skip_instr_count = 0; } break; case SCOPE_ELSE: /* Count any patches contained in our innter scope */ skip_patch_count += cur_scope->inner_scope_patches; skip_instr_count += cur_scope->end_addr - cur_scope->begin_addr; break; case SCOPE_ROOT: stop("Unexpected scope type encountered", EX_SOFTWARE); /* NOTREACHED */ } cur_scope = TAILQ_PREV(cur_scope, scope_tailq, scope_links); } }