slotdrvrlib.pp 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. {$MACRO ON}
  2. (******************************************************************************
  3. *
  4. * Copyright (c) 1998-2000 Palm, Inc. or its subsidiaries.
  5. * All rights reserved.
  6. *
  7. * File: SlotDrvrLib.h
  8. *
  9. * Release: Palm OS SDK 4.0 (63220)
  10. *
  11. * Description:
  12. * Sample Slot Driver library implementation.
  13. *
  14. * History:
  15. * 02/25/00 Created by Steve Minns
  16. * 09/15/00 lrt Updated CardMetricsType stucture to include more
  17. * useful fields, inc'd API Version
  18. *
  19. *****************************************************************************)
  20. unit slotdrvrlib;
  21. interface
  22. uses palmos, libtraps, expansionmgr;
  23. const
  24. slotDrvrAPIVersion = $00000002;
  25. // The number of bytes per sector is fixed
  26. slotSectorSize = 512;
  27. (********************************************************************
  28. * Card Metrics
  29. * These structures contains all of the information about the physical
  30. * structure of the card that may be needed by a filesystem in order
  31. * to format volumes on the card.
  32. ********************************************************************)
  33. slotDrvrPartitionTypeFAT12 = $01;
  34. slotDrvrPartitionTypeFAT16Under32MB = $04;
  35. slotDrvrPartitionTypeFAT16Over32MB = $06;
  36. slotDrvrBootablePartition = $80;
  37. slotDrvrNonBootablePartition = $00;
  38. type
  39. CardMetricsType = record
  40. totalSectors: UInt32; // The total number of sectors accessable via SlotCardSector[Read/Write]
  41. // (some media may contain extra sectors in case one goes bad,
  42. // or for storing configuration information, but they are handled
  43. // internally to the slot driver, and not accessable)
  44. bytesPerSector: UInt16; // The number of bytes in one sector.
  45. // currently for Palm, this must be the standard 512
  46. sectorsPerHead: UInt16; // The number of Sectors per Head
  47. // as given by guidelines in the specification for this media type
  48. // even though all of our disks accesses are LBA,
  49. // this is for compatibility when filling out MBRs and PBRs
  50. // if the media guidelines don't care, this value is set to 0
  51. headsPerCylinder: UInt16; // The number of Heads per Cylinder
  52. // as given by guidelines in the specification for this media type
  53. // even though all of our disks accesses are LBA,
  54. // this is for compatibility when filling out MBRs and PBRs
  55. // if the media guidelines don't care, this value is set to 0
  56. reserved1: UInt16; // Reserved
  57. sectorsPerBlock: UInt8; // A suggested number of Sectors per Block (Cluster)
  58. // as given by guidelines in the specification for this media type
  59. // if the media guidelines don't care, this value will be set to 0
  60. partitionType: UInt8; // The suggested partition type (System ID) of the first partition
  61. // as given by guidelines in the specification for this media type
  62. // if the media guidelines don't care, this value will be set to 0
  63. bootIndicator: UInt8; // The suggested bootability of the first partition
  64. // as given by guidelines in the specification for this media type
  65. // (generally, 0x80=bootable, default boot partition 0x00=not-bootable)
  66. // if the media guidelines don't care, this value will be set to 0xFF
  67. reserved2: UInt8; // Reserved
  68. partitionStart: UInt32; // The suggested starting sector of the first partition
  69. // as given by guidelines in the specification for this media type
  70. // if this value is set to zero, and the partitionSize value is non-zero
  71. // the media guidelines suggest to not use an MBR, and only use a PBR at sector 0
  72. // if the media guidelines don't care, the partitionSize value will be set to 0
  73. partitionSize: UInt32; // The suggested size of the first partition
  74. // as given by guidelines in the specification for this media type
  75. // if the media guidelines don't care, this value will be set to 0, and
  76. // the partitionStart parameter is also ignored
  77. end;
  78. CardMetricsTag = CardMetricsType;
  79. CardMetricsPtr = ^CardMetricsType;
  80. (********************************************************************
  81. * SlotDrvr library function trap ID's. Each library call gets a trap number:
  82. * SlotDrvrLibTrapXXXX which serves as an index into the library's dispatch table.
  83. * The constant sysLibTrapCustom is the first available trap number after
  84. * the system predefined library traps Open,Close,Sleep & Wake.
  85. *
  86. * WARNING!!! The order of these traps MUST match the order of the dispatch
  87. * table in SlotDrvrLibDispatch.c!!!
  88. ********************************************************************)
  89. const
  90. SlotTrapLibAPIVersion = sysLibTrapCustom;
  91. SlotTrapCustomControl = sysLibTrapCustom + 1;
  92. SlotTrapCardPresent = sysLibTrapCustom + 2;
  93. SlotTrapCardInfo = sysLibTrapCustom + 3;
  94. SlotTrapCardMediaType = sysLibTrapCustom + 4;
  95. SlotTrapCardIsFilesystemSupported = sysLibTrapCustom + 5;
  96. SlotTrapCardMetrics = sysLibTrapCustom + 6;
  97. SlotTrapCardLowLevelFormat = sysLibTrapCustom + 7;
  98. SlotTrapCardSectorRead = sysLibTrapCustom + 8;
  99. SlotTrapCardSectorWrite = sysLibTrapCustom + 9;
  100. SlotTrapPowerCheck = sysLibTrapCustom + 10;
  101. SlotTrapMediaType = sysLibTrapCustom + 11;
  102. SlotTrapCardReserve = sysLibTrapCustom + 12;
  103. SlotTrapCardRelease = sysLibTrapCustom + 13;
  104. SlotTrapCardGetSerialPort = sysLibTrapCustom + 14;
  105. (********************************************************************
  106. * API Prototypes
  107. ********************************************************************)
  108. (********************************************************************
  109. * Standard library open, close, sleep and wake functions
  110. ********************************************************************)
  111. function SlotOpen(slotLibRefNum: UInt16): Err; syscall sysLibTrapOpen;
  112. function SlotClose(slotLibRefNum: UInt16): Err; syscall sysLibTrapClose;
  113. function SlotSleep(slotLibRefNum: UInt16): Err; syscall sysLibTrapSleep;
  114. function SlotWake(slotLibRefNum: UInt16): Err; syscall sysLibTrapWake;
  115. (********************************************************************
  116. * Custom library API functions
  117. ********************************************************************)
  118. function SlotLibAPIVersion(slotLibRefNum: UInt16):UInt32; syscall SlotTrapLibAPIVersion;
  119. function SlotCustomControl(slotLibRefNum: UInt16; apiCreator: UInt32; apiSelector: UInt16; valueP: Pointer; var valueLenP: UInt16): Err; syscall SlotTrapCustomControl;
  120. function SlotCardPresent(slotLibRefNum: UInt16; slotRefNum: UInt16): Err; syscall SlotTrapCardPresent;
  121. function SlotCardInfo(slotLibRefNum, slotRefNum: UInt16; var infoP: ExpCardInfoType): Err; syscall SlotTrapCardInfo;
  122. function SlotCardMediaType(slotLibRefNum, slotRefNum: UInt16; var mediaTypeP: UInt32): Err; syscall SlotTrapCardMediaType;
  123. function SlotCardReserve(slotLibRefNum, slotRefNum: UInt16): Err; syscall SlotTrapCardReserve;
  124. function SlotCardRelease(slotLibRefNum, slotRefNum: UInt16): Err; syscall SlotTrapCardRelease;
  125. function SlotCardGetSerialPort(slotLibRefNum, slotRefNum: UInt16; var portP: UInt32): Err; syscall SlotTrapCardGetSerialPort;
  126. (********************************************************************
  127. * SlotDriver Formatting APIs:
  128. ********************************************************************)
  129. function SlotCardIsFilesystemSupported(slotLibRefNum, slotRefNum: UInt16; filesystemType: UInt32): Boolean; syscall SlotTrapCardIsFilesystemSupported;
  130. function SlotCardMetrics(slotLibRefNum, slotRefNum: UInt16; cardMetricsP: CardMetricsPtr): Err; syscall SlotTrapCardMetrics;
  131. function SlotCardLowLevelFormat(slotLibRefNum, slotRefNum: UInt16): Err; syscall SlotTrapCardLowLevelFormat;
  132. (********************************************************************
  133. * SlotDriver Logical Block Read/Write APIs:
  134. ********************************************************************)
  135. function SlotCardSectorRead(slotLibRefNum, slotRefNum: UInt16; sectorNumber: UInt32; var bufferP: UInt8; var numSectorsP: UInt32): Err; syscall SlotTrapCardSectorRead;
  136. function SlotCardSectorWrite(slotLibRefNum, slotRefNum: UInt16; sectorNumber: UInt32; var bufferP: UInt8; var numSectorsP: UInt32): Err; syscall SlotTrapCardSectorWrite;
  137. (********************************************************************
  138. * Power Mgmt APIs:
  139. ********************************************************************)
  140. const
  141. slotLibPowerFlag_WakeUp = $0001; // Add the power required to bring the slot hardware out of low-power mode
  142. slotLibPowerFlag_FormatMedia = $0002; // Add the power required to perform a low-level format of the card media
  143. function SlotPowerCheck(slotLibRefNum, slotRefNum, operationFlags, readBlocks, writeBlocks: UInt16): Err; syscall SlotTrapPowerCheck;
  144. implementation
  145. end.