From 2a16e08726a453232f82ff2129034d404d863c7e Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 21 Dec 2023 16:46:08 +0000 Subject: [PATCH] semihosting: Cleaned up the target controller structure and headers --- src/gdb_hostio.h | 42 ---------------------------------------- src/gdb_main.c | 17 +--------------- src/include/target.h | 15 -------------- src/target/semihosting.c | 1 - src/target/semihosting.h | 1 + 5 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 src/gdb_hostio.h diff --git a/src/gdb_hostio.h b/src/gdb_hostio.h deleted file mode 100644 index a8b949804d7..00000000000 --- a/src/gdb_hostio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of the Black Magic Debug project. - * - * Copyright (C) 2016 Black Sphere Technologies Ltd. - * Written by Gareth McMullin - * - * This program 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. - * - * This program 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 . - */ - -#ifndef GDB_HOSTIO_H -#define GDB_HOSTIO_H - -#include "target.h" - -int hostio_reply(target_controller_s *tc, char *packet, int len); - -/* Interface to host system calls */ -int hostio_open(target_controller_s *, target_addr_t path, size_t path_len, target_open_flags_e flags, mode_t mode); -int hostio_close(target_controller_s *, int fd); -int hostio_read(target_controller_s *, int fd, target_addr_t buf, unsigned int count); -int hostio_write(target_controller_s *, int fd, target_addr_t buf, unsigned int count); -long hostio_lseek(target_controller_s *, int fd, long offset, target_seek_flag_e flag); -int hostio_rename(target_controller_s *, target_addr_t oldpath, size_t old_len, target_addr_t newpath, size_t new_len); -int hostio_unlink(target_controller_s *, target_addr_t path, size_t path_len); -int hostio_stat(target_controller_s *, target_addr_t path, size_t path_len, target_addr_t buf); -int hostio_fstat(target_controller_s *, int fd, target_addr_t buf); -int hostio_gettimeofday(target_controller_s *, target_addr_t tv, target_addr_t tz); -int hostio_isatty(target_controller_s *, int fd); -int hostio_system(target_controller_s *, target_addr_t cmd, size_t cmd_len); - -#endif /* GDB_HOSTIO_H */ diff --git a/src/gdb_main.c b/src/gdb_main.c index 56b1a1e7f82..f57f4f0332e 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -32,9 +32,9 @@ #include "gdb_if.h" #include "gdb_packet.h" #include "gdb_main.h" -#include "gdb_hostio.h" #include "target.h" #include "target_internal.h" +#include "semihosting.h" #include "command.h" #include "crc32.h" #include "morse.h" @@ -111,21 +111,6 @@ static void gdb_target_printf(target_controller_s *tc, const char *fmt, va_list target_controller_s gdb_controller = { .destroy_callback = gdb_target_destroy_callback, .printf = gdb_target_printf, - -#if PC_HOSTED == 0 - .open = hostio_open, - .close = hostio_close, - .read = hostio_read, - .write = hostio_write, - .lseek = hostio_lseek, - .rename = hostio_rename, - .unlink = hostio_unlink, - .stat = hostio_stat, - .fstat = hostio_fstat, - .gettimeofday = hostio_gettimeofday, - .isatty = hostio_isatty, - .system = hostio_system, -#endif }; /* execute gdb remote command stored in 'pbuf'. returns immediately, no busy waiting. */ diff --git a/src/include/target.h b/src/include/target.h index 7554410ad8b..5146c470a4d 100644 --- a/src/include/target.h +++ b/src/include/target.h @@ -165,21 +165,6 @@ struct target_controller { void (*destroy_callback)(target_controller_s *, target_s *target); void (*printf)(target_controller_s *, const char *fmt, va_list); -#if PC_HOSTED == 0 - /* Interface to host system calls */ - int (*open)(target_controller_s *, target_addr_t path, size_t path_len, target_open_flags_e flags, mode_t mode); - int (*close)(target_controller_s *, int fd); - int (*read)(target_controller_s *, int fd, target_addr_t buf, unsigned int count); - int (*write)(target_controller_s *, int fd, target_addr_t buf, unsigned int count); - long (*lseek)(target_controller_s *, int fd, long offset, target_seek_flag_e flag); - int (*rename)(target_controller_s *, target_addr_t oldpath, size_t old_len, target_addr_t newpath, size_t new_len); - int (*unlink)(target_controller_s *, target_addr_t path, size_t path_len); - int (*stat)(target_controller_s *, target_addr_t path, size_t path_len, target_addr_t buf); - int (*fstat)(target_controller_s *, int fd, target_addr_t buf); - int (*gettimeofday)(target_controller_s *, target_addr_t tv, target_addr_t tz); - int (*isatty)(target_controller_s *, int fd); - int (*system)(target_controller_s *, target_addr_t cmd, size_t cmd_len); -#endif target_errno_e errno_; bool interrupted; }; diff --git a/src/target/semihosting.c b/src/target/semihosting.c index dc9b6985ecd..d52c7a97873 100644 --- a/src/target/semihosting.c +++ b/src/target/semihosting.c @@ -24,7 +24,6 @@ #include "target.h" #include "target_internal.h" #include "gdb_main.h" -#include "gdb_hostio.h" #include "gdb_packet.h" #include "cortexm.h" #include "semihosting.h" diff --git a/src/target/semihosting.h b/src/target/semihosting.h index 03b5691254b..6d768f17ab0 100644 --- a/src/target/semihosting.h +++ b/src/target/semihosting.h @@ -26,5 +26,6 @@ #include "general.h" int cortexm_hostio_request(target_s *target); +int hostio_reply(target_controller_s *tc, char *packet, int len); #endif /* TARGET_SEMIHOSTING_H */