Backported more bits, updated licences, etc.
Signed-off-by: Michel Pollet <buserror@gmail.com>
-/*
- * hcmd_adc.c
- *
- * Created on: 15 Oct 2015
- * Author: michel
+/* vim: ts=4
+ hcmd_adc.c
+
+ Copyright 2017 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
-/*
- * hcmd_symbols.c
- *
- * Created on: 15 Oct 2015
- * Author: michel
+/* vim: ts=4
+ hcmd_symbols.c
+
+ Copyright 2017 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include "history_avr.h"
+extern elf_firmware_t *code;
+
static const char *
demangle(
const char *symbol)
{
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);
}
}
{
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) &&
-/*
- * history.c
- *
- * Created on: 15 Oct 2015
- * Author: michel
+/* vim: ts=4
+ history.c
+
+ Copyright 2017 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
-/*
- * history.h
- *
- * Created on: 15 Oct 2015
- * Author: michel
+/* vim: ts=4
+ history.h
+
+ Copyright 2017 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
*/
#ifndef HISTORY_H_
-/*
- * hcmd_misc.c
- *
- * Created on: 15 Oct 2015
- * Author: michel
- */
+/* vim: ts=4
+ history_avr.c
+
+ Copyright 2017 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
+ */
#include <stdlib.h>
#include <stdio.h>
-/*
- * history_avr.h
- *
- * Created on: 18 Oct 2015
- * Author: michel
+/* vim: ts=4
+ history_avr.h
+
+ Copyright 2018 Michel Pollet <buserror@gmail.com>
+
+ 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 <http://www.gnu.org/licenses/>.
*/
#ifndef _HISTORY_AVR_H_
#include "history.h"
#include "history_cmd.h"
-extern elf_firmware_t code;
-
extern avr_t * avr;
-
extern int history_redisplay;
void history_avr_init();
-/*
+/* vim: ts=4
shavr.c
Copyright 2017 Michel Pollet <buserror@gmail.com>
#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 {
uart_pty_stop(&uart_pty);
}
+static void *
+avr_run_thread(
+ void * ignore)
+{
+ while (1) {
+ avr_run(avr);
+ }
+ return NULL;
+}
+
int
main(
int argc,
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();
}
-
}
-/*
+/* vim: ts=4
sim_args.c
Copyright 2017 Michel Pollet <buserror@gmail.com>
-/*
+/* vim: ts=4
sim_args.h
Copyright 2017 Michel Pollet <buserror@gmail.com>
-/*
+/* vim: ts=4
sim_prepare.c
Copyright 2017 Michel Pollet <buserror@gmail.com>
-/*
+/* vim: ts=4
uart_pty.c
Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
-/*
+/* vim: ts=4
uart_pty.h
Copyright 2012 Michel Pollet <buserror@gmail.com>