1 /* intrface.h: Header file for the interface of the embedded versions 2 3 Copyright (C) 2003-2004 Sebastian Reichelt 4 Copyright (C) 2003-2004 Kevin Kofler 5 Copyright (C) 2004 Billy Charvet 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 as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software Foundation, 19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20 21 #ifndef INTRFACE_H 22 #define INTRFACE_H 23 24 #include "generic.h" 25 26 // This specifies the current version of the export interface. The number has 27 // to be incremented whenever the interface changes. 28 #define CURRENT_INTERFACE_VERSION 17 29 30 // Optimization Information and Program Statistics 31 typedef struct ATTRIBUTE_PACKED { 32 const char 33 *Name; // Name of the data variable, with or without path. No data variable if NULL. 34 B2 35 CreateCopy, // Create and work on a copy of the variable. 36 CopyOnlyIfArchived; // Work on the original variable if it is not archived. 37 } DATA_VAR_INFO; 38 39 // Optimization Information and Program Statistics 40 typedef struct ATTRIBUTE_PACKED { 41 B2 42 RemoveUnused, // Remove unused sections. 43 OptimizeRelocs, // Optimize relocs for better readability in dumps. 44 OptimizeNOPs, // Optimize trailing NOPs in formats that insert them. 45 OptimizeReturns, // Optimize subroutine branches followed by RTS into jumps. 46 OptimizeBranches, // Optimize branches (e.g. to reduce relocation overhead). 47 OptimizeMoves, // Optimize move, load, and push instructions. 48 OptimizeTests, // Optimize compare and test instructions. 49 OptimizeCalcs, // Optimize calculation instructions. 50 UseFLineJumps, // Use F-Line jumps and subroutine jumps. 51 Use4ByteFLineJumps, // Use 4-byte F-Line jumps and subroutine jumps. 52 CutRanges, // Cut unneeded section ranges when optimizing. 53 ReorderSections, // Reorder sections to shorten references. 54 MergeConstants; // Merge constants and strings to avoid duplication. 55 SI4 56 ProgramSize, // Size of the on-calc program variable. 57 DataSize, // Size of the data variable. 58 BSSSize, // Size of the BSS section. 59 RelocCount, // Number of absolute relocs in the program. 60 NativeRelocCount, // Number of absolute relocs passed to the output format. 61 OptimizeBranchesResult, // Absolute relocs saved/savable by OptimizeBranches. 62 OptimizeMovesResult, // Absolute relocs saved/savable by OptimizeMoves. 63 OptimizeTestsResult, // Absolute relocs saved/savable by OptimizeTests. 64 OptimizeCalcsResult, // Absolute relocs saved/savable by OptimizeCalcs. 65 UseFLineJumpsResult, // Absolute relocs saved/savable by UseFLineJumps or Use4ByteFLineJumps. 66 CutRangesResult, // Bytes saved/savable by range-cutting. 67 NearAssemblyResult; // Bytes savable by using pc-relative assembly ('-l' option in GNU as). A value < 0 indicates that pc-relative assembly is impossible. 68 } OPTIMIZE_INFO; 69 70 // Calculator Type Enumeration 71 typedef enum { 72 // Calculator Models 73 CALC_TI92 = 0x01, CALC_TI89 = 0x02, CALC_TI92PLUS = 0x04, CALC_V200 = 0x08, 74 // Calculator Flags 75 CALC_FLAG_TITANIUM = 0x100 76 } ProgramCalcs; 77 #define HIGHEST_CALC CALC_V200 78 79 // File Role Constants (File Output) 80 typedef enum {FR_MAIN = 0, FR_DATA = 1, FR_DEBUGGING_INFO = 2} FileRoles; 81 82 // File Format Constants (File Output) 83 typedef enum {FF_NONE = -1, FF_TIOS = 0, FF_TIOS_UPGRADE = 1, FF_GDB_COFF = 2} FileFormats; 84 85 #ifdef TARGET_EMBEDDED 86 87 // This is the format of the exported GetInterfaceVersion function. 88 // The format must never change, otherwise using the wrong DLL will result in 89 // a crash. 90 #define EXP_GET_INTERFACE_VERSION() ATTRIBUTE_EXPORTED I4 GetInterfaceVersion (void) 91 extern EXP_GET_INTERFACE_VERSION (); 92 93 // Diagnostic Messages 94 typedef enum {MT_ERROR = 0, MT_WARNING = 1} MessageTypes; 95 typedef void (*ATTRIBUTE_INTERFACE ERROR_FUNCTION) (const char *FileName, const char *Text, I4 MessageType); 96 97 // File Output 98 typedef struct ATTRIBUTE_PACKED { 99 I1 *Data; // Pointer to the writable file data. 100 } INT_EXP_FILE; 101 102 typedef B2 (*ATTRIBUTE_INTERFACE OUTPUT_FILE_FUNCTION) (INT_EXP_FILE *File, I4 FileSize, I4 DestCalc, I4 FileRole, I4 FileFormat, I4 FileType, const char *Extension, B2 Executable, I4 *EffectiveSize); 103 typedef void (*ATTRIBUTE_INTERFACE OUTPUT_FILE_FINALIZE_FUNCTION) (INT_EXP_FILE *File); 104 105 // This is the format of the LinkFiles function of ld-tigcc. 106 #define EXP_LINK_FILES() ATTRIBUTE_EXPORTED I2 LinkFiles (const char **ObjectFiles, const char **ArchiveFiles, ERROR_FUNCTION ErrorMessage, OUTPUT_FILE_FUNCTION GetOutputFile, OUTPUT_FILE_FINALIZE_FUNCTION FinalizeOutputFile, B2 NativeMode, B2 FlashOS, B2 Fargo, DATA_VAR_INFO *DataVarInfo, OPTIMIZE_INFO *OptimizeInfo, B2 OmitBSSInitialization) 107 extern EXP_LINK_FILES (); 108 109 // This is the format of the CreateArchive function of ar-tigcc. 110 #define EXP_CREATE_ARCHIVE() ATTRIBUTE_EXPORTED I2 CreateArchive (const char *DestFile, const char **ObjectFiles, ERROR_FUNCTION ErrorMessage, B2 NoNames) 111 extern EXP_CREATE_ARCHIVE (); 112 113 #else /* !TARGET_EMBEDDED */ 114 115 // File Output (internal) 116 typedef struct { 117 FILE *File; // Pointer to FILE struct from stdio.h. 118 COUNT CheckSum; // Checksum of all bytes written. 119 BOOLEAN OutputBin; // Reduces the output to just the program image. 120 unsigned int FileFormat; // File format as defined in intrface.h. 121 unsigned int FileType; // File tag for FF_TIOS. 122 const char *Extension; // File extension for FF_TIOS. 123 } INT_EXP_FILE; 124 125 typedef BOOLEAN (*OUTPUT_FILE_FUNCTION) (INT_EXP_FILE *File, SIZE FileSize, unsigned int DestCalc, unsigned int FileRole, unsigned int FileFormat, unsigned int FileType, const char *Extension, BOOLEAN Executable, I4 *EffectiveSize); 126 typedef void (*OUTPUT_FILE_FINALIZE_FUNCTION) (INT_EXP_FILE *File); 127 128 #endif /* !TARGET_EMBEDDED */ 129 130 #endif 131