Subversion Repositories Kolibri OS

Rev

Rev 1505 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1018 diamond 1
SYSTEM FUNCTIONS of OS Kolibri 0.7.5.0
114 mikedld 2
 
3
Number of the function is located in the register eax.
118 diamond 4
The call of the system function is executed by "int 0x40" command.
5
All registers except explicitly declared in the returned value,
6
    including eflags, are preserved.
114 mikedld 7
 
8
 
9
======================================================================
10
============== Function 0 - define and draw the window. ==============
11
======================================================================
12
Defines an application window. Draws a frame of the window, header and
133 diamond 13
working area. For skinned windows defines standard close and minimize
14
buttons.
114 mikedld 15
Parameters:
118 diamond 16
  * eax = 0 - function number
114 mikedld 17
  * ebx = [coordinate on axis x]*65536 + [size on axis x]
18
  * ecx = [coordinate on axis y]*65536 + [size on axis y]
19
  * edx = 0xXYRRGGBB, where:
20
    * Y = style of the window:
131 diamond 21
      * Y=0 - type I - fixed-size window
118 diamond 22
      * Y=1 - only define window area, draw nothing
131 diamond 23
      * Y=2 - type II - variable-size window
24
      * Y=3 - skinned window
641 diamond 25
      * Y=4 - skinned fixed-size window
26
      * other possible values (from 5 up to 15) are reserved,
114 mikedld 27
        function call with such Y is ignored
118 diamond 28
    * RR, GG, BB = accordingly red, green, blue components of a color
29
      of the working area of the window (are ignored for style Y=2)
114 mikedld 30
    * X = DCBA (bits)
641 diamond 31
      * A = 1 - window has caption; for styles Y=3,4 caption string
118 diamond 32
                  must be passed in edi, for other styles use
33
                  subfunction 1 of function 71
34
      * B = 1 - coordinates of all graphics primitives are relative to
35
                  window client area
303 mikedld 36
      * C = 1 - don't fill working area on window draw
118 diamond 37
      * D = 0 - normal filling of the working area, 1 - gradient
38
    The following parameters are intended for windows
39
    of a type I and II, and ignored for styles Y=1,3:
40
  * esi = 0xXYRRGGBB - color of the header
41
    * RR, GG, BB define color
114 mikedld 42
    * Y=0 - usual window, Y=1 - unmovable window
118 diamond 43
    * X defines a gradient of header: X=0 - no gradient,
114 mikedld 44
      X=8 - usual gradient,
45
      for windows of a type II X=4 - negative gradient
118 diamond 46
    * other values of X and Y are reserved
47
  * edi = 0x00RRGGBB - color of the frame
114 mikedld 48
Returned value:
49
  * function does not return value
50
Remarks:
118 diamond 51
  * Position and sizes of the window are installed by the first
52
    call of this function and are ignored at subsequent; to change
53
    position and/or sizes of already created window use function 67.
641 diamond 54
  * For windows with styles Y=3,4 and caption (A=1) caption string
55
    is set by the first call of this function and is ignored
56
    at subsequent (strictly speaking, is ignored after a call to
57
    subfunction 2 of function 12 - end redraw); to change caption of
58
    already created window use subfunction 1 of function 71.
118 diamond 59
  * If the window has appropriate styles, position and/or sizes can be
60
    changed by user. Current position and sizes can be obtained
61
    by function 9.
62
  * The window must fit on the screen. If the transferred
63
    coordinates and sizes do not satisfy to this condition,
64
    appropriate coordinate (or, probably, both) is considered as zero,
131 diamond 65
    and if it does not help too, the appropriate size
118 diamond 66
    (or, probably, both) is installed in a size of the screen.
114 mikedld 67
 
131 diamond 68
    Further let us designate xpos,ypos,xsize,ysize - values passed
69
    in ebx,ecx. The coordinates are resulted concerning
118 diamond 70
    the left upper corner of the window, which, thus, is set as (0,0),
71
    coordinates of the right lower corner essence (xsize,ysize).
72
  * The sizes of the window are understood in sence of coordinates
73
    of the right lower corner. This concerns all other functions too.
74
    It means, that the real sizes are on 1 pixel more.
75
  * The window of type I looks as follows:
76
    * draw external frame of color indicated in edi, 1 pixel in width
77
    * draw header - rectangle with the left upper corner (1,1) and
78
      right lower (xsize-1,min(25,ysize)) color indicated in esi
79
      (taking a gradient into account)
80
    * if ysize>=26, fill the working area of the window -
81
      rectangle with the left upper corner (1,21) and right lower
82
      (xsize-1,ysize-1) (sizes (xsize-1)*(ysize-21)) with color
83
      indicated in edx (taking a gradient into account)
84
    * if A=1 and caption has been already set by subfunction 1
85
      of function 71, it is drawn in the corresponding place of header
86
  * The window of style Y=1 looks as follows:
114 mikedld 87
    * completely defined by the application
118 diamond 88
  * The window of type II looks as follows:
89
    * draw external frame of width 1 pixel with the "shaded" color
90
      edi (all components of the color decrease twice)
91
    * draw intermediate frame of width 3 pixels with color edi
92
    * draw internal frame of width 1 pixel with the "shaded" color edi
114 mikedld 93
    * draw header - rectangle with the left upper corner (4,4)
118 diamond 94
      and right lower (xsize-4,min(20,ysize)) color, indicated in esi
95
      (taking a gradient into account)
96
    * if ysize>=26, fill the working area of the window -
114 mikedld 97
      rectangle with the left upper corner (5,20) and right lower
118 diamond 98
      (xsize-5,ysize-5) with color indicated in edx
99
      (taking a gradient into account)
100
    * if A=1 and caption has been already set by subfunction 1
101
      of function 71, it is drawn in the corresponding place of header
102
  * The skinned window looks as follows:
114 mikedld 103
    * draw external frame of width 1 pixel
118 diamond 104
      with color 'outer' from the skin
105
    * draw intermediate frame of width 3 pixel
106
      with color 'frame' from the skin
107
    * draw internal frame of width 1 pixel
108
      with color 'inner' from the skin
109
    * draw header (on bitmaps from the skin) in a rectangle
114 mikedld 110
      (0,0) - (xsize,_skinh-1)
118 diamond 111
    * if ysize>=26, fill the working area of the window -
112
      rectangle with the left upper corner (5,_skinh) and right lower
113
      (xsize-5,ysize-5) with color indicated in edx
114
      (taking a gradient into account)
133 diamond 115
    * define two standard buttons: close and minimize
114 mikedld 116
      (see function 8)
118 diamond 117
    * if A=1 and edi contains (nonzero) pointer to caption string,
118
      it is drawn in place in header defined in the skin
119
    * value _skinh is accessible as the result of call
120
      subfunction 4 of function 48
114 mikedld 121
 
122
======================================================================
118 diamond 123
================ Function 1 - put pixel in the window. ===============
114 mikedld 124
======================================================================
125
Parameters:
118 diamond 126
  * eax = 1 - function number
127
  * ebx = x-coordinate (relative to the window)
128
  * ecx = y-coordinate (relative to the window)
129
  * edx = 0x00RRGGBB - color of a pixel
130
    edx = 0x01xxxxxx - invert color of a pixel
131
          (low 24 bits are ignored)
114 mikedld 132
Returned value:
133
  * function does not return value
134
 
135
======================================================================
118 diamond 136
============ Function 2 - get the code of the pressed key. ===========
114 mikedld 137
======================================================================
138
Takes away the code of the pressed key from the buffer.
139
Parameters:
118 diamond 140
  * eax = 2 - function number
114 mikedld 141
Returned value:
118 diamond 142
  * if the buffer is empty, function returns eax=1
143
  * if the buffer is not empty, function returns al=0,
144
    ah=code of the pressed key, high word of eax is zero
145
  * if there is "hotkey", function returns al=2,
146
    ah=scancode of the pressed key (0 for control keys),
147
    high word of eax contains a status of control keys at the moment
148
    of pressing a hotkey
114 mikedld 149
Remarks:
118 diamond 150
  * There is a common system buffer of the pressed keys
151
    by a size of 120 bytes, organized as queue.
152
  * There is one more common system buffer on 120 "hotkeys".
153
  * If the application with the inactive window calls this function,
154
    the buffer of the pressed keys is considered to be empty.
155
  * By default this function returns ASCII-codes; to switch
156
    to the scancodes mode (and back) use function 66.
157
    However, hotkeys are always notificated as scancodes.
158
  * To find out, what keys correspond to what codes, start
159
    the application keyascii and scancode.
160
  * Scancodes come directly from keyboard and are fixed;
161
    ASCII-codes turn out with usage of the conversion tables,
162
    which can be set by subfunction 2 of function 21
163
    and get by subfunction 2 of function 26.
164
  * As a consequence, ASCII-codes take into account current
165
    keyboard layout (rus/en) as opposed to scancodes.
166
  * This function notifies only about those hotkeys, which were
167
    defined by this thread by subfunction 4 of function 66.
114 mikedld 168
 
169
======================================================================
118 diamond 170
==================== Function 3 - get system time. ===================
114 mikedld 171
======================================================================
172
Parameters:
118 diamond 173
  * eax = 3 - function number
114 mikedld 174
Returned value:
175
  * eax = 0x00SSMMHH, where HH:MM:SS = Hours:Minutes:Seconds
118 diamond 176
  * each item is BCD-number, for example,
177
    for time 23:59:59 function returns 0x00595923
114 mikedld 178
Remarks:
118 diamond 179
  * See also subfunction 9 of function 26 - get time from
180
    the moment of start of the system; it is more convenient, because
181
    returns simply DWORD-value of the time counter.
182
  * System time can be set by function 22.
114 mikedld 183
 
184
======================================================================
118 diamond 185
============ Function 4 - draw text string in the window. ============
114 mikedld 186
======================================================================
187
Parameters:
118 diamond 188
  * eax = 4 - function number
114 mikedld 189
  * ebx = [coordinate on axis x]*65536 + [coordinate on axis y]
190
  * ecx = 0xX0RRGGBB, where
118 diamond 191
    * RR, GG, BB specify text color
139 diamond 192
    * X=ABnn (bits):
185 heavyiron 193
    * nn specifies the used font: 0=system monospaced,
194
      1=system font of variable width
139 diamond 195
    * A=0 - output esi characters, A=1 - output ASCIIZ-string
196
    * B=1 - fill background with the color edi
118 diamond 197
  * edx = pointer to the beginning of the string
139 diamond 198
  * esi = for A=0 length of the string, must not exceed 255;
199
          for A=1 is ignored
114 mikedld 200
Returned value:
201
  * function does not return value
202
Remarks:
118 diamond 203
  * First system font is read out at loading from the file char.mt,
204
    second - from char2.mt.
205
  * Both fonts have height 9 pixels, width of the monospaced font
206
    is equal to 6 pixels.
114 mikedld 207
 
208
======================================================================
118 diamond 209
========================= Function 5 - delay. ========================
114 mikedld 210
======================================================================
211
Delays execution of the program on the given time.
212
Parameters:
118 diamond 213
  * eax = 5 - function number
114 mikedld 214
  * ebx = time in the 1/100 of second
215
Returned value:
216
  * function does not return value
217
Remarks:
118 diamond 218
  * Passing ebx=0 does not transfer control to the next process
219
    and does not make any operations at all. If it is really required
220
    to transfer control to the next process (to complete a current
221
    time slice), use subfunction 1 of function 68.
114 mikedld 222
 
223
======================================================================
118 diamond 224
============== Function 6 - read the file from ramdisk. ==============
114 mikedld 225
======================================================================
226
Parameters:
118 diamond 227
  * eax = 6 - function number
228
  * ebx = pointer to the filename
229
  * ecx = number of start block, beginning from 1;
230
    ecx=0 - read from the beginning of the file (same as ecx=1)
231
  * edx = number of blocks to read;
232
    edx=0 - read one block (same as edx=1)
233
  * esi = pointer to memory area for the data
114 mikedld 234
Returned value:
118 diamond 235
  * eax = file size in bytes, if the file was successfully read
236
  * eax = -1, if the file was not found
114 mikedld 237
Remarks:
118 diamond 238
  * This function is out-of-date; function 70 allows
239
    to fulfil the same operations with the extended possibilities.
114 mikedld 240
  * Block = 512 bytes.
118 diamond 241
  * For reading all file you can specify the certainly large value
242
    in edx, for example, edx = -1; but in this case be ready that
243
    the program will "fall", if the file will appear too large and can
244
    not be placed in the program memory.
245
  * The filename must be either in the format 8+3 characters
246
    (first 8 characters - name itself, last 3 - extension,
247
    the short names and extensions are supplemented with spaces),
248
    or in the format 8.3 characters "FILE.EXT"/"FILE.EX "
249
    (name no more than 8 characters, dot, extension 3 characters
250
    supplemented if necessary by spaces).
251
    The filename must be written with capital letters. The terminating
252
    character with code 0 is not necessary (not ASCIIZ-string).
253
  * This function does not support folders on the ramdisk.
114 mikedld 254
 
255
======================================================================
256
=============== Function 7 - draw image in the window. ===============
257
======================================================================
118 diamond 258
Paramters:
259
  * eax = 7 - function number
260
  * ebx = pointer to the image in the format BBGGRRBBGGRR...
114 mikedld 261
  * ecx = [size on axis x]*65536 + [size on axis y]
262
  * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
263
Returned value:
264
  * function does not return value
265
Remarks:
118 diamond 266
  * Coordinates of the image are coordinates of the upper left corner
267
    of the image relative to the window.
114 mikedld 268
  * Size of the image in bytes is 3*xsize*ysize.
269
 
270
======================================================================
271
=============== Function 8 - define/delete the button. ===============
272
======================================================================
118 diamond 273
Parameters for button definition:
274
  * eax = 8 - function number
114 mikedld 275
  * ebx = [coordinate on axis x]*65536 + [size on axis x]
276
  * ecx = [coordinate on axis y]*65536 + [size on axis y]
277
  * edx = 0xXYnnnnnn, where:
278
    * nnnnnn = identifier of the button
118 diamond 279
    * high (31st) bit of edx is cleared
280
    * if 30th bit of edx is set - do not draw the button
281
    * if 29th bit of edx is set - do not draw a frame
114 mikedld 282
      at pressing the button
118 diamond 283
  * esi = 0x00RRGGBB - color of the button
284
Parameters for button deleting:
285
  * eax = 8 - function number
114 mikedld 286
  * edx = 0x80nnnnnn, where nnnnnn - identifier of the button
287
Returned value:
288
  * function does not return value
289
Remarks:
118 diamond 290
  * Sizes of the button must be more than 0 and less than 0x8000.
131 diamond 291
  * For skinned windows definition of the window
118 diamond 292
    (call of 0th function) creates two standard buttons -
293
    for close of the window with identifier 1 and
294
    for minimize of the window with identifier 0xffff.
295
  * The creation of two buttons with same identifiers is admitted.
296
  * The button with the identifier 0xffff at pressing is interpreted
297
    by the system as the button of minimization, the system handles
298
    such pressing independently, not accessing to the application.
299
    In rest it is usual button.
300
  * Total number of buttons for all applications is limited to 4095.
114 mikedld 301
 
302
======================================================================
118 diamond 303
============ Function 9 - information on execution thread. ===========
114 mikedld 304
======================================================================
305
Parameters:
118 diamond 306
  * eax = 9 - function number
307
  * ebx = pointer to 1-Kb buffer
308
  * ecx = number of the slot of the thread
309
    ecx = -1 - get information on the current thread
114 mikedld 310
Returned value:
118 diamond 311
  * eax = maximum number of the slot of a thread
312
  * buffer pointed to by ebx contains the following information:
313
    * +0: dword: usage of the processor (how many time units
314
      per second leaves on execution of this thread)
114 mikedld 315
    * +4: word: position of the window of thread in the window stack
118 diamond 316
    * +6: word: (has no relation to the specified thread)
317
      number of the thread slot, which window has in the window stack
318
      position ecx
114 mikedld 319
    * +8: word: reserved
320
    * +10 = +0xA: 11 bytes: name of the process
118 diamond 321
      (name of corresponding executable file in the format 8+3)
142 diamond 322
    * +21 = +0x15: byte: reserved, this byte is not changed
114 mikedld 323
    * +22 = +0x16: dword: address of the process in memory
324
    * +26 = +0x1A: dword: size of used memory - 1
325
    * +30 = +0x1E: dword: identifier (PID/TID)
118 diamond 326
    * +34 = +0x22: dword: coordinate of the thread window on axis x
327
    * +38 = +0x26: dword: coordinate of the thread window on axis y
328
    * +42 = +0x2A: dword: size of the thread window on axis x
329
    * +46 = +0x2E: dword: size of the thread window on axis y
330
    * +50 = +0x32: word: status of the thread slot:
331
      * 0 = thread is running
332
      * 1 = thread is suspended
333
      * 2 = thread is suspended while waiting for event
334
      * 3 = thread is terminating as a result of call to function -1
335
        or under duress as a result of call to subfunction 2
336
        of function 18 or termination of the system
337
      * 4 = thread is terminating as a result of exception
338
      * 5 = thread waits for event
339
      * 9 = requested slot is free, all other information on the slot
340
        is not meaningful
142 diamond 341
    * +52 = +0x34: word: reserved, this word is not changed
342
    * +54 = +0x36: dword: coordinate of the client area on axis x
343
    * +58 = +0x3A: dword: coordinate of the client area on axis y
344
    * +62 = +0x3E: dword: width of the client area
345
    * +66 = +0x42: dword: height of the client area
346
    * +70 = +0x46: byte: state of the window - bitfield
347
      * bit 0 (mask 1): window is maximized
348
      * bit 1 (mask 2): window is minimized to panel
349
      * bit 2 (mask 4): window is rolled up
1689 art_zh 350
    * +71 = +0x47: dword: event mask
114 mikedld 351
Remarks:
118 diamond 352
  * Slots are numbered starting from 1.
353
  * Returned value is not a total number of threads, because there
354
    can be free slots.
355
  * When process is starting, system automatically creates
356
    execution thread.
357
  * Function gives information on the thread. Each process has
358
    at least one thread. One process can create many threads,
359
    in this case each thread has its own slot and the fields
360
    +10, +22, +26 in these slots coincide.
361
    Applications have no common way to define whether two threads
114 mikedld 362
    belong to one process.
118 diamond 363
  * The active window - window on top of the window stack -
364
    receives the messages on a keyboard input. For such window
365
    the position in the window stack coincides with returned value.
366
  * Slot 1 corresponds to special system thread, for which:
367
    * the window is in the bottom of the window stack, the fields
368
      +4 and +6 contain value 1
369
    * name of the process - "OS/IDLE" (supplemented by spaces)
370
    * address of the process in memory is 0, size of used memory is
114 mikedld 371
      16 Mb (0x1000000)
372
    * PID=1
142 diamond 373
    * coordinates and sizes of the window and the client area are by
374
      convention set to 0
118 diamond 375
    * status of the slot is always 0 (running)
376
    * the execution time adds of time leaving on operations itself
377
      and idle time in waiting for interrupt (which can be got by call
378
      to subfunction 4 of function 18).
379
  * Beginning from slot 2, the normal applications are placed.
1445 art_zh 380
  * Applications are placed in memory at the address   0x0
381
    (kernel constant 'std_application_base_address').
118 diamond 382
    There is no intersection, as each process has its own page table.
383
  * At creation of the thread it is assigned the slot
384
    in the system table and identifier (Process/Thread IDentifier =
385
    PID/TID), which do not vary with time for given thread.
386
    After completion of the thread its slot can be anew used
387
    for another thread. The thread identifier can not be assigned
388
    to other thread even after completion of this thread.
389
    Identifiers, assigned to new threads, grow monotonously.
390
  * If the thread has not yet defined the window by call to
391
    function 0, the position and the sizes
392
    of its window are considered to be zero.
142 diamond 393
  * Coordinates of the client area are relative to the window.
118 diamond 394
  * At the moment only the part of the buffer by a size
142 diamond 395
    71 = 0x37 bytes is used. Nevertheless it is recommended to use
118 diamond 396
    1-Kb buffer for the future compatibility, in the future
397
    some fields can be added.
114 mikedld 398
 
399
======================================================================
118 diamond 400
==================== Function 10 - wait for event. ===================
114 mikedld 401
======================================================================
118 diamond 402
If the message queue is empty, waits for appearance of the message
403
in queue. In this state thread does not consume CPU time.
114 mikedld 404
Then reads out the message from queue.
405
 
406
Parameters:
118 diamond 407
  * eax = 10 - function number
114 mikedld 408
Returned value:
118 diamond 409
  * eax = event (see the list of events)
114 mikedld 410
Remarks:
118 diamond 411
  * Those events are taken into account only which enter into
412
    a mask set by function 40. By default it is
413
    redraw, key and button events.
414
  * To check, whether there is a message in queue, use function 11.
415
    To wait for no more than given time, use function 23.
114 mikedld 416
 
118 diamond 417
======================================================================
418
=============== Function 11 - check for event, no wait. ==============
419
======================================================================
420
If the message queue contains event, function reads out
421
and return it. If the queue is empty, function returns 0.
114 mikedld 422
Parameters:
118 diamond 423
  * eax = 11 - function number
114 mikedld 424
Returned value:
425
  * eax = 0 - message queue is empty
118 diamond 426
  * else eax = event (see the list of events)
114 mikedld 427
Remarks:
118 diamond 428
  * Those events are taken into account only, which enter into
429
    a mask set by function 40. By default it is
430
    redraw, key and button events.
431
  * To wait for event, use function 10.
432
    To wait for no more than given time, use function 23.
114 mikedld 433
 
434
======================================================================
118 diamond 435
=============== Function 12 - begin/end window redraw. ===============
114 mikedld 436
======================================================================
437
 
139 diamond 438
---------------- Subfunction 1 - begin window redraw. ----------------
114 mikedld 439
Parameters:
118 diamond 440
  * eax = 12 - function number
441
  * ebx = 1 - subfunction number
114 mikedld 442
Returned value:
443
  * function does not return value
444
 
139 diamond 445
----------------- Subfunction 2 - end window redraw. -----------------
114 mikedld 446
Parameters:
118 diamond 447
  * eax = 12 - function number
448
  * ebx = 2 - subfunction number
114 mikedld 449
Returned value:
450
  * function does not return value
451
Remarks:
118 diamond 452
  * Subfunction 1 deletes all buttons defined with
453
    function 8, they must be defined again.
114 mikedld 454
 
455
======================================================================
456
============ Function 13 - draw a rectangle in the window. ===========
457
======================================================================
458
Parameters:
118 diamond 459
  * eax = 13 - function number
114 mikedld 460
  * ebx = [coordinate on axis x]*65536 + [size on axis x]
461
  * ecx = [coordinate on axis y]*65536 + [size on axis y]
118 diamond 462
  * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill
114 mikedld 463
Returned value:
464
  * function does not return value
465
Remarks:
466
  * Coordinates are understood as coordinates of the left upper corner
118 diamond 467
    of a rectangle relative to the window.
114 mikedld 468
 
469
======================================================================
118 diamond 470
=================== Function 14 - get screen size. ===================
114 mikedld 471
======================================================================
472
Parameters:
118 diamond 473
  * eax = 14 - function number
114 mikedld 474
Returned value:
475
  * eax = [xsize]*65536 + [ysize], where
476
  * xsize = x-coordinate of the right lower corner of the screen =
118 diamond 477
            horizontal size - 1
114 mikedld 478
  * ysize = y-coordinate of the right lower corner of the screen =
118 diamond 479
            vertical size - 1
114 mikedld 480
Remarks:
118 diamond 481
  * See also subfunction 5 of function 48 - get sizes of
482
    working area of the screen.
114 mikedld 483
 
118 diamond 484
======================================================================
485
== Function 15, subfunction 1 - set a size of the background image. ==
486
======================================================================
114 mikedld 487
Parameters:
118 diamond 488
  * eax = 15 - function number
489
  * ebx = 1 - subfunction number
114 mikedld 490
  * ecx = width of the image
491
  * edx = height of the image
492
Returned value:
493
  * function does not return value
494
Remarks:
499 diamond 495
  * Before calling subfunctions 2 and 5 you should call this function
485 heavyiron 496
    to set image size!
118 diamond 497
  * For update of the screen (after completion of a series of commands
498
    working with a background) call subfunction 3.
499
  * There is a pair function for get size of the background image -
500
    subfunction 1 of function 39.
114 mikedld 501
 
502
======================================================================
118 diamond 503
=== Function 15, subfunction 2 - put pixel on the background image. ==
114 mikedld 504
======================================================================
505
Parameters:
118 diamond 506
  * eax = 15 - function number
507
  * ebx = 2 - subfunction number
114 mikedld 508
  * ecx = offset
118 diamond 509
  * edx = color of a pixel 0xRRGGBB
114 mikedld 510
Returned value:
511
  * function does not return value
512
Remarks:
118 diamond 513
  * Offset for a pixel with coordinates (x,y) is calculated as
114 mikedld 514
    (x+y*xsize)*3.
499 diamond 515
  * If the given offset exceeds size set by subfunction 1,
118 diamond 516
    the call is ignored.
517
  * For update of the screen (after completion of a series of commands
518
    working with a background) call subfunction 3.
519
  * There is a pair function for get pixel on the background image -
520
    subfunction 2 of function 39.
114 mikedld 521
 
522
======================================================================
523
=========== Function 15, subfunction 3 - redraw background. ==========
524
======================================================================
525
Parameters:
118 diamond 526
  * eax = 15 - function number
527
  * ebx = 3 - subfunction number
114 mikedld 528
Returned value:
529
  * function does not return value
530
 
118 diamond 531
======================================================================
532
== Function 15, subfunction 4 - set drawing mode for the background. =
533
======================================================================
114 mikedld 534
Parameters:
118 diamond 535
  * eax = 15 - function number
536
  * ebx = 4 - subfunction number
537
  * ecx = drawing mode:
114 mikedld 538
    * 1 = tile
539
    * 2 = stretch
540
Returned value:
541
  * function does not return value
542
Remarks:
118 diamond 543
  * For update of the screen (after completion of a series of commands
544
    working with a background) call subfunction 3.
545
  * There is a pair function for get drawing mode of the background -
546
    subfunction 4 of function 39.
114 mikedld 547
 
118 diamond 548
======================================================================
549
===================== Function 15, subfunction 5 =====================
550
============ Put block of pixels on the background image. ============
551
======================================================================
114 mikedld 552
Parameters:
118 diamond 553
  * eax = 15 - function number
554
  * ebx = 5 - subfunction number
555
  * ecx = pointer to the data in the format BBGGRRBBGGRR...
114 mikedld 556
  * edx = offset in data of the background image
118 diamond 557
  * esi = size of data in bytes = 3 * number of pixels
114 mikedld 558
Returned value:
559
  * function does not return value
560
Remarks:
499 diamond 561
  * Offset and size are not checked for correctness.
118 diamond 562
  * Color of each pixel is stored as 3-bytes value BBGGRR.
