~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/palmunits/systemmgr.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

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