From: Michel Pollet Date: Wed, 17 Jan 2018 09:18:48 +0000 (+0000) Subject: shavr: Code prompt working. sim paused X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=bf1b2e1942746e359bafc3568aca9e8e7a7cdcce;p=sx%2Fsimavr.git shavr: Code prompt working. sim paused Backported more bits, updated licences, etc. Signed-off-by: Michel Pollet --- diff --git a/shavr/src/hcmd_adc.c b/shavr/src/hcmd_adc.c index 4bdd3d7..97372d0 100644 --- a/shavr/src/hcmd_adc.c +++ b/shavr/src/hcmd_adc.c @@ -1,8 +1,22 @@ -/* - * hcmd_adc.c - * - * Created on: 15 Oct 2015 - * Author: michel +/* vim: ts=4 + hcmd_adc.c + + Copyright 2017 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . */ #include diff --git a/shavr/src/hcmd_symbols.c b/shavr/src/hcmd_symbols.c index 0cf4c8f..80e5c58 100644 --- a/shavr/src/hcmd_symbols.c +++ b/shavr/src/hcmd_symbols.c @@ -1,8 +1,22 @@ -/* - * hcmd_symbols.c - * - * Created on: 15 Oct 2015 - * Author: michel +/* vim: ts=4 + hcmd_symbols.c + + Copyright 2017 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . */ #include @@ -14,6 +28,8 @@ #include "history_avr.h" +extern elf_firmware_t *code; + static const char * demangle( const char *symbol) @@ -34,12 +50,12 @@ _locate_sym( { int size = 1; avr_symbol_t * sym = NULL; - for (int i = 0; i < code.symbolcount && !sym; i++) { - if (!strcmp(demangle(code.symbol[i]->symbol), name)) { - sym = code.symbol[i]; - if (i < code.symbolcount-1) { - if ((code.symbol[i+1]->addr >> 16) == (sym->addr >> 16)) { - size = code.symbol[i+1]->addr - sym->addr; + for (int i = 0; i < code->symbolcount && !sym; i++) { + if (!strcmp(demangle(code->symbol[i]->symbol), name)) { + sym = code->symbol[i]; + if (i < code->symbolcount-1) { + if ((code->symbol[i+1]->addr >> 16) == (sym->addr >> 16)) { + size = code->symbol[i+1]->addr - sym->addr; // printf("deduced size %d\r\n", size); } } @@ -160,12 +176,12 @@ _cmd_dump( { int size = 1; avr_symbol_t * sym = NULL; - for (int i = 0; i < code.symbolcount; i++) { - sym = code.symbol[i]; + for (int i = 0; i < code->symbolcount; i++) { + sym = code->symbol[i]; size = 0; - if (i < code.symbolcount-1) { - if ((code.symbol[i+1]->addr >> 16) == (sym->addr >> 16)) - size = code.symbol[i+1]->addr - sym->addr; + if (i < code->symbolcount-1) { + if ((code->symbol[i+1]->addr >> 16) == (sym->addr >> 16)) + size = code->symbol[i+1]->addr - sym->addr; } if ((sym->addr >> 16) == 0x80 && strncmp(sym->symbol, "__", 2) && diff --git a/shavr/src/history.c b/shavr/src/history.c index 812697a..4b11fe5 100644 --- a/shavr/src/history.c +++ b/shavr/src/history.c @@ -1,8 +1,22 @@ -/* - * history.c - * - * Created on: 15 Oct 2015 - * Author: michel +/* vim: ts=4 + history.c + + Copyright 2017 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . */ #include diff --git a/shavr/src/history.h b/shavr/src/history.h index 2048c4c..bcb211d 100644 --- a/shavr/src/history.h +++ b/shavr/src/history.h @@ -1,8 +1,22 @@ -/* - * history.h - * - * Created on: 15 Oct 2015 - * Author: michel +/* vim: ts=4 + history.h + + Copyright 2017 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . */ #ifndef HISTORY_H_ diff --git a/shavr/src/history_avr.c b/shavr/src/history_avr.c index 6a67072..b3aad91 100644 --- a/shavr/src/history_avr.c +++ b/shavr/src/history_avr.c @@ -1,10 +1,23 @@ -/* - * hcmd_misc.c - * - * Created on: 15 Oct 2015 - * Author: michel - */ +/* vim: ts=4 + history_avr.c + + Copyright 2017 Michel Pollet + + This file is part of simavr. + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . + */ #include #include diff --git a/shavr/src/history_avr.h b/shavr/src/history_avr.h index 0ed153c..f49986b 100644 --- a/shavr/src/history_avr.h +++ b/shavr/src/history_avr.h @@ -1,8 +1,22 @@ -/* - * history_avr.h - * - * Created on: 18 Oct 2015 - * Author: michel +/* vim: ts=4 + history_avr.h + + Copyright 2018 Michel Pollet + + This file is part of simavr. + + simavr is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + simavr is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with simavr. If not, see . */ #ifndef _HISTORY_AVR_H_ @@ -13,10 +27,7 @@ #include "history.h" #include "history_cmd.h" -extern elf_firmware_t code; - extern avr_t * avr; - extern int history_redisplay; void history_avr_init(); diff --git a/shavr/src/shavr.c b/shavr/src/shavr.c index 5d75790..ac29e9a 100644 --- a/shavr/src/shavr.c +++ b/shavr/src/shavr.c @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 shavr.c Copyright 2017 Michel Pollet @@ -38,15 +38,16 @@ #include "sim_vcd_file.h" #include "sim_args.h" +#include "history_avr.h" uart_pty_t uart_pty; avr_t * avr = NULL; avr_vcd_t vcd_file; -elf_firmware_t code;// = {0}; +elf_firmware_t *code = NULL; avr_t * sim_prepare( - sim_args_t * a ); + sim_args_t * a ); // TODO: Move to a header typedef struct avr_flash_desc_t { @@ -101,6 +102,16 @@ avr_special_deinit( uart_pty_stop(&uart_pty); } +static void * +avr_run_thread( + void * ignore) +{ + while (1) { + avr_run(avr); + } + return NULL; +} + int main( int argc, @@ -119,23 +130,28 @@ main( exit(1); } if (args.flash_file[0]) { - strncpy(flash_data.avr_flash_path, args.flash_file, sizeof(flash_data.avr_flash_path)); + strncpy(flash_data.avr_flash_path, + args.flash_file, + sizeof(flash_data.avr_flash_path)); flash_data.avr_flash_fd = 0; // register our own functions avr->custom.init = avr_special_init; avr->custom.deinit = avr_special_deinit; avr->custom.data = &flash_data; } - avr_init(avr); uart_pty_init(avr, &uart_pty); uart_pty_connect(&uart_pty, '0'); + code = &args.f; + + history_avr_init(); + +// pthread_t run; + //pthread_create(&run, NULL, avr_run_thread, NULL); + printf("Running...\n"); while (1) { - int state = avr_run(avr); - if ( state == cpu_Done || state == cpu_Crashed) - break; + history_avr_idle(); } - } diff --git a/shavr/src/sim_args.c b/shavr/src/sim_args.c index 4fda3ef..4fe31dd 100644 --- a/shavr/src/sim_args.c +++ b/shavr/src/sim_args.c @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 sim_args.c Copyright 2017 Michel Pollet diff --git a/shavr/src/sim_args.h b/shavr/src/sim_args.h index 5365af5..0c68bb0 100644 --- a/shavr/src/sim_args.h +++ b/shavr/src/sim_args.h @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 sim_args.h Copyright 2017 Michel Pollet diff --git a/shavr/src/sim_prepare.c b/shavr/src/sim_prepare.c index 80c6c75..650d46b 100644 --- a/shavr/src/sim_prepare.c +++ b/shavr/src/sim_prepare.c @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 sim_prepare.c Copyright 2017 Michel Pollet diff --git a/shavr/src/uart_pty.c b/shavr/src/uart_pty.c index 4f4edd0..e376a34 100644 --- a/shavr/src/uart_pty.c +++ b/shavr/src/uart_pty.c @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 uart_pty.c Copyright 2008, 2009 Michel Pollet diff --git a/shavr/src/uart_pty.h b/shavr/src/uart_pty.h index c6e0603..a5f9684 100644 --- a/shavr/src/uart_pty.h +++ b/shavr/src/uart_pty.h @@ -1,4 +1,4 @@ -/* +/* vim: ts=4 uart_pty.h Copyright 2012 Michel Pollet