intrface.h 6.3 KB

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