563
  * Pixels of the background image are written sequentially
564
    from left to right, from up to down.
565
  * Offset of pixel with coordinates (x,y) is (x+y*xsize)*3.
566
  * For update of the screen (after completion of a series of commands
567
    working with a background) call subfunction 3.
114 mikedld 568
 
569
======================================================================
546 diamond 570
===================== Function 15, subfunction 6 =====================
571
======== Map background data to the address space of process. ========
572
======================================================================
573
Parameters:
574
  * eax = 15 - function number
575
  * ebx = 6 - subfunction number
576
Returned value:
577
  * eax = pointer to background data, 0 if error
578
Remarks:
579
  * Mapped data are available for read and write.
580
  * Size of background data is 3*xsize*ysize. The system blocks
581
    changes of background sizes while process works with mapped data.
582
  * Color of each pixel is stored as 3-bytes value BBGGRR.
583
  * Pixels of the background image are written sequentially
584
    from left to right, from up to down.
585
 
586
======================================================================
587
===== Function 15, subfunction 7 - close mapped background data. =====
588
======================================================================
589
Parameters:
590
  * eax = 15 - function number
591
  * ebx = 7 - subfunction number
592
  * ecx = pointer to mapped data
593
Returned value:
594
  * eax = 1 - success, 0 - error
595
 
596
======================================================================
118 diamond 597
=============== Function 16 - save ramdisk on a floppy. ==============
114 mikedld 598
======================================================================
599
Parameters:
118 diamond 600
  * eax = 16 - function number
601
  * ebx = 1 or ebx = 2 - on which floppy save
114 mikedld 602
Returned value:
118 diamond 603
  * eax = 0 - success
114 mikedld 604
  * eax = 1 - error
605
 
606
======================================================================
118 diamond 607
======= Function 17 - get the identifier of the pressed button. ======
114 mikedld 608
======================================================================
609
Takes away the code of the pressed button from the buffer.
610
Parameters:
118 diamond 611
  * eax = 17 - function number
114 mikedld 612
Returned value:
118 diamond 613
  * if the buffer is empty, function returns eax=1
1018 diamond 614
  * if the buffer is not empty:
615
    * high 24 bits of eax contain button identifier (in particular,
616
      ah contains low byte of the identifier; if all buttons have
617
      the identifier less than 256, ah is enough to distinguish)
618
    * al = 0 - the button was pressed with left mouse button
619
    * al = bit corresponding to used mouse button otherwise
114 mikedld 620
Remarks:
118 diamond 621
  * "Buffer" keeps only one button, at pressing the new button the
622
    information about old is lost.
623
  * The call of this function by an application with inactive window
624
    will return answer "buffer is empty".
1018 diamond 625
  * Returned value for al corresponds to the state of mouse buttons
626
    as in subfunction 2 of function 37 at the beginning
627
    of button press, excluding lower bit, which is cleared.
114 mikedld 628
 
629
======================================================================
118 diamond 630
= Function 18, subfunction 2 - terminate process/thread by the slot. =
114 mikedld 631
======================================================================
632
Parameters:
118 diamond 633
  * eax = 18 - function number
634
  * ebx = 2 - subfunction number
114 mikedld 635
  * ecx = number of the slot of process/thread
636
Returned value:
637
  * function does not return value
638
Remarks:
118 diamond 639
  * It is impossible to terminate system thread OS/IDLE (with
640
    number of the slot 1),
641
    it is possible to terminate any normal process/thread.
642
  * See also subfunction 18 - terminate
643
    process/thread by the identifier.
114 mikedld 644
 
118 diamond 645
======================================================================
646
===================== Function 18, subfunction 3 =====================
647
============= Make active the window of the given thread. ============
648
======================================================================
114 mikedld 649
Parameters:
118 diamond 650
  * eax = 18 - function number
651
  * ebx = 3 - subfunction number
652
  * ecx = number of the thread slot
114 mikedld 653
Returned value:
654
  * function does not return value
655
Remarks:
118 diamond 656
  * If correct, but nonexistent slot is given,
657
    some window is made active.
658
  * To find out, which window is active, use subfunction 7.
114 mikedld 659
 
118 diamond 660
======================================================================
661
===================== Function 18, subfunction 4 =====================
662
=========== Get counter of idle time units per one second. ===========
663
======================================================================
664
Idle time units are units, in which the processor stands idle
665
in waiting for interrupt (in the command 'hlt').
114 mikedld 666
 
667
Parameters:
118 diamond 668
  * eax = 18 - function number
669
  * ebx = 4 - subfunction number
114 mikedld 670
Returned value:
118 diamond 671
  * eax = value of the counter of idle time units per one second
114 mikedld 672
 
673
======================================================================
118 diamond 674
========== Function 18, subfunction 5 - get CPU clock rate. ==========
114 mikedld 675
======================================================================
676
Parameters:
118 diamond 677
  * eax = 18 - function number
678
  * ebx = 5 - subfunction number
114 mikedld 679
Returned value:
118 diamond 680
  * eax = clock rate (modulo 2^32 clock ticks = 4GHz)
114 mikedld 681
 
118 diamond 682
======================================================================
1074 Galkov 683
 Function 18, subfunction 6 - save ramdisk to the file on hard drive.
118 diamond 684
======================================================================
114 mikedld 685
Parameters:
118 diamond 686
  * eax = 18 - function number
687
  * ebx = 6 - subfunction number
341 heavyiron 688
  * ecx = pointer to the full path to file
689
    (for example, "/hd0/1/kolibri/kolibri.img")
114 mikedld 690
Returned value:
118 diamond 691
  * eax = 0 - success
692
  * else eax = error code of the file system
499 diamond 693
Remarks:
118 diamond 694
  * All folders in the given path must exist, otherwise function
695
    returns value 5, "file not found".
114 mikedld 696
 
697
======================================================================
118 diamond 698
=========== Function 18, subfunction 7 - get active window. ==========
114 mikedld 699
======================================================================
700
Parameters:
118 diamond 701
  * eax = 18 - function number
702
  * ebx = 7 - subfunction number
114 mikedld 703
Returned value:
118 diamond 704
  * eax = number of the active window
705
    (number of the slot of the thread with active window)
114 mikedld 706
Remarks:
118 diamond 707
  * Active window is at the top of the window stack and receives
708
    messages on all keyboard input.
709
  * To make a window active, use subfunction 3.
114 mikedld 710
 
118 diamond 711
======================================================================
712
== Function 18, subfunction 8 - disable/enable the internal speaker. =
713
======================================================================
714
If speaker sound is disabled, all calls to subfunction 55 of
715
function 55 are ignored. If speaker sound is enabled,
716
they are routed on builtin speaker.
114 mikedld 717
 
118 diamond 718
------------------- Subsubfunction 1 - get status. -------------------
114 mikedld 719
Parameters:
118 diamond 720
  * eax = 18 - function number
721
  * ebx = 8 - subfunction number
722
  * ecx = 1 - number of the subsubfunction
114 mikedld 723
Returned value:
118 diamond 724
  * eax = 0 - speaker sound is enabled; 1 - disabled
114 mikedld 725
 
118 diamond 726
----------------- Subsubfunction 2 - toggle status. ------------------
727
Toggles states of disable/enable.
114 mikedld 728
Parameters:
118 diamond 729
  * eax = 18 - function number
730
  * ebx = 8 - subfunction number
731
  * ecx = 2 - number of the subsubfunction
114 mikedld 732
Returned value:
733
  * function does not return value
734
 
118 diamond 735
======================================================================
1018 diamond 736
== Function 18, subfunction 9 - system shutdown with the parameter. ==
118 diamond 737
======================================================================
114 mikedld 738
Parameters:
118 diamond 739
  * eax = 18 - function number
740
  * ebx = 9 - subfunction number
114 mikedld 741
  * ecx = parameter:
118 diamond 742
    * 2 = turn off computer
743
    * 3 = reboot computer
744
    * 4 = restart the kernel from the file 'kernel.mnt' on ramdisk
114 mikedld 745
Returned value:
118 diamond 746
  * at incorrect ecx the registers do not change (i.e. eax=18)
747
  * by correct call function always returns eax=0
748
    as the tag of success
114 mikedld 749
Remarks:
118 diamond 750
  * Do not rely on returned value by incorrect call, it can be
751
    changed in future versions of the kernel.
1018 diamond 752
 
118 diamond 753
======================================================================
754
===== Function 18, subfunction 10 - minimize application window. =====
755
======================================================================
756
Minimizes the own window.
114 mikedld 757
Parameters:
118 diamond 758
  * eax = 18 - function number
759
  * ebx = 10 - subfunction number
114 mikedld 760
Returned value:
761
  * function does not return value
762
Remarks:
118 diamond 763
  * The minimized window from the point of view of function 9
764
    keeps position and sizes.
1074 Galkov 765
  * Restoring of an application window occurs at its activation by
118 diamond 766
    subfunction 3.
767
  * Usually there is no necessity to minimize/restire a window
768
    obviously: minimization of a window is carried out by the system
769
    at pressing the minimization button (for skinned windows
770
    it is defined automatically by function 0,
771
    for other windows it can be defined manually by function 8),
772
    restore of a window is done by the application '@panel'.
114 mikedld 773
 
774
======================================================================
1074 Galkov 775
 Function 18, subfunction 11 - get information on the disk subsystem.
114 mikedld 776
======================================================================
777
Parameters:
118 diamond 778
  * eax = 18 - function number
779
  * ebx = 11 - subfunction number
114 mikedld 780
  * ecx = type of the table:
781
    * 1 = short version, 10 bytes
782
    * 2 = full version, 65536 bytes
118 diamond 783
  * edx = pointer to the buffer (in the application) for the table
114 mikedld 784
Returned value:
785
  * function does not return value
118 diamond 786
Format of the table: short version:
787
  * +0: byte: information about FDD's (drives for floppies),
788
    AAAABBBB, where AAAA gives type of the first drive, BBBB -
789
    of the second regarding to the following list:
114 mikedld 790
    * 0 = there is no drive
791
    * 1 = 360Kb, 5.25''
792
    * 2 = 1.2Mb, 5.25''
793
    * 3 = 720Kb, 3.5''
794
    * 4 = 1.44Mb, 3.5''
118 diamond 795
    * 5 = 2.88Mb, 3.5'' (such drives are not used anymore)
796
    For example, for the standard configuration from one 1.44-drive
797
    here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B:
798
    the value is 24h.
799
  * +1: byte: information about hard disks and CD-drives, AABBCCDD,
114 mikedld 800
    where AA corresponds to the controller IDE0, ..., DD - IDE3:
801
    * 0 = device is absent
118 diamond 802
    * 1 = hard drive
803
    * 2 = CD-drive
804
    For example, in the case HD on IDE0 and CD on IDE2
805
    this field contains 48h.
806
  * +2: 4 db: number of the retrieved partitions on hard disks
807
    at accordingly IDE0,...,IDE3.
808
    If the hard disk on IDEx is absent, appropriate byte is zero,
809
    otherwise it shows number of the recognized partitions, which
810
    can be not presented (if the drive is not formatted or if
811
    the file system is not supported). Current version of the kernel
277 diamond 812
    supports only FAT16, FAT32 and NTFS for hard disks.
114 mikedld 813
  * +6: 4 db: reserved
118 diamond 814
Format of the table: full version:
815
  * +0: 10 db: same as for the short version
114 mikedld 816
  * +10: 100 db: data for the first partition
817
  * +110: 100 db: data for the second partition
818
  * ...
819
  * +10+100*(n-1): 100 db: data for the last partition
118 diamond 820
The partitions are located as follows: at first sequentially all
821
recoginzed partitions on HD on IDE0 (if present),
822
then on HD on IDE1 (if present) and so on up to IDE3.
823
Format of the information about partition
824
(at moment only FAT is supported):
114 mikedld 825
  * +0: dword: first physical sector of the partition
826
  * +4: dword: last physical sector of the partition
118 diamond 827
    (belongs to the partition)
277 diamond 828
  * +8: byte: file system type:
829
    16=FAT16, 32=FAT32, 1=NTFS
830
  * other data are dependent on file system, are modified with
831
    kernel modifications and therefore are not described
114 mikedld 832
Remarks:
118 diamond 833
  * The short table can be used for obtaining the information about
834
    available devices.
114 mikedld 835
 
836
======================================================================
118 diamond 837
========== Function 18, subfunction 13 - get kernel version. =========
114 mikedld 838
======================================================================
839
Parameters:
118 diamond 840
  * eax = 18 - function number
841
  * ebx = 13 - subfunction number
842
  * ecx = pointer to the buffer (not less than 16 bytes), where
843
    the information will be placed
114 mikedld 844
Returned value:
845
  * function does not return value
846
Structure of the buffer:
847
db a,b,c,d for version a.b.c.d
1689 art_zh 848
db 0
540 victor 849
dd REV - kernel SVN revision number
1689 art_zh 850
For Kolibri 0.7.7.0 kernel:
851
db 0,7,7,0
114 mikedld 852
db 2
1689 art_zh 853
dd 1657
114 mikedld 854
 
118 diamond 855
======================================================================
856
======= Function 18, subfunction 14 - wait for screen retrace. =======
857
======================================================================
858
Waits for the beginning of retrace of the scanning ray of the screen
859
monitor.
114 mikedld 860
Parameters:
118 diamond 861
  * eax = 18 - function number
862
  * ebx = 14 - subfunction number
114 mikedld 863
Returned value:
118 diamond 864
  * eax = 0 as the tag of success
114 mikedld 865
Remarks:
118 diamond 866
  * Function is intended only for active high-efficiency graphics
114 mikedld 867
    applications; is used for smooth output of a graphics.
868
 
118 diamond 869
======================================================================
870
== Function 18, subfunction 15 - center mouse cursor on the screen. ==
871
======================================================================
114 mikedld 872
Parameters:
118 diamond 873
  * eax = 18 - function number
874
  * ebx = 15 - subfunction number
114 mikedld 875
Returned value:
118 diamond 876
  * eax = 0 as the tag of success
114 mikedld 877
 
878
======================================================================
118 diamond 879
========= Function 18, subfunction 16 - get size of free RAM. ========
114 mikedld 880
======================================================================
881
Parameters:
118 diamond 882
  * eax = 18 - function number
883
  * ebx = 16 - subfunction number
114 mikedld 884
Returned value:
885
  * eax = size of free memory in kilobytes
886
 
887
======================================================================
118 diamond 888
======== Function 18, subfunction 17 - get full amount of RAM. =======
114 mikedld 889
======================================================================
890
Parameters:
118 diamond 891
  * eax = 18 - function number
892
  * ebx = 17 - subfunction number
114 mikedld 893
Returned value:
118 diamond 894
  * eax = total size of existing memory in kilobytes
114 mikedld 895
 
896
======================================================================
118 diamond 897
===================== Function 18, subfunction 18 ====================
898
============= Terminate process/thread by the identifier. ============
114 mikedld 899
======================================================================
900
Parameters:
118 diamond 901
  * eax = 18 - function number
902
  * ebx = 18 - subfunction number
903
  * ecx = identifer of process/thread (PID/TID)
114 mikedld 904
Returned value:
118 diamond 905
  * eax = 0 - success
906
  * eax = -1 - error (process is not found or is system)
114 mikedld 907
Remarks:
118 diamond 908
  * It is impossible to terminate system thread OS/IDLE (identifier
909
    1), it is possible to terminate any normal process/thread.
910
  * See also subfunction 2 - terminate
911
    process/thread by given slot.
114 mikedld 912
 
913
======================================================================
131 diamond 914
======== Function 18, subfunction 19 - get/set mouse features. =======
120 mario79 915
======================================================================
131 diamond 916
 
917
---------------- Subsubfunction 0 - get mouse speed. -----------------
120 mario79 918
Parameters:
919
  * eax = 18 - function number
920
  * ebx = 19 - subfunction number
131 diamond 921
  * ecx = 0 - subsubfunction number
922
Returned value:
923
  * eax = current mouse speed
120 mario79 924
 
131 diamond 925
---------------- Subsubfunction 1 - set mouse speed. -----------------
926
Parameters:
927
  * eax = 18 - function number
928
  * ebx = 19 - subfunction number
929
  * ecx = 1 - subsubfunction number
930
  * edx = new value for speed
931
Returned value:
932
  * function does not return value
120 mario79 933
 
131 diamond 934
---------------- Subsubfunction 2 - get mouse delay. -----------------
935
Parameters:
936
  * eax = 18 - function number
937
  * ebx = 19 - subfunction number
938
  * ecx = 2 - subsubfunction number
939
Returned value:
940
  * eax = current mouse delay
120 mario79 941
 
131 diamond 942
---------------- Subsubfunction 3 - set mouse delay. -----------------
943
Parameters:
944
  * eax = 18 - function number
945
  * ebx = 19 - subfunction number
946
  * ecx = 3 - subsubfunction number
947
  * edx = new value for mouse delay
948
Returned value:
949
  * function does not return value
120 mario79 950
 
131 diamond 951
----------- Subsubfunction 4 - set mouse pointer position. -----------
952
Parameters:
953
  * eax = 18 - function number
954
  * ebx = 19 - subfunction number
955
  * ecx = 4 - subsubfunction number
956
  * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
957
Returned value:
958
  * function does not return value
621 mario79 959
 
641 diamond 960
-------- Subsubfunction 5 - simulate state of mouse buttons. ---------
621 mario79 961
Parameters:
962
  * eax = 18 - function number
963
  * ebx = 19 - subfunction number
964
  * ecx = 5 - subsubfunction number
641 diamond 965
  * edx = information about emulated state of mouse buttons:
966
    (same as return value in subfunction 2 of function 37)
621 mario79 967
    * bit 0 is set = left button is pressed
968
    * bit 1 is set = right button is pressed
969
    * bit 2 is set = middle button is pressed
970
    * bit 3 is set = 4th button is pressed
971
    * bit 4 is set = 5th button is pressed
972
Returned value:
973
  * function does not return value
120 mario79 974
Remarks:
131 diamond 975
  * It is recommended to set speed of the mouse (in subsubfunction 1)
976
    from 1 up to 9. The installed value is not inspected by the kernel
977
    code, so set it carefully, at incorrect value the cursor
978
    can "freeze". Speed of the mouse can be regulated through the
979
    application SETUP.
980
  * Recommended delay of the mouse (in subsubfunction 3) = 10. Lower
981
    value is not handled by COM mice. At the very large values the
982
    movement of the mouse on 1 pixel is impossible and the cursor will
983
    jump on the value of installed speed (subsubfunction 1). The
984
    installed value is not inspected by the kernel code.
133 diamond 985
    Mouse delay can be regulated through the application SETUP.
131 diamond 986
  * The subsubfunction 4 does not check the passed value. Before
987
    its call find out current screen resolution (with function 14)
988
    and check that the value of position is inside the limits of the
989
    screen.
120 mario79 990
 
991
======================================================================
193 diamond 992
======== Function 18, subfunction 20 - get information on RAM. =======
993
======================================================================
994
Parameters:
995
  * eax = 18 - function number
996
  * ebx = 20 - subfunction number
997
  * ecx = pointer to the buffer for information (36 bytes)
998
Returned value:
999
  * eax = total size of existing RAM in pages
1000
    or -1 if error has occured
1001
  * buffer pointed to by ecx contains the following information:
1002
    * +0:  dword: total size of existing RAM in pages
1003
    * +4:  dword: size of free RAM in pages
