Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 2511 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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