list.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* list.h: List model definitions
  2. Copyright (C) 2003 Sebastian Reichelt, Kevin Kofler
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  14. #ifndef INSERT_MODEL_RELOC_H
  15. #define INSERT_MODEL_RELOC_H
  16. #include "../../generic.h"
  17. #include "../../data.h"
  18. // *** Generic ***
  19. // A type for a function implementing a reloc model. SourceSection is
  20. // the section whose relocs are to be determined. If Count is true,
  21. // the function must return the number of items; otherwise it must
  22. // return the location of the next item in SourceSection, or -1 if
  23. // there is no next item. NextItem may never be NULL; but the data it
  24. // points to is NULL in the first call. If it is NULL after a call,
  25. // this means that no more items follow.
  26. // If some user data is optional, then the list model will usually
  27. // fill it with information about the current item.
  28. typedef OFFSET (LIST_MODEL) (SECTION *SourceSection, void **NextItem, void *UserData, BOOLEAN Count, BOOLEAN Emit);
  29. // Get the number of items from the LIST_MODEL passed to the
  30. // function via the Model parameter, for a particular source section.
  31. COUNT GetSectionItemCount (LIST_MODEL *Model, SECTION *SourceSection, void *UserData);
  32. // Get the number of items from the LIST_MODEL passed to the
  33. // function via the Model parameter. If SourceSection is NULL, loop
  34. // through all sections in the program.
  35. COUNT GetItemCount (LIST_MODEL *Model, PROGRAM *Program, SECTION *SourceSection, void *UserData);
  36. // *** Relocs ***
  37. // User data for RelocListModel.
  38. typedef struct {
  39. SECTION *TargetSection; // If non-NULL, identifies the section the relocs must point to.
  40. } RELOC_USER_DATA;
  41. // A LIST_MODEL for relocs. This list model will return all relocs
  42. // in SourceSection (that point to TargetSection if it is not NULL).
  43. OFFSET RelocListModel (SECTION *SourceSection, RELOC **NextItem, RELOC_USER_DATA *UserData, BOOLEAN Count, BOOLEAN Emit);
  44. // *** ROM Calls ***
  45. // A structured type for a used ROM call.
  46. typedef struct {
  47. COUNT RelocCount; // The number of references to this ROM call.
  48. } ROM_CALL_FUNCTION_DATA;
  49. // User data for ROMCallListModel.
  50. typedef struct {
  51. ROM_CALL_FUNCTION_DATA *ROMFunctions; // Information about the ROM calls used in the program, as an array with the ROM call number as the index.
  52. COUNT ROMFunctionCount; // Number of used ROM calls.
  53. OFFSET CurFunction; // Current ROM call number for which to count/return references (if >= 0).
  54. } ROM_CALL_USER_DATA;
  55. // A LIST_MODEL for ROM calls. This list model will return all ROM calls
  56. // in SourceSection (that point to CurFunction if it is >= 0).
  57. OFFSET ROMCallListModel (SECTION *SourceSection, ROM_CALL **NextItem, ROM_CALL_USER_DATA *UserData, BOOLEAN Count, BOOLEAN Emit);
  58. // *** RAM Calls ***
  59. // Available types of RAM calls.
  60. typedef enum {RT_RAM_CALL_4 = 0, RT_EXTRA_RAM_4 = 1, RT_RAM_CALL_2 = 2, RT_EXTRA_RAM_2 = 3, RT_ALL_TYPES = -1, RT_UNSUPPORTED = -2} RAM_CALL_TYPE;
  61. #define RAM_CALL_TYPE_COUNT 4
  62. #define GetRAMCallType(RAMCall) ((RAMCall)->Size == 4 ? ((RAMCall)->ExtraRAMAddr ? RT_EXTRA_RAM_4 : RT_RAM_CALL_4) : (RAMCall)->Size == 2 ? ((RAMCall)->ExtraRAMAddr ? RT_EXTRA_RAM_2 : RT_RAM_CALL_2) : RT_UNSUPPORTED)
  63. // A structured type for a used RAM call (with a specific type).
  64. typedef struct {
  65. COUNT RelocCount; // The number of references to this RAM call.
  66. } RAM_CALL_FUNCTION_DATA;
  67. // A structured type for a RAM call type, containing all RAM calls available for it.
  68. typedef struct {
  69. RAM_CALL_FUNCTION_DATA *Functions; // Information about the RAM calls used with this type, as an array with the RAM call number as the index.
  70. COUNT FunctionCount; // The number of RAM calls used in this type.
  71. } RAM_CALL_TYPE_DATA;
  72. // User data for RAMCallListModel.
  73. typedef struct {
  74. RAM_CALL_TYPE_DATA RAMTypes[RAM_CALL_TYPE_COUNT]; // Information about the RAM calls used in the program, sorted by type.
  75. COUNT RAMFunctionCount; // The total number of RAM calls used in the program.
  76. RAM_CALL_TYPE CurType; // Current RAM call type to count/return, or RT_ALL_TYPES.
  77. OFFSET CurFunction; // Current RAM call number for which to count/return references (if >= 0).
  78. } RAM_CALL_USER_DATA;
  79. // A LIST_MODEL for RAM calls. This list model will return all ROM calls
  80. // in SourceSection (of type CurType if it is not RT_ALL_TYPES, that point
  81. // to CurFunction if it is >= 0).
  82. OFFSET RAMCallListModel (SECTION *SourceSection, RAM_CALL **NextItem, RAM_CALL_USER_DATA *UserData, BOOLEAN Count, BOOLEAN Emit);
  83. // A structured type for an imported function in a library.
  84. typedef struct {
  85. COUNT RelocCount; // The number of references to this library export.
  86. } LIB_FUNCTION_DATA;
  87. // Extra information about each library.
  88. typedef struct {
  89. LIBRARY *Lib; // The library this data belongs to.
  90. LIB_FUNCTION_DATA *Functions; // Information about the library exports used in the program.
  91. COUNT FunctionCount; // The number of library exports used.
  92. } LIB_DATA;
  93. // User data for LibCallListModel.
  94. typedef struct {
  95. COUNT LibCount; // The number of libraries in the Libs field.
  96. LIB_DATA *Libs; // An array of all libraries used in the program, with additional information.
  97. COUNT UsedLibCount; // The number of libraries actually referenced.
  98. COUNT LibFunctionCount; // The total number of library exports used in the program.
  99. LIBRARY *CurLibrary; // Pointer to the library of the current item (output only).
  100. OFFSET CurLib; // Current library (from Libs) for which to count/return references (if >= 0).
  101. OFFSET CurFunction; // Current library export for which to count/return references (if >= 0).
  102. } LIB_CALL_USER_DATA;
  103. // A LIST_MODEL for library calls. This list model will return all library
  104. // calls in SourceSection (that point to CurFunction in CurLib if they are
  105. // >= 0).
  106. OFFSET LibCallListModel (SECTION *SourceSection, LIB_CALL **NextItem, LIB_CALL_USER_DATA *UserData, BOOLEAN Count, BOOLEAN Emit);
  107. #endif