1004
    * +8:  dword: number of page faults (exceptions #PF)
1005
                 in applications
1006
    * +12: dword: size of kernel heap in bytes
1007
    * +16: dword: free in kernel heap in bytes
1008
    * +20: dword: total number of memory blocks in kernel heap
1009
    * +24: dword: number of free memory blocks in kernel heap
1010
    * +28: dword: size of maximum free block in kernel heap
1011
                 (reserved)
1012
    * +32: dword: size of maximum allocated block in kernel heap
1013
                 (reserved)
1014
 
1015
======================================================================
641 diamond 1016
===================== Function 18, subfunction 21 ====================
1017
======== Get slot number of process/thread by the identifier. ========
608 alver 1018
======================================================================
1019
Parameters:
1020
  * eax = 18 - function number
1021
  * ebx = 21 - subfunction number
641 diamond 1022
  * ecx = identifer of process/thread (PID/TID)
608 alver 1023
Returned value:
641 diamond 1024
  * eax = 0 - error (invalid identifier)
1025
  * otherwise eax = slot number
608 alver 1026
 
1027
======================================================================
641 diamond 1028
===================== Function 18, subfunction 22 ====================
1029
============== Operations with window of another thread. =============
608 alver 1030
======================================================================
1031
Parameters:
1032
  * eax = 18 - function number
1033
  * ebx = 22 - subfunction number
641 diamond 1034
  * ecx = operation type:
1035
    * 0 = minimize window of the thread with given slot number
1036
    * 1 = minimize window of the thread with given identifier
1037
    * 2 = restore window of the thread with given slot number
1038
    * 3 = restore window of the thread with given identifier
1039
  * edx = parameter (slot number or PID/TID)
608 alver 1040
Returned value:
641 diamond 1041
  * eax = 0 - success
1042
  * eax = -1 - error (invalid identifier)
1043
Remarks:
1044
  * The thread can minimize its window with subfunction 10.
1045
  * One can restore and activate window simultaneously with
1046
    subfunction 3 (which requires slot number).
608 alver 1047
 
1048
======================================================================
118 diamond 1049
==================== Function 20 - MIDI interface. ===================
114 mikedld 1050
======================================================================
1051
 
118 diamond 1052
----------------------- Subfunction 1 - reset ------------------------
114 mikedld 1053
Parameters:
118 diamond 1054
  * eax = 20 - function number
1055
  * ebx = 1 - subfunction number
114 mikedld 1056
 
1057
-------------------- Subfunction 2 - output byte ---------------------
1058
Parameters:
118 diamond 1059
  * eax = 20 - function number
1060
  * ebx = 2 - subfunction number
114 mikedld 1061
  * cl = byte for output
118 diamond 1062
Returned value (is the same for both subfunctions):
1063
  * eax = 0 - success
114 mikedld 1064
  * eax = 1 - base port is not defined
1065
Remarks:
1074 Galkov 1066
  * Previously the base port must be defined by
118 diamond 1067
    subfunction 1 of function 21.
114 mikedld 1068
 
1069
======================================================================
118 diamond 1070
======== Function 21, subfunction 1 - set MPU MIDI base port. ========
114 mikedld 1071
======================================================================
1072
Parameters:
118 diamond 1073
  * eax = 21 - function number
1074
  * ebx = 1 - subfunction number
1075
  * ecx = number of base port
1076
Returned value
1077
  * eax = 0 - success
114 mikedld 1078
  * eax = -1 - erratic number of a port
1079
Remarks:
118 diamond 1080
  * Number of a port must satisfy to conditions 0x100<=ecx<=0xFFFF.
1081
  * The installation of base is necessary for function 20.
1082
  * To get base port use subfunction 1 of function 26.
114 mikedld 1083
 
1084
======================================================================
118 diamond 1085
========== Function 21, subfunction 2 - set keyboard layout. =========
114 mikedld 1086
======================================================================
118 diamond 1087
Keyboard layout is used to convert keyboard scancodes to ASCII-codes,
1088
which will be read by function 2.
114 mikedld 1089
Parameters:
118 diamond 1090
  * eax = 21 - function number
1091
  * ebx = 2 - subfunction number
1092
  * ecx = which layout to set:
114 mikedld 1093
    * 1 = normal layout
1094
    * 2 = layout at pressed Shift
1095
    * 3 = layout at pressed Alt
118 diamond 1096
  * edx = pointer to layout - table of length 128 bytes
114 mikedld 1097
Or:
1098
  * ecx = 9
118 diamond 1099
  * dx = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
114 mikedld 1100
Returned value:
118 diamond 1101
  * eax = 0 - success
1102
  * eax = 1 - incorrect parameter
114 mikedld 1103
Remarks:
118 diamond 1104
  * If Alt is pressed, the layout with Alt is used;
1105
    if Alt is not pressed, but Shift is pressed,
1106
    the layout with Shift is used;
1107
    if Alt and Shift are not pressed, but Ctrl is pressed, the normal
1108
    layout is used and then from the code is subtracted 0x60;
1109
    if no control key is pressed, the normal layout is used.
1074 Galkov 1110
  * To get layout and country identifier use
118 diamond 1111
    subfunction 2 of function 26.
1112
  * Country identifier is global system variable, which is not used
1113
    by the kernel itself; however the application '@panel' displays
1114
    the corresponding icon.
1115
  * The application @panel switches layouts on user request.
114 mikedld 1116
 
1117
======================================================================
118 diamond 1118
============== Function 21, subfunction 3 - set CD base. =============
114 mikedld 1119
======================================================================
1120
Parameters:
118 diamond 1121
  * eax = 21 - function number
1122
  * ebx = 3 - subfunction number
1123
  * ecx = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
114 mikedld 1124
Returned value:
1125
  * eax = 0
1126
Remarks:
118 diamond 1127
  * CD base is used by function 24.
1128
  * To get CD base use subfunction 3 of function 26.
114 mikedld 1129
 
1130
======================================================================
118 diamond 1131
========== Function 21, subfunction 5 - set system language. =========
114 mikedld 1132
======================================================================
1133
Parameters:
118 diamond 1134
  * eax = 21 - function number
1135
  * ebx = 5 - subfunction number
1136
  * ecx = system language (1=eng, 2=fi, 3=ger, 4=rus)
114 mikedld 1137
Returned value:
1138
  * eax = 0
1139
Remarks:
118 diamond 1140
  * System language is global system variable and is not used
1141
    by the kernel itself, however application @panel draws the
1142
    appropriate icon.
1143
  * Function does not check for correctness, as the kernel does not
1144
    use this variable.
1145
  * To get system language use subfunction 5 of function 26.
114 mikedld 1146
 
1147
======================================================================
118 diamond 1148
============== Function 21, subfunction 7 - set HD base. =============
114 mikedld 1149
======================================================================
118 diamond 1150
The HD base defines hard disk to write with usage of obsolete
346 diamond 1151
syntax /HD in obsolete function 58; at usage of modern syntax
1152
/HD0,/HD1,/HD2,/HD3 base is set automatically.
114 mikedld 1153
Parameters:
118 diamond 1154
  * eax = 21 - function number
1155
  * ebx = 7 - subfunction number
1156
  * ecx = HD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
114 mikedld 1157
Returned value:
1158
  * eax = 0
1159
Remarks:
118 diamond 1160
  * Any application at any time can change the base.
1161
  * Do not change base, when any application works with hard disk.
1162
    If you do not want system bugs.
1163
  * To get HD base use subfunction 7 of function 26.
1074 Galkov 1164
  * It is also necessary to define used partition of hard disk by
118 diamond 1165
    subfunction 8.
114 mikedld 1166
 
1167
======================================================================
118 diamond 1168
========= Function 21, subfunction 8 - set used HD partition. ========
114 mikedld 1169
======================================================================
118 diamond 1170
The HD partition defines partition of the hard disk to write with
346 diamond 1171
usage of obsolete syntax /HD and obsolete function 58;
118 diamond 1172
at usage of functions 58 and 70 and modern syntax /HD0,/HD1,/HD2,/HD3
346 diamond 1173
base and partition are set automatically.
114 mikedld 1174
Parameters:
118 diamond 1175
  * eax = 21 - function number
1176
  * ebx = 8 - subfunction number
1177
  * ecx = HD partition (beginning from 1)
1178
Return value:
114 mikedld 1179
  * eax = 0
1180
Remarks:
118 diamond 1181
  * Any application at any time can change partition.
1182
  * Do not change partition when any application works with hard disk.
1183
    If you do not want system bugs.
1184
  * To get used partition use subfunction 8 of function 26.
1185
  * There is no correctness checks.
1074 Galkov 1186
  * To get the number of partitions of a hard disk use
118 diamond 1187
    subfunction 11 of function 18.
1188
  * It is also necessary to define used HD base by subfunction 7.
114 mikedld 1189
 
1190
======================================================================
1074 Galkov 1191
 Function 21, subfunction 11 - enable/disable low-level access to HD.
114 mikedld 1192
======================================================================
1193
Parameters:
118 diamond 1194
  * eax = 21 - function number
1195
  * ebx = 11 - subfunction number
1196
  * ecx = 0/1 - disable/enable
114 mikedld 1197
Returned value:
1198
  * eax = 0
1199
Remarks:
118 diamond 1200
  * Is used in LBA-read (subfunction 8 of function 58).
1201
  * The current implementation uses only low bit of ecx.
1202
  * To get current status use subfunction 11 of function 26.
114 mikedld 1203
 
1204
======================================================================
1074 Galkov 1205
 Function 21, subfunction 12 - enable/disable low-level access to PCI.
114 mikedld 1206
======================================================================
1207
Parameters:
118 diamond 1208
  * eax = 21 - function number
1209
  * ebx = 12 - subfunction number
1210
  * ecx = 0/1 - disable/enable
114 mikedld 1211
Returned value:
1212
  * eax = 0
1213
Remarks:
118 diamond 1214
  * Is used in operations with PCI bus (function 62).
1215
  * The current implementation uses only low bit of ecx.
1216
  * To get current status use subfunction 12 of function 26.
114 mikedld 1217
 
1218
======================================================================
118 diamond 1219
============ Function 21, subfunction 13, subsubfunction 1 ===========
1220
======== Initialize + get information on the driver vmode.mdr. =======
114 mikedld 1221
======================================================================
1222
Parameters:
118 diamond 1223
  * eax = 21 - function number
1224
  * ebx = 13 - subfunction number
1225
  * ecx = 1 - number of the driver function
1226
  * edx = pointer to 512-bytes buffer
114 mikedld 1227
Returned value:
118 diamond 1228
  * if driver is not loaded
1229
    (never happens in the current implementation):
114 mikedld 1230
    * eax = -1
118 diamond 1231
    * ebx, ecx destroyed
1232
  * if driver is loaded:
1233
    * eax = 'MDAZ' (in fasm style, that is 'M' - low byte, 'Z' - high)
1234
      - signature
1235
    * ebx = current frequency of the scanning (in Hz)
1236
    * ecx destroyed
1237
    * buffer pointed to by edx is filled
114 mikedld 1238
Format of the buffer:
118 diamond 1239
  * +0: 32*byte: driver name, "Trans VideoDriver"
1240
    (without quotes, supplemented by spaces)
1241
  * +32 = +0x20: dword: driver version (version x.y is encoded as
1242
    y*65536+x), for the current implementation is 1 (1.0)
1243
  * +36 = +0x24: 7*dword: reserved (0 in the current implementation)
1244
  * +64 = +0x40: 32*word: list of supported videomodes (each word
1245
    is number of a videomode, after list itself there are zeroes)
1246
  * +128 = +0x80: 32*(5*word): list of supported frequences of the
1247
    scannings for videomodes: for each videomode listed in the
1248
    previous field up to 5 supported frequences are given
1249
    (unused positions contain zeroes)
114 mikedld 1250
Remarks:
118 diamond 1251
  * Function initializes the driver (if it is not initialized yet)
1252
    and must be called first, before others (otherwise they will do
1253
    nothing and return -1).
1254
  * The current implementation supports only one frequency
1255
    of the scanning on videomode.
114 mikedld 1256
 
1257
======================================================================
118 diamond 1258
============ Function 21, subfunction 13, subsubfunction 2 ===========
1259
================ Get information on current videomode. ===============
114 mikedld 1260
======================================================================
1261
Parameters:
118 diamond 1262
  * eax = 21 - function number
1263
  * ebx = 13 - subfunction number
1264
  * ecx = 2 - number of the driver function
114 mikedld 1265
Returned value:
118 diamond 1266
  * eax = -1 - driver is not loaded or not initialized;
1267
    ebx,ecx are destroyed
114 mikedld 1268
  * eax = [width]*65536 + [height]
118 diamond 1269
  * ebx = frequency of the vertical scanning (in Hz)
114 mikedld 1270
  * ecx = number of current videomode
1271
Remarks:
1074 Galkov 1272
  * Driver must be initialized by call to
118 diamond 1273
    driver function 1.
1274
  * If only screen sizes are required, it is more expedient to use
1275
    function 14 taking into account that it
1276
    returns sizes on 1 less.
114 mikedld 1277
 
1278
======================================================================
118 diamond 1279
=== Function 21, subfunction 13, subsubfunction 3 - set videomode. ===
114 mikedld 1280
======================================================================
1281
Parameters:
118 diamond 1282
  * eax = 21 - function number
1283
  * ebx = 13 - subfunction number
1284
  * ecx = 3 - number of the driver function
1285
  * edx = [scanning frequency]*65536 + [videomode number]
114 mikedld 1286
Returned value:
118 diamond 1287
  * eax = -1 - driver is not loaded, not initialized or
1288
    an error has occured
1289
  * eax = 0 - success
1290
  * ebx, ecx destroyed
114 mikedld 1291
Remarks:
118 diamond 1292
  * Driver must be initialized by driver function 1.
1293
  * The videomode number and frequency must be in the table
1294
    returned by driver function 1.
114 mikedld 1295
 
1296
======================================================================
118 diamond 1297
============ Function 21, subfunction 13, subsubfunction 4 ===========
1298
================== Return to the initial videomode. ==================
114 mikedld 1299
======================================================================
118 diamond 1300
Returns the screen to the videomode set at system boot.
114 mikedld 1301
Parameters:
118 diamond 1302
  * eax = 21 - function number
1303
  * ebx = 13 - subfunction number
1304
  * ecx = 4 - number of the driver function
114 mikedld 1305
Returned value:
118 diamond 1306
  * eax = -1 - driver is not loaded or not initialized
1307
  * eax = 0 - success
1308
  * ebx, ecx destroyed
114 mikedld 1309
Remarks:
118 diamond 1310
  * Driver must be initialized by call to driver function 1.
114 mikedld 1311
 
118 diamond 1312
======================================================================
1313
============ Function 21, subfunction 13, subsubfunction 5 ===========
1314
===== Increase/decrease the size of the visible area of monitor. =====
1315
======================================================================
114 mikedld 1316
Parameters:
118 diamond 1317
  * eax = 21 - function number
1318
  * ebx = 13 - subfunction number
1319
  * ecx = 5 - number of the driver function
1320
  * edx = 0/1 - decrease/increase horizontal size on 1 position
1321
  * edx = 2/3 - is not supported in the current implementation;
1322
    is planned as decrease/increase vertical size on 1 position
114 mikedld 1323
Returned value:
118 diamond 1324
  * eax = -1 - driver is not loaded or not initialized
1325
  * eax = 0 - success
1326
  * ebx, ecx destroyed
114 mikedld 1327
Remarks:
118 diamond 1328
  * Driver must be initialized by call to driver function 1.
1329
  * Function influences only the physical size of the screen image;
1330
    the logical size (number of pixels) does not change.
114 mikedld 1331
 
1332
======================================================================
118 diamond 1333
================= Function 22 - set system date/time. ================
114 mikedld 1334
======================================================================
1335
Parameters:
118 diamond 1336
  * eax = 22 - function number
1337
  * ebx = 0 - set time
1338
    * ecx = 0x00SSMMHH - time in the binary-decimal code (BCD):
114 mikedld 1339
    * HH=hour 00..23
1340
    * MM=minute 00..59
1341
    * SS=second 00..59
118 diamond 1342
  * ebx = 1 - set date
1343
    * ecx = 0x00DDMMYY - date in the binary-decimal code (BCD):
114 mikedld 1344
    * DD=day 01..31
1345
    * MM=month 01..12
1346
    * YY=year 00..99
118 diamond 1347
  * ebx = 2 - set day of week
114 mikedld 1348
    * ecx = 1 for Sunday, ..., 7 for Saturday
118 diamond 1349
  * ebx = 3 - set alarm clock
114 mikedld 1350
    * ecx = 0x00SSMMHH
1351
Returned value:
118 diamond 1352
  * eax = 0 - success
1353
  * eax = 1 - incorrect parameter
114 mikedld 1354
  * eax = 2 - CMOS-battery was unloaded
1355
Remarks:
118 diamond 1356
  * Value of installation of day of week seems to be doubtful,
1357
    as it a little where is used
1358
    (day of week can be calculated by date).
1359
  * Alarm clock can be set on operation in the given time every day.
1360
    But there is no existing system function to disable it.
1361
  * Operation of alarm clock consists in generation IRQ8.
1362
  * Generally CMOS supports for alarm clock set of value 0xFF
1363
    as one of parameters and it means that the appropriate parameter
1364
    is ignored. But current implementation does not allow this
1365
    (will return 1).
1366
  * Alarm clock is a global system resource; the set of
1367
    an alarm clock cancels automatically the previous set.
1368
    However, at moment no program uses it.
114 mikedld 1369
 
1370
======================================================================
118 diamond 1371
============= Function 23 - wait for event with timeout. =============
114 mikedld 1372
======================================================================
118 diamond 1373
If the message queue is empty, waits for new message in the queue,
1374
but no more than given time. Then reads out a message from the queue.
114 mikedld 1375
 
1376
Parameters:
118 diamond 1377
  * eax = 23 - function number
114 mikedld 1378
  * ebx = timeout (in 1/100 of second)
1379
Returned value:
118 diamond 1380
  * eax = 0 - the message queue is empty
1381
  * otherwise eax = event (see the list of events)
114 mikedld 1382
Remarks:
118 diamond 1383
  * Only those events are taken into account, which enter into
1384
    the mask set by function 40. By default it is
1385
    redraw, key and button events.
1386
  * To check for presence of a message in the queue use function 11.
1387
    To wait without timeout use function 10.
1388
  * Transmission ebx=0 results in immediate returning eax=0.
1389
  * Current implementation returns immediately with eax=0,
1390
    if the addition of ebx with the current value of time counter
1391
    makes 32-bit overflow.
114 mikedld 1392
 
1393
======================================================================
118 diamond 1394
======== Function 24, subfunction 1 - begin to play CD-audio. ========
114 mikedld 1395
======================================================================
1396
Parameters:
118 diamond 1397
  * eax = 24 - function number
1398
  * ebx = 1 - subfunction number
114 mikedld 1399
  * ecx = 0x00FRSSMM, where
118 diamond 1400
    * MM = starting minute
1401
    * SS = starting second
1402
    * FR = starting frame
114 mikedld 1403
Returned value:
118 diamond 1404
  * eax = 0 - success
1405
  * eax = 1 - CD base is not defined
114 mikedld 1406
Remarks:
1074 Galkov 1407
  * Previously CD base must be defined by the call to
118 diamond 1408
    subfunction 3 of function 21.
1409
  * One second includes 75 frames, one minute includes 60 seconds.
1410
  * The function is asynchronous (returns control, when play begins).
114 mikedld 1411
 
1412
======================================================================
118 diamond 1413
======= Function 24, subfunction 2 - get information on tracks. ======
114 mikedld 1414
======================================================================
1415
Parameters:
118 diamond 1416
  * eax = 24 - function number
1417
  * ebx = 2 - subfunction number
1418
  * ecx = pointer to the buffer for the table
1419
    (maximum 8*64h+4 bytes=100 tracks)
114 mikedld 1420
Returned value:
118 diamond 1421
  * eax = 0 - success
1422
  * eax = 1 - CD base is not defined
114 mikedld 1423
Remarks:
118 diamond 1424
  * The format of the table with tracks information is the same as
1425
    for ATAPI-CD command 43h (READ TOC), usual table (subcommand 00h).
1426
    Function returns addresses in MSF.
1074 Galkov 1427
  * Previously CD base port must be set by call to
118 diamond 1428
    subfunction 3 of function 21.
1429
  * Function returns information only about no more than 100
1430
    first tracks. In most cases it is enough.
114 mikedld 1431
 
1432
======================================================================
118 diamond 1433
========== Function 24, subfunction 3 - stop play CD-audio. ==========
114 mikedld 1434
======================================================================
1435
Parameters:
118 diamond 1436
  * eax = 24 - function number
1437
  * ebx = 1 - subfunction number
114 mikedld 1438
Returned value:
118 diamond 1439
  * eax = 0 - success
1440
  * eax = 1 - CD base is not defined
499 diamond 1441
Remarks:
1074 Galkov 1442
  * Previously CD base port must be defined by call to
118 diamond 1443
    subfunction 3 of function 21.
114 mikedld 1444
 
1445
======================================================================
641 diamond 1446
======= Function 24, subfunction 4 - eject tray of disk drive. =======
588 diamond 1447
======================================================================
1448
Parameters:
1449
  * eax = 24 - function number
1450
  * ebx = 4 - subfunction number
641 diamond 1451
  * ecx = position of CD/DVD-drive
1452
      (from 0=Primary Master to 3=Secondary Slave)
588 diamond 1453
Returned value:
641 diamond 1454
  * function does not return value
588 diamond 1455
Remarks:
1456
  * The function is supported only for ATAPI devices (CD and DVD).
641 diamond 1457
  * When the tray is being ejected,
1458
    manual control of tray is unlocked.
1459
  * When the tray is being ejected, the code clears the cache for
1460
    corresponding device.
588 diamond 1461
  * An example of usage of the function is the application CD_tray.
1462
 
1463
======================================================================
641 diamond 1464
======== Function 24, subfunction 5 - load tray of disk drive. =======
588 diamond 1465
======================================================================
1466
Parameters:
1467
  * eax = 24 - function number
1468
  * ebx = 5 - subfunction number
641 diamond 1469
  * ecx = position of CD/DVD-drive
1470
      (from 0=Primary Master to 3=Secondary Slave)
588 diamond 1471
Returned value:
641 diamond 1472
  * function does not return value
588 diamond 1473
Remarks:
1474
  * The function is supported only for ATAPI devices (CD and DVD).
1475
  * An example of usage of the function is the application CD_tray.
1476
 
1477
======================================================================
118 diamond 1478
======== Function 26, subfunction 1 - get MPU MIDI base port. ========
114 mikedld 1479
======================================================================
1480
Parameters:
118 diamond 1481
  * eax = 26 - function number
1482
  * ebx = 1 - subfunction number
114 mikedld 1483
Returned value:
118 diamond 1484
  * eax = port number
1485
Parameters:
1486
  * To set base port use subfunction 1 of function 21.
114 mikedld 1487
 
1488
======================================================================
1489
========== Function 26, subfunction 2 - get keyboard layout. =========
1490
======================================================================
118 diamond 1491
The keyboard layout is used to convert keyboard scancodes to
1492
ASCII-codes for function 2.
114 mikedld 1493
Parameters:
118 diamond 1494
  * eax = 26 - function number
1495
  * ebx = 2 - subfunction number
114 mikedld 1496
  * ecx = what layout to get:
1497
    * 1 = normal layout
118 diamond 1498
    * 2 = layout with pressed Shift
1499
    * 3 = layout with pressed Alt
1500
  * edx = pointer to the 128-bytes buffer, where the layout will be
1501
    copied
114 mikedld 1502
Returned value:
1503
  * function does not return value
118 diamond 1504
Or:
1505
  * eax = 26 - function number
1506
  * ebx = 2 - subfunction number
114 mikedld 1507
  * ecx = 9
1508
Returned value:
118 diamond 1509
  * eax = country identifier (1=eng, 2=fi, 3=ger, 4=rus)
114 mikedld 1510
Remarks:
118 diamond 1511
  * If Alt is pressed, the layout with Alt is used;
1512
    if Alt is not pressed, but Shift is pressed,
1513
    the layout with Shift is used;
1514
    if Alt and Shift are not pressed, but Ctrl is pressed, the normal
1515
    layout is used and then from the code is subtracted 0x60;
1516
    if no control key is pressed, the normal layout is used.
1074 Galkov 1517
  * To set layout and country identifier use
118 diamond 1518
    subfunction 2 of function 21.
1519
  * Country identifier is global system variable, which is not used
1520
    by the kernel itself; however the application '@panel' displays
1521
    the corresponding icon (using this function).
1522
  * The application @panel switches layouts on user request.
114 mikedld 1523
 
1524
======================================================================
118 diamond 1525
============== Function 26, subfunction 3 - get CD base. =============
114 mikedld 1526
======================================================================
1527
Parameters:
118 diamond 1528
  * eax = 26 - function number
1529
  * ebx = 3 - subfunction number
114 mikedld 1530
Returned value:
118 diamond 1531
  * eax = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
114 mikedld 1532
Remarks:
118 diamond 1533
  * CD base is used by function 24.
1534
  * To set CD base use subfunction 3 of function 21.
114 mikedld 1535
 
1536
======================================================================
118 diamond 1537
========== Function 26, subfunction 5 - get system language. =========
114 mikedld 1538
======================================================================
1539
Parameters:
118 diamond 1540
  * eax = 26 - function number
1541
  * ebx = 5 - subfunction number
114 mikedld 1542
Returned value:
118 diamond 1543
  * eax = system language (1=eng, 2=fi, 3=ger, 4=rus)
114 mikedld 1544
Remarks:
118 diamond 1545
  * System language is global system variable and is not used
1546
    by the kernel itself, however application @panel draws the
1547
    appropriate icon (using this function).
1548
  * To set system language use subfunction 5 of function 21.
114 mikedld 1549
 
1550
======================================================================
118 diamond 1551
============== Function 26, subfunction 7 - get HD base. =============
114 mikedld 1552
======================================================================
118 diamond 1553
The HD base defines hard disk to write with usage of obsolete
346 diamond 1554
syntax /HD in obsolete function 58; at usage of modern syntax
1555
/HD0,/HD1,/HD2,/HD3 base is set automatically.
114 mikedld 1556
Parameters:
118 diamond 1557
  * eax = 26 - function number
1558
  * ebx = 7 - subfunction number
114 mikedld 1559
Returned value:
118 diamond 1560
  * eax = HD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
114 mikedld 1561
Remarks:
118 diamond 1562
  * Any application in any time can change HD base.
1563
  * To set base use subfunction 7 of function 21.
1564
  * To get used partition of hard disk use subfunction 8.
114 mikedld 1565
 
1566
======================================================================
118 diamond 1567
========= Function 26, subfunction 8 - get used HD partition. ========
114 mikedld 1568
======================================================================
118 diamond 1569
The HD partition defines partition of the hard disk to write with
346 diamond 1570
usage of obsolete syntax /HD in obsolete function 58;
118 diamond 1571
at usage of functions 58 and 70 and modern syntax /HD0,/HD1,/HD2,/HD3
346 diamond 1572
base and partition are set automatically.
114 mikedld 1573
Parameters:
118 diamond 1574
  * eax = 26 - function number
1575
  * ebx = 8 - subfunction number
114 mikedld 1576
Returned value:
118 diamond 1577
  * eax = HD partition (beginning from 1)
114 mikedld 1578
Remarks:
118 diamond 1579
  * Any application in any time can change partition.
1580
  * To set partition use subfunction 8 of function 21.
1581
  * To get number of partitions on a hard disk use
1582
    subfunction 11 of function 18.
1583
  * To get base of used hard disk, use subfunction 7.
114 mikedld 1584
 
1585
======================================================================
118 diamond 1586
=== Function 26, subfunction 9 - get the value of the time counter. ==
114 mikedld 1587
======================================================================
1588
Parameters:
118 diamond 1589
  * eax = 26 - function number
1590
  * ebx = 9 - subfunction number
114 mikedld 1591
Returned value:
118 diamond 1592
  * eax = number of 1/100s of second, past from the system boot time
114 mikedld 1593
Remarks:
118 diamond 1594
  * Counter takes modulo 2^32, that correspond to a little more
1595
    than 497 days.
1596
  * To get system time use function 3.
114 mikedld 1597
 
1598
======================================================================
118 diamond 1599
===================== Function 26, subfunction 11 ====================
1600
========== Find out whether low-level HD access is enabled. ==========
114 mikedld 1601
======================================================================
1602
Parameters:
118 diamond 1603
  * eax = 26 - function number
1604
  * ebx = 11 - subfunction number
114 mikedld 1605
Returned value:
118 diamond 1606
  * eax = 0/1 - disabled/enabled
114 mikedld 1607
Remarks:
118 diamond 1608
  * Is used in LBA read (subfunction 8 of function 58).
1609
  * To set current state use subfunction 11 of function 21.
114 mikedld 1610
 
1611
======================================================================
118 diamond 1612
===================== Function 26, subfunction 12 ====================
1613
========== Find out whether low-level PCI access is enabled. =========
114 mikedld 1614
======================================================================
1615
Parameters:
118 diamond 1616
  * eax = 26 - function number
1617
  * ebx = 12 - subfunction number
114 mikedld 1618
Returned value:
118 diamond 1619
  * eax = 0/1 - disabled/enabled
114 mikedld 1620
Remarks:
118 diamond 1621
  * Is used by operations with PCI bus (function 62).
1622
  * The current implementation uses only low bit of ecx.
1623
  * To set the current state use subfunction 12 of function 21.
114 mikedld 1624
 
1625
======================================================================
118 diamond 1626
=================== Function 29 - get system date. ===================
114 mikedld 1627
======================================================================
1628
Parameters:
118 diamond 1629
  * eax = 29 - function number
114 mikedld 1630
Returned value:
1631
  * eax = 0x00DDMMYY, where
118 diamond 1632
    (binary-decimal coding, BCD, is used)
1633
  * YY = two low digits of year (00..99)
1634
  * MM = month (01..12)
1635
  * DD = day (01..31)
114 mikedld 1636
Remarks:
118 diamond 1637
  * To set system date use function 22.
114 mikedld 1638
 
1639
======================================================================
521 diamond 1640
============= Function 30 - work with the current folder. ============
1641
======================================================================
1642
 
1643
--------- Subfunction 1 - set current folder for the thread. ---------
1644
Parameters:
1645
  * eax = 30 - function number
1646
  * ebx = 1 - subfunction number
1647
  * ecx = pointer to ASCIIZ-string with the path to new current folder
1648
Returned value:
1649
  * function does not return value
1650
 
1651
--------- Subfunction 2 - get current folder for the thread. ---------
1652
Parameters:
1653
  * eax = 30 - function number
1654
  * ebx = 2 - subfunction number
1655
  * ecx = pointer to buffer
1656
  * edx = size of buffer
1657
Returned value:
1658
  * eax = size of the current folder's name (including terminating 0)
1659
Remarks:
1660
  * If the buffer is too small to hold all data, only first (edx-1)
1661
    bytes are copied and than terminating 0 is inserted.
1689 art_zh 1662
  * By default, current folder for the thread is "/rd/1".
1663
  * At process/thread creation the current folder will be inherited
521 diamond 1664
 
1665
======================================================================
118 diamond 1666
======= Function 35 - read the color of a pixel on the screen. =======
114 mikedld 1667
======================================================================
1668
Parameters:
1669
  * eax = 35
1670
  * ebx = y*xsize+x, where
118 diamond 1671
  * (x,y) = coordinates of a pixel (beginning from 0)
1672
  * xsize = horizontal screen size
114 mikedld 1673
Returned value:
118 diamond 1674
  * eax = color 0x00RRGGBB
114 mikedld 1675
Remarks:
118 diamond 1676
  * To get screen sizes use function 14. Pay attention,
1677
    that it subtracts 1 from both sizes.
1678
  * There is also direct access (without any system calls)
1679
    to videomemory through the selector gs. To get parameters of
1680
    the current videomode, use function 61.
114 mikedld 1681
 
1682
======================================================================
1018 diamond 1683
=================== Function 36 - read screen area. ==================
921 mario79 1684
======================================================================
1685
Paramters:
1686
  * eax = 36 - function number
1018 diamond 1687
  * ebx = pointer to the previously allocated memory area,
1688
        where will be placed the image in the format BBGGRRBBGGRR...
921 mario79 1689
  * ecx = [size on axis x]*65536 + [size on axis y]
1690
  * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
1691
Returned value:
1692
  * function does not return value
1693
Remarks:
1694
  * Coordinates of the image are coordinates of the upper left corner
923 mario79 1695
    of the image relative to the screen.
921 mario79 1696
  * Size of the image in bytes is 3*xsize*ysize.
1697
 
1698
======================================================================
277 diamond 1699
=================== Function 37 - work with mouse. ===================
114 mikedld 1700
======================================================================
1701
 
118 diamond 1702
---------- Subfunction 0 - screen coordinates of the mouse -----------
114 mikedld 1703
Parameters:
118 diamond 1704
  * eax = 37 - function number
1705
  * ebx = 0 - subfunction number
114 mikedld 1706
Returned value:
118 diamond 1707
  * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
1708
    (beginning from 0)
114 mikedld 1709
 
118 diamond 1710
-- Subfunction 1 - coordinates of the mouse relative to the window ---
114 mikedld 1711
Parameters:
118 diamond 1712
  * eax = 37 - function number
1713
  * ebx = 1 - subfunction number
114 mikedld 1714
Returned value:
118 diamond 1715
  * eax = x*65536 + y, (x,y)=coordinates of the mouse pointer
1716
    relative to the application window (beginning from 0)
114 mikedld 1717
Remarks:
118 diamond 1718
  * The value is calculated by formula (x-xwnd)*65536 + (y-ywnd).
1719
    If y>=ywnd, the low word is non-negative and contains
1720
    relative y-coordinate, and the high word - relative x-coordinate
1721
    (with correct sign). Otherwise the low word is negative and still
1722
    contains relative y-coordinate, and to the high word
1723
    1 should be added.
114 mikedld 1724
 
118 diamond 1725
------------ Subfunction 2 - pressed buttons of the mouse ------------
114 mikedld 1726
Parameters:
118 diamond 1727
  * eax = 37 - function number
1728
  * ebx = 2 - subfunction number
114 mikedld 1729
Returned value:
118 diamond 1730
  * eax contains information on the pressed mouse buttons:
1731
  * bit 0 is set = left button is pressed
1732
  * bit 1 is set = right button is pressed
486 kastigar 1733
  * bit 2 is set = middle button is pressed
1734
  * bit 3 is set = 4th button is pressed
1735
  * bit 4 is set = 5th button is pressed
118 diamond 1736
  * other bits are cleared
114 mikedld 1737
 
277 diamond 1738
-------------------- Subfunction 4 - load cursor ---------------------
1739
Parameters:
1740
  * eax = 37 - function number
1741
  * ebx = 4 - subfunction number
1742
  * dx = data source:
1743
  * dx = LOAD_FROM_FILE = 0 - data in a file
1744
    * ecx = pointer to full path to the cursor file
1745
    * the file must be in the format .cur, which is standard for
1746
      MS Windows, at that of the size 32*32 pixels
1747
  * dx = LOAD_FROM_MEM = 1 - data of file are already loaded in memory
1748
    * ecx = pointer to data of the cursor file
1749
    * the data format is the same as in the previous case
1750
  * dx = LOAD_INDIRECT = 2 - data in memory
1751
    * ecx = pointer to cursor image in the format ARGB 32*32 pixels
1752
    * edx = 0xXXYY0002, where
1753
      * XX = x-coordinate of cursor hotspot
1754
      * YY = y-coordinate
1755
      * 0 <= XX, YY <= 31
1756
Returned value:
1757
  * eax = 0 - failed
1758
  * otherwise eax = cursor handle
1759
 
1760
--------------------- Subfunction 5 - set cursor ---------------------
1761
Sets new cursor for the window of the current thread.
1762
Parameters:
1763
  * eax = 37 - function number
1764
  * ebx = 5 - subfunction number
1765
  * ecx = cursor handle
1766
Returned value:
1767
  * eax = handle of previous cursor
1768
Remarks:
1769
  * If the handle is incorrect, the function restores the default
1770
    cursor (standard arrow). In particular, ecx=0 restores it.
1771
 
1772
------------------- Subfunction 6 - delete cursor --------------------
1773
Parameters:
1774
  * eax = 37 - function number
1775
  * ebx = 6 - subfunction number
1776
  * ecx = cursor handle
1777
Returned value:
1778
  * eax destroyed
1779
Remarks:
1780
  * The cursor must be loaded previously by the current thread
1781
    (with the call to subfunction 4). The function does not delete
1782
    system cursors and cursors, loaded by another applications.
1783
  * If the active cursor (set by subfunction 5) is deleted,
1784
    the system restores the default cursor (standard arrow).
1785
 
499 diamond 1786
------------------ Subfunction 7 - get scroll data -------------------
486 kastigar 1787
Parameters:
1788
  * eax = 37 - function number
1789
  * ebx = 7 - subfunction number
1790
Returned value:
499 diamond 1791
  * eax = [horizontal offset]*65536 + [vertical offset]
486 kastigar 1792
Remarks:
499 diamond 1793
  * Scroll data is available for active window only.
1794
  * Values are zeroed after reading.
1795
  * Values are signed.
486 kastigar 1796
 
114 mikedld 1797
======================================================================
1798
====================== Function 38 - draw line. ======================
1799
======================================================================
1800
Parameters:
118 diamond 1801
  * eax = 38 - function number
1802
  * ebx = [start coordinate on axis x]*65536 +
1803
              [end coordinate on axis x]
1804
  * ecx = [start coordinate on axis y]*65536 +
1805
              [end coordinate on axis y]
1806
  * edx = 0x00RRGGBB - color
133 diamond 1807
    edx = 0x01xxxxxx - draw inversed line
1808
          (low 24 bits are ignored)
114 mikedld 1809
Returned value:
1810
  * function does not return value
1811
Remarks:
118 diamond 1812
  * Coordinates are relative to the window.
1813
  * End point is also drawn.
114 mikedld 1814
 
1815
======================================================================
118 diamond 1816
== Function 39, subfunction 1 - get a size of the background image. ==
114 mikedld 1817
======================================================================
1818
Parameters:
118 diamond 1819
  * eax = 39 - function number
1820
  * ebx = 1 - subfunction number
114 mikedld 1821
Returned value:
1822
  * eax = [width]*65536 + [height]
1823
Remarks:
118 diamond 1824
  * There is a pair function to set sizes of background image -
1825
    subfunction 1 of function 15. After which it is necessary,
1826
    of course, anew to define image.
114 mikedld 1827
 
1828
======================================================================
118 diamond 1829
== Function 39, subfunction 2 - get pixel from the background image. =
114 mikedld 1830
======================================================================
1831
Parameters:
118 diamond 1832
  * eax = 39 - function number
1833
  * ebx = 2 - subfunction number
114 mikedld 1834
  * ecx = offset
1835
Returned value:
118 diamond 1836
  * eax = 0x00RRGGBB - pixel color, if offset is valid
1837
    (less than 0x160000-16)
1838
  * eax = 2 otherwise
114 mikedld 1839
Remarks:
118 diamond 1840
  * Do not rely on returned value for invalid offsets, it may be
1841
    changed in future kernel versions.
1842
  * Offset for pixel with coordinates (x,y)
1843
    is calculated as (x+y*xsize)*3.
1074 Galkov 1844
  * There is a pair function to set pixel on the background image -
118 diamond 1845
    subfunction 2 of function 15.
114 mikedld 1846
 
1847
======================================================================
118 diamond 1848
== Function 39, subfunction 4 - get drawing mode for the background. =
114 mikedld 1849
======================================================================
1850
Parameters:
118 diamond 1851
  * eax = 39 - function number
1852
  * ebx = 4 - subfunction number
114 mikedld 1853
Returned value:
118 diamond 1854
  * eax = 1 - tile
1855
  * eax = 2 - stretch
114 mikedld 1856
Remarks:
1074 Galkov 1857
  * There is a pair function to set drawing mode -
118 diamond 1858
    subfunction 4 of function 15.
114 mikedld 1859
 
1860
======================================================================
118 diamond 1861
=========== Function 40 - set the mask for expected events. ==========
114 mikedld 1862
======================================================================
118 diamond 1863
The mask for expected events affects function working with events
1864
10, 11, 23 - they notify only about events allowed by this mask.
114 mikedld 1865
Parameters:
118 diamond 1866
  * eax = 40 - function number
114 mikedld 1867
  * ebx = mask: bit i corresponds to event i+1 (see list of events)
118 diamond 1868
    (set bit permits notice on event)
114 mikedld 1869
Returned value:
1153 clevermous 1870
  * eax = previous value of mask
114 mikedld 1871
Remarks:
118 diamond 1872
  * Default mask (7=111b) enables nofices about redraw,
1873
    keys and buttons. This is enough for many applications.
1874
  * Events prohibited in the mask are saved anyway, when come;
1875
    they are simply not informed with event functions.
1876
  * Event functions take into account the mask on moment of
1877
    function call, not on moment of event arrival.
114 mikedld 1878
 
1879
======================================================================
118 diamond 1880
==================== Function 41 - get IRQ owner. ====================
114 mikedld 1881
======================================================================
1882
Parameters:
118 diamond 1883
  * eax = 41 - function number
1884
  * ebx = IRQ number, 0..15
114 mikedld 1885
Returned value:
118 diamond 1886
  * eax = owner PID
1887
  * eax = 0, if there is no owner
114 mikedld 1888
  * eax = -1 for incorrect ebx
1889
 
1890
======================================================================
1018 diamond 1891
================== Function 42 - work with IRQ data. =================
114 mikedld 1892
======================================================================
118 diamond 1893
When an IRQ occurs, the system reads data from ports indicated
1894
earlier by function 44 and writes this data to
1018 diamond 1895
internal buffer. This function reads out data from that buffer.
1896
 
1897
--------------------- Subfunction 0 - read data ----------------------
114 mikedld 1898
Parameters:
118 diamond 1899
  * eax = 42 - function number
760 Rus 1900
  * bl = IRQ number, 0..15
1018 diamond 1901
  * bh = 0 - subfunction number
1902
  * rest of ebx must be zeroed
1903
  * ecx = pointer to a buffer with size not less than 4000 bytes
760 Rus 1904
Returned value: (use value of eax to distinguish)
1018 diamond 1905
  * if the thread is not IRQ owner
1906
    (or IRQ number is incorrect): eax = -1
1907
  * if there is no data: eax = 0
118 diamond 1908
  * if all is ok:
1018 diamond 1909
    eax = size of data read (in bytes)
760 Rus 1910
 
1018 diamond 1911
------------- Subfunction 1 - get size of data in buffer -------------
760 Rus 1912
Parameters:
1913
  * eax = 42 - function number
1914
  * bl = IRQ number, 0..15
1018 diamond 1915
  * bh = 0 - subfunction number
1916
  * rest of ebx must be zeroed
1917
Returned value:
1918
  * if the thread is not IRQ owner
1919
    (or IRQ number is incorrect): eax = -1
1920
  * otherwise eax = size of data in buffer
114 mikedld 1921
Remarks:
118 diamond 1922
  * Previously the thread must reserve indicated IRQ for itself
1923
    by function 45.
1924
  * The size of data buffer is 4000 bytes, on overflow
1925
    "fresh" data cease to be written in the buffer.
114 mikedld 1926
 
1927
======================================================================
118 diamond 1928
================ Function 43 - input/output to a port. ===============
114 mikedld 1929
======================================================================
1930
 
118 diamond 1931
------------------------ Output data to port -------------------------
114 mikedld 1932
Parameters:
118 diamond 1933
  * eax = 43 - function number
114 mikedld 1934
  * bl = byte for output
118 diamond 1935
  * ecx = port number 0xnnnn (from 0 to 0xFFFF)
114 mikedld 1936
Returned value:
118 diamond 1937
  * eax = 0 - success
1938
  * eax = 1 - the thread has not reserved the selected port
114 mikedld 1939
 
118 diamond 1940
------------------------ Input data from port ------------------------
114 mikedld 1941
Parameters:
118 diamond 1942
  * eax = 43 - function number
1943
  * ebx is ignored
1944
  * ecx = 0x8000nnnn, where nnnn = port number (from 0 to 0xFFFF)
114 mikedld 1945
Returned value:
118 diamond 1946
  * eax = 0 - success, thus ebx = entered byte
1947
  * eax = 1 - the thread has not reserved the selected port
114 mikedld 1948
Remarks:
118 diamond 1949
  * Previously the thread must reserve the selected port
1950
    for itself by function 46.
1951
  * Instead of call to this function it is better to use
1952
    processor instructions in/out - this is much
1953
    faster and a bit shorter and easier.
114 mikedld 1954
 
1955
======================================================================
118 diamond 1956
=========== Function 44 - define operations at IRQ arrival. ==========
114 mikedld 1957
======================================================================
118 diamond 1958
At IRQ arrival the system can read the data from ports defined
1959
by this function and write these data to internal buffer, whence
1960
they can be read by функцией 42.
114 mikedld 1961
Parameters:
118 diamond 1962
  * eax = 44 - function number
1963
  * ebx = pointer to the array of structures each describing one port:
1964
    * +0: word: 0 means end of array, otherwise port number
114 mikedld 1965
    * +2: byte: reserved (ignored)
118 diamond 1966
    * +3: byte: 1=read byte from this port, 2=read word
1967
  * ecx = IRQ number, 0..15
114 mikedld 1968
Returned value:
118 diamond 1969
  * eax = 0 - success
1970
  * eax = 1 - the thread is not owner of selected IRQ
114 mikedld 1971
Remarks:
118 diamond 1972
  * Previously the thread must reserve for itself selected IRQ
1973
    by function 45.
114 mikedld 1974
  * First 16 ports are considered only.
118 diamond 1975
  * The current implementation considers incorrect value of field +3
1976
    as a signal to terminate IRQ processing.
114 mikedld 1977
 
1978
======================================================================
118 diamond 1979
=================== Function 45 - reserve/free IRQ. ==================
114 mikedld 1980
======================================================================
1981
Parameters:
118 diamond 1982
  * eax = 45 - function number
114 mikedld 1983
  * ebx = 0 - reserve, 1 = free
118 diamond 1984
  * ecx = IRQ number, 0..15
114 mikedld 1985
Returned value:
118 diamond 1986
  * eax = 0 - success
1987
  * eax = 1 - error (invalid IRQ number
1988
    or attempt to reserve not free IRQ
1989
    or to free IRQ, not reserved by this thread)
114 mikedld 1990
Remarks:
118 diamond 1991
  * IRQ reservation is required for functions 42 and 44.
1992
  * Only one thread can reserve the specific IRQ.
1993
  * IRQs, handled by the system itself, are reserved by the system
1994
    (thread 1) at booting.
1995
  * When a thread terminates, all reserved by it IRQs
1996
    are freed automatically.
114 mikedld 1997
 
1998
======================================================================
118 diamond 1999
====== Function 46 - reserve/free a group of input/output ports. =====
114 mikedld 2000
======================================================================
118 diamond 2001
To work with reserved ports an application can access directly by
2002
commands in/out (recommended way) and can use function 43
2003
(not recommended way).
114 mikedld 2004
Parameters:
118 diamond 2005
  * eax = 46 - function number
114 mikedld 2006
  * ebx = 0 - reserve, 1 - free
118 diamond 2007
  * ecx = start port number
2008
  * edx = end port number (inclusive)
114 mikedld 2009
Returned value:
118 diamond 2010
  * eax = 0 - success
114 mikedld 2011
  * eax = 1 - error
2012
Remarks:
118 diamond 2013
  * For ports reservation: an error occurs if and only if
2014
    one from the following condition satisfies:
2015
    * start port is more than end port;
2016
    * the selected range contains incorrect port number
2017
      (correct are from 0 to 0xFFFF);
2018
    * limit for the total number of reserved areas is exceeded
2019
      (maximum 255 are allowed);
2020
    * the selected range intersects with any of earlier reserved
2021
  * For ports free: an error is an attempt to free range,
2022
    that was not earlier reserved by this function
2023
    (with same ecx,edx).
2024
  * If an error occurs (for both cases) function performs no action.
277 diamond 2025
  * At booting the system reserves for itself ports
2026
    0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (inclusively).
118 diamond 2027
  * When a thread terminates, all reserved by it ports
2028
    are freed automatically.
114 mikedld 2029
 
2030
======================================================================
118 diamond 2031
============= Function 47 - draw a number in the window. =============
114 mikedld 2032
======================================================================
2033
Parameters:
118 diamond 2034
  * eax = 47 - function number
2035
  * ebx = parameters of conversion number to text:
114 mikedld 2036
    * bl = 0 - ecx contains number
665 diamond 2037
    * bl = 1 - ecx contains pointer to dword/qword-number
118 diamond 2038
    * bh = 0 - display in decimal number system
2039
    * bh = 1 - display in hexadecimal system
2040
    * bh = 2 - display in binary system
499 diamond 2041
    * bits 16-21 = how many digits to display
655 mario79 2042
    * bits 22-29 reserved and must be set to 0
665 diamond 2043
    * bit 30 set = display qword (64-bit) number (must be bl=1)
2044
    * bit 31 set = do not display leading zeroes of the number
118 diamond 2045
  * ecx = number (if bl=0) or pointer (if bl=1)
114 mikedld 2046
  * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
139 diamond 2047
  * esi = 0xX0RRGGBB:
2048
    * RR, GG, BB specify the color
2049
    * X = ABnn (bits)
2050
    * nn = font (0/1)
2051
    * A is ignored
2052
    * B=1 - fill background with the color edi
114 mikedld 2053
Returned value:
2054
  * function does not return value
2055
Remarks:
118 diamond 2056
  * The given length must not exceed 60.
2057
  * The exactly given amount of digits is output. If number is small
2058
    and can be written by smaller amount of digits, it is supplemented
2059
    by leading zeroes; if the number is big and can not be written by
2060
    given amount of digits, extra digits are not drawn.
2061
  * Parameters of fonts are shown in the description of function 4
2062
    (text output).
114 mikedld 2063
 
2064
======================================================================
118 diamond 2065
========= Function 48, subfunction 0 - apply screen settings. ========
114 mikedld 2066
======================================================================
2067
Parameters:
118 diamond 2068
  * eax = 48 - function number
2069
  * ebx = 0 - subfunction number
114 mikedld 2070
  * ecx = 0 - reserved
2071
Returned value:
2072
  * function does not return value
2073
Remarks:
118 diamond 2074
  * Function redraws the screen after parameters change by
114 mikedld 2075
    subfunctions 1 and 2.
118 diamond 2076
  * Function call without prior call to one of indicated subfunctions
2077
    is ignored.
2078
  * Function call with nonzero ecx is ignored.
114 mikedld 2079
 
2080
======================================================================
118 diamond 2081
=========== Function 48, subfunction 1 - set button style. ===========
114 mikedld 2082
======================================================================
2083
Parameters:
118 diamond 2084
  * eax = 48 - function number
2085
  * ebx = 1 - subfunction number
2086
  * ecx = button style:
2087
    * 0 = flat
2088
    * 1 = 3d
114 mikedld 2089
Returned value:
2090
  * function does not return value
2091
Remarks:
118 diamond 2092
  * After call to this function one should redraw the screen by
2093
    subfunction 0.
2094
  * Button style influences only to their draw of function 8.
114 mikedld 2095
 
118 diamond 2096
======================================================================
2097
====== Function 48, subfunction 2 - set standard window colors. ======
2098
======================================================================
114 mikedld 2099
Parameters:
118 diamond 2100
  * eax = 48 - function number
2101
  * ebx = 2 - subfunction number
2102
  * ecx = pointer to the color table
114 mikedld 2103
  * edx = size of the color table
118 diamond 2104
    (must be 40 bytes for future compatibility)
2105
Format of the color table is shown in description of subfunction 3.
114 mikedld 2106
Returned value:
2107
  * function does not return value
2108
Remarks:
118 diamond 2109
  * After call to this function one should redraw the screen by
2110
    subfunction 0.
2111
  * Table of standard colors influences only to applications,
2112
    which receive this table obviously (by subfunction 3)
2113
    and use it (specifying colors from it to drawing functions).
2114
  * Table of standard colors is included in skin and is installed
2115
    anew with skin installation (by subfunction 8).
2116
  * Color table can be viewed/changed interactively with
2117
    the application 'desktop'.
114 mikedld 2118
 
2119
======================================================================
118 diamond 2120
====== Function 48, subfunction 3 - get standard window colors. ======
114 mikedld 2121
======================================================================
2122
Parameters:
118 diamond 2123
  * eax = 48 - function number
2124
  * ebx = 3 - subfunction number
2125
  * ecx = pointer to the buffer with size edx bytes,
2126
    where table will be written
2127
  * edx = size of color table
2128
    (must be 40 bytes for future compatibility)
114 mikedld 2129
Returned value:
2130
  * function does not return value
118 diamond 2131
Format of the color table:
2132
each item is dword-value for color 0x00RRGGBB
2133
  * +0: dword: frames - color of frame
2134
  * +4: dword: grab - color of header
2135
  * +8: dword: grab_button - color of button on header bar
2136
  * +12 = +0xC: dword: grab_button_text - color of text on button
2137
    on header bar
2138
  * +16 = +0x10: dword: grab_text - color of text on header
2139
  * +20 = +0x14: dword: work - color of working area
2140
  * +24 = +0x18: dword: work_button - color of button in working area
2141
  * +28 = +0x1C: dword: work_button_text - color of text on button
2142
    in working area
2143
  * +32 = +0x20: dword: work_text - color of text in working area
2144
  * +36 = +0x24: dword: work_graph - color of graphics in working area
114 mikedld 2145
Remarks:
118 diamond 2146
  * Structure of the color table is described in the standard
2147
    include file 'macros.inc' as 'system_colors'; for example,
2148
    it is possible to write:
1074 Galkov 2149
        sc      system_colors           ; variable declaration
2150
        ...                             ; somewhere one must call
2151
                                        ; this function with ecx=sc
2152
        mov     ecx, [sc.work_button_text]      ; read text color on
2153
                                        ; buttin in working area
118 diamond 2154
  * A program itself desides to use or not to use color table.
2155
    For usage program must simply at calls to drawing functions select
2156
    color taken from the table.
2157
  * At change of the table of standard colors (by subfunction 2 with
2158
    the subsequent application of changes by subfunction 0 or
2159
    at skin set by subfunction 8) the system sends to all windows
2160
    redraw message (the event with code 1).
2161
  * Color table can be viewed/changed interactively with
2162
    the application 'desktop'.
114 mikedld 2163
 
2164
======================================================================
118 diamond 2165
============ Function 48, subfunction 4 - get skin height. ===========
114 mikedld 2166
======================================================================
2167
Parameters:
118 diamond 2168
  * eax = 48 - function number
2169
  * ebx = 4 - subfunction number
114 mikedld 2170
Returned value:
118 diamond 2171
  * eax = skin height
114 mikedld 2172
Remarks:
118 diamond 2173
  * Skin height is defined as the height of a header
2174
    of skinned windows.
2175
  * See also general structure of window in the description
2176
    of function 0.
114 mikedld 2177
 
2178
======================================================================
118 diamond 2179
======== Function 48, subfunction 5 - get screen working area. =======
114 mikedld 2180
======================================================================
2181
Parameters:
118 diamond 2182
  * eax = 48 - function number
2183
  * ebx = 5 - subfunction number
114 mikedld 2184
Returned value:
2185
  * eax = [left]*65536 + [right]
2186
  * ebx = [top]*65536 + [bottom]
2187
Remarks:
118 diamond 2188
  * The screen working area defines position and coordinates of
2189
    a maximized window.
2190
  * The screen working area in view of normal work is all screen
2191
    without system panel (the application '@panel').
2192
  * (left,top) are coordinates of the left upper corner,
2193
    (right,bottom) are coordinates of the right lower one.
2194
    Thus the size of working area on x axis can be calculated by
2195
    formula right-left+1, on y axis - by formula bottom-right+1.
2196
  * See also function 14,
2197
    to get sizes of all screen.
2198
  * There is a pair function to set working area - subfunction 6.
114 mikedld 2199
 
2200
======================================================================
118 diamond 2201
======== Function 48, subfunction 6 - set screen working area. =======
114 mikedld 2202
======================================================================
2203
Parameters:
118 diamond 2204
  * eax = 48 - function number
2205
  * ebx = 6 - subfunction number
114 mikedld 2206
  * ecx = [left]*65536 + [right]
2207
  * edx = [top]*65536 + [bottom]
2208
Returned value:
2209
  * function does not return value
2210
Remarks:
118 diamond 2211
  * The screen working area defines position and coordinates of
2212
    a maximized window.
2213
  * This function is used only by the application '@panel',
2214
    which set working area to all screen without system panel.
2215
  * (left,top) are coordinates of the left upper corner,
2216
    (right,bottom) are coordinates of the right lower one.
2217
    Thus the size of working area on x axis can be calculated by
2218
    formula right-left+1, on y axis - by formula bottom-right+1.
2219
  * If 'left'>='right', x-coordinate of working area is not changed.
2220
    If 'left'<0, 'left' will not be set. If 'right' is greater than or
2221
    equal to screen width, 'right' will not be set.
2222
    Similarly on y axis.
2223
  * See also function 14,
2224
    to get sizes of all screen.
2225
  * There is a pair function to get working area - subfunction 5.
2226
  * This function redraws the screen automatically,
2227
    updating coordinates and sizes of maximized windows.
2228
    The system sends to all windows redraw message (the event 1).
114 mikedld 2229
 
2230
======================================================================
118 diamond 2231
=========== Function 48, subfunction 7 - get skin margins. ===========
114 mikedld 2232
======================================================================
118 diamond 2233
Returns the area of a header of a skinned window, intended for
2234
a text of a header.
114 mikedld 2235
Parameters:
118 diamond 2236
  * eax = 48 - function number
2237
  * ebx = 7 - subfunction number
114 mikedld 2238
Returned value:
2239
  * eax = [left]*65536 + [right]
2240
  * ebx = [top]*65536 + [bottom]
2241
Remarks:
118 diamond 2242
  * An application decides itself to use or not to use this function.
2243
  * It is recommended to take into account returned value
2244
    of this function for choice of a place for drawing header text
2245
    (by function 4) or a substitute of header text
2246
    (at the discretion of an application).
114 mikedld 2247
 
2248
======================================================================
118 diamond 2249
============= Function 48, subfunction 8 - set used skin. ============
114 mikedld 2250
======================================================================
2251
Parameters:
118 diamond 2252
  * eax = 48 - function number
2253
  * ebx = 8 - subfunction number
2254
  * ecx = pointer to a block for function 58, in
2255
    which the fields of intermediate buffer and file name are filled
114 mikedld 2256
Returned value:
118 diamond 2257
  * eax = 0 - success
2258
  * otherwise eax = file system error code; if file does not
2259
    contain valid skin, function returns error 3
2260
    (unknown file system).
114 mikedld 2261
Remarks:
118 diamond 2262
  * After successful skin loading the system sends to all windows
2263
    redraw message (the event 1).
2264
  * At booting the system reads skin from file 'default.skn'
2265
    on ramdisk.
2266
  * User can change the skin statically by creating hisself
2267
    'default.skn' or dynamically with the application 'desktop'.
114 mikedld 2268
 
2269
======================================================================
118 diamond 2270
=========== Function 49 - Advanced Power Management (APM). ===========
114 mikedld 2271
======================================================================
2272
Parameters:
118 diamond 2273
  * eax = 49 - function number
2274
  * dx = number of the APM function
2275
    (analogue of ax in APM specification)
2276
  * bx, cx = parameters of the APM function
114 mikedld 2277
Returned value:
118 diamond 2278
  * 16-bit registers ax, bx, cx, dx, si, di and carry flag CF
2279
    are set according to the APM specification
2280
  * high halves of 32-bit registers eax, ebx, ecx,
2281
    edx, esi, edi are destroyed
114 mikedld 2282
Remarks:
118 diamond 2283
  * APM 1.2 specification is described in the document
2284
    "Advanced Power Management (APM) BIOS Specification"
2285
    (Revision 1.2), available at
114 mikedld 2286
    http://www.microsoft.com/whdc/archive/amp_12.mspx;
118 diamond 2287
    besides it is included in famous Interrupt List by Ralf Brown
114 mikedld 2288
    (http://www.pobox.com/~ralf/files.html,
2289
    ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/).
2290
 
2291
======================================================================
118 diamond 2292
=================== Function 50 - set window shape. ==================
114 mikedld 2293
======================================================================
118 diamond 2294
Normal windows have rectangular shape. This function can give to
2295
a window any shape. The shape is given by a set of points inside
2296
the base rectangle belonging to a window. Position and coordinates
2297
of the base rectangle are set by function 0
2298
and changed by function 67.
114 mikedld 2299
 
118 diamond 2300
--------------------------- Set shape data ---------------------------
114 mikedld 2301
Parameters:
118 diamond 2302
  * eax = 50 - function number
2303
  * ebx = 0 - subfunction number
2304
  * ecx = pointer to shape data (array of bytes 0/1)
114 mikedld 2305
Returned value:
2306
  * function does not return value
2307
 
118 diamond 2308
-------------------------- Set shape scale ---------------------------
114 mikedld 2309
Parameters:
118 diamond 2310
  * eax = 50 - function number
2311
  * ebx = 1 - subfunction number
2312
  * ecx sets a scale: each byte of data defines
2313
    (2^scale)*(2^scale) pixels
114 mikedld 2314
Returned value:
2315
  * function does not return value
2316
Remarks:
118 diamond 2317
  * Default scale is 0 (scale factor is 1). If in the shape data
2318
    one byte corresponds to one pixel, there is no necessity
2319
    to set scale.
2320
  * Let's designate xsize = window width (in pixels), ysize = height;
2321
    pay attention, that they are one pixel more than defined by
114 mikedld 2322
    functions 0, 67.
118 diamond 2323
  * On definition of scale xsize and ysize must be divisible
2324
    on 2^scale.
2325
  * Byte of data on offset 'a' must be 0/1 and defines belonging
2326
    to a window of square with the side 2^scale (if scale=0,
2327
    this is one pixel) and coordinates of the left upper corner
114 mikedld 2328
    (a mod (xsize shr scale), a div (xsize shr scale))
118 diamond 2329
  * Data size: (xsize shr scale)*(ysize shr scale).
2330
  * Data must be presented in the memory and not change
2331
    after set of shape.
2332
  * The system views the shape data at every window redraw by
2333
    function 0.
2334
  * The call of subfunction 0 with NULL pointer results in return
2335
    to the rectangular shape.
114 mikedld 2336
 
2337
======================================================================
2338
==================== Function 51 - create thread. ====================
2339
======================================================================
2340
Parameters:
118 diamond 2341
  * eax = 51 - function number
2342
  * ebx = 1 - unique subfunction
2343
  * ecx = address of thread entry point (starting eip)
2344
  * edx = pointer to thread stack (starting esp)
114 mikedld 2345
Returned value:
118 diamond 2346
  * eax = -1 - error (there is too many threads)
2347
  * otherwise eax = TID - thread identifier
1074 Galkov 2348
    
114 mikedld 2349
 
2350
======================================================================
118 diamond 2351
=== Function 52, subfunction 0 - get network driver configuration. ===
114 mikedld 2352
======================================================================
2353
Parameters:
118 diamond 2354
  * eax = 52 - function number
2355
  * ebx = 0 - subfunction number
114 mikedld 2356
Returned value:
118 diamond 2357
  * eax = configuration dword
114 mikedld 2358
Remarks:
118 diamond 2359
  * Configuration dword can be set by subfunction 2.
2360
  * The kernel does not use this variable. The value of this
2361
    variable and working with it subfunctions 0 and 2 is represented
2362
    doubtful.
114 mikedld 2363
 
2364
======================================================================
118 diamond 2365
========= Function 52, subfunction 1 - get local IP-address. =========
114 mikedld 2366
======================================================================
2367
Parameters:
118 diamond 2368
  * eax = 52 - function number
2369
  * ebx = 1 - subfunction number
114 mikedld 2370
Returned value:
2371
  * eax = IP-address (4 bytes)
2372
Remarks:
118 diamond 2373
  * Local IP-address is set by subfunction 3.
114 mikedld 2374
 
2375
======================================================================
118 diamond 2376
=== Function 52, subfunction 2 - set network driver configuration. ===
114 mikedld 2377
======================================================================
2378
Parameters:
118 diamond 2379
  * eax = 52 - function number
2380
  * ebx = 2 - subfunction number
2381
  * ecx = configuration dword; if low 7 bits derivate the number 3,
2382
    function [re-]initializes Ethernet-card, otherwise
2383
    Ethernet turns off
114 mikedld 2384
Returned value:
118 diamond 2385
  * if Ethernet-interface is not requested, function returns eax=2,
2386
    but this can be changed in future kernel versions
2387
  * if Ethernet-interface is requested, eax=0 means error
2388
    (absence of Ethernet-card), and nonzero value - success
114 mikedld 2389
Remarks:
118 diamond 2390
  * Configuration dword can be read by subfunction 0.
2391
  * The kernel does not use this variable. The value of this
2392
    variable, subfunction 0 and part of subfunction 2, which set it,
114 mikedld 2393
    is represented doubtful.
2394
 
2395
======================================================================
2396
========= Function 52, subfunction 3 - set local IP-address. =========
2397
======================================================================
2398
Parameters:
118 diamond 2399
  * eax = 52 - function number
2400
  * ebx = 3 - subfunction number
114 mikedld 2401
  * ecx = IP-address (4 bytes)
2402
Returned value:
118 diamond 2403
  * the current implementation returns eax=3, but this can be changed
2404
    in future versions
114 mikedld 2405
Remarks:
118 diamond 2406
  * Local IP-address can be get by subfunction 1.
114 mikedld 2407
 
2408
======================================================================
118 diamond 2409
= Function 52, subfunction 6 - add data to the stack of input queue. =
114 mikedld 2410
======================================================================
2411
Parameters:
118 diamond 2412
  * eax = 52 - function number
2413
  * ebx = 6 - subfunction number
2414
  * edx = data size
2415
  * esi = data pointer
114 mikedld 2416
Returned value:
2417
  * eax = -1 - error
118 diamond 2418
  * eax = 0 - success
114 mikedld 2419
Remarks:
118 diamond 2420
  * This function is intended only for slow network drivers
2421
    (PPP, SLIP).
2422
  * Data size must not exceed 1500 bytes, though function
2423
    performs no checks on correctness.
114 mikedld 2424
 
2425
======================================================================
1074 Galkov 2426
 Function 52, subfunction 8 - read data from the network output queue.
114 mikedld 2427
======================================================================
2428
Parameters:
118 diamond 2429
  * eax = 52 - function number
2430
  * ebx = 8 - subfunction number
2431
  * esi = pointer to 1500-byte buffer
114 mikedld 2432
Returned value:
118 diamond 2433
  * eax = number of read bytes (in the current implementation
2434
    either 0 = no data or 1500)
2435
  * data was copied in buffer
114 mikedld 2436
Remarks:
118 diamond 2437
  * This function is intended only for slow network drivers
2438
    (PPP, SLIP).
114 mikedld 2439
 
2440
======================================================================
118 diamond 2441
============ Function 52, subfunction 9 - get gateway IP. ============
114 mikedld 2442
======================================================================
2443
Parameters:
118 diamond 2444
  * eax = 52 - function number
2445
  * ebx = 9 - subfunction number
114 mikedld 2446
Returned value:
2447
  * eax = gateway IP (4 bytes)
2448
 
2449
======================================================================
118 diamond 2450
=========== Function 52, subfunction 10 - get subnet mask. ===========
114 mikedld 2451
======================================================================
2452
Parameters:
118 diamond 2453
  * eax = 52 - function number
2454
  * ebx = 10 - subfunction number
114 mikedld 2455
Returned value:
118 diamond 2456
  * eax = subnet mask
114 mikedld 2457
 
2458
======================================================================
118 diamond 2459
============ Function 52, subfunction 11 - set gateway IP. ===========
114 mikedld 2460
======================================================================
2461
Parameters:
118 diamond 2462
  * eax = 52 - function number
2463
  * ebx = 11 - subfunction number
114 mikedld 2464
  * ecx = gateway IP (4 bytes)
2465
Returned value:
118 diamond 2466
  * the current implementation returns eax=11, but this can be changed
2467
    in future versions
114 mikedld 2468
 
2469
======================================================================
118 diamond 2470
=========== Function 52, subfunction 12 - set subnet mask. ===========
114 mikedld 2471
======================================================================
2472
Parameters:
118 diamond 2473
  * eax = 52 - function number
2474
  * ebx = 12 - subfunction number
2475
  * ecx = subnet mask
114 mikedld 2476
Returned value:
118 diamond 2477
  * the current implementation returns eax=12, but this can be changed
2478
    in future versions
114 mikedld 2479
 
2480
======================================================================
118 diamond 2481
============== Function 52, subfunction 13 - get DNS IP. =============
114 mikedld 2482
======================================================================
2483
Parameters:
118 diamond 2484
  * eax = 52 - function number
2485
  * ebx = 13 - subfunction number
114 mikedld 2486
Returned value:
2487
  * eax = DNS IP (4 bytes)
2488
 
2489
======================================================================
118 diamond 2490
============== Function 52, subfunction 14 - set DNS IP. =============
114 mikedld 2491
======================================================================
2492
Parameters:
118 diamond 2493
  * eax = 52 - function number
2494
  * ebx = 14 - subfunction number
114 mikedld 2495
  * ecx = DNS IP (4 bytes)
2496
Returned value:
118 diamond 2497
  * the current implementation returns eax=14, but this can be changed
2498
    in future versions
114 mikedld 2499
 
2500
======================================================================
277 diamond 2501
======== Function 52, subfunction 15 - get local MAC address. ========
2502
======================================================================
2503
Parameters:
2504
  * eax = 52 - function number
2505
  * ebx = 15 - subfunction number
2506
  * ecx = 0 - read first 4 bytes,
2507
    ecx = 4 - read last 2 bytes
2508
Returned value:
2509
  * for ecx=0: eax = first 4 bytes of MAC address
2510
  * for ecx=4: ax = last 2 bytes of MAC address,
2511
               high half of eax is destroyed
2512
  * for other ecx: eax = -1 indicates an error
2513
 
2514
======================================================================
118 diamond 2515
============ Function 53, subfunction 0 - open UDP-socket. ===========
114 mikedld 2516
======================================================================
2517
Parameters:
118 diamond 2518
  * eax = 53 - function number
2519
  * ebx = 0 - subfunction number
1154 clevermous 2520
  * ecx = local port (only low word is taken into account),
2521
    ecx = 0 - let the system choose a port
118 diamond 2522
  * edx = remote port (only low word is taken into account)
114 mikedld 2523
  * esi = remote IP
2524
Returned value:
118 diamond 2525
  * eax = -1 = 0xFFFFFFFF - error; ebx destroyed
2526
  * eax = socket handle (some number which unambiguously identifies
2527
    socket and have sense only for the system) - success;
2528
    ebx destroyed
114 mikedld 2529
 
2530
======================================================================
118 diamond 2531
=========== Function 53, subfunction 1 - close UDP-socket. ===========
114 mikedld 2532
======================================================================
2533
Parameters:
118 diamond 2534
  * eax = 53 - function number
2535
  * ebx = 1 - subfunction number
2536
  * ecx = socket handle
114 mikedld 2537
Returned value:
118 diamond 2538
  * eax = -1 - incorrect handle
2539
  * eax = 0 - success
2540
  * ebx destroyed
114 mikedld 2541
Remarks:
118 diamond 2542
  * The current implementation does not close automatically all
2543
    sockets of a thread at termination. In particular, one should not
2544
    kill a thread with many opened sockets - there will be an outflow
2545
    of resources.
114 mikedld 2546
 
2547
======================================================================
2548
============== Function 53, subfunction 2 - poll socket. =============
2549
======================================================================
2550
Parameters:
118 diamond 2551
  * eax = 53 - function number
2552
  * ebx = 2 - subfunction number
2553
  * ecx = socket handle
114 mikedld 2554
Returned value:
1018 diamond 2555
  * eax = number of read bytes, 0 for incorrect handle
118 diamond 2556
  * ebx destroyed
114 mikedld 2557
 
2558
======================================================================
118 diamond 2559
========= Function 53, subfunction 3 - read byte from socket. ========
114 mikedld 2560
======================================================================
2561
Parameters:
118 diamond 2562
  * eax = 53 - function number
2563
  * ebx = 3 - subfunction number
2564
  * ecx = socket handle
114 mikedld 2565
Returned value:
1018 diamond 2566
  * if there is no read data or handle is incorrect: eax=0, bl=0,
118 diamond 2567
    other bytes of ebx are destroyed
2568
  * if there are read data: eax=number of rest bytes
2569
    (possibly 0), bl=read byte, other bytes of ebx are destroyed
114 mikedld 2570
 
2571
======================================================================
118 diamond 2572
========== Function 53, subfunction 4 - write to UDP-socket. =========
114 mikedld 2573
======================================================================
2574
Parameters:
118 diamond 2575
  * eax = 53 - function number
2576
  * ebx = 4 - subfunction number
2577
  * ecx = socket handle
2578
  * edx = number of bytes to write
2579
  * esi = pointer to data to write
114 mikedld 2580
Returned value:
1018 diamond 2581
  * eax = 0xffffffff - error (invalid handle or not enough memory)
118 diamond 2582
  * eax = 0 - success
2583
  * ebx destroyed
114 mikedld 2584
Remarks:
118 diamond 2585
  * Number of bytes to write must not exceed 1500-28, though
2586
    the appropriate check is not made.
114 mikedld 2587
 
2588
======================================================================
2589
============ Function 53, subfunction 5 - open TCP-socket. ===========
2590
======================================================================
2591
Parameters:
118 diamond 2592
  * eax = 53 - function number
2593
  * ebx = 5 - subfunction number
1154 clevermous 2594
  * ecx = local port (only low word is taken into account),
2595
    ecx = 0 - let the system choose a port
118 diamond 2596
  * edx = remote port (only low word is taken into account)
114 mikedld 2597
  * esi = remote IP
118 diamond 2598
  * edi = open mode: SOCKET_PASSIVE=0 or SOCKET_ACTIVE=1
114 mikedld 2599
Returned value:
118 diamond 2600
  * eax = -1 = 0xFFFFFFFF - error; ebx destroys
2601
  * eax = socket handle (some number which unambiguously identifies
2602
    socket and have sense only for the system) - success;
2603
    ebx destroyed
114 mikedld 2604
 
2605
======================================================================
118 diamond 2606
========= Function 53, subfunction 6 - get TCP-socket status. ========
114 mikedld 2607
======================================================================
2608
Parameters:
118 diamond 2609
  * eax = 53 - function number
2610
  * ebx = 6 - subfunction number
2611
  * ecx = socket handle
114 mikedld 2612
Returned value:
1018 diamond 2613
  * eax = 0 for incorrect handle or socket status: one of
114 mikedld 2614
  * TCB_LISTEN = 1
2615
  * TCB_SYN_SENT = 2
2616
  * TCB_SYN_RECEIVED = 3
2617
  * TCB_ESTABLISHED = 4
2618
  * TCB_FIN_WAIT_1 = 5
2619
  * TCB_FIN_WAIT_2 = 6
2620
  * TCB_CLOSE_WAIT = 7
2621
  * TCB_CLOSING = 8
2622
  * TCB_LAST_ASK = 9
2623
  * TCB_TIME_WAIT = 10
2624
  * TCB_CLOSED = 11
1018 diamond 2625
  * ebx destroyed
114 mikedld 2626
 
2627
======================================================================
118 diamond 2628
========== Function 53, subfunction 7 - write to TCP-socket. =========
114 mikedld 2629
======================================================================
2630
Parameters:
118 diamond 2631
  * eax = 53 - function number
2632
  * ebx = 7 - subfunction number
2633
  * ecx = socket handle
2634
  * edx = number of bytes to write
2635
  * esi = pointer to data to write
114 mikedld 2636
Returned value:
1018 diamond 2637
  * eax = 0xffffffff - error (invalid handle or not enough memory)
118 diamond 2638
  * eax = 0 - success
2639
  * ebx destroyed
114 mikedld 2640
Remarks:
118 diamond 2641
  * Number of bytes to write must not exceed 1500-40, though
2642
    the appropriate check is not made.
114 mikedld 2643
 
2644
======================================================================
118 diamond 2645
=========== Function 53, subfunction 8 - close TCP-socket. ===========
114 mikedld 2646
======================================================================
2647
Parameters:
118 diamond 2648
  * eax = 53 - function number
2649
  * ebx = 8 - subfunction number
2650
  * ecx = socket handle
114 mikedld 2651
Returned value:
1018 diamond 2652
  * eax = -1 - error (invalid handle or
2653
    not enough memory for socket close packet)
118 diamond 2654
  * eax = 0 - success
2655
  * ebx destroyed
114 mikedld 2656
Remarks:
118 diamond 2657
  * The current implementation does not close automatically all
2658
    sockets of a thread at termination. In particular, one should not
2659
    kill a thread with many opened sockets - there will be an outflow
2660
    of resources.
114 mikedld 2661
 
2662
======================================================================
118 diamond 2663
=== Function 53, subfunction 9 - check whether local port is free. ===
114 mikedld 2664
======================================================================
2665
Parameters:
118 diamond 2666
  * eax = 53 - function number
2667
  * ebx = 9 - subfunction number
2668
  * ecx = local port number (low 16 bits are used only)
114 mikedld 2669
Returned value:
2670
  * eax = 0 - port is used
2671
  * eax = 1 - port is free
118 diamond 2672
  * ebx destroyed
114 mikedld 2673
 
2674
======================================================================
314 diamond 2675
===== Function 53, subfunction 10 - query Ethernet cable status. =====
2676
======================================================================
2677
Parameters:
2678
  * eax = 53 - function number
2679
  * ebx = 10 - subfunction number
2680
Returned value:
2681
  * al = -1 - a network driver is not loaded or
2682
              does not support this function
2683
  * al = 0 - Ethernet cable is unplugged
2684
  * al = 1 - Ethernet cable is plugged
346 diamond 2685
  * ebx destroyed
314 diamond 2686
Remarks:
2687
  * The current kernel implementation supports this function
2688
    only for RTL8139 network cards.
2689
 
2690
======================================================================
346 diamond 2691
======= Function 53, subfunction 11 - read network stack data. =======
340 heavyiron 2692
======================================================================
346 diamond 2693
Paramters:
2694
  * eax = 53 - function number
2695
  * ebx = 11 - subfunction number
2696
  * ecx = socket handle
2697
  * edx = pointer to buffer
2698
  * esi = number of bytes to read;
2699
  * esi = 0 - read all data (maximum 4096 bytes)
2700
Returned value:
1018 diamond 2701
  * eax = number of bytes read (0 for incorrect handle)
346 diamond 2702
  * ebx destroyed
340 heavyiron 2703
 
2704
======================================================================
1074 Galkov 2705
= Function 53, subfunction 255 - debug information of network driver.
114 mikedld 2706
======================================================================
2707
Parameters:
118 diamond 2708
  * eax = 53 - function number
2709
  * ebx = 255 - subfunction number
114 mikedld 2710
  * ecx = type of requested information (see below)
2711
Returned value:
2712
  * eax = requested information
118 diamond 2713
  * ebx destroyed
2714
Possible values for ecx:
114 mikedld 2715
  * 100: length of queue 0 (empty queue)
2716
  * 101: length of queue 1 (ip-out queue)
2717
  * 102: length of queue 2 (ip-in queue)
2718
  * 103: length of queue 3 (net1out queue)
118 diamond 2719
  * 200: number of items in the ARP table
2720
  * 201: size of the ARP table (in items) (20 for current version)
2721
  * 202: read item at edx of the ARP table to the temporary buffer,
2722
    whence 5 following types take information;
114 mikedld 2723
    in this case eax is not defined
118 diamond 2724
  * 203: IP-address saved by type 202
2725
  * 204: high dword of MAC-address saved by type 202
2726
  * 205: low word of MAC-address saved by type 202
2727
  * 206: status word saved by type 202
2728
  * 207: ttl word saved by type 202
2729
  * 2: total number of received IP-packets
2730
  * 3: total number of transferred IP-packets
2731
  * 4: total number of dumped received packets
2732
  * 5: total number of received ARP-packets
2733
  * 6: status of packet driver, 0=inactive, nonzero=active
114 mikedld 2734
 
2735
======================================================================
1074 Galkov 2736
 Function 55, subfunction 55 - begin to play data on built-in speaker.
114 mikedld 2737
======================================================================
2738
Parameters:
118 diamond 2739
  * eax = 55 - function number
2740
  * ebx = 55 - subfunction number
2741
  * esi = pointer to data
114 mikedld 2742
Returned value:
118 diamond 2743
  * eax = 0 - success
2744
  * eax = 55 - error (speaker is off or busy)
2745
Data is an array of items with variable length.
2746
Format of each item is defined by first byte:
114 mikedld 2747
  * 0 = end of data
118 diamond 2748
  * 1..0x80 = sets sound duration on 1/100 of second; sound note
2749
    is defined by immediate value of frequency
2750
    * following word (2 bytes) contains frequency divider;
2751
      frequency is defined as 1193180/divider
114 mikedld 2752
  * 0x81 = invalid
118 diamond 2753
  * 0x82..0xFF = note is defined by octave and number:
2754
    * duration in 1/100 of second = (first byte)-0x81
114 mikedld 2755
    * there is one more byte;
118 diamond 2756
    * (second byte)=0xFF - delay
2757
    * otherwise it looks like a*0x10+b, where b=number of the note in
2758
      an octave from 1 to 12, a=number of octave (beginning from 0)
114 mikedld 2759
Remarks:
118 diamond 2760
  * Speaker play can be disabled/enabled by
2761
    subfunction 8 of function 18.
2762
  * Function returns control, having informed the system
2763
    an information on request. Play itself goes independently from
2764
    the program.
2765
  * The data must be kept in the memory at least up to the end
2766
    of play.
114 mikedld 2767
 
2768
======================================================================
641 diamond 2769
======================= Function 57 - PCI BIOS. ======================
2770
======================================================================
2771
Parameters:
2772
  * eax = 57 - function number
2773
  * ebp corresponds to al in PCI BIOS specification
2774
  * other registers are set according to PCI BIOS specification
2775
Returned value:
2776
  * CF is undefined
2777
  * other registers are set according to PCI BIOS specification
2778
Remarks:
2779
  * Many effects of this function can be also achieved with
2780
    corresponding subfunctions of function 62.
2781
  * The function calls PCI32 BIOS extension, documented e.g. in
2782
    http://alpha1.dyns.net/files/PCI/bios21.pdf.
2783
  * If BIOS does not support this extension, its behavior is emulated
2784
    (through kernel-mode analogues of subfunctions of function 62).
2785
 
2786
======================================================================
118 diamond 2787
================ Function 58 - work with file system. ================
114 mikedld 2788
======================================================================
2789
Parameters:
2790
  * eax = 58
118 diamond 2791
  * ebx = pointer to the information structure
114 mikedld 2792
Returned value:
118 diamond 2793
  * eax = 0 - success; otherwise file system error code
2794
  * some subfunctions return value in other registers too
2795
General format of the information structure:
2796
  * +0: dword: subfunction number
114 mikedld 2797
  * +4: dword: number of block
2798
  * +8: dword: size
118 diamond 2799
  * +12 = +0xC: dword: pointer to data
2800
  * +16 = +0x10: dword: pointer to a memory for system operations
114 mikedld 2801
    (4096 bytes)
118 diamond 2802
  * +20 = +0x14: n db: ASCIIZ-string with the file name
2803
Specifications - in documentation on the appropriate subfunction.
2804
Filename is case-insensitive for latin letters, russian letters
2805
must be capital.
2806
Format of filename:
114 mikedld 2807
/base/number/dir1/dir2/.../dirn/file,
118 diamond 2808
where /base/number identifies device, on which file is located:
114 mikedld 2809
one of
118 diamond 2810
  * /RD/1 = /RAMDISK/1 to access ramdisk
2811
  * /FD/1 = /FLOPPYDISK/1 to access first floppy drive,
2812
    /FD/2 = /FLOPPYDISK/2 to access second one
2813
  * /HD/x = /HARDDISK/x - obsolete variant of access to hard disk
2814
    (in this case base is defined by subfunction 7 of function 21),
2815
    x - partition number (beginning from 1)
2816
  * /HD0/x, /HD1/x, /HD2/x, /HD3/x to access accordingly to devices
2817
    IDE0 (Primary Master), IDE1 (Primary Slave),
114 mikedld 2818
    IDE2 (Secondary Master), IDE3 (Secondary Slave);
118 diamond 2819
    x - partition number on the selected hard drive, varies from 1
2820
    to 255 (on each hard drive the indexing starts from 1)
114 mikedld 2821
Remarks:
118 diamond 2822
  * In the first two cases it is also possible to use FIRST
2823
    instead of 1, SECOND instead of 2, but it is not recommended
2824
    for convenience of transition to the future extensions.
2825
  * Limitation n<=39 is imposed.
2826
  * Names of folders and file dir1,...,dirn,file must have the
2827
    format 8.3: name no more than 8 characters, dot, extension no
2828
    more than 3 characters. Trailing spaces are ignored, no other
2829
    spaces is allowed. If name occupies equally 8 characters,
2830
    dot may be omitted (though it is not recommended to use this
2831
    feature for convenience of transition to the future extensions).
2832
  * This function does not support folders on ramdisk.
114 mikedld 2833
Examples:
2834
  * '/RAMDISK/FIRST/KERNEL.ASM',0
2835
    '/rd/1/kernel.asm',0
2836
  * '/HD0/1/kernel.asm',0
2837
  * '/hd0/1/menuet/pics/tanzania.bmp',0
118 diamond 2838
Existing subfunctions:
2839
  * subfunction 0 - read file/folder
2840
  * subfunction 8 - LBA-read from device
2841
  * subfunction 15 - get file system information
114 mikedld 2842
 
2843
======================================================================
118 diamond 2844
=========== Function 58, subfunction 0 - read file/folder. ===========
114 mikedld 2845
======================================================================
2846
Parameters:
2847
  * eax = 58
118 diamond 2848
  * ebx = pointer to the information structure
2849
Format of the information structure:
2850
  * +0: dword: 0 = subfunction number
2851
  * +4: dword: first block to read (beginning from 0)
2852
  * +8: dword: amount of blocks to read
2853
  * +12 = +0xC: dword: pointer to buffer for data
2854
  * +16 = +0x10: dword: pointer to buffer for system operations
114 mikedld 2855
    (4096 bytes)
118 diamond 2856
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
2857
    given in the general description
114 mikedld 2858
Returned value:
118 diamond 2859
  * eax = 0 - success, otherwise file system error code
2860
  * ebx = file size (in bytes) or -1=0xffffffff, if file was not found
114 mikedld 2861
Remarks:
118 diamond 2862
  * Block size is 512 bytes.
114 mikedld 2863
  * This function is obsolete, for reading files use subfunction 0
118 diamond 2864
    of function 70, for reading folders - subfunction 1 of
2865
    function 70.
2866
  * Function can read contents of a folder. Only FAT file system is
2867
    supported. The format of FAT-folder is described
2868
    in any FAT documentation.
2869
  * Size of a folder is determined by size of FAT clusters chain.
2870
  * If file was ended before last requested block was read,
2871
    the function will read as many as it can, and after that return
2872
    eax=6 (EOF).
2873
  * Function can read root folders /rd/1,/fd/x,/hd[n]/x, but
2874
    in the first two cases the current implementation does not follow
2875
    to the declared rules:
114 mikedld 2876
    for /rd/1:
118 diamond 2877
    * if one want to read 0 blocks, function considers,
2878
      that he requested 1;
2879
    * if one requests more than 14 blocks or starting block is
2880
      not less than 14, function returns eax=5 (not found) и ebx=-1;
1074 Galkov 2881
    * size of ramdisk root folder is 14 blocks,
118 diamond 2882
      0x1C00=7168 байт; but function returns ebx=0
2883
      (except of the case of previous item);
2884
    * strangely enough, it is possible to read 14th block (which
2885
      generally contains a garbage - I remind, the indexing begins
2886
      from 0);
2887
    * if some block with the number not less than 14 was requested,
2888
      function returns eax=6(EOF); otherwise eax=0.
2889
    For /fd/x:
2890
    * if the start block is not less than 14, function returns
2891
      eax=5 (not found) and ebx=0;
2892
    * note that format of FAT12 allows floppies with the root size
2893
      more or less than 14 blocks;
2894
    * check for length is not performed;
2895
    * if data was successful read, function returns
2896
      eax=0,ebx=0; otherwise eax=10 (access denied), ebx=-1.
2897
  * The function handles reading of special folders /,/rd,/fd,/hd[n];
2898
    but the result does not correspond to expected (on operations with
2899
    normal files/folders), does not follow the declared rules,
2900
    may be changed in future versions of the kernel and consequently
2901
    is not described. To obtain the information about the equipment
2902
    use subfunction 11 of function 18 or
2903
    read corresponding folder with subfunction 1 of function 70.
114 mikedld 2904
 
2905
======================================================================
118 diamond 2906
========= Function 58, subfunction 8 - LBA-read from device. =========
114 mikedld 2907
======================================================================
2908
Parameters:
118 diamond 2909
  * eax = 58 - function number
2910
  * ebx = pointer to the information structure
2911
Format of the information structure:
2912
  * +0: dword: 8 = subfunction number
2913
  * +4: dword: number of block to read (beginning from 0)
2914
  * +8: dword: ignored (set to 1)
2915
  * +12 = +0xC: dword: pointer to buffer for data (512 bytes)
2916
  * +16 = +0x10: dword: pointer to buffer for system operations
114 mikedld 2917
    (4096 bytes)
118 diamond 2918
  * +20 = +0x14: ASCIIZ-name of device: case-insensitive, one of
2919
    /rd/1 = /RamDisk/1, /hd/n = /HardDisk/n,
114 mikedld 2920
    1<=n<=4 - number of device: 1=IDE0, ..., 4=IDE3.
118 diamond 2921
    Instead of digits it is allowed, though not recommended for
2922
    convenience of transition to future extensions, to use
2923
    'first','second','third','fourth'.
114 mikedld 2924
Returned value:
118 diamond 2925
  * for device name /hd/xxx, where xxx is not in the list above:
114 mikedld 2926
    * eax = ebx = 1
118 diamond 2927
  * for invalid device name (except for the previous case):
114 mikedld 2928
    * eax = 5
118 diamond 2929
    * ebx does not change
2930
  * if LBA-access is disabled by subfunction 11 of function 21:
114 mikedld 2931
    * eax = 2
118 diamond 2932
    * ebx destroyed
2933
  * for ramdisk: attempt to read block outside ramdisk
2934
    (18*2*80 blocks) results in
114 mikedld 2935
    * eax = 3
2936
    * ebx = 0
118 diamond 2937
  * for successful read:
114 mikedld 2938
    * eax = ebx = 0
2939
Remarks:
118 diamond 2940
  * Block size is 512 bytes; function reads one block.
2941
  * Do not depend on returned value, it can be changed
2942
    in future versions.
1074 Galkov 2943
  * Function requires that LBA-access to devices is enabled by
2944
    subfunction 11 of function 21. To check this one can use
118 diamond 2945
    subfunction 11 of function 26.
2946
  * LBA-read of floppy is not supported.
2947
  * Function reads data on physical hard drive; if for any reason
2948
    data of the concrete partition are required, application must
2949
    define starting sector of this partition (either directly
2950
    through MBR, or from the full structure returned by
2951
    подфункцией 11 функции 18).
2952
  * Function does not check error code of hard disk, so request of
2953
    nonexisting sector reads something (most probably it will be
2954
    zeroes, but this is defined by device) and this is considered
2955
    as success (eax=0).
114 mikedld 2956
 
118 diamond 2957
======================================================================
2958
==== Function 58, subfunction 15 - get information on file system. ===
2959
======================================================================
114 mikedld 2960
Parameters:
118 diamond 2961
  * eax = 58 - function number
2962
  * ebx = pointer to the information structure
2963
Format of the information structure:
2964
  * +0: dword: 15 = subfunction number
114 mikedld 2965
  * +4: dword: ignored
2966
  * +8: dword: ignored
2967
  * +12 = +0xC: dword: ignored
2968
  * +16 = +0x10: dword: ignored
118 diamond 2969
  * +20 = +0x14: (only second character is checked)
114 mikedld 2970
    /rd=/RAMDISK or /hd=/HARDDISK
2971
Returned value:
118 diamond 2972
  * if the second character does not belong to set {'r','R','h','H'}:
114 mikedld 2973
    * eax = 3
2974
    * ebx = ecx = dword [fileinfo] = 0
2975
  * for ramdisk:
2976
    * eax = 0 (success)
2977
    * ebx = total number of clusters = 2847
2978
    * ecx = number of free clusters
2979
    * dword [fileinfo] = cluster size = 512
118 diamond 2980
  * for hard disk: base and partition are defined by subfunctions
2981
    7 and 8 of function 21:
114 mikedld 2982
    * eax = 0 (success)
2983
    * ebx = total number of clusters
2984
    * ecx = number of free clusters
2985
    * dword [fileinfo] = cluster size (in bytes)
2986
Remarks:
118 diamond 2987
  * Be not surprised to strange layout of 4th returned parameter
2988
    - when this code was writing, at system calls application got
2989
    only registers eax,ebx,ecx (from pushad-structure transmitted
2990
    as argument to the system function). Now it is corrected, so,
2991
    probably, it is meaningful to return cluster size in edx, while
2992
    this function is not used yet.
2993
  * There exists also subfunction 11 of function 18,
2994
    which returns information on file system. From the full table
2995
    of disk subsystem it is possible to deduce cluster size (there
2996
    it is stored in sectors) and total number of clusters
2997
    for hard disks.
114 mikedld 2998
 
2999
======================================================================
118 diamond 3000
========== Function 60 - Inter Process Communication (IPC). ==========
114 mikedld 3001
======================================================================
118 diamond 3002
IPC is used for message dispatching from one process/thread to
3003
another. Previously it is necessary to agree how to interpret
114 mikedld 3004
the concrete message.
3005
 
118 diamond 3006
----------- Subfunction 1 - set the area for IPC receiving -----------
3007
Is called by process-receiver.
114 mikedld 3008
Parameters:
118 diamond 3009
  * eax = 60 - function number
3010
  * ebx = 1 - subfunction number
3011
  * ecx = pointer to the buffer
3012
  * edx = size of the buffer
114 mikedld 3013
Returned value:
118 diamond 3014
  * eax = 0 - always success
3015
Format of IPC-buffer:
3016
  * +0: dword: if nonzero, buffer is considered locked;
3017
    lock/unlock the buffer, when you work with it and need that
3018
    buffer data are not changed from outside (no new messages)
114 mikedld 3019
  * +4: dword: occupied place in the buffer (in bytes)
3020
  * +8: first message
3021
  * +8+n: second message
3022
  * ...
118 diamond 3023
Format of a message:
3024
  * +0: dword: PID of sender
3025
  * +4: dword: message length (not including this header)
3026
  * +8: n*byte: message data
114 mikedld 3027
 
118 diamond 3028
------------------ Subfunction 2 - send IPC message ------------------
3029
Is called by process-sender.
114 mikedld 3030
Parameters:
118 diamond 3031
  * eax = 60 - function number
3032
  * ebx = 2 - subfunction number
114 mikedld 3033
  * ecx = PID of receiver
118 diamond 3034
  * edx = pointer to the message data
3035
  * esi = message length (in bytes)
114 mikedld 3036
Returned value:
118 diamond 3037
  * eax = 0 - success
3038
  * eax = 1 - the receiver has not defined buffer for IPC messages
3039
    (can be, still have no time,
3040
    and can be, this is not right process)
3041
  * eax = 2 - the receiver has blocked IPC-buffer; try to wait a bit
3042
  * eax = 3 - overflow of IPC-buffer of the receiver
114 mikedld 3043
  * eax = 4 - process/thread with such PID does not exist
3044
Remarks:
118 diamond 3045
  * Immediately after writing of IPC-message to the buffer the system
3046
    sends to the receiver the event with code 7 (see event codes).
114 mikedld 3047
 
3048
======================================================================
118 diamond 3049
==== Function 61 - get parameters for the direct graphics access. ====
114 mikedld 3050
======================================================================
118 diamond 3051
The data of the graphics screen (the memory area which displays
3052
screen contents) are accessible to a program directly, without
3053
any system calls, through the selector gs:
1074 Galkov 3054
        mov     eax, [gs:0]
118 diamond 3055
places in eax the first dword of the buffer, which contains
3056
information on color of the left upper point (and, possibly, colors
3057
of several following).
1074 Galkov 3058
        mov     [gs:0], eax
118 diamond 3059
by work in VESA modes with LFB sets color of the left upper point
3060
(and, possibly, colors of several following).
3061
To interpret the data of graphics screen program needs to know
3062
some parameters, returning by this function.
114 mikedld 3063
Remarks:
118 diamond 3064
  * Graphics parameters changes very seldom at work,
3065
    namely, only in cases, when user works with the application VRR.
3066
  * At videomode change the system redraws all windows (event
3067
    with code 1) and redraws the background (event 5).
3068
    Same events occur in other cases too, which meet much more often,
3069
    than videomode change.
3070
  * By operation in videomodes with LFB the selector gs points to
3071
    LFB itself, so reading/writing on gs result directly in
3072
    change of screen contents. By operation in videomodes without
3073
    LFB gs points to some data area in the kernel, and all functions
3074
    of screen output fulfil honesty double operation on writing
3075
    directly to the screen and writing to this buffer. In result
3076
    at reading contents of this buffer the results correspond to
3077
    screen contents (with, generally speaking, large color
3078
    resolution), and writing is ignored.
3079
    One exception is the mode 320*200, for which main loop of the
3080
    system thread updates the screen according to mouse movements.
114 mikedld 3081
 
3082
------------------------- Screen resolution --------------------------
3083
Parameters:
118 diamond 3084
  * eax = 61 - function number
3085
  * ebx = 1 - subfunction number
114 mikedld 3086
Returned value:
118 diamond 3087
  * eax = [resolution on x axis]*65536 + [resolution on y axis]
114 mikedld 3088
Remarks:
118 diamond 3089
  * One can use function 14 paying attention that
3090
    it returns sizes on 1 pixel less. It is fully equivalent way.
114 mikedld 3091
 
118 diamond 3092
---------------------- Number of bits per pixel ----------------------
114 mikedld 3093
Parameters:
118 diamond 3094
  * eax = 61 - function number
3095
  * ebx = 2 - subfunction number
114 mikedld 3096
Returned value:
118 diamond 3097
  * eax = number of bits per pixel (24 or 32)
114 mikedld 3098
 
118 diamond 3099
-------------------- Number of bytes per scanline --------------------
114 mikedld 3100
Parameters:
118 diamond 3101
  * eax = 61 - function number
3102
  * ebx = 3 - subfunction number
114 mikedld 3103
Returned value:
118 diamond 3104
  * eax = number of bytes occupied by one scanline
114 mikedld 3105
    (horizontal line on the screen)
3106
 
3107
======================================================================
118 diamond 3108
===== Function 62, subfunction 0 - get version of PCI-interface. =====
114 mikedld 3109
======================================================================
3110
Parameters:
118 diamond 3111
  * eax = 62 - function number
3112
  * bl = 0 - subfunction number
114 mikedld 3113
Returned value:
118 diamond 3114
  * eax = -1 - PCI access is disabled; otherwise
3115
  * ah.al = version of PCI-interface (ah=version, al=subversion)
3116
  * high word of eax is zeroed
114 mikedld 3117
Remarks:
118 diamond 3118
  * Previously low-level access to PCI for applications must be
3119
    enabled by subfunction 12 of function 21.
3120
  * If PCI BIOS is not supported, the value of ax is undefined.
114 mikedld 3121
 
3122
======================================================================
118 diamond 3123
==== Function 62, subfunction 1 - get number of the last PCI-bus. ====
114 mikedld 3124
======================================================================
3125
Parameters:
118 diamond 3126
  * eax = 62 - function number
3127
  * bl = 1 - subfunction number
114 mikedld 3128
Returned value:
118 diamond 3129
  * eax = -1 - access to PCI is disabled; otherwise
3130
  * al = number of the last PCI-bus; other bytes of eax are destroyed
114 mikedld 3131
Remarks:
118 diamond 3132
  * Previously low-level access to PCI for applications must be
3133
    enabled by subfunction 12 of function 21.
3134
  * If PCI BIOS is not supported, the value of ax is undefined.
114 mikedld 3135
 
3136
======================================================================
118 diamond 3137
===================== Function 62, subfunction 2 =====================
3138
===== Get mechanism of addressing to the PCI configuration space. ====
114 mikedld 3139
======================================================================
3140
Parameters:
118 diamond 3141
  * eax = 62 - function number
3142
  * bl = 2 - subfunction number
114 mikedld 3143
Returned value:
118 diamond 3144
  * eax = -1 - access to PCI is disabled; otherwise
3145
  * al = mechanism (1 or 2); other bytes of eax are destroyed
114 mikedld 3146
Remarks:
118 diamond 3147
  * Previously low-level access to PCI for applications must be
3148
    enabled by subfunction 12 of function 21.
3149
  * Addressing mechanism is selected depending on
3150
    equipment characteristics.
3151
  * Subfunctions of read and write work automatically
3152
    with the selected mechanism.
114 mikedld 3153
 
3154
======================================================================
118 diamond 3155
======== Function 62, subfunctions 4,5,6 - read PCI-register. ========
114 mikedld 3156
======================================================================
3157
Parameters:
118 diamond 3158
  * eax = 62 - function number
3159
  * bl = 4 - read byte
3160
  * bl = 5 - read word
3161
  * bl = 6 - read dword
114 mikedld 3162
  * bh = number of PCI-bus
118 diamond 3163
  * ch = dddddfff, where ddddd = number of the device on the bus,
3164
    fff = function number of device
3165
  * cl = number of register (must be even for bl=5,
3166
    divisible by 4 for bl=6)
114 mikedld 3167
Returned value:
118 diamond 3168
  * eax = -1 - error (access to PCI is disabled or parameters
3169
    are not supported); otherwise
3170
  * al/ax/eax (depending on requested size) contains the data;
3171
    the other part of register eax is destroyed
114 mikedld 3172
Remarks:
118 diamond 3173
  * Previously low-level access to PCI for applications must be
3174
    enabled by subfunction 12 of function 21.
3175
  * Access mechanism 2 supports only 16 devices on a bus and ignores
3176
    function number. To get access mechanism use subfunction 2.
3177
  * Some registers are standard and exist for all devices, some are
3178
    defined by the concrete device. The list of registers of the
3179
    first type can be found e.g. in famous
114 mikedld 3180
    Interrupt List by Ralf Brown
3181
    (http://www.pobox.com/~ralf/files.html,
3182
    ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/);
118 diamond 3183
    registers of the second type must be listed
3184
    in the device documentation.
114 mikedld 3185
 
3186
======================================================================
118 diamond 3187
====== Function 62, subfunctions 8,9,10 - write to PCI-register. =====
114 mikedld 3188
======================================================================
3189
Parameters:
118 diamond 3190
  * eax = 62 - function number
3191
  * bl = 8 - write byte
3192
  * bl = 9 - write word
3193
  * bl = 10 - write dword
114 mikedld 3194
  * bh = number of PCI-bus
118 diamond 3195
  * ch = dddddfff, where ddddd = number of the device on the bus,
3196
    fff = function number of device
3197
  * cl = number of register (must be even for bl=9,
3198
    divisible by 4 for bl=10)
3199
  * dl/dx/edx (depending on requested size) contatins
3200
    the data to write
114 mikedld 3201
Returned value:
118 diamond 3202
  * eax = -1 - error (access to PCI is disabled or parameters
3203
    are not supported)
3204
  * eax = 0 - success
114 mikedld 3205
Remarks:
118 diamond 3206
  * Previously low-level access to PCI for applications must be
3207
    enabled by subfunction 12 of function 21.
3208
  * Access mechanism 2 supports only 16 devices on a bus and ignores
3209
    function number. To get access mechanism use subfunction 2.
3210
  * Some registers are standard and exist for all devices, some are
3211
    defined by the concrete device. The list of registers of the
3212
    first type can be found e.g. in famous Interrupt List by
3213
    Ralf Brown; registers of the second type must be listed
3214
    in the device documentation.
114 mikedld 3215
 
3216
======================================================================
1353 art_zh 3217
===================== Function 62, subfunction 11 ====================
3218
==              Initialize user-accessible MMIO channel             ==
3219
======================================================================
3220
Parameters:
3221
  * eax = 62 - function
3222
  * bl  = 11 - subfunction
3223
  * cx  = PCI-address (bbbbbbbb dddddfff)
3224
Returns:
3225
  * eax = -1 - PCI access not granted;
3226
  * eax = -2 - no user MMIO access to this PCI address;
3227
  * eax = -3 - memory allocation error; otherwise
3228
  * eax = available user heap size.
3229
Remarks:
3230
  * Low-level PCI access must be allowed (fn21:12)
3231
  * PCI-address should correspond the system var [mmio_pci_addr]
3232
 
3233
======================================================================
3234
===================== Function 62, subfunction 12 ====================
3235
==            Request user-accessible MMIO address space            ==
3236
======================================================================
3237
Parameters:
3238
  * eax = 62 - function
3239
  * bl  = 12 - subfunction
3240
  * bh  = BAR number in PCI configuration space
3241
  * ecx = MMIO-block size needed (bytes)
3242
  * edx = MMIO-offset (number of whole 4Kb-pages!)
3243
Returns:
3244
  * eax = -1 - user PCI access denied;
3245
  * eax = -2 - invalid BAR number;
3246
  * eax = -3 - BAR contains no valid IO addres;
3247
  * eax = -4 - BAR addresses IO ports;
3248
  * eax = -5 - dynamic allocation error; otherwise
3249
  * eax = MMIO start address (in application's linear space).
3250
Remarks:
3251
  * Low-level PCI access must be allowed (fn21:12)
3252
  * The system var [mmio_pci_addr] sets the actual PCI-address
3253
  * The granted MMIO addresses should be released after use (fn62:13)
3254
 
3255
======================================================================
3256
===================== Function 62, subfunction 13 ====================
3257
==              Release a block of user MMIO addresses              ==
3258
======================================================================
3259
Џ а ¬Ґвал:
3260
  * eax = 62 - function
3261
  * bl  = 12 - subfunction
3262
  * ecx = MMIO start address (in application's linear space).
3263
Returns:
3264
  * eax = 1 if the block is successfully released;
3265
  * eax = 0 in case of reallocation error;
3266
Remarks:
3267
  * A valid uMMIO block should exist at this address (fn62:12)
3268
 
3269
======================================================================
118 diamond 3270
============== Function 63 - work with the debug board. ==============
114 mikedld 3271
======================================================================
118 diamond 3272
The debug board is the global system buffer (with the size
499 diamond 3273
1024 bytes), to which any program can write (generally speaking,
118 diamond 3274
arbitrary) data and from which other program can read these data.
3275
By the agreement written data are text strings interpreted as
3276
debug messages on a course of program execution. The kernel in
3277
some situations also writes to the debug board information on
3278
execution of some functions; by the agreement kernel messages
3279
begins from the prefix "K : ".
3280
For view of the debug board the application 'board' was created,
3281
which reads data from the buffer and displays them in its window.
3282
'board' interpretes the sequence of codes 13,10 as newline.
3283
A character with null code in an end of line is not necessary,
114 mikedld 3284
but also does not prevent.
118 diamond 3285
Because debugger has been written, the value of the debug board
3286
has decreased, as debugger allows to inspect completely a course of
3287
program execution without any efforts from the direction of program
3288
itself. Nevertheless in some cases the debug board is still useful.
114 mikedld 3289
 
118 diamond 3290
----------------------------- Write byte -----------------------------
114 mikedld 3291
Parameters:
118 diamond 3292
  * eax = 63 - function number
3293
  * ebx = 1 - subfunction number
3294
  * cl = data byte
114 mikedld 3295
Returned value:
3296
  * function does not return value
3297
Remarks:
118 diamond 3298
  * Byte is written to the buffer. Buffer size is 512 bytes.
3299
    At buffer overflow all obtained data are lost.
3300
  * For output to the debug board of more complicated objects
3301
    (strings, numbers) it is enough to call this function in cycle.
3302
    It is possible not to write the appropriate code manually and use
3303
    file 'debug.inc', which is included into the distributive.
114 mikedld 3304
 
118 diamond 3305
----------------------------- Read byte ------------------------------
3306
Takes away byte from the buffer.
114 mikedld 3307
Parameters:
118 diamond 3308
  * eax = 63 - function number
3309
  * ebx = 2 - subfunction number
114 mikedld 3310
Returned value:
118 diamond 3311
  * eax = ebx = 0 - the buffer is empty
3312
  * eax = byte, ebx = 1 - byte was successfully read
114 mikedld 3313
 
3314
======================================================================
118 diamond 3315
============== Function 64 - resize application memory. ==============
114 mikedld 3316
======================================================================
3317
Parameters:
118 diamond 3318
  * eax = 64 - function number
3319
  * ebx = 1 - unique subfunction
3320
  * ecx = new memory size
114 mikedld 3321
Returned value:
118 diamond 3322
  * eax = 0 - success
3323
  * eax = 1 - not enough memory
114 mikedld 3324
Remarks:
193 diamond 3325
  * There is another way to dynamically allocate/free memory -
3326
    subfunctions 11, 12, 13 of function 68.
3327
  * The function cannot be used together with 68.11, 68.12, 68.13.
3328
    The function call will be ignored after creation of process heap
3329
    with function 68.11.
114 mikedld 3330
 
3331
======================================================================
283 diamond 3332
======== Function 65 - draw image with palette in the window. ========
3333
======================================================================
3334
Parameters:
3335
  * eax = 65 - function number
3336
  * ebx = pointer to the image
3337
  * ecx = [size on axis x]*65536 + [size on axis y]
3338
  * edx = [coordinate on axis x]*65536 + [coordinate on axis y]
1018 diamond 3339
  * esi = number of bits per pixel, must be 1,2,4,8,15,16,24 or 32
3340
  * edi = pointer to palette (2 to the power esi colors 0x00RRGGBB);
3341
          ignored when esi > 8
314 diamond 3342
  * ebp = offset of next row data relative to previous row data
283 diamond 3343
Returned value:
3344
  * function does not return value
3345
Remarks:
3346
  * Coordinates of the image are coordinates of the upper left corner
3347
    of the image relative to the window.
1018 diamond 3348
  * Format of image with 1 bit per pixel: each byte of image
3349
    (possibly excluding last bytes in rows), contains information on
3350
    the color of 8 pixels, MSB corresponds to first pixel.
3351
  * Format of image with 2 bits per pixel: each byte of image
3352
    (possibly excluding last bytes in rows), contains information on
3353
    the color of 4 pixels, two MSBs correspond to first pixel.
3354
  * Format of image with 4 bits per pixel: each byte of image
3355
    excluding last bytes in rows (if width is odd) contains
3356
    information on the color of 2 pixels, high-order tetrad
3357
    corresponds to first pixel.
3358
  * Format of image with 8 bits per pixel: each byte of image is
3359
    index in the palette.
3360
  * Format of image with 15 bits per pixel: the color of each pixel
3361
    is coded as (bit representation) 0RRRRRGGGGGBBBBB - 5 bits per
3362
    each color.
3363
  * Format of image with 16 bits per pixel: the color of each pixel
3364
    is coded as RRRRRGGGGGGBBBBB (5+6+5).
3365
  * Format of image with 24 bits per pixel: the color of each pixel
3366
    is coded as 3 bytes - sequentially blue, green, red components.
3367
  * Format of image with 32 bits per pixel: similar to 24, but
3368
    one additional ignored byte is present.
314 diamond 3369
  * The call to function 7 is equivalent to call to this function
3370
    with esi=24, ebp=0.
283 diamond 3371
 
3372
======================================================================
118 diamond 3373
================== Function 66 - work with keyboard. =================
114 mikedld 3374
======================================================================
118 diamond 3375
The input mode influences results of reading keys by function 2.
3376
When a program loads, ASCII input mode is set for it.
114 mikedld 3377
 
118 diamond 3378
-------------- Subfunction 1 - set keyboard input mode. --------------
114 mikedld 3379
Parameters:
118 diamond 3380
  * eax = 66 - function number
3381
  * ebx = 1 - subfunction number
114 mikedld 3382
  * ecx = mode:
3383
    * 0 = normal (ASCII-characters)
3384
    * 1 = scancodes
3385
Returned value:
3386
  * function does not return value
3387
 
118 diamond 3388
-------------- Subfunction 2 - get keyboard input mode. --------------
114 mikedld 3389
Parameters:
118 diamond 3390
  * eax = 66 - function number
3391
  * ebx = 2 - subfunction number
114 mikedld 3392
Returned value:
3393
  * eax = current mode
3394
 
118 diamond 3395
------------ Subfunction 3 - get status of control keys. -------------
114 mikedld 3396
Parameters:
118 diamond 3397
  * eax = 66 - function number
3398
  * ebx = 3 - subfunction number
114 mikedld 3399
Returned value:
3400
  * eax = bit mask:
118 diamond 3401
  * bit 0 (mask 1): left Shift is pressed
3402
  * bit 1 (mask 2): right Shift is pressed
3403
  * bit 2 (mask 4): left Ctrl is pressed
3404
  * bit 3 (mask 8): right Ctrl is pressed
3405
  * bit 4 (mask 0x10): left Alt is pressed
3406
  * bit 5 (mask 0x20): right Alt is pressed
3407
  * bit 6 (mask 0x40): CapsLock is on
3408
  * bit 7 (mask 0x80): NumLock is on
3409
  * bit 8 (mask 0x100): ScrollLock is on
3410
  * other bits are cleared
114 mikedld 3411
 
118 diamond 3412
-------------- Subfunction 4 - set system-wide hotkey. ---------------
3413
When hotkey is pressed, the system notifies only those applications,
3414
which have installed it; the active application (which receives
3415
all normal input) does not receive such keys.
3416
The notification consists in sending event with the code 2.
3417
Reading hotkey is the same as reading normal key - by function 2.
114 mikedld 3418
Parameters:
118 diamond 3419
  * eax = 66 - function number
3420
  * ebx = 4 - subfunction number
3421
  * cl determines key scancode;
3422
    use cl=0 to give combinations such as Ctrl+Shift
3423
  * edx = 0xXYZ determines possible states of control keys:
3424
    * Z (low 4 bits) determines state of LShift and RShift:
3425
      * 0 = no key must be pressed;
3426
      * 1 = exactly one key must be pressed;
3427
      * 2 = both keys must be pressed;
3428
      * 3 = must be pressed LShift, but not RShift;
3429
      * 4 = must be pressed RShift, but not LShift
3430
    * Y - similar for LCtrl and RCtrl;
3431
    * X - similar for LAlt and RAlt
114 mikedld 3432
Returned value:
118 diamond 3433
  * eax=0 - success
3434
  * eax=1 - too mant hotkeys (maximum 256 are allowed)
114 mikedld 3435
Remarks:
118 diamond 3436
  * Hotkey can work either at pressing or at release. Release
3437
    scancode of a key is more on 128 than pressing scancode
3438
    (i.e. high bit is set).
3439
  * Several applications can set the same combination;
3440
    all such applications will be informed on pressing
3441
    such combination.
114 mikedld 3442
 
118 diamond 3443
-------------- Subfunction 5 - delete installed hotkey. --------------
114 mikedld 3444
Parameters:
118 diamond 3445
  * eax = 66 - function number
3446
  * ebx = 5 - subfunction number
3447
  * cl = scancode of key and edx = 0xXYZ the same as in subfunction 4
114 mikedld 3448
Returned value:
118 diamond 3449
  * eax = 0 - success
114 mikedld 3450
  * eax = 1 - there is no such hotkey
3451
Remarks:
118 diamond 3452
  * When a process/thread terminates, all hotkey installed by it are
3453
    deleted.
3454
  * The call to this subfunction does not affect other applications.
3455
    If other application has defined the same combination, it will
3456
    still receive notices.
114 mikedld 3457
 
3458
======================================================================
118 diamond 3459
========= Function 67 - change position/sizes of the window. =========
114 mikedld 3460
======================================================================
3461
Parameters:
118 diamond 3462
  * eax = 67 - function number
114 mikedld 3463
  * ebx = new x-coordinate of the window
3464
  * ecx = new y-coordinate of the window
3465
  * edx = new x-size of the window
3466
  * esi = new y-size of the window
3467
Returned value:
3468
  * function does not return value
3469
Remarks:
118 diamond 3470
  * The value -1 for a parameter means "do not change"; e.g. to move
3471
    the window without resizing it is possible to specify edx=esi=-1.
3472
  * Previously the window must be defined by function 0.
114 mikedld 3473
    It sets initial coordinates and sizes of the window.
118 diamond 3474
  * Sizes of the window are understood in sense of function 0,
3475
    that is one pixel less than real sizes.
3476
  * The function call for maximized windows is simply ignored.
3477
  * For windows of appropriate styles position and/or sizes can be
3478
    changed by user; current position and sizes can be obtained by
3479
    call to function 9.
3480
  * The function sends to the window redraw event (with the code 1).
114 mikedld 3481
 
3482
======================================================================
118 diamond 3483
====== Function 68, subfunction 0 - get the task switch counter. =====
114 mikedld 3484
======================================================================
3485
Parameters:
118 diamond 3486
  * eax = 68 - function number
3487
  * ebx = 0 - subfunction number
114 mikedld 3488
Returned value:
118 diamond 3489
  * eax = number of task switches from the system booting
3490
    (modulo 2^32)
114 mikedld 3491
 
3492
======================================================================
118 diamond 3493
======= Function 68, subfunction 1 - switch to the next thread. ======
114 mikedld 3494
======================================================================
118 diamond 3495
The function completes the current time slice allocated to the
3496
thread and switches to the next. (Which thread in which process
3497
will be next, is unpredictable). Later, when execution queue
3498
will reach the current thread, execution will be continued.
114 mikedld 3499
Parameters:
118 diamond 3500
  * eax = 68 - function number
3501
  * ebx = 1 - subfunction number
114 mikedld 3502
Returned value:
3503
  * function does not return value
3504
 
3505
======================================================================
118 diamond 3506
============= Function 68, subfunction 2 - cache + rdpmc. ============
114 mikedld 3507
======================================================================
3508
Parameters:
118 diamond 3509
  * eax = 68 - function number
3510
  * ebx = 2 - subfunction number
3511
  * ecx = required action:
3512
    * ecx = 0 - enable instruction 'rdpmc'
3513
      (ReaD Performance-Monitoring Counters) for applications
3514
    * ecx = 1 - find out whether cache is disabled/enabled
3515
    * ecx = 2 - enable cache
3516
    * ecx = 3 - disable cache
114 mikedld 3517
Returned value:
3518
  * for ecx=0:
118 diamond 3519
    * eax = the value of cr4
114 mikedld 3520
  * for ecx=1:
3521
    * eax = (cr0 and 0x60000000):
118 diamond 3522
    * eax = 0 - cache is on
3523
    * eax <> 0 - cache is off
114 mikedld 3524
  * for ecx=2 and ecx=3:
3525
    * function does not return value
3526
 
3527
======================================================================
3528
=========== Function 68, subfunction 3 - read MSR-register. ==========
3529
======================================================================
118 diamond 3530
MSR = Model Specific Register; the complete list of MSR-registers
3531
of a processor is included to the documentation on it (for example,
3532
IA-32 Intel Architecture Software Developer's Manual,
3533
Volume 3, Appendix B); each processor family has its own subset
3534
of the MSR-registers.
114 mikedld 3535
Parameters:
118 diamond 3536
  * eax = 68 - function number
3537
  * ebx = 3 - subfunction number
3538
  * ecx is ignored
3539
  * edx = MSR address
114 mikedld 3540
Returned value:
118 diamond 3541
  * ebx:eax = high:low dword of the result
114 mikedld 3542
Remarks:
118 diamond 3543
  * If ecx contains nonexistent or not implemented for this processor
3544
    MSR, processor will generate an exception in the kernel, which
3545
    will kill the thread.
3546
  * Previously it is necessary to check, whether MSRs are supported
3547
    as a whole, with the instruction 'cpuid'. Otherwise processor
3548
    will generate other exception in the kernel, which will anyway
3549
    kill the thread.
114 mikedld 3550
 
3551
======================================================================
118 diamond 3552
========= Function 68, subfunction 4 - write to MSR-register. ========
114 mikedld 3553
======================================================================
118 diamond 3554
MSR = Model Specific Register; the complete list of MSR-registers
3555
of a processor is included to the documentation on it (for example,
3556
IA-32 Intel Architecture Software Developer's Manual,
3557
Volume 3, Appendix B); each processor family has its own subset
3558
of the MSR-registers.
114 mikedld 3559
Parameters:
118 diamond 3560
  * eax = 68 - function number
3561
  * ebx = 4 - subfunction number
3562
  * ecx is ignored
3563
  * edx = MSR address
3564
  * esi:edi = high:low dword
114 mikedld 3565
Returned value:
499 diamond 3566
  * function does not return value
3567
Remarks:
118 diamond 3568
  * If ecx contains nonexistent or not implemented for this processor
3569
    MSR, processor will generate an exception in the kernel, which
3570
    will kill the thread.
3571
  * Previously it is necessary to check, whether MSRs are supported
3572
    as a whole, with the instruction 'cpuid'. Otherwise processor
3573
    will generate other exception in the kernel, which will anyway
3574
    kill the thread.
114 mikedld 3575
 
3576
======================================================================
193 diamond 3577
======= Function 68, subfunction 11 - initialize process heap. =======
114 mikedld 3578
======================================================================
3579
Parameters:
118 diamond 3580
  * eax = 68 - function number
193 diamond 3581
  * ebx = 11 - subfunction number
114 mikedld 3582
Returned value:
193 diamond 3583
  * eax = 0 - failed
3584
  * otherwise size of created heap
114 mikedld 3585
Remarks:
193 diamond 3586
  * The function call initializes heap, from which one can in future
3587
    allocate and free memory blocks with subfunctions 12 and 13.
3588
    Heap size is equal to total amount of free application memory.
3589
  * The second function call from the same process results in
3590
    returning the size of the existing heap.
3591
  * After creation of the heap calls to function 64 will be ignored.
114 mikedld 3592
 
3593
======================================================================
193 diamond 3594
======== Function 68, subfunction 12 - allocate memory block. ========
114 mikedld 3595
======================================================================
3596
Parameters:
118 diamond 3597
  * eax = 68 - function number
193 diamond 3598
  * ebx = 12 - subfunction number
3599
  * ecx = required size in bytes
114 mikedld 3600
Returned value:
193 diamond 3601
  * eax = pointer to the allocated block
114 mikedld 3602
Remarks:
193 diamond 3603
  * Before this call one must initialize process heap by call to
3604
    subfunction 11.
3605
  * The function allocates an integer number of pages (4 Kb) in such
3606
    way that the real size of allocated block is more than or equal to
3607
    requested size.
114 mikedld 3608
 
3609
======================================================================
193 diamond 3610
========== Function 68, subfunction 13 - free memory block. ==========
114 mikedld 3611
======================================================================
3612
Parameters:
118 diamond 3613
  * eax = 68 - function number
193 diamond 3614
  * ebx = 13 - subfunction number
3615
  * ecx = pointer to the memory block
114 mikedld 3616
Returned value:
193 diamond 3617
  * eax = 1 - success
3618
  * eax = 0 - failed
114 mikedld 3619
Remarks:
448 diamond 3620
  * The memory block must have been allocated by subfunction 12
3621
    or subfunction 20.
114 mikedld 3622
 
3623
======================================================================
1074 Galkov 3624
===================== Function 68, subfunction 14 ====================
3625
====== Waiting delivering of signal from another program/driver ======
114 mikedld 3626
======================================================================
3627
Parameters:
118 diamond 3628
  * eax = 68 - function number
193 diamond 3629
  * ebx = 14 - subfunction number
1074 Galkov 3630
  * ecx = pointer to the buffer for information (24 bytes)
114 mikedld 3631
Returned value:
193 diamond 3632
  * buffer pointed to by ecx contains the following information:
1074 Galkov 3633
    * +0: dword: identifier for underlying data of signal
3634
    * +4: data of signal (20 bytes), format of which is defining by
3635
          first dword
114 mikedld 3636
 
3637
======================================================================
1077 Galkov 3638
====== Function 68, subfunction 15 - set FPU exception handler. ======
193 diamond 3639
======================================================================
1077 Galkov 3640
Deleted (in current implementation only 0 is returned).
3641
Using subfunctions 24, 25 is true.
193 diamond 3642
 
3643
======================================================================
3644
============= Function 68, subfunction 16 - load driver. =============
3645
======================================================================
3646
Parameters:
3647
  * eax = 68 - function number
3648
  * ebx = 16 - subfunction number
3649
  * ecx = pointer to ASCIIZ-string with driver name
3650
Returned value:
3651
  * eax = 0 - failed
3652
  * otherwise eax = driver handle
3653
Remarks:
3654
  * If the driver was not loaded yet, it is loaded;
3655
    if the driver was loaded yet, nothing happens.
3656
  * Driver name is case-sensitive.
3657
    Maximum length of the name is 16 characters, including
3658
    terminating null character, the rest is ignored.
346 diamond 3659
  * Driver ABC is loaded from file /rd/1/drivers/ABC.obj.
193 diamond 3660
 
3661
======================================================================
3662
============ Function 68, subfunction 17 - driver control. ===========
3663
======================================================================
3664
Parameters:
3665
  * eax = 68 - function number
3666
  * ebx = 17 - subfunction number
3667
  * ecx = pointer to the control structure:
3668
    * +0: dword: handle of driver
3669
    * +4: dword: code of driver function
3670
    * +8: dword: pointer to input data
3671
    * +12 = +0xC: dword: size of input data
3672
    * +16 = +0x10: dword: pointer to output data
3673
    * +20 = +0x14: dword: size of output data
3674
Returned value:
1213 serge 3675
  * eax =  error code
3676
 
3677
     -1  - any error.
3678
     -2, -3, -4, etc. reserved for kernel error codes
3679
      1, 2, 3, etc    driver specific error codes
193 diamond 3680
Remarks:
3681
  * Function codes and the structure of input/output data
3682
    are defined by driver.
3683
  * Previously one must obtain driver handle by subfunction 16.
3684
 
3685
======================================================================
1077 Galkov 3686
====== Function 68, subfunction 18 - set SSE exception handler. ======
193 diamond 3687
======================================================================
1077 Galkov 3688
Deleted (in current implementation only 0 is returned).
3689
Using subfunctions 24, 25 is true.
193 diamond 3690
 
3691
======================================================================
277 diamond 3692
=============== Function 68, subfunction 19 - load DLL. ==============
3693
======================================================================
3694
Parameters:
3695
  * eax = 68 - function number
3696
  * ebx = 19 - subfunction number
3697
  * ecx = pointer to ASCIIZ-string with the full path to DLL
3698
Returned value:
3699
  * eax = 0 - failed
3700
  * otherwise eax = pointer to DLL export table
3701
Remarks:
3702
  * Export table is an array of structures of 2 dword's, terminated
3703
    by zero. The first dword in structure points to function name,
3704
    the second dword contains address of function.
3705
 
3706
======================================================================
448 diamond 3707
======= Function 68, subfunction 20 - reallocate memory block. =======
3708
======================================================================
3709
Parameters:
3710
  * eax = 68 - function number
3711
  * ebx = 20 - subfunction number
3712
  * ecx = new size in bytes
3713
  * edx = pointer to already allocated block
3714
Returned value:
3715
  * eax = pointer to the reallocated block, 0 = error
3716
Remarks:
3717
  * Before this call one must initialize process heap by call to
3718
    subfunction 11.
3719
  * The function allocates an integer number of pages (4 Kb) in such
3720
    way that the real size of allocated block is more than or equal to
3721
    requested size.
3722
  * If edx=0, the function call is equivalent to memory allocation
3723
    with subfunction 12. Otherwise the block at edx
3724
    must be allocated earlier with subfunction 12 or this subfunction.
3725
  * If ecx=0, the function frees memory block at edx and returns 0.
3726
  * The contents of the block are unchanged up to the shorter of
3727
    the new and old sizes.
1689 art_zh 3728
======================================================================
3729
======== Function 68, subfunction 22 - open named memory area. =======
3730
======================================================================
3731
Parameters:
3732
  * eax = 68 - function number
3733
  * ebx = 22 - subfunction number
3734
  * ecx = area name. Maximum of 31 characters with terminating zero
3735
  * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS
3736
  * esi = flags for open and access:
3737
    * SHM_OPEN        = 0x00 - open existing memory area. If an area
3738
                          with such name does not exist, the function
3739
                          will return error code 5.
3740
    * SHM_OPEN_ALWAYS = 0x04 - open existing or create new
3741
                          memory area.
3742
    * SHM_CREATE      = 0x08 - create new memory area. If an area
3743
                          with such name already exists, the function
3744
                          will return error code 10.
3745
    * SHM_READ        = 0x00 - only read access
3746
    * SHM_WRITE       = 0x01 - read and write access
3747
Returned value:
3748
  * eax = pointer to memory area, 0 if error has occured
3749
  * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS):
3750
    edx = 0 - success, otherwise - error code
3751
  * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS):
3752
    edx = error code (if eax=0) or area size in bytes
3753
Error codes:
3754
  * E_NOTFOUND = 5
3755
  * E_ACCESS = 10
3756
  * E_NOMEM = 30
3757
  * E_PARAM = 33
3758
Remarks:
3759
  * Before this call one must initialize process heap by call to
3760
    subfunction 11.
3761
  * If a new area is created, access flags set maximal rights
3762
    for other processes. An attempt from other process to open
3763
    with denied rights will fail with error code E_ACCESS.
3764
  * The process which has created an area always has write access.
448 diamond 3765
 
3766
======================================================================
1689 art_zh 3767
======= Function 68, subfunction 23 - close named memory area. =======
3768
======================================================================
3769
Parameters:
3770
  * eax = 68 - function number
3771
  * ebx = 23 - subfunction number
3772
  * ecx = area name. Maximum of 31 characters with terminating zero
3773
Returned value:
3774
  * eax destroyed
3775
Remarks:
3776
  * A memory area is physically freed (with deleting all data and
3777
    freeing physical memory), when all threads which have opened
3778
    this area will close it.
3779
  * When thread is terminating, all opened by it areas are closed.
3780
 
3781
======================================================================
1077 Galkov 3782
====== Function 68, subfunction 24 - set new exceptions handler ======
3783
======================================================================
3784
Parameters:
3785
  * eax = 68 - function number
3786
  * ebx = 24 - subfunction number
3787
  * ecx = address of the new exception handler
3788
  * edx = the mask of processing exceptions
3789
Returned value:
3790
  * eax = address of the old exception handler (0, if it was not set)
3791
  * ebx = the old mask of exception handler
3792
Remarks:
3793
  * Bit number in mask of exceptions is correspond to exception number
3794
    by CPU-specification (Intel-PC). For example, FPU-exception have
3795
    number 16 (#MF), and SSE-exception - 19 (#XF)
3796
  * The current implementation ignore the inquiry for hook of 7
3797
    exception - system process #NM by one's own.
3798
  * User handler get exception number in stack parameter. So, correct
3799
    exit from handler is: RET 4. Return from handler is to the same
3800
    instruction, that was cause the exception
3801
  * When control is transfering to user handler, corresponding bit in
3802
    exception mask is clearing. Rising this exception in consequence
3803
    - reduce to default-handling. Exactly: terminating the application,
3804
    or suspending with debug-notify to owner.
3805
  * After completion of critical operations in user handler, it may be
1078 Galkov 3806
    rising corresponding bit in exception mask by using subfunction 25
1077 Galkov 3807
    Clearing exceptions flags in FPU and/or XMM modules - is
3808
    responsibility of user handler too.
3809
 
3810
======================================================================
3811
==== Function 68, subfunction 25 - change state of signal activity ===
3812
======================================================================
3813
Parameters:
3814
  * eax = 68 - function number
3815
  * ebx = 25 - subfunction number
3816
  * ecx = signal number
3817
  * edx = value of activity (0/1)
3818
Returned value:
3819
  * eax = value of old activity for this signal (0/1)
1689 art_zh 3820
  * eax = -1 - invalid signal number
1077 Galkov 3821
Remarks:
3822
  * In current implementation, it is changed only exception mask for
1078 Galkov 3823
    user exception handler, wich was previously set by subfunction 24.
1077 Galkov 3824
    At that, number of signal correspond to exception number.
3825
 
3826
======================================================================
118 diamond 3827
====================== Fucntion 69 - debugging. ======================
114 mikedld 3828
======================================================================
118 diamond 3829
A process can load other process as debugged by set of corresponding
193 diamond 3830
bit by call to subfunction 7 of function 70.
118 diamond 3831
A process can have only one debugger; one process can debug some
3832
others. The system notifies debugger on events occuring with
3833
debugged process. Messages are written to the buffer defined by
114 mikedld 3834
subfunction 0.
118 diamond 3835
Format of a message:
3836
  * +0: dword: message code
3837
  * +4: dword: PID of debugged process
3838
  * +8: there can be additional data depending on message code
3839
Message codes:
114 mikedld 3840
  * 1 = exception
118 diamond 3841
    * in addition dword-number of the exception is given
3842
    * process is suspended
3843
  * 2 = process has terminated
3844
    * comes at any termination: both through the system function -1,
3845
      and at "murder" by any other process (including debugger itself)
114 mikedld 3846
  * 3 = debug exception int 1 = #DB
118 diamond 3847
    * in addition dword-image of the register DR6 is given:
3848
      * bits 0-3: condition of the corresponding breakpoint (set by
3849
        subfunction 9) is satisfied
3850
      * бит 14: exception has occured because of the trace mode
3851
        (flag TF is set TF)
3852
    * process is suspended
3853
When debugger terminates, all debugged processes are killed.
3854
If debugger does not want this, it must previously detach by
114 mikedld 3855
subfunction 3.
3856
 
1018 diamond 3857
All subfunctions are applicable only to processes/threads started
3858
from the current by function 70 with set debugging flag.
118 diamond 3859
Debugging of multithreaded programs is not supported yet.
3860
The full list of subfunctions:
3861
  * subfunction 0 - define data area for debug messages
3862
  * subfunction 1 - get contents of registers of debugged thread
3863
  * subfunction 2 - set contents of registers of debugged thread
3864
  * subfunction 3 - detach from debugged process
3865
  * subfunction 4 - suspend debugged thread
3866
  * subfunction 5 - resume debugged thread
3867
  * subfunction 6 - read from the memory of debugged process
3868
  * subfunction 7 - write to the memory of debugged process
3869
  * subfunction 8 - terminate debugged thread
3870
  * subfunction 9 - set/clear hardware breakpoint
114 mikedld 3871
 
3872
======================================================================
118 diamond 3873
= Function 69, subfunction 0 - define data area fror debug messages. =
114 mikedld 3874
======================================================================
3875
Parameters:
118 diamond 3876
  * eax = 69 - function number
3877
  * ebx = 0 - subfunction number
114 mikedld 3878
  * ecx = pointer
3879
Format of data area:
118 diamond 3880
  * +0: dword: N = buffer size (not including this header)
3881
  * +4: dword: occupied place
114 mikedld 3882
  * +8: N*byte: buffer
3883
Returned value:
3884
  * function does not return value
3885
Remarks:
118 diamond 3886
  * If the size field is negative, the buffer is considered locked
3887
    and at arrival of new message the system will wait.
3888
    For synchronization frame all work with the buffer by operations
3889
    lock/unlock
1074 Galkov 3890
        neg     [bufsize]
118 diamond 3891
  * Data in the buffer are considered as array of items with variable
3892
    length - messages. Format of a message is explained in
3893
    general description.
114 mikedld 3894
 
3895
======================================================================
118 diamond 3896
===================== Function 69, subfunction 1 =====================
3897
============ Get contents of registers of debugged thread. ===========
114 mikedld 3898
======================================================================
3899
Parameters:
118 diamond 3900
  * eax = 69 - function number
3901
  * ebx = 1 - subfunction number
114 mikedld 3902
  * ecx = thread identifier
118 diamond 3903
  * edx = size of context structure, must be 0x28=40 bytes
3904
  * esi = pointer to context structure
114 mikedld 3905
Returned value:
3906
  * function does not return value
118 diamond 3907
Format of context structure: (FPU is not supported yet)
114 mikedld 3908
  * +0: dword: eip
3909
  * +4: dword: eflags
3910
  * +8: dword: eax
3911
  * +12 = +0xC: dword: ecx
3912
  * +16 = +0x10: dword: edx
3913
  * +20 = +0x14: dword: ebx
3914
  * +24 = +0x18: dword: esp
3915
  * +28 = +0x1C: dword: ebp
3916
  * +32 = +0x20: dword: esi
3917
  * +36 = +0x24: dword: edi
3918
Remarks:
118 diamond 3919
  * If the thread executes code of ring-0, the function returns
3920
    contents of registers of ring-3.
3921
  * Process must be loaded for debugging (as is shown in
3922
    general description).
114 mikedld 3923
 
3924
======================================================================
118 diamond 3925
===================== Function 69, subfunction 2 =====================
3926
============ Set contents of registers of debugged thread. ===========
114 mikedld 3927
======================================================================
3928
Parameters:
118 diamond 3929
  * eax = 69 - function number
3930
  * ebx = 2 - subfunction number
114 mikedld 3931
  * ecx = thread identifier
118 diamond 3932
  * edx = size of context structure, must be 0x28=40 bytes
114 mikedld 3933
Returned value:
3934
  * function does not return value
118 diamond 3935
Format of context structure is shown in the description of
3936
subfunction 1.
114 mikedld 3937
Remarks:
118 diamond 3938
  * If the thread executes code of ring-0, the function returns
3939
    contents of registers of ring-3.
3940
  * Process must be loaded for debugging (as is shown in
3941
    general description).
114 mikedld 3942
 
3943
======================================================================
118 diamond 3944
===== Function 69, subfunction 3 - detach from debugged process. =====
114 mikedld 3945
======================================================================
3946
Parameters:
118 diamond 3947
  * eax = 69 - function number
3948
  * ebx = 3 - subfunction number
114 mikedld 3949
  * ecx = identifier
3950
Returned value:
3951
  * function does not return value
3952
Remarks:
118 diamond 3953
  * If the process was suspended, it resumes execution.
114 mikedld 3954
 
3955
======================================================================
1018 diamond 3956
======== Function 69, subfunction 4 - suspend debugged thread. =======
114 mikedld 3957
======================================================================
3958
Parameters:
118 diamond 3959
  * eax = 69 - function number
3960
  * ebx = 4 - subfunction number
3961
  * ecx = thread identifier
114 mikedld 3962
Returned value:
3963
  * function does not return value
1018 diamond 3964
Remarks:
3965
  * Process must be loaded for debugging (as is shown in
3966
    general description).
114 mikedld 3967
 
3968
======================================================================
1018 diamond 3969
======== Function 69, subfunction 5 - resume debugged thread. ========
114 mikedld 3970
======================================================================
3971
Parameters:
118 diamond 3972
  * eax = 69 - function number
3973
  * ebx = 5 - subfunction number
3974
  * ecx = thread identifier
114 mikedld 3975
Returned value:
3976
  * function does not return value
1018 diamond 3977
Remarks:
3978
  * Process must be loaded for debugging (as is shown in
3979
    general description).
114 mikedld 3980
 
3981
======================================================================
118 diamond 3982
= Fucntion 69, subfunction 6 - read from memory of debugged process. =
114 mikedld 3983
======================================================================
3984
Parameters:
118 diamond 3985
  * eax = 69 - function number
3986
  * ebx = 6 - subfunction number
114 mikedld 3987
  * ecx = identifier
118 diamond 3988
  * edx = number of bytes to read
3989
  * esi = address in the memory of debugged process
3990
  * edi = pointer to buffer for data
114 mikedld 3991
Returned value:
118 diamond 3992
  * eax = -1 at an error (invalid PID or buffer)
3993
  * otherwise eax = number of read bytes (possibly, 0,
3994
    if esi is too large)
114 mikedld 3995
Remarks:
118 diamond 3996
  * Process must be loaded for debugging (as is shown in
3997
    general description).
114 mikedld 3998
 
3999
======================================================================
118 diamond 4000
== Function 69, subfunction 7 - write to memory of debugged process. =
114 mikedld 4001
======================================================================
4002
Parameters:
118 diamond 4003
  * eax = 69 - function number
4004
  * ebx = 7 - subfunction number
114 mikedld 4005
  * ecx = identifier
118 diamond 4006
  * edx = number of bytes to write
4007
  * esi = address of memory in debugged process
4008
  * edi = pointer to data
114 mikedld 4009
Returned value:
118 diamond 4010
  * eax = -1 at an error (invalid PID or buffer)
4011
  * otherwise eax = number of written bytes (possibly, 0,
4012
    if esi is too large)
114 mikedld 4013
Remarks:
118 diamond 4014
  * Process must be loaded for debugging (as is shown in
4015
    general description).
114 mikedld 4016
 
4017
======================================================================
118 diamond 4018
======= Function 69, subfunction 8 - terminate debugged thread. ======
114 mikedld 4019
======================================================================
4020
Parameters:
118 diamond 4021
  * eax = 69 - function number
4022
  * ebx = 8 - subfunction number
114 mikedld 4023
  * ecx = identifier
4024
Returned value:
4025
  * function does not return value
4026
Remarks:
118 diamond 4027
  * Process must be loaded for debugging (as is shown in
4028
    general description).
4029
  * The function is similar to subfunction 2 of function 18
4030
    with two differences: it requires first remark and
4031
    accepts PID rather than slot number.
114 mikedld 4032
 
4033
======================================================================
118 diamond 4034
===== Function 69, subfunction 9 - set/clear hardware breakpoint. ====
114 mikedld 4035
======================================================================
4036
Parameters:
118 diamond 4037
  * eax = 69 - function number
4038
  * ebx = 9 - subfunction number
114 mikedld 4039
  * ecx = thread identifier
118 diamond 4040
  * dl = index of breakpoint, from 0 to 3 inclusively
114 mikedld 4041
  * dh = flags:
118 diamond 4042
    * if high bit is cleared - set breakpoint:
114 mikedld 4043
      * bits 0-1 - condition:
4044
        * 00 = breakpoint on execution
118 diamond 4045
        * 01 = breakpoint on read
4046
        * 11 = breakpoint on read/write
4047
      * bits 2-3 - length; for breakpoints on exception it must be
4048
        00, otherwise one of
4049
        * 00 = byte
114 mikedld 4050
        * 01 = word
118 diamond 4051
        * 11 = dword
4052
      * esi = breakpoint address; must be aligned according to
4053
        the length (i.e. must be even for word breakpoints,
4054
        divisible by 4 for dword)
4055
    * if high bit is set - clear breakpoint
114 mikedld 4056
Returned value:
118 diamond 4057
  * eax = 0 - success
114 mikedld 4058
  * eax = 1 - error in the input data
118 diamond 4059
  * eax = 2 - (reserved, is never returned in the current
4060
    implementation) a global breakpoint with that index is already set
114 mikedld 4061
Remarks:
118 diamond 4062
  * Process must be loaded for debugging (as is shown in
4063
    general description).
4064
  * Hardware breakpoints are implemented through DRx-registers of
4065
    the processor, all limitations results from this.
4066
  * The function can reinstall the breakpoint, previously set
4067
    by it (and it does not inform on this).
4068
    Carry on the list of set breakpoints in the debugger.
4069
  * Breakpoints generate debug exception #DB, on which the system
4070
    notifies debugger.
4071
  * Breakpoints on write and read/write act after
4072
    execution of the caused it instruction.
114 mikedld 4073
 
4074
======================================================================
118 diamond 4075
==== Function 70 - work with file system with long names support. ====
114 mikedld 4076
======================================================================
4077
Parameters:
4078
  * eax = 70
118 diamond 4079
  * ebx = pointer to the information structure
114 mikedld 4080
Returned value:
118 diamond 4081
  * eax = 0 - success; otherwise file system error code
4082
  * some subfunctions return value in other registers too
4083
General format of the information structure:
4084
  * +0: dword: subfunction number
4085
  * +4: dword: file offset
4086
  * +8: dword: high dword of offset (must be 0) or flags field
114 mikedld 4087
  * +12 = +0xC: dword: size
118 diamond 4088
  * +16 = +0x10: dword: pointer to data
4089
  * +20 = +0x14: n db: ASCIIZ-string with the filename
114 mikedld 4090
    or
4091
  * +20 = +0x14: db 0
118 diamond 4092
  * +21 = +0x15: dd pointer to ASCIIZ-string with the filename
4093
Specifications - in documentation on the appropriate subfunction.
4094
Filename is case-insensitive. Russian letters must be written in
4095
the encoding cp866 (DOS).
4096
Format of filename:
114 mikedld 4097
/base/number/dir1/dir2/.../dirn/file,
118 diamond 4098
where /base/number identifies device, on which file is located:
114 mikedld 4099
one of
118 diamond 4100
  * /RD/1 = /RAMDISK/1 to access ramdisk
4101
  * /FD/1 = /FLOPPYDISK/1 to access first floppy drive,
4102
    /FD/2 = /FLOPPYDISK/2 to access second one
4103
  * /HD0/x, /HD1/x, /HD2/x, /HD3/x to access accordingly to devices
4104
    IDE0 (Primary Master), IDE1 (Primary Slave),
114 mikedld 4105
    IDE2 (Secondary Master), IDE3 (Secondary Slave);
118 diamond 4106
    x - partition number on the selected hard drive, varies from 1
4107
    to 255 (on each hard drive the indexing starts from 1)
4108
  * /CD0/1, /CD1/1, /CD2/1, /CD3/1 to access accordingly to
4109
    CD on IDE0 (Primary Master), IDE1 (Primary Slave),
4110
    IDE2 (Secondary Master), IDE3 (Secondary Slave)
546 diamond 4111
  * /SYS means system folder; with the usual boot (from floppy)
4112
    is equivalent to /RD/1
114 mikedld 4113
Examples:
4114
  * '/rd/1/kernel.asm',0
4115
  * '/HD0/1/kernel.asm',0
4116
  * '/hd0/2/menuet/pics/tanzania.bmp',0
4117
  * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
546 diamond 4118
  * '/sys/MySuperApp.ini',0
1689 art_zh 4119
Also function supports relative names.  If the path begins not
4120
with '/', it is considered relative to a current folder. To get or
4121
set a current folder, use the function 30.
4122
 
118 diamond 4123
Available subfunctions:
114 mikedld 4124
  * subfunction 0 - read file
4125
  * subfunction 1 - read folder
4126
  * subfunction 2 - create/rewrite file
131 diamond 4127
  * subfunction 3 - write to existing file
133 diamond 4128
  * subfunction 4 - set file size
118 diamond 4129
  * subfunction 5 - get attributes of file/folder
4130
  * subfunction 6 - set attributes of file/folder
114 mikedld 4131
  * subfunction 7 - start application
193 diamond 4132
  * subfunction 8 - delete file/folder
321 diamond 4133
  * subfunction 9 - create folder
118 diamond 4134
For CD-drives due to hardware limitations only subfunctions
4135
0,1,5 and 7 are available, other subfunctions return error
4136
with code 2.
641 diamond 4137
At the first call of subfunctions 0,1,5,7 to ATAPI devices
4138
(CD and DVD) the manual control of tray is locked due to caching
4139
drive data. Unlocking is made when subfunction 4 of function 24
4140
is called for corresponding device.
114 mikedld 4141
 
4142
======================================================================
118 diamond 4143
=== Function 70, subfunction 0 - read file with long names support. ==
114 mikedld 4144
======================================================================
4145
Parameters:
118 diamond 4146
  * eax = 70 - function number
4147
  * ebx = pointer to the information structure
4148
Format of the information structure:
4149
  * +0: dword: 0 = subfunction number
4150
  * +4: dword: file offset (in bytes)
4151
  * +8: dword: 0 (reserved for high dword of offset)
4152
  * +12 = +0xC: dword: number of bytes to read
4153
  * +16 = +0x10: dword: pointer to buffer for data
4154
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4155
    given in the general description
114 mikedld 4156
    or
4157
  * +20 = +0x14: db 0
118 diamond 4158
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4159
Returned value:
118 diamond 4160
  * eax = 0 - success, otherwise file system error code
4161
  * ebx = number of read bytes or -1=0xffffffff if file was not found
114 mikedld 4162
Remarks:
118 diamond 4163
  * If file was ended before last requested block was read,
4164
    the function will read as many as it can, and after that return
4165
    eax=6 (EOF).
4166
  * The function does not allow to read folder (returns eax=10,
4167
    access denied).
114 mikedld 4168
 
118 diamond 4169
======================================================================
4170
== Function 70, subfunction 1 - read folder with long names support. =
4171
======================================================================
114 mikedld 4172
Parameters:
118 diamond 4173
  * eax = 70 - function number
4174
  * ebx = pointer to the information structure
4175
Format of the information structure:
4176
  * +0: dword: 1 = subfunction number
4177
  * +4: dword: index of starting block (beginning from 0)
4178
  * +8: dword: flags field:
114 mikedld 4179
    * bit 0 (mask 1): in what format to return names,
4180
      0=ANSI, 1=UNICODE
118 diamond 4181
    * other bits are reserved and must be set to 0 for the future
4182
      compatibility
4183
  * +12 = +0xC: dword: number of blocks to read
4184
  * +16 = +0x10: dword: pointer to buffer for data, buffer size
4185
    must be not less than 32 + [+12]*560 bytes
4186
  * +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
4187
    given in the general description
114 mikedld 4188
    or
4189
  * +20 = +0x14: db 0
118 diamond 4190
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4191
Returned value:
118 diamond 4192
  * eax = 0 - success, otherwise file system error code
4193
  * ebx = number of files, information on which was written to
4194
    the buffer, or -1=0xffffffff, if folder was not found
114 mikedld 4195
Structure of the buffer:
4196
  * +0: 32*byte: header
4197
  * +32 = +0x20: n1*byte: block with information on file 1
118 diamond 4198
  * +32+n1: n2*byte: block with information on file 2
114 mikedld 4199
  * ...
4200
Structure of header:
118 diamond 4201
  * +0: dword: version of structure (current is 1)
4202
  * +4: dword: number of placed blocks; is not greater than requested
4203
    in the field +12 of information structure; can be less, if
4204
    there are no more files in folder (the same as in ebx)
4205
  * +8: dword: total number of files in folder
4206
  * +12 = +0xC: 20*byte: reserved (zeroed)
4207
Structure of block of data for folder entry (BDFE):
4208
  * +0: dword: attributes of file:
4209
    * bit 0 (mask 1): file is read-only
4210
    * bit 1 (mask 2): file is hidden
4211
    * bit 2 (mask 4): file is system
4212
    * bit 3 (mask 8): this is not a file but volume label
4213
      (for one partition meets no more than once and
4214
      only in root folder)
4215
    * bit 4 (mask 0x10): this is a folder
4216
    * bit 5 (mask 0x20): file was not archived - many archivation
4217
      programs have an option to archive only files with this bit set,
4218
      and after archiving this bit is cleared - it can be useful
4219
      for automatically creating of backup-archives as at writing
4220
      this bit is usually set
4221
  * +4: byte: type of name data:
4222
    (coincides with bit 0 of flags in the information structure)
4223
    * 0 = ASCII = 1-byte representation of each character
4224
    * 1 = UNICODE = 2-byte representation of each character
114 mikedld 4225
  * +5: 3*byte: reserved (zero)
118 diamond 4226
  * +8: 4*byte: time of file creation
4227
  * +12 = +0xC: 4*byte: date of file creation
4228
  * +16 = +0x10: 4*byte: time of last access (read or write)
114 mikedld 4229
  * +20 = +0x14: 4*byte: date of last access
118 diamond 4230
  * +24 = +0x18: 4*byte: time of last modification
4231
  * +28 = +0x1C: 4*byte: date of last modification
4232
  * +32 = +0x20: qword: file size in bytes (up to 16777216 Tb)
114 mikedld 4233
  * +40 = +0x28: name
118 diamond 4234
    * for ASCII format: maximum length is 263 characters
4235
      (263 bytes), byte after the name has value 0
321 diamond 4236
    * for UNICODE format: maximum length is 259 characters
118 diamond 4237
      (518 bytes), 2 bytes after the name have value 0
4238
Time format:
114 mikedld 4239
  * +0: byte: seconds
4240
  * +1: byte: minutes
4241
  * +2: byte: hours
4242
  * +3: byte: reserved (0)
118 diamond 4243
  * for example, 23.59.59 is written as (in hex) 3B 3B 17 00
4244
Date format:
4245
  * +0: byte: day
4246
  * +1: byte: month
4247
  * +2: word: year
4248
  * for example, 25.11.1979 is written as (in hex) 19 0B BB 07
114 mikedld 4249
Remarks:
118 diamond 4250
  * If BDFE contains ASCII name, the length of BDFE is 304 bytes,
4251
    if UNICODE name - 560 bytes. Value of length is aligned
4252
    on 16-byte bound (to accelerate processing in CPU cache).
4253
  * First character after a name is zero (ASCIIZ-string). The further
4254
    data contain garbage.
4255
  * If files in folder were ended before requested number was read,
4256
    the function will read as many as it can, and after that return
4257
    eax=6 (EOF).
114 mikedld 4258
  * Any folder on the disk, except for root, contains two special
118 diamond 4259
    entries "." and "..", identifying accordingly the folder itself
4260
    and the parent folder.
4261
  * The function allows also to read virtual folders "/", "/rd",
4262
    "/fd", "/hd[n]", thus attributes of subfolders are set to 0x10,
4263
    and times and dates are zeroed. An alternative way to get the
4264
    equipment information - subfunction 11 of function 18.
114 mikedld 4265
 
4266
======================================================================
118 diamond 4267
===================== Function 70, subfunction 2 =====================
4268
============ Create/rewrite file with long names support. ============
114 mikedld 4269
======================================================================
4270
Parameters:
118 diamond 4271
  * eax = 70 - function number
4272
  * ebx = pointer to the information structure
4273
Format of the information structure:
4274
  * +0: dword: 2 = subfunction number
114 mikedld 4275
  * +4: dword: 0 (reserved)
4276
  * +8: dword: 0 (reserved)
118 diamond 4277
  * +12 = +0xC: dword: number of bytes to read
4278
  * +16 = +0x10: dword: pointer to data
4279
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4280
    given in the general description
114 mikedld 4281
    or
4282
  * +20 = +0x14: db 0
118 diamond 4283
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4284
Returned value:
118 diamond 4285
  * eax = 0 - success, otherwise file system error code
4286
  * ebx = number of written bytes (possibly 0)
114 mikedld 4287
Remarks:
118 diamond 4288
  * If a file with given name did not exist, it is created;
4289
    if it existed, it is rewritten.
4290
  * If there is not enough free space on disk, the function will
4291
    write as many as can and then return error code 8.
4292
  * The function is not supported for CD (returns error code 2).
114 mikedld 4293
 
4294
======================================================================
131 diamond 4295
===================== Function 70, subfunction 3 =====================
4296
=========== Write to existing file with long names support. ==========
4297
======================================================================
4298
Parameters:
4299
  * eax = 70 - function number
4300
  * ebx = pointer to the information structure
4301
Format of the information structure:
4302
  * +0: dword: 3 = subfunction number
4303
  * +4: dword: file offset (in bytes)
4304
  * +8: dword: high dword of offset (must be 0 for FAT)
4305
  * +12 = +0xC: dword: number of bytes to write
4306
  * +16 = +0x10: dword: pointer to data
4307
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4308
    given in the general description
4309
    or
4310
  * +20 = +0x14: db 0
4311
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
4312
Returned value:
4313
  * eax = 0 - success, otherwise file system error code
4314
  * ebx = number of written bytes (possibly 0)
4315
Remarks:
4316
  * The file must already exist, otherwise function returns eax=5.
4317
  * The only result of write 0 bytes is update in the file attributes
4318
    date/time of modification and access to the current date/time.
4319
  * If beginning and/or ending position is greater than file size
4320
    (except for the previous case), the file is expanded to needed
4321
    size with zero characters.
133 diamond 4322
  * The function is not supported for CD (returns error code 2).
131 diamond 4323
 
4324
======================================================================
133 diamond 4325
============ Function 70, subfunction 4 - set end of file. ===========
4326
======================================================================
4327
Parameters:
4328
  * eax = 70 - function number
4329
  * ebx = pointer to the information structure
4330
Format of the information structure:
4331
  * +0: dword: 4 = subfunction number
4332
  * +4: dword: low dword of new file size
4333
  * +8: dword: high dword of new file size (must be 0 for FAT)
4334
  * +12 = +0xC: dword: 0 (reserved)
4335
  * +16 = +0x10: dword: 0 (reserved)
4336
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4337
    given in the general description
4338
    or
4339
  * +20 = +0x14: db 0
4340
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
4341
Returned value:
4342
  * eax = 0 - success, otherwise file system error code
4343
  * ebx destroyed
4344
Remarks:
4345
  * If the new file size is less than old one, file is truncated.
4346
    If the new size is greater than old one, file is expanded with
4347
    characters with code 0. If the new size is equal to old one,
4348
    the only result of call is set date/time of modification and
4349
    access to the current date/time.
4350
  * If there is not enough free space on disk for expansion, the
4351
    function will expand to maximum possible size and then return
4352
    error code 8.
4353
  * The function is not supported for CD (returns error code 2).
4354
 
4355
======================================================================
118 diamond 4356
==== Function 70, subfunction 5 - get information on file/folder. ====
114 mikedld 4357
======================================================================
4358
Parameters:
118 diamond 4359
  * eax = 70 - function number
4360
  * ebx = pointer to the information structure
4361
Format of the information structure:
4362
  * +0: dword: 5 = subfunction number
114 mikedld 4363
  * +4: dword: 0 (reserved)
4364
  * +8: dword: 0 (reserved)
4365
  * +12 = +0xC: dword: 0 (reserved)
118 diamond 4366
  * +16 = +0x10: dword: pointer to buffer for data (40 bytes)
4367
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4368
    given in the general description
114 mikedld 4369
    or
4370
  * +20 = +0x14: db 0
118 diamond 4371
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4372
Returned value:
118 diamond 4373
  * eax = 0 - success, otherwise file system error code
4374
  * ebx destroyed
4375
Information on file is returned in the BDFE format (block of data
4376
for folder entry), explained in the description of
4377
subfunction 1, but without filename
4378
(i.e. only first 40 = 0x28 bytes).
114 mikedld 4379
Remarks:
118 diamond 4380
  * The function does not support virtual folders such as /, /rd and
4381
    root folders like /rd/1.
114 mikedld 4382
 
4383
======================================================================
118 diamond 4384
===== Function 70, subfunction 6 - set attributes of file/folder. ====
114 mikedld 4385
======================================================================
4386
Parameters:
118 diamond 4387
  * eax = 70 - function number
4388
  * ebx = pointer to the information structure
4389
Format of the information structure:
4390
  * +0: dword: 6 = subfunction number
114 mikedld 4391
  * +4: dword: 0 (reserved)
4392
  * +8: dword: 0 (reserved)
4393
  * +12 = +0xC: dword: 0 (reserved)
118 diamond 4394
  * +16 = +0x10: dword: pointer to buffer with attributes (32 bytes)
4395
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4396
    given in the general description
114 mikedld 4397
    or
4398
  * +20 = +0x14: db 0
118 diamond 4399
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4400
Returned value:
118 diamond 4401
  * eax = 0 - success, otherwise file system error code
4402
  * ebx destroyed
4403
File attributes are first 32 bytes in BDFE (block of data
4404
for folder entry), explained in the description of subfunction 1
4405
(that is, without name and size of file). Attribute
4406
file/folder/volume label (bits 3,4 in dword +0) is not changed.
4407
Byte +4 (name format) is ignored.
114 mikedld 4408
Remarks:
118 diamond 4409
  * The function does not support virtual folders such as /, /rd and
4410
    root folders like /rd/1.
4411
  * The function is not supported for CD (returns error code 2).
114 mikedld 4412
 
4413
======================================================================
118 diamond 4414
=========== Function 70, subfunction 7 - start application. ==========
114 mikedld 4415
======================================================================
4416
Parameters:
118 diamond 4417
  * eax = 70 - function number
4418
  * ebx = pointer to the information structure
4419
Format of the information structure:
4420
  * +0: dword: 7 = subfunction number
4421
  * +4: dword: flags field:
4422
    * бит 0: start process as debugged
4423
    * other bits are reserved and must be set to 0
4424
  * +8: dword: 0 or pointer to ASCIIZ-string with parameters
114 mikedld 4425
  * +12 = +0xC: dword: 0 (reserved)
4426
  * +16 = +0x10: dword: 0 (reserved)
118 diamond 4427
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4428
    given in the general description
114 mikedld 4429
    or
4430
  * +20 = +0x14: db 0
118 diamond 4431
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
114 mikedld 4432
Returned value:
4433
  * eax > 0 - program is loaded, eax contains PID
118 diamond 4434
  * eax < 0 - an error has occured, -eax contains
4435
    file system error code
4436
  * ebx destroyed
114 mikedld 4437
Remarks:
118 diamond 4438
  * Command line must be terminated by the character with the code 0
4439
    (ASCIIZ-string); function takes into account either all characters
4440
    up to terminating zero inclusively or first 256 character
4441
    regarding what is less.
4442
  * If the process is started as debugged, it is created in
4443
    the suspended state; to run use subfunction 5 of function 69.
114 mikedld 4444
 
4445
======================================================================
193 diamond 4446
========== Function 70, subfunction 8 - delete file/folder. ==========
4447
======================================================================
4448
Parameters:
4449
  * eax = 70 - function number
4450
  * ebx = pointer to the information structure
4451
Format of the information structure:
4452
  * +0: dword: 8 = subfunction number
4453
  * +4: dword: 0 (reserved)
4454
  * +8: dword: 0 (reserved)
4455
  * +12 = +0xC: dword: 0 (reserved)
4456
  * +16 = +0x10: dword: 0 (reserved)
4457
  * +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
4458
    given in the general description
4459
    or
4460
  * +20 = +0x14: db 0
4461
  * +21 = +0x15: dd pointer to ASCIIZ-string with file name
4462
Returned value:
4463
  * eax = 0 - success, otherwise file system error code
4464
  * ebx destroyed
4465
Remarks:
4466
  * The function is not supported for CD (returns error code 2).
4467
  * The function can delete only empty folders (attempt to delete
4468
    nonempty folder results in error with code 10, "access denied").
4469
 
4470
======================================================================
321 diamond 4471
============= Function 70, subfunction 9 - create folder. ============
4472
======================================================================
4473
Parameters:
4474
  * eax = 70 - function number
4475
  * ebx = pointer to the information structure
4476
Format of the information structure:
4477
  * +0: dword: 9 = subfunction number
4478
  * +4: dword: 0 (reserved)
4479
  * +8: dword: 0 (reserved)
4480
  * +12 = +0xC: dword: 0 (reserved)
4481
  * +16 = +0x10: dword: 0 (reserved)
4482
  * +20 = +0x14: ASCIIZ-name of folder, the rules of names forming are
4483
    given in the general description
4484
    or
4485
  * +20 = +0x14: db 0
4486
  * +21 = +0x15: dd pointer to ASCIIZ-string with folder name
4487
Returned value:
4488
  * eax = 0 - success, otherwise file system error code
4489
  * ebx destroyed
4490
Remarks:
4491
  * The function is not supported for CD (returns error code 2).
4492
  * The parent folder must already exist.
4493
  * If target folder already exists, function returns success (eax=0).
4494
 
4495
======================================================================
118 diamond 4496
========== Function 71, subfunction 1 - set window caption. ==========
114 mikedld 4497
======================================================================
4498
Parameters:
4499
  * eax = 71 - function number
4500
  * ebx = 1 - subfunction number
118 diamond 4501
  * ecx = pointer to caption string
114 mikedld 4502
Returned value:
118 diamond 4503
  * function does not return value
114 mikedld 4504
Remarks:
118 diamond 4505
  * String must be in the ASCIIZ-format. Disregarding real string
4506
    length, no more than 255 characters are drawn.
4507
  * Pass NULL in ecx to remove caption.
114 mikedld 4508
 
4509
======================================================================
665 diamond 4510
=============== Function 72 - send message to a window. ==============
4511
======================================================================
4512
 
4513
- Subfunction 1 - send message with parameter to the active window. --
4514
Parameters:
4515
  * eax = 72 - function number
4516
  * ebx = 1 - subfunction number
4517
  * ecx = event code: 2 or 3
4518
  * edx = parameter: key code for ecx=2, button identifier for ecx=3
4519
Returned value:
4520
  * eax = 0 - success
4521
  * eax = 1 - buffer is full
4522
 
4523
======================================================================
118 diamond 4524
=============== Function -1 - terminate thread/process ===============
114 mikedld 4525
======================================================================
4526
Parameters:
118 diamond 4527
  * eax = -1 - function number
114 mikedld 4528
Returned value:
118 diamond 4529
  * function does not return neither value nor control
114 mikedld 4530
Remarks:
118 diamond 4531
  * If the process did not create threads obviously, it has only
4532
    one thread, which termination results in process termination.
4533
  * If the current thread is last in the process, its termination
4534
    also results in process terminates.
4535
  * This function terminates the current thread. Other thread can be
4536
    killed by call to subfunction 2 of function 18.
114 mikedld 4537
 
4538
======================================================================
4539
=========================== List of events ===========================
4540
======================================================================
118 diamond 4541
Next event can be retrieved by the call of one from functions 10
4542
(to wait for event), 11 (to check without waiting), 23
4543
(to wait during the given time).
4544
These functions return only those events, which enter into a mask set
4545
by function 40. By default it is first three,
4546
there is enough for most applications.
114 mikedld 4547
Codes of events:
118 diamond 4548
  * 1 = redraw event (is reset by call to function 0)
4549
  * 2 = key on keyboard is pressed (acts, only when the window is
4550
    active) or hotkey is pressed; is reset, when all keys from
4551
    the buffer are read out by function 2
4552
  * 3 = button is pressed, defined earlier by function 8
4553
    (or close button, created implicitly by function 0;
4554
    minimize button is handled by the system and sends no message;
4555
    acts, only when the window is active;
4556
    is reset when all buttons from the buffer
4557
    are read out by function 17)
4558
  * 4 = reserved (in current implementation never comes even after
4559
    unmasking by function 40)
4560
  * 5 = the desktop background is redrawed (is reset automatically
4561
    after redraw, so if in redraw time program does not wait and
4562
    does not check events, it will not remark this event)
4563
  * 6 = mouse event (something happened - button pressing or moving;
4564
    is reset at reading)
4565
  * 7 = IPC event (see function 60 -
4566
    Inter Process Communication; is reset at reading)
4567
  * 8 = network event (is reset at reading)
4568
  * 9 = debug event (is reset at reading; see
4569
    debug subsystem)
4570
  * 16..31 = event with appropriate IRQ
4571
    (16=IRQ0, 31=IRQ15) (is reset after reading all IRQ data)
114 mikedld 4572
 
4573
======================================================================
118 diamond 4574
=================== Error codes of the file system ===================
114 mikedld 4575
======================================================================
118 diamond 4576
  * 0 = success
4577
  * 1 = base and/or partition of a hard disk is not defined
4578
    (by subfunctions 7, 8 of function 21)
4579
  * 2 = function is not supported for the given file system
4580
  * 3 = unknown file system
448 diamond 4581
  * 4 = reserved, is never returned in the current implementation
118 diamond 4582
  * 5 = file not found
4583
  * 6 = end of file, EOF
4584
  * 7 = pointer lies outside of application memory
4585
  * 8 = disk is full
4586
  * 9 = FAT table is destroyed
114 mikedld 4587
  * 10 = access denied
118 diamond 4588
  * 11 = device error
4589
Application start functions can return also following errors:
4590
  * 30 = 0x1E = not enough memory
4591
  * 31 = 0x1F = file is not executable
4592
  * 32 = 0x20 = too many processes