Subversion Repositories Kolibri OS

Rev

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

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