From f1761a379fe8dbab8378279291549b2b2aefdb80 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 22 Jul 2022 06:16:37 +0900 Subject: [PATCH] Clean up debug feature. Signed-off-by: NIIBE Yutaka --- src/debug.c | 126 ---------------------------------------------------- src/debug.h | 9 ---- src/main.c | 3 -- 3 files changed, 138 deletions(-) delete mode 100644 src/debug.c delete mode 100644 src/debug.h diff --git a/src/debug.c b/src/debug.c deleted file mode 100644 index 2de4092..0000000 --- a/src/debug.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * debug.c -- Debuging with virtual COM port - * - * Copyright (C) 2010 Free Software Initiative of Japan - * Author: NIIBE Yutaka - * - * This file is a part of Gnuk, a GnuPG USB Token implementation. - * - * Gnuk 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. - * - * Gnuk 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 this program. If not, see . - * - */ - -#include -#include - -extern void _write (const char *s, int len); - -static void -put_hex (uint8_t nibble) -{ - uint8_t c; - - if (nibble < 0x0a) - c = '0' + nibble; - else - c = 'a' + nibble - 0x0a; - - _write ((const char *)&c, 1); -} - -void -put_byte (uint8_t b) -{ - put_hex (b >> 4); - put_hex (b &0x0f); - _write ("\r\n", 2); -} - -void -put_byte_with_no_nl (uint8_t b) -{ - _write (" ", 1); - put_hex (b >> 4); - put_hex (b &0x0f); -} - -void -put_short (uint16_t x) -{ - put_hex (x >> 12); - put_hex ((x >> 8)&0x0f); - put_hex ((x >> 4)&0x0f); - put_hex (x & 0x0f); - _write ("\r\n", 2); -} - -void -put_word (uint32_t x) -{ - put_hex (x >> 28); - put_hex ((x >> 24)&0x0f); - put_hex ((x >> 20)&0x0f); - put_hex ((x >> 16)&0x0f); - put_hex ((x >> 12)&0x0f); - put_hex ((x >> 8)&0x0f); - put_hex ((x >> 4)&0x0f); - put_hex (x & 0x0f); - _write ("\r\n", 2); -} - -void -put_int (uint32_t x) -{ - char s[10]; - int i; - - for (i = 0; i < 10; i++) - { - s[i] = '0' + (x % 10); - x /= 10; - if (x == 0) - break; - } - - while (i) - { - _write (s+i, 1); - i--; - } - - _write (s, 1); - _write ("\r\n", 2); -} - -void -put_binary (const char *s, int len) -{ - int i; - - for (i = 0; i < len; i++) - { - put_byte_with_no_nl (s[i]); - if ((i & 0x0f) == 0x0f) - _write ("\r\n", 2); - } - _write ("\r\n", 2); -} - -void -put_string (const char *s) -{ - _write (s, strlen (s)); -} - - diff --git a/src/debug.h b/src/debug.h deleted file mode 100644 index 091c0c5..0000000 --- a/src/debug.h +++ /dev/null @@ -1,9 +0,0 @@ -struct stdout { - chopstx_mutex_t m; - /**/ - chopstx_mutex_t m_dev; - chopstx_cond_t cond_dev; - uint8_t connected; -}; - -extern struct stdout stdout; diff --git a/src/main.c b/src/main.c index 017b624..e6c9b40 100644 --- a/src/main.c +++ b/src/main.c @@ -514,10 +514,7 @@ main (int argc, const char *argv[]) void fatal (uint8_t code) { - extern void _write (const char *s, int len); - fatal_code = code; eventflag_signal (&led_event, LED_FATAL); - _write ("fatal\r\n", 7); for (;;); }