summaryrefslogtreecommitdiff
path: root/src/target/image.h
diff options
context:
space:
mode:
authordrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-05-29 12:04:20 +0000
committerdrath <drath@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2007-05-29 12:04:20 +0000
commitcbefac0be0b1b633b8d34cf75839de67064e90e2 (patch)
tree2b8b0783febb94b5a2ebb9da183ca216e7dbd9f7 /src/target/image.h
parent237e894805dd757cc24029af1b4b1e824c51712b (diff)
downloadopenocd+libswd-cbefac0be0b1b633b8d34cf75839de67064e90e2.tar.gz
openocd+libswd-cbefac0be0b1b633b8d34cf75839de67064e90e2.tar.bz2
openocd+libswd-cbefac0be0b1b633b8d34cf75839de67064e90e2.tar.xz
openocd+libswd-cbefac0be0b1b633b8d34cf75839de67064e90e2.zip
- add missing image handling files
git-svn-id: svn://svn.berlios.de/openocd/trunk@156 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target/image.h')
-rw-r--r--src/target/image.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/target/image.h b/src/target/image.h
new file mode 100644
index 00000000..3df175a8
--- /dev/null
+++ b/src/target/image.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2007 by Dominic Rath *
+ * Dominic.Rath@gmx.de *
+ * *
+ * 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 2 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef IMAGE_H
+#define IMAGE_H
+
+#include "fileio.h"
+#include "target.h"
+
+#define IMAGE_MAX_ERROR_STRING (128)
+
+typedef enum image_type
+{
+ IMAGE_BINARY, /* plain binary */
+ IMAGE_IHEX, /* intel hex-record format */
+ IMAGE_MEMORY, /* target-memory pseudo-image */
+/*
+ * Possible future enhancements:
+ * IMAGE_ELF,
+ * IMAGE_SRECORD,
+ */
+} image_type_t;
+
+typedef struct image_s
+{
+ image_type_t type; /* image type (plain, ihex, ...) */
+ void *type_private; /* type private data */
+ int base_address_set; /* whether the image start address has been set */
+ u32 base_address; /* base address of image in target memory */
+ int start_address_set; /* whether the image has a start address (entry point) associated */
+ u32 start_address; /* start address, if one is set */
+ u32 size; /* image size in byte */
+ char error_str[IMAGE_MAX_ERROR_STRING];
+} image_t;
+
+typedef struct image_binary_s
+{
+ fileio_t fileio;
+} image_binary_t;
+
+typedef struct image_ihex_s
+{
+ fileio_t fileio;
+ u32 position;
+ u32 raw_size;
+ u8 *buffer;
+} image_ihex_t;
+
+typedef struct image_memory_s
+{
+ target_t *target;
+} image_memory_t;
+
+extern int image_open(image_t *image, void *source, enum fileio_access access);
+extern int image_read(image_t *image, u32 size, u8 *buffer, u32 *size_written);
+extern int image_write(image_t *image, u32 size, u8 *buffer, u32 *size_written);
+extern int image_close(image_t *image);
+extern int identify_image_type(image_type_t *type, char *type_string);
+
+#define ERROR_IMAGE_FORMAT_ERROR (-1400)
+#define ERROR_IMAGE_TYPE_UNKNOWN (-1401)
+
+#endif /* IMAGE_H */