Subversion Repositories Kolibri OS

Rev

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

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