tifiles.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* Hey EMACS -*- linux-c -*- */
  2. /* $Id: tifiles.h 3205 2007-02-24 11:09:24Z roms $ */
  3. /* libTIFILES - file format library, a part of the TiLP project
  4. * Copyright (C) 1999-2005 Romain Liévin
  5. * Copyright (C) 2007 Kevin Kofler
  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 of the License, or
  10. * (at your option) 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
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __TIFILES_H__
  22. #define __TIFILES_H__
  23. #include <stdint.h>
  24. #define TIEXPORT2 /**/
  25. #define TICALL /**/
  26. #define FILES_NCALCS 14 // # of supported calcs
  27. /**
  28. * CalcModel:
  29. *
  30. * An enumeration which contains the following calculator types:
  31. **/
  32. #if !defined(__TICONV_H__)
  33. typedef enum
  34. {
  35. CALC_NONE = 0,
  36. CALC_TI73, CALC_TI82, CALC_TI83, CALC_TI83P, CALC_TI84P, CALC_TI85, CALC_TI86,
  37. CALC_TI89, CALC_TI89T, CALC_TI92, CALC_TI92P, CALC_V200,
  38. CALC_TI84P_USB, CALC_TI89T_USB,
  39. } CalcModel;
  40. #endif
  41. /**
  42. * DeviceType:
  43. *
  44. * An enumeration which contains soem device IDs for FLASH apps:
  45. **/
  46. typedef enum
  47. {
  48. DEVICE_TYPE_83P = 0x73,
  49. DEVICE_TYPE_73 = 0x74,
  50. DEVICE_TYPE_89 = 0x98,
  51. DEVICE_TYPE_92P = 0x88,
  52. } DeviceType;
  53. /**
  54. * FlashPage:
  55. * @offset: FLASH offset (see TI link guide).
  56. * @page: FLASH page (see TI link guide).
  57. * @flag: see link guide.
  58. * @size: length of pure data (up to 16384 bytes)
  59. * @data: pure FLASH data.
  60. *
  61. * A generic structure used to store the content of a TI8x memory page for FLASH.
  62. **/
  63. typedef struct
  64. {
  65. uint16_t addr;
  66. uint16_t page;
  67. uint8_t flag;
  68. uint16_t size;
  69. uint8_t* data;
  70. } FlashPage;
  71. /**
  72. * FlashContent:
  73. * @model: a calculator model.
  74. * @revision_major:
  75. * @revision_minor:
  76. * @flags:
  77. * @object_type:
  78. * @revision_day:
  79. * @revision_month:
  80. * @revision_year:
  81. * @name: name of FLASH app or OS
  82. * @device_type: a device ID
  83. * @data_type: a type ID
  84. * @hw_id: hardware ID (used on TI9x only, 0 otherwise)
  85. * @data_length: length of pure data
  86. * @data_part: pure FLASH data (TI9x only) or license or certificate
  87. * @num_pages: number of FLASH pages (TI8x only)
  88. * @pages: NULL-terminated array of FLASH pages (TI8x only)
  89. * @next: pointer to next structure (linked list of contents)
  90. *
  91. * A generic structure used to store the content of a FLASH file (os or app).
  92. **/
  93. typedef struct _FlashContent FlashContent;
  94. struct _FlashContent
  95. {
  96. CalcModel model;
  97. //FlashHeader header;
  98. uint8_t revision_major;
  99. uint8_t revision_minor;
  100. uint8_t flags;
  101. uint8_t object_type;
  102. uint8_t revision_day;
  103. uint8_t revision_month;
  104. uint16_t revision_year;
  105. char name[9];
  106. uint8_t device_type;
  107. uint8_t data_type;
  108. uint8_t hw_id;
  109. uint32_t data_length;
  110. uint8_t* data_part; // TI9x only
  111. int num_pages; // TI8x only
  112. FlashPage** pages; // TI8x only
  113. FlashContent* next; // TI9x only
  114. };
  115. /* Functions */
  116. // namespace scheme: library_class_function like tifiles_fext_get
  117. #ifdef __cplusplus
  118. extern "C" {
  119. #endif
  120. /*********************/
  121. /* General functions */
  122. /*********************/
  123. // filetypes.c
  124. TIEXPORT2 int TICALL tifiles_file_is_ti (const char *filename);
  125. TIEXPORT2 int TICALL tifiles_file_is_os(const char *filename);
  126. TIEXPORT2 int TICALL tifiles_file_is_tib (const char *filename);
  127. TIEXPORT2 int TICALL tifiles_file_is_flash (const char *filename);
  128. TIEXPORT2 CalcModel TICALL tifiles_file_get_model (const char *filename);
  129. // filesXX.c
  130. TIEXPORT2 FlashContent* TICALL tifiles_content_create_flash(CalcModel model);
  131. TIEXPORT2 int TICALL tifiles_content_delete_flash(FlashContent *content);
  132. TIEXPORT2 int TICALL tifiles_file_read_flash(const char *filename, FlashContent *content);
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif