| 1 | /* |
| 2 | * avarice - The "avarice" program. |
| 3 | * Copyright (C) 2001 Scott Finneran |
| 4 | * Copyright (C) 2002 Intel Corporation |
| 5 | * Copyright (C) 2005 Joerg Wunsch |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License Version 2 |
| 9 | * as published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
| 19 | * |
| 20 | * This file contains functions for interfacing with the JTAG box. |
| 21 | * |
| 22 | * $Id: jtagmisc.cc 290 2011-12-12 13:24:07Z joerg_wunsch $ |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | #include <stdarg.h> |
| 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <unistd.h> |
| 30 | #include <sys/stat.h> |
| 31 | #include <termios.h> |
| 32 | #include <fcntl.h> |
| 33 | #include <string.h> |
| 34 | |
| 35 | #include "avarice.h" |
| 36 | #include "jtag.h" |
| 37 | #include "jtag1.h" |
| 38 | |
| 39 | void jtag1::setJtagParameter(uchar item, uchar newValue) |
| 40 | { |
| 41 | uchar *response = NULL; |
| 42 | uchar command[] = {'B', 0, 0, JTAG_EOM }; |
| 43 | |
| 44 | command[1] = item; |
| 45 | command[2] = newValue; |
| 46 | |
| 47 | response = doJtagCommand(command, sizeof(command), 1); |
| 48 | if (response[0] != JTAG_R_OK) |
| 49 | throw jtag_exception("Unknown parameter"); |
| 50 | |
| 51 | delete [] response; |
| 52 | } |
| 53 | |
| 54 | uchar jtag1::getJtagParameter(uchar item) |
| 55 | { |
| 56 | uchar *response = NULL; |
| 57 | uchar command[] = {'q', 0, JTAG_EOM }; |
| 58 | unsigned char result = 0; |
| 59 | |
| 60 | command[1] = item; |
| 61 | response = doJtagCommand(command, sizeof(command), 2); |
| 62 | if (response[1] != JTAG_R_OK) |
| 63 | throw jtag_exception("Unknown parameter"); |
| 64 | |
| 65 | result = response[0]; |
| 66 | |
| 67 | delete [] response; |
| 68 | |
| 69 | return result; |
| 70 | } |
| 71 | |
| 72 |