systemmgr.pp 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. {$MACRO ON}
  2. {$define Rsc := }
  3. (******************************************************************************
  4. *
  5. * Copyright (c) 1994-2000 Palm, Inc. or its subsidiaries.
  6. * All rights reserved.
  7. *
  8. * File: SystemMgr.h
  9. *
  10. * Release: Palm OS SDK 4.0 (63220)
  11. *
  12. * Description:
  13. * Pilot system equates
  14. *
  15. * History:
  16. * 10/27/94 RM Created by Ron Marianetti
  17. * 10/07/96 SCL Added sysAppLaunchFlagDataRelocated flag
  18. * 11/13/96 vmk Added sysErrDelayWakened error code
  19. * 08/12/98 dia Added sysFtrNumGremlinsSupportGlobals.
  20. * 08/18/98 SCL Added sysFtrNumHwrMiscFlags and ...FlagsExt.
  21. * Redefined sysFtrNumProcessorID.
  22. * 08/23/98 SCL Merged in tsmErrorClass.
  23. * 09/07/98 kwk Added SysWantEvent routine declaration.
  24. * 10/05/98 jfs Added SysLCDContrast trap descriptor
  25. * 04/08/99 kwk Added sysFtrNumVendor (OS 3.3 and later)
  26. * 06/28/99 kwk Added omErrorClass.
  27. * 08/11/99 kwk Added sysFtrNumCharEncodingFlags.
  28. * 11/01/99 kwk Moved SysWantEvent to SystemPrv.h
  29. * 12/03/99 SCL Moved SysAppInfoType, SysAppStartup, and SysAppExit
  30. * here from SystemPrv.h (for StartupCode/Runtime)
  31. * 07/19/00 gap Added launch code sysAppLaunchCmdAttention for use by
  32. * Attention Manager
  33. * 7/26/00 jhl Integrate HSIMgr functionality
  34. * 09/22/00 BGT Integrated sysAppLaunchNppiNoUI and sysAppLaunchNppiUI
  35. *
  36. *****************************************************************************)
  37. unit systemmgr;
  38. interface
  39. uses palmos, coretraps, libtraps, errorbase, bitmap, datamgr, systemresources, event_;
  40. (************************************************************
  41. * System Constants
  42. *************************************************************)
  43. // Define the number of ticks/second
  44. // NOTE: It is strongly recommended that developers avoid using these
  45. // defines, and use the SysTicksPerSecond() API (below) instead....
  46. //#if EMULATION_LEVEL == EMULATION_MAC
  47. // #define sysTicksPerSecond 60 // 60/sec on Macintosh
  48. //#elif EMULATION_LEVEL == EMULATION_NONE
  49. const
  50. sysTicksPerSecond_ = 100; // 100/sec on Pilot
  51. //#elif EMULATION_LEVEL == EMULATION_WINDOWS
  52. // #define sysTicksPerSecond 1000 // 1000/sec on Windows PC
  53. //#elif EMULATION_LEVEL == EMULATION_UNIX
  54. // #define sysTicksPerSecond 1000
  55. // // 1000/sec on Linux
  56. //#else
  57. // #error Invalid EMULATION_LEVEL
  58. //#endif
  59. (************************************************************
  60. * Rules for creating and using the Command Parameter Block
  61. * passed to SysUIAppSwitch
  62. *************************************************************)
  63. // A parameter block containing application-specific information may be passed
  64. // to an application when launching it via SysUIAppSwitch. To create the
  65. // parameter block, you allocate a memory block using MemPtrNew and then you must
  66. // call MemPtrSetOwner to set the block's owner ID to 0. This assigns the block's
  67. // ownership to the system so that it will not be automatically freed by the system
  68. // when the calling app exits. The command block must be self contained. It must not
  69. // have pointers to anything on the stack or in memory blocks owned by an application.
  70. // The launching and launched applications do not need to worry about freeing the
  71. // command block since the system will do this after the launched application exits.
  72. // If no parameter block is being passed, this parameter must be NULL.
  73. (************************************************************
  74. * Action Codes
  75. *
  76. * IMPORTANT ACTION CODE CONSIDERATIONS:
  77. *
  78. * Many action codes are "sent" to apps via a direct function call into the app's
  79. * PilotMain() function without launching the app. For these action codes, the
  80. * application's global and static variables are *not* available, unless the
  81. * application is already running. Some action codes are synchronized with the
  82. * currently running UI applcation via the event manager (alarm action codes,
  83. * for example), while others, such as HotSync action codes, are sent from a
  84. * background thread. To find out if your app is running (is the current UI
  85. * app) when an action code is received, test the sysAppLaunchFlagSubCall flag
  86. * (defined in SystemMgr.h) which is passed to your PilotMain in the
  87. * launchFlags parameter (the third PilotMain parameter). If it is non-zero,
  88. * you may assume that your app is currently running and the global variables
  89. * are accessible. This information is useful if your app maintains an open
  90. * data database (or another similar resource) when it is running. If the app
  91. * receives an action code and the sysAppLaunchFlagSubCall is set in
  92. * launchFlags, the handler may access global variables and use the open
  93. * database handle while handling the call. On the other hand, if the
  94. * sysAppLaunchFlagSubCall flag is not set (ie., zero), the handler will need
  95. * to open and close the database itself and is not allowed to access global
  96. * or static variables.
  97. *
  98. *************************************************************)
  99. // NOTE: for defining custom action codes, see sysAppLaunchCmdCustomBase below.
  100. // System SysAppLaunch Commands
  101. const
  102. sysAppLaunchCmdNormalLaunch = 0; // Normal Launch
  103. sysAppLaunchCmdFind = 1; // Find string
  104. sysAppLaunchCmdGoTo = 2; // Launch and go to a particular record
  105. sysAppLaunchCmdSyncNotify = 3; // Sent to apps whose databases changed during
  106. // HotSync after the sync has been completed,
  107. // including when the app itself has been installed
  108. // by HotSync. The data database(s) must have the
  109. // same creator ID as the application for this
  110. // mechanism to function correctly. This is a
  111. // good opportunity to update/initialize/validate
  112. // the app's data, such as resorting records,
  113. // setting alarms, etc.
  114. //
  115. // Parameter block: None.
  116. // Restrictions: No accessing of global or
  117. // static variables; no User Interface calls.
  118. // Notes: This action code is sent via a
  119. // direct function call into the app's
  120. // PilotMain function from the background
  121. // thread of the HotSync application.
  122. sysAppLaunchCmdTimeChange = 4; // Sent to all applications and preference
  123. // panels when the system time is changed.
  124. // This notification is the right place to
  125. // update alarms and other time-related
  126. // activities and resources.
  127. //
  128. // Parameter block: None.
  129. // Restrictions: No accessing of global or
  130. // static variables; no User Interface calls.
  131. // Notes: This action code is sent via a direct
  132. // function call into the app's PilotMain
  133. // function without "launching" the app.
  134. sysAppLaunchCmdSystemReset = 5; // Sent to all applications and preference
  135. // panels when the system is either soft-reset
  136. // or hard-reset. This notification is the
  137. // right place to initialize and/or validate
  138. // your application's preferences/features/
  139. // database(s) as well as to update alarms and
  140. // other time-related activities and resources.
  141. //
  142. // Parameter block: SysAppLaunchCmdSystemResetType
  143. // Restrictions: No accessing of global or
  144. // static variables; no User Interface calls.
  145. // Notes: This action code is sent via a direct
  146. // function call into the app's PilotMain
  147. // function without "launching" the app.
  148. sysAppLaunchCmdAlarmTriggered = 6; // Sent to an application at the time its
  149. // alarm time expires (even when another app
  150. // is already displaying its alarm dialog box).
  151. // This call is intended to allow the app to
  152. // perform some very quick activity, such as
  153. // scheduling the next alarm or performing a
  154. // quick maintenance task. The handler for
  155. // sysAppLaunchCmdAlarmTriggered must take as
  156. // little time as possible and is *not* allowed
  157. // to block (this would delay notification for
  158. // alarms set by other applications).
  159. //
  160. // Parameter block: SysAlarmTriggeredParamType
  161. // (defined in AlarmMgr.h)
  162. // Restrictions: No accessing of global or
  163. // static variables unless sysAppLaunchFlagSubCall
  164. // flag is set, as discussed above.
  165. // Notes: This action code is sent via a direct
  166. // function call into the app's PilotMain
  167. // function without "launching" the app.
  168. sysAppLaunchCmdDisplayAlarm = 7; // Sent to an application when it is time
  169. // to display the alarm UI. The application
  170. // is responsible for making any alarm sounds
  171. // and for displaying the alarm UI.
  172. // sysAppLaunchCmdDisplayAlarm calls are ordered
  173. // chronoligically and are not overlapped.
  174. // This means that your app will receive
  175. // sysAppLaunchCmdDisplayAlarm only after
  176. // all earlier alarms have been displayed.
  177. //
  178. // Parameter block: SysDisplayAlarmParamType
  179. // (defined in AlarmMgr.h)
  180. // Restrictions: No accessing of global or
  181. // static variables unless sysAppLaunchFlagSubCall
  182. // flag is set, as discussed above. UI calls are
  183. // allowed to display the app's alarm dialog.
  184. // Notes: This action code is sent via a direct
  185. // function call into the app's PilotMain
  186. // function without "launching" the app.
  187. sysAppLaunchCmdCountryChange = 8; // The country has changed
  188. sysAppLaunchCmdSyncRequestLocal = 9; // Sent to the HotSync application to request a
  189. // local HotSync. ("HotSync" button was pressed.)
  190. sysAppLaunchCmdSyncRequest = sysAppLaunchCmdSyncRequestLocal; // for backward compatibility
  191. sysAppLaunchCmdSaveData = 10; // Sent to running app before sysAppLaunchCmdFind
  192. // or other action codes that will cause data
  193. // searches or manipulation.
  194. sysAppLaunchCmdInitDatabase = 11; // Sent to an application when a database with
  195. // a matching Creator ID is created during
  196. // HotSync (in response to a "create db"
  197. // request). This allows the application to
  198. // initialize a newly-created database during
  199. // HotSync. This might include creating some
  200. // default records, setting up the database's
  201. // application and sort info blocks, etc.
  202. //
  203. // Parameter block: SysAppLaunchCmdInitDatabaseType
  204. // Restrictions: No accessing of global or
  205. // static variables; no User Interface calls.
  206. // Notes: This action code is sent via a
  207. // direct function call into the app's
  208. // PilotMain function from the background
  209. // thread of the HotSync application.
  210. sysAppLaunchCmdSyncCallApplicationV10 = 12; // Used by DesktopLink Server command "call application";
  211. // Pilot v1.0 only!!!
  212. //------------------------------------------------------------------------
  213. // New launch codes defined for PalmOS 2.0
  214. //------------------------------------------------------------------------
  215. sysAppLaunchCmdPanelCalledFromApp = 13; // The panel should display a done
  216. // button instead of the pick list.
  217. // The Done button will return the user
  218. // to the last app.
  219. sysAppLaunchCmdReturnFromPanel = 14; // A panel returned to this app
  220. sysAppLaunchCmdLookup = 15; // Lookup info managed by an app
  221. sysAppLaunchCmdSystemLock = 16; // Lock the system until a password is entered.
  222. sysAppLaunchCmdSyncRequestRemote = 17; // Sent to the HotSync application to request
  223. // a remote HotSync. ("Remote HotSync" button
  224. // was pressed.)
  225. sysAppLaunchCmdHandleSyncCallApp = 18; // Pilot v2.0 and greater. Sent by DesktopLink Server to an application to handle
  226. // the "call application" command; use DlkControl with
  227. // control code dlkCtlSendCallAppReply to send the reply(see DLServer.h).
  228. // This action code replaces the v1.0 code sysAppLaunchCmdSyncCallApplication.
  229. // vmk 11/26/96
  230. sysAppLaunchCmdAddRecord = 19; // Add a record to an applications's database.
  231. //------------------------------------------------------------------------
  232. // Standard Service Panel launch codes (used by network panel, dialer panel, etc.)
  233. //------------------------------------------------------------------------
  234. sysSvcLaunchCmdSetServiceID = 20;
  235. sysSvcLaunchCmdGetServiceID = 21;
  236. sysSvcLaunchCmdGetServiceList = 22;
  237. sysSvcLaunchCmdGetServiceInfo = 23;
  238. sysAppLaunchCmdFailedAppNotify = 24; // An app just switched to failed.
  239. sysAppLaunchCmdEventHook = 25; // Application event hook callback
  240. sysAppLaunchCmdExgReceiveData = 26; // Exg command for app to receive data.
  241. sysAppLaunchCmdExgAskUser = 27; // Exg command sent before asking user.
  242. //------------------------------------------------------------------------
  243. // Standard Dialer Service launch codes (30 - 39 reserved)
  244. //------------------------------------------------------------------------
  245. // sysDialLaunchCmdDial: dials the modem(optionally displays dial progress UI), given service id
  246. // and serial library reference number
  247. sysDialLaunchCmdDial = 30;
  248. // sysDialLaunchCmdHangUp: hangs up the modem(optionally displays disconnect progress UI), given service id
  249. // and serial library reference number
  250. sysDialLaunchCmdHangUp = 31;
  251. sysDialLaunchCmdLast = 39;
  252. //------------------------------------------------------------------------
  253. // Additional standard Service Panel launch codes (used by network panel, dialer panel, etc)
  254. // (40-49 reserved)
  255. //------------------------------------------------------------------------
  256. sysSvcLaunchCmdGetQuickEditLabel = 40; // SvcQuickEditLabelInfoType
  257. sysSvcLaunchCmdLast = 49;
  258. //------------------------------------------------------------------------
  259. // New launch codes defined for PalmOS 3.x where x >= 1
  260. //------------------------------------------------------------------------
  261. sysAppLaunchCmdURLParams = 50; // Sent from the Web Clipper application.
  262. // This launch code gets used to satisfy
  263. // URLs like the following:
  264. // palm:memo.appl?param1=value1&param2=value2
  265. // Everything in the URL past the '?' is passed
  266. // to the app as the cmdPBP parameter of PilotMain().
  267. sysAppLaunchCmdNotify = 51; // This is a NotifyMgr notification sent
  268. // via SysNotifyBroadcast. The cmdPBP parameter
  269. // points to a SysNotifyParamType structure
  270. // containing more specific information
  271. // about the notification (e.g., what it's for).
  272. sysAppLaunchCmdOpenDB = 52; // Sent to switch to an application and have it
  273. // "open" up the given data file. The cmdPBP
  274. // pointer is a pointer to a SysAppLaunchCmdOpenDBType
  275. // structure that has the cardNo and localID of the database
  276. // to open. This action code is used by the Launcher
  277. // to launch data files, like Eleven PQA files that
  278. // have the dmHdrAttrLaunchableData bit set in their
  279. // database attributes.
  280. sysAppLaunchCmdAntennaUp = 53; // Sent to switch only to the launcher when
  281. // the antenna is raised and the launcher
  282. // is the application in the buttons preferences
  283. // that is to be run when the antenna is raised is
  284. // the launcher.
  285. sysAppLaunchCmdGoToURL = 54; // Sent to Clipper to have it launch and display
  286. // a given URL. cmdPBP points to the URL string.
  287. // Begin Change - BGT 03/21/2000
  288. //------------------------------------------------------------------------
  289. // New launch codes defined for Network panel plug-in
  290. //------------------------------------------------------------------------
  291. sysAppLaunchNppiNoUI = 55; // Sent to network panel plug-in ("nppi") to have it launch
  292. // without UI and load to netlib
  293. sysAppLaunchNppiUI = 56; // Sent to network panel plug-in ("nppi") to have it launch
  294. // with UI
  295. // End Change - BGT 03/21/2000
  296. //------------------------------------------------------------------------
  297. // New launch codes defined for PalmOS 4.x where x >= 0
  298. //------------------------------------------------------------------------
  299. sysAppLaunchCmdExgPreview = 57; // Sent to an application by the Exchange Manager when the
  300. // application needs to produce a preview.
  301. sysAppLaunchCmdCardLaunch = 58; // Sent to an application by the Launcher when the
  302. // application is being run from a card.
  303. sysAppLaunchCmdExgGetData = 59; // Exg command for app to send data requested by an ExgGet
  304. sysAppLaunchCmdAttention = 60; // sent to an application by the attention manager
  305. // when the application needs to take action on an entry
  306. // that has been submitted to the attention manager queue.
  307. sysAppLaunchPnpsPreLaunch = 61; // pre-launch code for Pnps devices,
  308. // cmdPBP points to SysAppLaunchCmdPnpsType
  309. // ***ADD NEW SYSTEM ACTION CODES BEFORE THIS COMMENT***
  310. //------------------------------------------------------------------------
  311. // Custom action code base (custom action codes begin at this value)
  312. //------------------------------------------------------------------------
  313. sysAppLaunchCmdCustomBase = $8000;
  314. // Your custom launch codes can be defined like this:
  315. //
  316. // type
  317. // MyAppCustomActionCodes = WordEnum;
  318. // const
  319. // myAppCmdDoSomething = sysAppLaunchCmdCustomBase;
  320. // myAppCmdDoSomethingElse = Succ(myAppCmdDoSomething);
  321. // myAppCmdEtcetera = Succ(myAppCmdDoSomethingElse);
  322. //------------------------------------------------------------------------
  323. // SysAppLaunch flags (passed to PilotMain)
  324. //------------------------------------------------------------------------
  325. sysAppLaunchFlagNewThread = $01; // create a new thread for application
  326. // - implies sysAppLaunchFlagNewStack
  327. sysAppLaunchFlagNewStack = $02; // create separate stack for application
  328. sysAppLaunchFlagNewGlobals = $04; // create new globals world for application
  329. // - implies new owner ID for Memory chunks
  330. sysAppLaunchFlagUIApp = $08; // notifies launch routine that this is a UI app being
  331. // launched.
  332. sysAppLaunchFlagSubCall = $10; // notifies launch routine that the app is calling it's
  333. // entry point as a subroutine call. This tells the launch
  334. // code that it's OK to keep the A5 (globals) pointer valid
  335. // through the call.
  336. // IMPORTANT: This flag is for internal use by
  337. // SysAppLaunch only!!! It should NEVER be set
  338. // by the caller.
  339. sysAppLaunchFlagDataRelocated = $80; // global data (static ptrs) have been "relocated"
  340. // by either SysAppStartup or StartupCode.c
  341. // IMPORTANT: This flag is for internal use by
  342. // SysAppLaunch only!!! It should NEVER be set
  343. // by the caller.
  344. // The set of private, internal flags that should never be set by the caller
  345. sysAppLaunchFlagPrivateSet = sysAppLaunchFlagSubCall or sysAppLaunchFlagDataRelocated;
  346. //-------------------------------------------------------------------
  347. // Parameter blocks for action codes
  348. // NOTE: The parameter block for the sysAppLaunchCmdFind and sysAppLaunchCmdGoTo
  349. // action codes are defined in "Find.h";
  350. //---------------------------------------------------------------------------
  351. // For sysAppLaunchCmdSaveData
  352. type
  353. SysAppLaunchCmdSaveDataType = record
  354. uiComing: Boolean; // true if system dialog will be put up
  355. // before coming action code arrives.
  356. reserved1: UInt8;
  357. end;
  358. // For sysAppLaunchCmdSystemReset
  359. SysAppLaunchCmdSystemResetType = record
  360. hardReset: Boolean; // true if system was hardReset, false if soft-reset.
  361. createDefaultDB: Boolean; // true if app should create default database.
  362. end;
  363. // For sysAppLaunchCmdInitDatabase
  364. SysAppLaunchCmdInitDatabaseType = record
  365. dbP: DmOpenRef; // Handle of the newly-created database,
  366. // already open for read/write access.
  367. // IMPORTANT: The handler *MUST* leave
  368. // this database handle open on return.
  369. creator: UInt32; // Creator ID of the newly-created database
  370. type_: UInt32; // Type ID of the newly-created database
  371. version: UInt16; // Version number of the newly-created database
  372. end;
  373. // For sysAppLaunchCmdSyncCallApplicationV10
  374. // This structure used on Pilot v1.0 only. See sysAppLaunchCmdHandleSyncCallApp
  375. // for later platforms.
  376. SysAppLaunchCmdSyncCallApplicationTypeV10 = record
  377. action: UInt16; // call action id (app-specific)
  378. paramSize: UInt16; // parameter size
  379. paramP: Pointer; // ptr to parameter
  380. remoteSocket: UInt8; // remote socket id
  381. tid: UInt8; // command transaction id
  382. handled: Boolean; // if handled, MUST be set true by the app
  383. reserved1: UInt8;
  384. end;
  385. // For sysAppLaunchCmdHandleSyncCallApp (Pilot v2.0 and greater).
  386. // This structure replaces SysAppLaunchCmdSyncCallApplicationType
  387. // which was used in Pilot v1.0
  388. SysAppLaunchCmdHandleSyncCallAppType = record
  389. pbSize: UInt16; // this parameter block size (set to sizeof SysAppLaunchCmdHandleSyncCallAppType)
  390. action: UInt16; // call action id (app-specific)
  391. paramP: Pointer; // ptr to parameter
  392. dwParamSize: UInt32; // parameter size
  393. dlRefP: Pointer; // DesktopLink reference pointer for passing
  394. // to DlkControl()'s dlkCtlSendCallAppReply code
  395. handled: Boolean; // initialized to FALSE by DLServer; if
  396. // handled, MUST be set TRUE by the app(the
  397. // handler MUST call DlkControl with
  398. // control code dlkCtlSendCallAppReply);
  399. // if the handler is not going to send a reply,
  400. // it should leave this field set to FALSE, in which
  401. // case DesktopLink Server will send the default
  402. // "unknown request" reply.
  403. reserved1: UInt8;
  404. replyErr: Err; // error from dlkCtlSendCallAppReply
  405. // RESERVED FOR FUTURE EXTENSIONS
  406. dwReserved1: UInt32; // RESERVED -- set to null!!!
  407. dwReserved2: UInt32; // RESERVED -- set to null!!!
  408. // Target executable creator and type for testing the mechanism
  409. // in EMULATION MODE ONLY!!!
  410. // #if EMULATION_LEVEL != EMULATION_NONE
  411. // creator: UInt32;
  412. // type_: UInt32;
  413. // #endif
  414. end;
  415. // For sysAppLaunchCmdFailedAppNotify
  416. SysAppLaunchCmdFailedAppNotifyType = record
  417. creator: UInt32;
  418. type_: UInt32;
  419. result: Err;
  420. end;
  421. // For sysAppLaunchCmdOpenDB
  422. SysAppLaunchCmdOpenDBType = record
  423. cardNo: UInt16;
  424. dbID: LocalID;
  425. end;
  426. // For sysAppLaunchCmdCardLaunch
  427. type
  428. SysAppLaunchCmdCardType = record
  429. err: Err;
  430. volRefNum: UInt16;
  431. path: PChar;
  432. startFlags: UInt16; // See vfsStartFlagXXX constants below
  433. end;
  434. const
  435. sysAppLaunchStartFlagAutoStart = $0001; // this bit in the 'startFlags' field is set for an app which is run automatically on card insertion
  436. sysAppLaunchStartFlagNoUISwitch = $0002; // set this bit in the 'startFlags' field to prevent a UI switch to the start.prc app
  437. sysAppLaunchStartFlagNoAutoDelete = $0004; // set this bit in the 'startFlags' field to prevent VFSMgr from deleting start.prc app on volume unmount
  438. //for launch code sysAppLaunchPnpsPreLaunch
  439. type
  440. SysAppLaunchCmdPnpsType = record
  441. error: Err; // an error code from the pre-launch application, set to errNone to prevent normal launching
  442. volRefNum: UInt16; // Non-zero if an optional file system was mounted
  443. slotLibRefNum: UInt16; // always valid for a slot driver call
  444. slotRefNum: UInt16; // always valid for a slot driver call
  445. end;
  446. (************************************************************
  447. * Structure of Application info for an application. Applications
  448. * do not necessarily have to be on their own thread - there
  449. * can be more than 1 app on the same AMX task. Each application
  450. * has an assocated SysAppInfoType structure which holds the
  451. * application specific information like the database MemHandle of the
  452. * app, the code MemHandle, the stack chunk pointer, the owner ID, etc.
  453. *
  454. * As of PalmOS 3.X, one of these structures is created for each
  455. * app running as an action code.
  456. *
  457. ****
  458. ****IMPORTANT: ADD NEW FIELDS AT THE END OF THE STRUCTURE FOR
  459. **** BACKWARD COMPATIBILITY
  460. ****
  461. *************************************************************)
  462. SysAppInfoTag = record
  463. cmd: Int16; // command code for app
  464. cmdPBP: MemPtr; // cmd ParamBlock
  465. launchFlags: UInt16; // launch flags
  466. taskID: UInt32; // AMX task ID of task that app runs in
  467. codeH: MemHandle; // code MemHandle of the main code segment
  468. dbP: DmOpenRef; // Application database access MemPtr of App
  469. stackP: ^UInt8; // stack chunk for the App
  470. globalsChunkP: ^UInt8; // globals chunk for the App
  471. memOwnerID: UInt16; // owner ID for Memory Manager chunks
  472. dmAccessP: MemPtr; // pointer to linked list of opened DB's
  473. dmLastErr: Err; // Last error from Data Manager
  474. errExceptionP: MemPtr; // ErrTry,Catch exception list
  475. // PalmOS v3.0 fields begin here
  476. a5Ptr: ^UInt8; // A5 MemPtr for this app
  477. stackEndP: ^UInt8; // stack chunk end for the App (last byte)
  478. globalEndP: ^UInt8; // global chunk end for the App (last byte)
  479. rootP: ^SysAppInfoType;// Points to the SysAppInfoType first
  480. // allocated for this thread.
  481. extraP: MemPtr; // unused MemPtr for the App.
  482. end;
  483. SysAppInfoType = SysAppInfoTag;
  484. SysAppInfoPtr = ^SysAppInfoType;
  485. (************************************************************
  486. * Function prototype for libraries
  487. *************************************************************)
  488. // ***IMPORTANT***
  489. // ***IMPORTANT***
  490. // ***IMPORTANT***
  491. //
  492. // The assembly level TrapDispatcher() function uses a hard-coded value for
  493. // the size of the structure SysLibTblEntryType to obtain a pointer to a
  494. // library entry in the library table. Therefore, any changes to this structure,
  495. // require corresponding changes in TrapDispatcher() in ROMBoot.c. Furthermore,
  496. // it is advantageous to keep the size of the structure a power of 2 as this
  497. // improves performance by allowing the entry offset to be calculated by shifting
  498. // left instead of using the multiply instruction. vmk 8/27/96 (yes, I fell into
  499. // this trap myself)
  500. SysLibTblEntryType = record
  501. dispatchTblP: ^MemPtr; // pointer to library dispatch table
  502. globalsP: Pointer; // Library globals
  503. // New INTERNAL fields for v2.0 (vmk 8/27/96):
  504. dbID: LocalID; // database id of the library
  505. codeRscH: Pointer; // library code resource handle for RAM-based libraries
  506. end;
  507. SysLibTblEntryPtr = ^SysLibTblEntryType;
  508. // Emulated versions of libraries have a slightly different dispatch table
  509. // Enough for the offset to the library name and the name itself.
  510. //#if EMULATION_LEVEL != EMULATION_NONE
  511. SimDispatchTableType = record
  512. numEntries: UInt32 ; // number of library entries
  513. entries: array [0..0] of Pointer; // dispatch routine entries
  514. // followed by pointer to name
  515. end;
  516. SimDispatchTablePtr = ^SimDispatchTableType;
  517. //#endif
  518. // Library entry point procedure
  519. SysLibEntryProcPtr = function(refNum: UInt16; entryP: SysLibTblEntryPtr): Err;
  520. // This library refNum is reserved for the Debugger comm library
  521. const
  522. sysDbgCommLibraryRefNum = 0;
  523. // This portID is reserved for identifying the debugger's port
  524. sysDbgCommPortID = $C0FF;
  525. // This refNum signals an invalid refNum
  526. sysInvalidRefNum = $FFFF;
  527. (************************************************************
  528. * Function prototype for Kernel
  529. *************************************************************)
  530. // Task termination procedure prototype for use with SysTaskSetTermProc
  531. type
  532. SysTermProcPtr = procedure(taskID: UInt32; reason: Int32);
  533. // Timer procedure for use with SysTimerCreate
  534. SysTimerProcPtr = procedure(timerID, param: Int32);
  535. (************************************************************
  536. * Structure of the pref=0 resource in applications. Note, this
  537. * structure must mirror the structure of the sysResTAppPrefs
  538. * resource as defined in SystemResources.h.
  539. *************************************************************)
  540. type
  541. SysAppPrefs = record
  542. priority: UInt16; // task priority
  543. stackSize: UInt32; // required stack space
  544. minHeapSpace: UInt32; // minimum heap space required
  545. end;
  546. SysAppPrefsType = SysAppPrefs;
  547. SysAppPrefsPtr = ^SysAppPrefsType;
  548. (************************************************************
  549. * Structure of the xprf=0 resource in resource DBs. Note, this
  550. * structure must mirror the structure of the sysResTExtPrefs
  551. * resource as defined in SystemResources.h. Also, fields can only
  552. * be added (at the end), never removed or changed.
  553. *************************************************************)
  554. const
  555. sysExtPrefsVers = 1;
  556. // Flags defined for SysExtPrefsType.flags
  557. const
  558. sysExtPrefsNoOverlayFlag = $00000001;
  559. type
  560. SysExtPrefsType = record
  561. version: UInt16; // version of structure.
  562. flags: UInt32; // 32 boolean flags.
  563. end;
  564. (************************************************************
  565. * System Errors
  566. *************************************************************)
  567. const
  568. sysErrTimeout = sysErrorClass or 1;
  569. sysErrParamErr = sysErrorClass or 2;
  570. sysErrNoFreeResource = sysErrorClass or 3;
  571. sysErrNoFreeRAM = sysErrorClass or 4;
  572. sysErrNotAllowed = sysErrorClass or 5;
  573. sysErrSemInUse = sysErrorClass or 6;
  574. sysErrInvalidID = sysErrorClass or 7;
  575. sysErrOutOfOwnerIDs = sysErrorClass or 8;
  576. sysErrNoFreeLibSlots = sysErrorClass or 9;
  577. sysErrLibNotFound = sysErrorClass or 10;
  578. sysErrDelayWakened = sysErrorClass or 11; // SysTaskDelay wakened by SysTaskWake before delay completed.
  579. sysErrRomIncompatible = sysErrorClass or 12;
  580. sysErrBufTooSmall = sysErrorClass or 13;
  581. sysErrPrefNotFound = sysErrorClass or 14;
  582. // NotifyMgr error codes:
  583. sysNotifyErrEntryNotFound = sysErrorClass or 16; // could not find registration entry in the list
  584. sysNotifyErrDuplicateEntry = sysErrorClass or 17; // identical entry already exists
  585. sysNotifyErrBroadcastBusy = sysErrorClass or 19; // a broadcast is already in progress - try again later.
  586. sysNotifyErrBroadcastCancelled = sysErrorClass or 20; // a handler cancelled the broadcast
  587. // AMX error codes continued - jb 10/20/98
  588. sysErrMbId = sysErrorClass or 21;
  589. sysErrMbNone = sysErrorClass or 22;
  590. sysErrMbBusy = sysErrorClass or 23;
  591. sysErrMbFull = sysErrorClass or 24;
  592. sysErrMbDepth = sysErrorClass or 25;
  593. sysErrMbEnv = sysErrorClass or 26;
  594. // NotifyMgr Phase #2 Error Codes:
  595. sysNotifyErrQueueFull = sysErrorClass or 27; // deferred queue is full.
  596. sysNotifyErrQueueEmpty = sysErrorClass or 28; // deferred queue is empty.
  597. sysNotifyErrNoStackSpace = sysErrorClass or 29; // not enough stack space for a broadcast
  598. sysErrNotInitialized = sysErrorClass or 30; // manager is not initialized
  599. // AMX error/warning codes continued - jed 9/10/99
  600. sysErrNotAsleep = sysErrorClass or 31; // Task woken by SysTaskWake was not asleep, 1 wake pending
  601. sysErrNotAsleepN = sysErrorClass or 32; // Task woken by SysTaskWake was not asleep, >1 wake pending
  602. // Power Manager error codes - soe, srj 9/19/00
  603. pwrErrNone = pwrErrorClass or 0;
  604. pwrErrBacklight = pwrErrorClass or 1;
  605. pwrErrRadio = pwrErrorClass or 2;
  606. pwrErrBeam = pwrErrorClass or 3;
  607. pwrErrGeneric = pwrErrorClass or 4;
  608. (************************************************************
  609. * System Features
  610. *************************************************************)
  611. sysFtrCreator = sysFileCSystem; // Feature Creator
  612. sysFtrNumROMVersion = 1; // ROM Version
  613. // 0xMMmfsbbb, where MM is major version, m is minor version
  614. // f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development,
  615. // bbb is build number for non-releases
  616. // V1.12b3 would be: 0x01122003
  617. // V2.00a2 would be: 0x02001002
  618. // V1.01 would be: 0x01013000
  619. sysFtrNumProcessorID = 2; // Product id
  620. // 0xMMMMRRRR, where MMMM is the processor model and RRRR is the revision.
  621. sysFtrNumProcessorMask = $FFFF0000; // Mask to obtain processor model
  622. sysFtrNumProcessor328 = $00010000; // Motorola 68328 (Dragonball)
  623. sysFtrNumProcessorEZ = $00020000; // Motorola 68EZ328 (Dragonball EZ)
  624. sysFtrNumProcessorVZ = $00030000; // Motorola 68VZ328 (Dragonball VZ)
  625. sysFtrNumProductID = sysFtrNumProcessorID; // old (obsolete) define
  626. sysFtrNumBacklight = 3; // Backlight
  627. // bit 0: 1 if present. 0 if Feature does not exist or backlight is not present
  628. sysFtrNumEncryption = 4; // Which encryption schemes are present
  629. sysFtrNumEncryptionMaskDES = $00000001; // bit 0: 1 if DES is present
  630. sysFtrNumCountry = 5; // International ROM identifier
  631. // Result is of type CountryType as defined in Preferences.h.
  632. // Result is essentially the "default" country for this ROM.
  633. // Assume cUnitedStates if sysFtrNumROMVersion >= 02000000
  634. // and feature does not exist. Result is in low sixteen bits.
  635. sysFtrNumLanguage = 6; // Language identifier
  636. // Result is of untyped; values are defined in Incs:BuildRules.h
  637. // Result is essentially the "default" language for this ROM.
  638. // This is new for the WorkPad (v2.0.2) and did NOT exist for any of the
  639. // following: GermanPersonal, GermanPro, FrenchPersonal, FrenchPro
  640. // Thus we can't really assume anything if the feature doesn't exist,
  641. // though the actual language MAY be determined from sysFtrNumCountry,
  642. // above. Result is in low sixteen bits.
  643. sysFtrNumDisplayDepth = 7; // Display depth
  644. // Result is the "default" display depth for the screen. (PalmOS 3.0)
  645. // This value is used by ScrDisplayMode when setting the default display depth.
  646. sysFtrNumHwrMiscFlags = 8; // GHwrMiscFlags value (PalmOS 3.1)
  647. sysFtrNumHwrMiscFlagsExt = 9; // GHwrMiscFlagsExt value (PalmOS 3.1)
  648. sysFtrNumIntlMgr = 10;
  649. // Result is a set of flags that define functionality supported
  650. // by the Int'l Manager. (PalmOS 3.1)
  651. sysFtrNumEncoding = 11;
  652. // Result is the character encoding (defined in PalmLocale.h) supported
  653. // by this ROM. If this feature doesn't exist then the assumed encoding
  654. // is Palmlatin (superset of Windows code page 1252). (PalmOS 3.1)
  655. sysFtrDefaultFont = 12;
  656. // Default font ID used for displaying text. (PalmOS 3.1)
  657. sysFtrDefaultBoldFont = 13;
  658. // Default font ID used for displaying bold text. (PalmOS 3.1)
  659. sysFtrNumGremlinsSupportGlobals = 14; // Globals for supporting gremlins.
  660. // This value is a pointer to a memory location that stores global variables needed
  661. // for intelligently supporting gremlins. Currently, it is only used in Progress.c.
  662. // It is only initialized on first use (gremlins and progress bar in combination)
  663. // when ERROR_CHECK_LEVEL == ERROR_CHECK_FULL. (PalmOS 3.2)
  664. sysFtrNumVendor = 15;
  665. // Result is the vendor id, in the low sixteen bits. (PalmOS 3.3)
  666. sysFtrNumCharEncodingFlags = 16;
  667. // Flags for a given character encoding, specified in TextMgr.h (PalmOS 3.5)
  668. sysFtrNumNotifyMgrVersion = 17; // version of the NotifyMgr, if any (PalmOS 3.5)
  669. sysFtrNumOEMROMVersion = 18; // Supplemental ROM version, provided by OEM
  670. // This value may be present in OEM devices, and is in the same format
  671. // as sysFtrNumROMVersion. (PalmOS 3.5)
  672. sysFtrNumErrorCheckLevel = 19; // ROM build setting of ERROR_CHECK_LEVEL
  673. // May be set to ERROR_CHECK_NONE, ERROR_CHECK_PARTIAL, or ERROR_CHECK_FULL
  674. // as defined in <BuildDefines.h>. (PalmOS 3.5)
  675. sysFtrNumOEMCompanyID = 20; // GHwrOEMCompanyID value (PalmOS 3.5)
  676. sysFtrNumOEMDeviceID = 21; // GHwrOEMDeviceID value (PalmOS 3.5)
  677. sysFtrNumOEMHALID = 22; // GHwrOEMHALID value (PalmOS 3.5)
  678. sysFtrNumDefaultCompression = 23; // Default Clipper's compression (Palmos 3.5)
  679. sysFtrNumWinVersion = 24; // Window version (PalmOS 4.0)
  680. sysFtrNumAccessorTrapPresent = 25; // If accessor trap exists (PalmOS 4.0)
  681. (************************************************************
  682. * ROM token information (for SysGetROMToken, below)
  683. *************************************************************)
  684. // Additional tokens and token information is located in <Hardware.h>
  685. sysROMTokenSnum = Rsc('snum'); // Memory Card Flash ID (serial number)
  686. (************************************************************
  687. * Macros for extracting and combining ROM/OS version components
  688. *************************************************************)
  689. // ROM/OS stage numbers
  690. sysROMStageDevelopment = 0;
  691. sysROMStageAlpha = 1;
  692. sysROMStageBeta = 2;
  693. sysROMStageRelease = 3;
  694. // MACRO: sysMakeROMVersion
  695. //
  696. // Builds a ROM version value from the major, minor, fix, stage, and build numbers
  697. //
  698. function sysMakeROMVersion(major, minor, fix, stage: UInt8; buildNum: UInt16): UInt32;
  699. // Macros for parsing the ROM version number
  700. // (the system OS version is obtained by calling
  701. // FtrGet(sysFtrCreator, sysFtrNumROMVersion, dwOSVerP), where dwOSVerP is
  702. // a pointer to to a UInt32 variable that is to receive the OS version number)
  703. function sysGetROMVerMajor(dwROMVer: UInt32): UInt16;
  704. function sysGetROMVerMinor(dwROMVer: UInt32): UInt16;
  705. function sysGetROMVerFix(dwROMVer: UInt32): UInt16;
  706. function sysGetROMVerStage(dwROMVer: UInt32): UInt16;
  707. function sysGetROMVerBuild(dwROMVer: UInt32): UInt16;
  708. (************************************************************
  709. * System Types
  710. *************************************************************)
  711. // Types of batteries installed.
  712. type
  713. SysBatteryKind = Enum;
  714. const
  715. sysBatteryKindAlkaline=0;
  716. sysBatteryKindNiCad = Succ(sysBatteryKindAlkaline);
  717. sysBatteryKindLiIon = Succ(sysBatteryKindNiCad);
  718. sysBatteryKindRechAlk = Succ(sysBatteryKindLiIon);
  719. sysBatteryKindNiMH = Succ(sysBatteryKindRechAlk);
  720. sysBatteryKindLiIon1400 = Succ(sysBatteryKindNiMH);
  721. sysBatteryKindLast = $FF; // insert new battery types BEFORE this one
  722. // Different battery states (output of hwrBattery)
  723. type
  724. SysBatteryState = Enum;
  725. const
  726. sysBatteryStateNormal = 0;
  727. sysBatteryStateLowBattery = Succ(sysBatteryStateNormal);
  728. sysBatteryStateCritBattery = Succ(sysBatteryStateLowBattery);
  729. sysBatteryStateShutdow = Succ(sysBatteryStateCritBattery);
  730. // SysCreateDataBaseList can generate a list of database.
  731. type
  732. SysDBListItemType = record
  733. name: array [0..dmDBNameLength-1] of Char;
  734. creator: UInt32;
  735. type_: UInt32;
  736. version: UInt16;
  737. dbID: LocalID;
  738. cardNo: UInt16;
  739. iconP: BitmapPtr;
  740. end;
  741. // Structure of a generic message that can be send to a mailbox
  742. // through the SysMailboxSend call. Note, this structure MUST
  743. // be CJ_MAXMSZ bytes large, where CJ_MAXMSZ is defined in
  744. // the AMX includes.
  745. SysMailboxMsgType = record
  746. data: array [0..2] of UInt32;
  747. end;
  748. // Constants used by the SysEvGroupSignal call
  749. const
  750. sysEvGroupSignalConstant = 0;
  751. sysEvGroupSignalPulse = 1;
  752. // Constants used by the SysEvGroupWait call
  753. sysEvGroupWaitOR = 0;
  754. sysEvGroupWaitAND = 1;
  755. (************************************************************
  756. * System Pre-defined "file descriptors"
  757. * These are used by applications that use the Net Library's
  758. * NetLibSelect() call
  759. *************************************************************)
  760. sysFileDescStdIn = 0;
  761. //============================================================================
  762. // jhl 7/26/00 Integrate HSIMgr functionality
  763. //============================================================================
  764. sysNotifyHSISerialPortInUseEvent = Rsc('hsiu'); // Sent when serial port is in use
  765. sysNotifyHSIPeripheralRespondedEvent = Rsc('hspr'); // Sent with peripheral response
  766. sysNotifyHSIPeripheralNotRespondingEvent = Rsc('hspn'); // Sent when peripheral does not respond
  767. sysNotifyHSINoConnectionEvent = Rsc('ncon'); // Sent on VID of no connection
  768. sysNotifyHSIUSBCradleEvent = sysPortUSBDesktop; // Sent on VID of USB Cradle
  769. sysNotifyHSIRS232CradleEvent = Rsc('rs2c'); // Sent on VID of RS232 Cradle
  770. sysNotifyHSIUSBPeripheralEvent = sysPortUSBPeripheral; // Sent on VID of USB Peripheral
  771. sysNotifyHSIRS232PeripheralEvent = Rsc('rs2p'); // Sent on VID of RS232 Peripheral
  772. sysNotifyHSIDebugEvent = Rsc('dbug'); // Sent on VID of Debug
  773. sysMaxHSIResponseSize = 64;
  774. sysHSISerialInquiryBaud = 9600;
  775. sysHSISerialInquiryString = 'ATI3\015\012';
  776. sysHSISerialInquiryStringLen = 6;
  777. sysHSISerialInterChrTimeout = 3; // ticks (20-30 ms)
  778. sysHSISerialInquiryTimeout = 11; // ticks (100-110 ms)
  779. type
  780. SysHSIResponseType = record
  781. // "Voltage ID" from modem pin converted to 4 character VID
  782. // VID: UInt32;
  783. // Actual voltage detected on modem VID pin
  784. // mVolts: UInt16;
  785. // Character string received in response to inquiry string
  786. // (will be NUL terminated)
  787. responseBuffer: array [0..sysMaxHSIResponseSize-1] of Char;
  788. // Length of string in responseBuffer
  789. responseLength: UInt16;
  790. end;
  791. (************************************************************
  792. * Function Prototypes
  793. *************************************************************)
  794. // Prototype for Pilot applications entry point
  795. // UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags);
  796. // SystemMgr routines
  797. procedure SysUnimplemented; syscall sysTrapSysUnimplemented;
  798. procedure SysColdBoot(card0P: Pointer; card0Size: UInt32; card1P: Pointer;
  799. card1Size, sysCardHeaderOffset: UInt32); syscall sysTrapSysColdBoot;
  800. procedure SysInit; syscall sysTrapSysInit;
  801. procedure SysReset; syscall sysTrapSysReset;
  802. //procedure SysPowerOn(card0P: Pointer; card0Size: UInt32; card1P: Pointer;
  803. // card1Size, sysCardHeaderOffset: UInt32; reFormat: Boolean); syscall sysTrapSysPowerOn;
  804. procedure SysDoze(onlyNMI: Boolean); syscall sysTrapSysDoze;
  805. function SysSetPerformance(var sysClockP: UInt32; var cpuDutyP: UInt16): Err; syscall sysTrapSysSetPerformance;
  806. procedure SysSleep(untilReset, emergency: Boolean); syscall sysTrapSysSleep;
  807. function SysSetAutoOffTime(seconds: UInt16): UInt16; syscall sysTrapSysSetAutoOffTime;
  808. function SysTicksPerSecond: UInt16; syscall sysTrapSysTicksPerSecond;
  809. function SysLaunchConsole: Err; syscall sysTrapSysLaunchConsole;
  810. function SysHandleEvent(var eventP: EventType): Boolean; syscall sysTrapSysHandleEvent;
  811. procedure SysUILaunch; syscall sysTrapSysUILaunch;
  812. function SysUIAppSwitch(cardNo: UInt16; dbID: LocalID; cmd: UInt16; cmdPBP: MemPtr): Err; syscall sysTrapSysUIAppSwitch;
  813. function SysCurAppDatabase(var cardNoP: UInt16; var dbIDP: LocalID): Err; syscall sysTrapSysCurAppDatabase;
  814. function SysBroadcastActionCode(cmd: UInt16; cmdPBP: MemPtr): Err; syscall sysTrapSysBroadcastActionCode;
  815. function SysAppLaunch(cardNo: UInt16; dbID: LocalID; launchFlags, cmd: UInt16;
  816. cmdPBP: MemPtr; var resultP: UInt32): Err; syscall sysTrapSysAppLaunch;
  817. function SysNewOwnerID: UInt16; syscall sysTrapSysNewOwnerID;
  818. function SysSetA5(newValue: UInt32): UInt32; syscall sysTrapSysSetA5;
  819. // Routines used by startup code
  820. function SysAppStartup(var appInfoPP: SysAppInfoPtr; var prevGlobalsP, globalsPtrP: MemPtr): Err; syscall sysTrapSysAppStartup;
  821. function SysAppExit(appInfoP: SysAppInfoPtr; prevGlobalsP, globalsP: MemPtr): Err; syscall sysTrapSysAppExit;
  822. //#if EMULATION_LEVEL != EMULATION_NONE
  823. // Simulator-specific routines
  824. //MemPtr SysCardImageInfo(UInt16 cardNo, UInt32 *sizeP;
  825. //
  826. //void SysCardImageDeleted(UInt16 cardNo;
  827. //#endif // EMULATION_LEVEL != EMULATION_NONE
  828. function SysUIBusy(set_, value: Boolean): UInt16; syscall sysTrapSysUIBusy;
  829. function SysLCDContrast(set_: Boolean; newContrastLevel: UInt8): UInt8; syscall sysTrapSysLCDContrast;
  830. function SysLCDBrightness(set_: Boolean; newBrightnessLevel: UInt8): UInt8; syscall sysTrapSysLCDBrightness;
  831. // System Dialogs
  832. procedure SysBatteryDialog; syscall sysTrapSysBatteryDialog;
  833. // Utilities
  834. function SysSetTrapAddress(trapNum: UInt16; procP: Pointer): Err; syscall sysTrapSysSetTrapAddress;
  835. function SysGetTrapAddress(trapNum: UInt16): Pointer; syscall sysTrapSysGetTrapAddress;
  836. function SysDisableInts: UInt16; syscall sysTrapSysDisableInts;
  837. procedure SysRestoreStatus(status: UInt16); syscall sysTrapSysRestoreStatus;
  838. function SysGetOSVersionString: PChar; syscall sysTrapSysGetOSVersionString;
  839. // The following trap is a public definition of HwrGetROMToken from <Hardware.h>
  840. // See token definitions (like sysROMTokenSerial) above...
  841. function SysGetROMToken(cardNo: UInt16; token: UInt32; var dataP: UInt8Ptr; var sizeP: UInt16): Err; syscall sysTrapHwrGetROMToken;
  842. // Library Management
  843. function SysLibInstall(libraryP: SysLibEntryProcPtr; var refNumP: UInt16): Err; syscall sysTrapSysLibInstall;
  844. function SysLibLoad(libType, libCreator: UInt32; var refNumP: UInt16): Err; syscall sysTrapSysLibLoad;
  845. function SysLibRemove(refNum: UInt16): Err; syscall sysTrapSysLibRemove;
  846. function SysLibFind(const nameP: PChar; var refNumP: UInt16): Err; syscall sysTrapSysLibFind;
  847. function SysLibTblEntry(refNum: UInt16): SysLibTblEntryPtr; syscall sysTrapSysLibTblEntry;
  848. // Generic Library calls
  849. function SysLibOpen(refNum: UInt16): Err; syscall sysLibTrapOpen;
  850. function SysLibClose(refNum: UInt16): Err; syscall sysLibTrapClose;
  851. function SysLibSleep(refNum: UInt16): Err; syscall sysLibTrapSleep;
  852. function SysLibWake(refNum: UInt16): Err; syscall sysLibTrapWake;
  853. //-----------------------------------------------------
  854. // Kernel Prototypes
  855. //-----------------------------------------------------
  856. // Task Creation and deleation
  857. function SysTranslateKernelErr(err: Err): Err; syscall sysTrapSysTranslateKernelErr;
  858. function SysTaskCreate(var taskIDP, creator: UInt32; codeP: ProcPtr; stackP: MemPtr;
  859. stackSize, attr, priority, tSlice: UInt32): Err; syscall sysTrapSysTaskCreate;
  860. function SysTaskDelete(taskID, priority: UInt32): Err; syscall sysTrapSysTaskDelete;
  861. function SysTaskTrigger(taskID: UInt32): Err; syscall sysTrapSysTaskTrigger;
  862. function SysTaskID: UInt32; syscall sysTrapSysTaskID;
  863. function SysTaskDelay(delay: Int32): Err; syscall sysTrapSysTaskDelay;
  864. function SysTaskSetTermProc(taskID: UInt32; termProcP: SysTermProcPtr): Err; syscall sysTrapSysTaskSetTermProc;
  865. function SysTaskSwitching(enable: Boolean): Err; syscall sysTrapSysTaskSwitching;
  866. function SysTaskWait(timeout: Int32): Err; syscall sysTrapSysTaskWait;
  867. function SysTaskWake(taskID: UInt32): Err; syscall sysTrapSysTaskWake;
  868. procedure SysTaskWaitClr; syscall sysTrapSysTaskWaitClr;
  869. function SysTaskSuspend(taskID: UInt32): Err; syscall sysTrapSysTaskSuspend;
  870. function SysTaskResume(taskID: UInt32): Err; syscall sysTrapSysTaskResume;
  871. // Counting Semaphores
  872. function SysSemaphoreCreate(var smIDP, tagP: UInt32; initValue: Int32): Err; syscall sysTrapSysSemaphoreCreate;
  873. function SysSemaphoreDelete(smID: UInt32): Err; syscall sysTrapSysSemaphoreDelete;
  874. function SysSemaphoreWait(smID, priority: UInt32; timeout: Int32): Err; syscall sysTrapSysSemaphoreWait;
  875. function SysSemaphoreSignal(smID: UInt32): Err; syscall sysTrapSysSemaphoreSignal;
  876. function SysSemaphoreSet(smID: UInt32): Err; syscall sysTrapSysSemaphoreSet;
  877. // Resource Semaphores
  878. function SysResSemaphoreCreate(var smIDP, tagP: UInt32): Err; syscall sysTrapSysResSemaphoreCreate;
  879. function SysResSemaphoreDelete(smID: UInt32): Err; syscall sysTrapSysResSemaphoreDelete;
  880. function SysResSemaphoreReserve(smID, priority: UInt32; timeout: Int32): Err; syscall sysTrapSysResSemaphoreReserve;
  881. function SysResSemaphoreRelease(smID: UInt32): Err; syscall sysTrapSysResSemaphoreRelease;
  882. // Timers
  883. function SysTimerCreate(var timerIDP, tagP: UInt32; timerProc: SysTimerProcPtr;
  884. periodicDelay, param: UInt32): Err; syscall sysTrapSysTimerCreate;
  885. function SysTimerDelete(timerID: UInt32): Err; syscall sysTrapSysTimerDelete;
  886. function SysTimerWrite(timerID, value: UInt32): Err; syscall sysTrapSysTimerWrite;
  887. function SysTimerRead(timerID: UInt32; var valueP: UInt32): Err; syscall sysTrapSysTimerRead;
  888. // Information
  889. function SysKernelInfo(paramP: Pointer): Err; syscall sysTrapSysKernelInfo;
  890. function SysCreateDataBaseList(type_, creator: UInt32; var dbCount: UInt16;
  891. var dbIDs: MemHandle; lookupName: Boolean): Boolean; syscall sysTrapSysCreateDataBaseList;
  892. function SysCreatePanelList(var panelCount: UInt16; var panelIDs: MemHandle): Boolean; syscall sysTrapSysCreatePanelList;
  893. function SysBatteryInfo(set_: Boolean; var warnThresholdP, criticalThresholdP: UInt16;
  894. var maxTicksP: Int16; var kindP: SysBatteryKind; var pluggedIn: Boolean;
  895. var percentP: UInt8): UInt16; syscall sysTrapSysBatteryInfo;
  896. function SysBatteryInfoV20(set_: Boolean; warnThresholdP, criticalThresholdP: UInt16;
  897. var maxTicksP: Int16; var kindP: SysBatteryKind; var pluggedIn: Boolean): UInt16; syscall sysTrapSysBatteryInfoV20;
  898. function SysGetStackInfo(var startPP, endPP: MemPtr): Boolean; syscall sysTrapSysGetStackInfo;
  899. // Mailboxes
  900. function SysMailboxCreate(var mbIDP, tagP: UInt32; depth: UInt32): Err; syscall sysTrapSysMailboxCreate;
  901. function SysMailboxDelete(mbID: UInt32): Err; syscall sysTrapSysMailboxDelete;
  902. function SysMailboxFlush(mbID: UInt32): Err; syscall sysTrapSysMailboxFlush;
  903. function SysMailboxSend(mbID: UInt32; msgP: Pointer; wAck: UInt32): Err; syscall sysTrapSysMailboxSend;
  904. function SysMailboxWait(mbID: UInt32; msgP: Pointer; priority: UInt32; timeout: Int32): Err; syscall sysTrapSysMailboxWait;
  905. // Event Groups
  906. function SysEvGroupCreate(var evIDP, tagP: UInt32; init: UInt32): Err; syscall sysTrapSysEvGroupCreate;
  907. //Err SysEvGroupDelete(UInt32 evID) // save trap table space - don't need
  908. //; syscall sysTrapSysEvGroupDelete;
  909. function SysEvGroupSignal(evID, mask, value: UInt32; type_: Int32): Err; syscall sysTrapSysEvGroupSignal;
  910. function SysEvGroupRead(evID: UInt32; var valueP: UInt32): Err; syscall sysTrapSysEvGroupRead;
  911. function SysEvGroupWait(evID, mask, value: UInt32; matchType, timeout: Int32): Err; syscall sysTrapSysEvGroupWait;
  912. (************************************************************
  913. * Assembly Function Prototypes
  914. *************************************************************)
  915. //#define _SysSemaphoreSignal ASM_; syscall sysTrapSysSemaphoreSignal
  916. //#define _SysSemaphoreSet ASM_; syscall sysTrapSysSemaphoreSet
  917. //#define _SysDoze ASM_; syscall sysTrapSysDoze
  918. implementation
  919. function sysMakeROMVersion(major, minor, fix, stage: UInt8; buildNum: UInt16): UInt32;
  920. begin
  921. sysMakeROMVersion :=
  922. ((major and $0FF) shl 24) or
  923. ((minor and $00F) shl 20) or
  924. ((fix and $00F) shl 16) or
  925. ((stage and $00F) shl 12) or
  926. (buildNum and $0FFF);
  927. end;
  928. function sysGetROMVerMajor(dwROMVer: UInt32): UInt16;
  929. begin
  930. sysGetROMVerMajor := (dwROMVer shr 24) and $00FF;
  931. end;
  932. function sysGetROMVerMinor(dwROMVer: UInt32): UInt16;
  933. begin
  934. sysGetROMVerMinor := (dwROMVer shr 20) and $000F;
  935. end;
  936. function sysGetROMVerFix(dwROMVer: UInt32): UInt16;
  937. begin
  938. sysGetROMVerFix := (dwROMVer shr 16) and $000F;
  939. end;
  940. function sysGetROMVerStage(dwROMVer: UInt32): UInt16;
  941. begin
  942. sysGetROMVerStage := (dwROMVer shr 12) and $000F;
  943. end;
  944. function sysGetROMVerBuild(dwROMVer: UInt32): UInt16;
  945. begin
  946. sysGetROMVerBuild := dwROMVer and $0FFF;
  947. end;
  948. end.