Subversion Repositories Kolibri OS

Rev

Rev 1635 | Rev 2106 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1635 Rev 2010
Line 1... Line 1...
1
SYSTEM FUNCTIONS of OS Kolibri 0.7.5.0
1
SYSTEM FUNCTIONS of OS Kolibri 0.7.7.0
Line 2... Line 2...
2
 
2
 
3
Number of the function is located in the register eax.
3
Number of the function is located in the register eax.
4
The call of the system function is executed by "int 0x40" command.
4
The call of the system function is executed by "int 0x40" command.
5
All registers except explicitly declared in the returned value,
5
All registers except explicitly declared in the returned value,
Line 345... Line 345...
345
    * +66 = +0x42: dword: height of the client area
345
    * +66 = +0x42: dword: height of the client area
346
    * +70 = +0x46: byte: state of the window - bitfield
346
    * +70 = +0x46: byte: state of the window - bitfield
347
      * bit 0 (mask 1): window is maximized
347
      * bit 0 (mask 1): window is maximized
348
      * bit 1 (mask 2): window is minimized to panel
348
      * bit 1 (mask 2): window is minimized to panel
349
      * bit 2 (mask 4): window is rolled up
349
      * bit 2 (mask 4): window is rolled up
-
 
350
    * +71 = +0x47: dword: event mask
350
Remarks:
351
Remarks:
351
  * Slots are numbered starting from 1.
352
  * Slots are numbered starting from 1.
352
  * Returned value is not a total number of threads, because there
353
  * Returned value is not a total number of threads, because there
353
    can be free slots.
354
    can be free slots.
354
  * When process is starting, system automatically creates
355
  * When process is starting, system automatically creates
Line 374... Line 375...
374
    * status of the slot is always 0 (running)
375
    * status of the slot is always 0 (running)
375
    * the execution time adds of time leaving on operations itself
376
    * the execution time adds of time leaving on operations itself
376
      and idle time in waiting for interrupt (which can be got by call
377
      and idle time in waiting for interrupt (which can be got by call
377
      to subfunction 4 of function 18).
378
      to subfunction 4 of function 18).
378
  * Beginning from slot 2, the normal applications are placed.
379
  * Beginning from slot 2, the normal applications are placed.
379
  * Applications are placed in memory at the address   0x0 
380
  * The normal applications are placed in memory at the address
380
    (kernel constant 'std_application_base_address').
381
    0 (kernel constant 'std_application_base_address').
381
    There is no intersection, as each process has its own page table.
382
    There is no intersection, as each process has its own page table.
382
  * At creation of the thread it is assigned the slot
383
  * At creation of the thread it is assigned the slot
383
    in the system table and identifier (Process/Thread IDentifier =
384
    in the system table and identifier (Process/Thread IDentifier =
384
    PID/TID), which do not vary with time for given thread.
385
    PID/TID), which do not vary with time for given thread.
385
    After completion of the thread its slot can be anew used
386
    After completion of the thread its slot can be anew used
Line 842... Line 843...
842
    the information will be placed
843
    the information will be placed
843
Returned value:
844
Returned value:
844
  * function does not return value
845
  * function does not return value
845
Structure of the buffer:
846
Structure of the buffer:
846
db a,b,c,d for version a.b.c.d
847
db a,b,c,d for version a.b.c.d
847
db UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2
848
db 0: reserved
848
dd REV - kernel SVN revision number
849
dd REV - kernel SVN revision number
849
For Kolibri 0.7.1.0 kernel:
850
For Kolibri 0.7.7.0+ kernel:
850
db 0,7,0,0
851
db 0,7,7,0
851
db 2
852
db 0
852
dd 638
853
dd 1675
Line 853... Line 854...
853
 
854
 
854
======================================================================
855
======================================================================
855
======= Function 18, subfunction 14 - wait for screen retrace. =======
856
======= Function 18, subfunction 14 - wait for screen retrace. =======
856
======================================================================
857
======================================================================
Line 1656... Line 1657...
1656
Returned value:
1657
Returned value:
1657
  * eax = size of the current folder's name (including terminating 0)
1658
  * eax = size of the current folder's name (including terminating 0)
1658
Remarks:
1659
Remarks:
1659
  * If the buffer is too small to hold all data, only first (edx-1)
1660
  * If the buffer is too small to hold all data, only first (edx-1)
1660
    bytes are copied and than terminating 0 is inserted.
1661
    bytes are copied and than terminating 0 is inserted.
1661
 
-
 
1662
======================================================================
-
 
1663
=============== Function 32 - delete file from ramdisk. ==============
-
 
1664
======================================================================
-
 
1665
Parameters:
-
 
1666
  * eax = 32 - function number
-
 
1667
  * ebx = pointer to the filename
-
 
1668
Returned value:
-
 
1669
  * eax = 0 - success; otherwise file system error code
-
 
1670
Remarks:
-
 
1671
  * This function is obsolete; function 58 allows to fulfill
-
 
1672
    the same operations with the extended possibilities.
-
 
1673
  * The current implementation returns only values 0(success) and
-
 
1674
    5(file not found).
-
 
1675
  * The filename must be either in the format 8+3 characters
1662
  * By default, current folder for the thread is "/rd/1".
1676
    (first 8 characters - name itself, last 3 - extension,
-
 
1677
    the short names and extensions are supplemented with spaces),
-
 
1678
    or in the format 8.3 characters "FILE.EXT"/"FILE.EX "
-
 
1679
    (name no more than 8 characters, dot, extension 3 characters
-
 
1680
    supplemented if necessary by spaces).
-
 
1681
    The filename must be written with capital letters. The terminating
-
 
1682
    character with code 0 is not necessary (not ASCIIZ-string).
-
 
1683
  * This function does not support folders on the ramdisk.
1663
  * At process/thread creation the current folder will be inherited 
1684
 
-
 
1685
======================================================================
-
 
1686
================ Function 33 - write file to ramdisk. ================
-
 
1687
======================================================================
-
 
1688
Parameters:
-
 
1689
  * eax = 33 - function number
-
 
1690
  * ebx = pointer to the filename
-
 
1691
  * ecx = pointer to data for writing
-
 
1692
  * edx = number of bytes for writing
-
 
1693
  * should be set esi=0
1664
    from the parent.
1694
Returned value:
-
 
1695
  * eax = 0 - success, otherwise file system error code
-
 
1696
Remarks:
-
 
1697
  * This function is obsolete; function 70 allows to fulfil
-
 
1698
    the same operations with extended possibilities.
-
 
1699
  * If esi contains non-zero value and selected file already exists,
-
 
1700
    one more file with the same name will be created.
-
 
1701
  * Otherwise file will be overwritten.
-
 
1702
  * The filename must be either in the format 8+3 characters
-
 
1703
    (first 8 characters - name itself, last 3 - extension,
-
 
1704
    the short names and extensions are supplemented with spaces),
-
 
1705
    or in the format 8.3 characters "FILE.EXT"/"FILE.EX "
-
 
1706
    (name no more than 8 characters, dot, extension 3 characters
-
 
1707
    supplemented if necessary by spaces).
-
 
1708
    The filename must be written with capital letters. The terminating
-
 
1709
    character with code 0 is not necessary (not ASCIIZ-string).
-
 
1710
  * This function does not support folders on the ramdisk.
-
 
Line 1711... Line 1665...
1711
 
1665
 
1712
======================================================================
1666
======================================================================
1713
======= Function 35 - read the color of a pixel on the screen. =======
1667
======= Function 35 - read the color of a pixel on the screen. =======
1714
======================================================================
1668
======================================================================
Line 3259... Line 3213...
3259
    first type can be found e.g. in famous Interrupt List by
3213
    first type can be found e.g. in famous Interrupt List by
3260
    Ralf Brown; registers of the second type must be listed
3214
    Ralf Brown; registers of the second type must be listed
3261
    in the device documentation.
3215
    in the device documentation.
Line 3262... Line 3216...
3262
 
3216
 
3263
======================================================================
-
 
3264
===================== Function 62, subfunction 11 ====================
-
 
3265
==              Initialize user-accessible MMIO channel             ==
-
 
3266
======================================================================
-
 
3267
Parameters:
-
 
3268
  * eax = 62 - function
-
 
3269
  * bl  = 11 - subfunction
-
 
3270
  * cx  = PCI-address (bbbbbbbb dddddfff) 
-
 
3271
Returns:
-
 
3272
  * eax = -1 - PCI access not granted; 
-
 
3273
  * eax = -2 - no user MMIO access to this PCI address; 
-
 
3274
  * eax = -3 - memory allocation error; otherwise
-
 
3275
  * eax = available user heap size.
-
 
3276
Remarks:
-
 
3277
  * Low-level PCI access must be allowed (fn21:12)
-
 
3278
  * PCI-address should correspond the system var [mmio_pci_addr]
-
 
3279
 
-
 
3280
======================================================================
-
 
3281
===================== Function 62, subfunction 12 ====================
-
 
3282
==            Request user-accessible MMIO address space            ==
-
 
3283
======================================================================
-
 
3284
Parameters:
-
 
3285
  * eax = 62 - function
-
 
3286
  * bl  = 12 - subfunction
-
 
3287
  * bh  = BAR number in PCI configuration space
-
 
3288
  * ecx = MMIO-block size needed (bytes)
-
 
3289
  * edx = MMIO-offset (number of whole 4Kb-pages!)
-
 
3290
Returns:
-
 
3291
  * eax = -1 - user PCI access denied; 
-
 
3292
  * eax = -2 - invalid BAR number; 
-
 
3293
  * eax = -3 - BAR contains no valid IO addres;
-
 
3294
  * eax = -4 - BAR addresses IO ports;
-
 
3295
  * eax = -5 - dynamic allocation error; otherwise
-
 
3296
  * eax = MMIO start address (in application's linear space).
-
 
3297
Remarks:
-
 
3298
  * Low-level PCI access must be allowed (fn21:12)
-
 
3299
  * The system var [mmio_pci_addr] sets the actual PCI-address
-
 
3300
  * The granted MMIO addresses should be released after use (fn62:13)
-
 
3301
 
-
 
3302
======================================================================
-
 
3303
===================== Function 62, subfunction 13 ====================
-
 
3304
==              Release a block of user MMIO addresses              ==
-
 
3305
======================================================================
-
 
3306
 à ¬¥âàë:
-
 
3307
  * eax = 62 - function
-
 
3308
  * bl  = 12 - subfunction
-
 
3309
  * ecx = MMIO start address (in application's linear space).
-
 
3310
Returns:
-
 
3311
  * eax = 1 if the block is successfully released; 
-
 
3312
  * eax = 0 in case of reallocation error; 
-
 
3313
Remarks:
-
 
3314
  * A valid uMMIO block should exist at this address (fn62:12)
-
 
3315
 
-
 
3316
======================================================================
3217
======================================================================
3317
============== Function 63 - work with the debug board. ==============
3218
============== Function 63 - work with the debug board. ==============
3318
======================================================================
3219
======================================================================
3319
The debug board is the global system buffer (with the size
3220
The debug board is the global system buffer (with the size
3320
1024 bytes), to which any program can write (generally speaking,
3221
1024 bytes), to which any program can write (generally speaking,
Line 3419... Line 3320...
3419
======================================================================
3320
======================================================================
3420
================== Function 66 - work with keyboard. =================
3321
================== Function 66 - work with keyboard. =================
3421
======================================================================
3322
======================================================================
3422
The input mode influences results of reading keys by function 2.
3323
The input mode influences results of reading keys by function 2.
3423
When a program loads, ASCII input mode is set for it.
3324
When a program loads, ASCII input mode is set for it.
3424
If subfunction is not support then eax=-1.
-
 
Line 3425... Line 3325...
3425
 
3325
 
3426
-------------- Subfunction 1 - set keyboard input mode. --------------
3326
-------------- Subfunction 1 - set keyboard input mode. --------------
3427
Parameters:
3327
Parameters:
3428
  * eax = 66 - function number
3328
  * eax = 66 - function number
Line 3668... Line 3568...
3668
  * The memory block must have been allocated by subfunction 12
3568
  * The memory block must have been allocated by subfunction 12
3669
    or subfunction 20.
3569
    or subfunction 20.
Line 3670... Line 3570...
3670
 
3570
 
3671
======================================================================
3571
======================================================================
3672
===================== Function 68, subfunction 14 ====================
3572
===================== Function 68, subfunction 14 ====================
3673
====== Waiting delivering of signal from another program/driver ======
3573
============ Wait for signal from another program/driver. ============
3674
======================================================================
3574
======================================================================
3675
Parameters:
3575
Parameters:
3676
  * eax = 68 - function number
3576
  * eax = 68 - function number
3677
  * ebx = 14 - subfunction number
3577
  * ebx = 14 - subfunction number
3678
  * ecx = pointer to the buffer for information (24 bytes)
3578
  * ecx = pointer to the buffer for information (24 bytes)
3679
Returned value:
3579
Returned value:
3680
  * buffer pointed to by ecx contains the following information:
3580
  * buffer pointed to by ecx contains the following information:
3681
    * +0: dword: identifier for underlying data of signal
3581
    * +0: dword: identifier for following data of signal
3682
    * +4: data of signal (20 bytes), format of which is defining by
3582
    * +4: dword: data of signal (20 bytes), format of which is defined
3683
          first dword
-
 
3684
 
-
 
3685
======================================================================
-
 
3686
====== Function 68, subfunction 15 - set FPU exception handler. ======
-
 
3687
======================================================================
-
 
3688
Deleted (in current implementation only 0 is returned).
-
 
Line 3689... Line 3583...
3689
Using subfunctions 24, 25 is true.
3583
          by the first dword
3690
 
3584
 
3691
======================================================================
3585
======================================================================
3692
============= Function 68, subfunction 16 - load driver. =============
3586
============= Function 68, subfunction 16 - load driver. =============
Line 3718... Line 3612...
3718
    * +8: dword: pointer to input data
3612
    * +8: dword: pointer to input data
3719
    * +12 = +0xC: dword: size of input data
3613
    * +12 = +0xC: dword: size of input data
3720
    * +16 = +0x10: dword: pointer to output data
3614
    * +16 = +0x10: dword: pointer to output data
3721
    * +20 = +0x14: dword: size of output data
3615
    * +20 = +0x14: dword: size of output data
3722
Returned value:
3616
Returned value:
3723
  * eax =  error code
3617
  * eax = determined by driver
3724
      0  - successful call
-
 
3725
     -1  - any error.
-
 
3726
     -2, -3, -4, etc. reserved for kernel error codes
-
 
3727
      1, 2, 3, etc    driver specific error codes
-
 
3728
Remarks:
3618
Remarks:
3729
  * Function codes and the structure of input/output data
3619
  * Function codes and the structure of input/output data
3730
    are defined by driver.
3620
    are defined by driver.
3731
  * Previously one must obtain driver handle by subfunction 16.
3621
  * Previously one must obtain driver handle by subfunction 16.
Line 3732... Line 3622...
3732
 
3622
 
3733
======================================================================
-
 
3734
====== Function 68, subfunction 18 - set SSE exception handler. ======
-
 
3735
======================================================================
-
 
3736
Deleted (in current implementation only 0 is returned).
-
 
3737
Using subfunctions 24, 25 is true.
-
 
3738
 
-
 
3739
======================================================================
3623
======================================================================
3740
=============== Function 68, subfunction 19 - load DLL. ==============
3624
=============== Function 68, subfunction 19 - load DLL. ==============
3741
======================================================================
3625
======================================================================
3742
Parameters:
3626
Parameters:
3743
  * eax = 68 - function number
3627
  * eax = 68 - function number
Line 3773... Line 3657...
3773
  * If ecx=0, the function frees memory block at edx and returns 0.
3657
  * If ecx=0, the function frees memory block at edx and returns 0.
3774
  * The contents of the block are unchanged up to the shorter of
3658
  * The contents of the block are unchanged up to the shorter of
3775
    the new and old sizes.
3659
    the new and old sizes.
Line 3776... Line 3660...
3776
 
3660
 
-
 
3661
======================================================================
-
 
3662
======== Function 68, subfunction 22 - open named memory area. =======
-
 
3663
======================================================================
-
 
3664
Parameters:
-
 
3665
  * eax = 68 - function number
-
 
3666
  * ebx = 22 - subfunction number
-
 
3667
  * ecx = area name. Maximum of 31 characters with terminating zero
-
 
3668
  * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS
-
 
3669
  * esi = flags for open and access:
-
 
3670
    * SHM_OPEN        = 0x00 - open existing memory area. If an area
-
 
3671
                          with such name does not exist, the function
-
 
3672
                          will return error code 5.
-
 
3673
    * SHM_OPEN_ALWAYS = 0x04 - open existing or create new
-
 
3674
                          memory area.
-
 
3675
    * SHM_CREATE      = 0x08 - create new memory area. If an area
-
 
3676
                          with such name already exists, the function
-
 
3677
                          will return error code 10.
-
 
3678
    * SHM_READ        = 0x00 - only read access
-
 
3679
    * SHM_WRITE       = 0x01 - read and write access
-
 
3680
Returned value:
-
 
3681
  * eax = pointer to memory area, 0 if error has occured
-
 
3682
  * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS):
-
 
3683
    edx = 0 - success, otherwise - error code
-
 
3684
  * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS):
-
 
3685
    edx = error code (if eax=0) or area size in bytes
-
 
3686
Error codes:
-
 
3687
  * E_NOTFOUND = 5
-
 
3688
  * E_ACCESS = 10
-
 
3689
  * E_NOMEM = 30
-
 
3690
  * E_PARAM = 33
-
 
3691
Remarks:
-
 
3692
  * Before this call one must initialize process heap by call to
-
 
3693
    subfunction 11.
-
 
3694
  * If a new area is created, access flags set maximal rights
-
 
3695
    for other processes. An attempt from other process to open
-
 
3696
    with denied rights will fail with error code E_ACCESS.
-
 
3697
  * The process which has created an area always has write access.
-
 
3698
 
-
 
3699
======================================================================
-
 
3700
======= Function 68, subfunction 23 - close named memory area. =======
-
 
3701
======================================================================
-
 
3702
Parameters:
-
 
3703
  * eax = 68 - function number
-
 
3704
  * ebx = 23 - subfunction number
-
 
3705
  * ecx = area name. Maximum of 31 characters with terminating zero
-
 
3706
Returned value:
-
 
3707
  * eax destroyed
-
 
3708
Remarks:
-
 
3709
  * A memory area is physically freed (with deleting all data and
-
 
3710
    freeing physical memory), when all threads which have opened
-
 
3711
    this area will close it.
-
 
3712
  * When thread is terminating, all opened by it areas are closed.
-
 
3713
 
3777
======================================================================
3714
======================================================================
3778
====== Function 68, subfunction 24 - set new exceptions handler ======
3715
======== Function 68, subfunction 24 - set exception handler. ========
3779
======================================================================
3716
======================================================================
3780
Parameters:
3717
Parameters:
3781
  * eax = 68 - function number
3718
  * eax = 68 - function number
3782
  * ebx = 24 - subfunction number
3719
  * ebx = 24 - subfunction number
3783
  * ecx = address of the new exception handler
3720
  * ecx = address of the new exception handler
3784
  * edx = the mask of processing exceptions
3721
  * edx = the mask of handled exceptions
3785
Returned value:
3722
Returned value:
3786
  * eax = address of the old exception handler (0, if it was not set)
3723
  * eax = address of the old exception handler (0, if it was not set)
3787
  * ebx = the old mask of exception handler
3724
  * ebx = the old mask of handled exceptions
3788
Remarks:
3725
Remarks:
3789
  * Bit number in mask of exceptions is correspond to exception number
3726
  * Bit number in mask of exceptions corresponds to exception number
3790
    by CPU-specification (Intel-PC). For example, FPU-exception have
3727
    in CPU-specification (Intel-PC). For example, FPU exceptions have
3791
    number 16 (#MF), and SSE-exception - 19 (#XF)
3728
    number 16 (#MF), and SSE exceptions - 19 (#XF).
3792
  * The current implementation ignore the inquiry for hook of 7
3729
  * The current implementation ignores the inquiry for hook of 7
3793
    exception - system process #NM by one's own.
3730
    exception - the system handles #NM by its own.
3794
  * User handler get exception number in stack parameter. So, correct
3731
  * The exception handler is called with exception number as first
3795
    exit from handler is: RET 4. Return from handler is to the same
3732
    (and only) stack parameter. So, correct exit from the handler is
-
 
3733
    RET 4. It returns to the instruction, that caused the exception,
-
 
3734
    for faults, and to the next instruction for traps (see
3796
    instruction, that was cause the exception
3735
    classification of exceptions in CPU specification).
3797
  * When control is transfering to user handler, corresponding bit in
3736
  * When user handler receives control, the corresponding bit in
3798
    exception mask is clearing. Rising this exception in consequence
3737
    the exception mask is cleared. Raising this exception
-
 
3738
    in consequence leads to default handling, that is,
3799
    - reduce to default-handling. Exactly: terminating the application,
3739
    terminating the application in absence of debugger or
3800
    or suspending with debug-notify to owner.
3740
    suspend with notification of debugger otherwise.
3801
  * After completion of critical operations in user handler, it may be
3741
  * After user handler completes critical operations, it can set
3802
    rising corresponding bit in exception mask by using subfunction 25
3742
    the corresponding bit in the exception mask with subfunction 25.
3803
    Clearing exceptions flags in FPU and/or XMM modules - is
3743
    Also user handler is responsible for clearing exceptions flags in
Line 3804... Line 3744...
3804
    responsibility of user handler too.
3744
    FPU and/or SSE.
3805
 
3745
 
3806
======================================================================
3746
======================================================================
3807
==== Function 68, subfunction 25 - change state of signal activity ===
3747
====== Function 68, subfunction 25 - set FPU exception handler. ======
3808
======================================================================
3748
======================================================================
3809
Parameters:
3749
Parameters:
3810
  * eax = 68 - function number
3750
  * eax = 68 - function number
3811
  * ebx = 25 - subfunction number
3751
  * ebx = 25 - subfunction number
3812
  * ecx = signal number
3752
  * ecx = signal number
-
 
3753
  * edx = value of activity (0/1)
3813
  * edx = value of activity (0/1)
3754
Returned value:
3814
Returned value:
3755
  * eax = -1 - invalid signal number
3815
  * eax = value of old activity for this signal (0/1)
3756
  * otherwise eax = old value of activity for this signal (0/1)
3816
Remarks:
3757
Remarks:
3817
  * In current implementation, it is changed only exception mask for
3758
  * In current implementation only mask for user excepton handler,
Line 3818... Line 3759...
3818
    user exception handler, wich was previously set by subfunction 24.
3759
    which has been previously set by subfunction 24,
3819
    At that, number of signal correspond to exception number.
3760
    is changed. Signal number corresponds to exception number.
3820
 
3761
 
3821
======================================================================
3762
======================================================================
3822
====================== Fucntion 69 - debugging. ======================
3763
====================== Function 69 - debugging. ======================
3823
======================================================================
3764
======================================================================
3824
A process can load other process as debugged by set of corresponding
3765
A process can load other process as debugged by set of corresponding
Line 4109... Line 4050...
4109
  * '/rd/1/kernel.asm',0
4050
  * '/rd/1/kernel.asm',0
4110
  * '/HD0/1/kernel.asm',0
4051
  * '/HD0/1/kernel.asm',0
4111
  * '/hd0/2/menuet/pics/tanzania.bmp',0
4052
  * '/hd0/2/menuet/pics/tanzania.bmp',0
4112
  * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
4053
  * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
4113
  * '/sys/MySuperApp.ini',0
4054
  * '/sys/MySuperApp.ini',0
-
 
4055
Also function supports relative names.  If the path begins not 
-
 
4056
with '/', it is considered relative to a current folder. To get or 
-
 
4057
set a current folder, use the function 30.
-
 
4058
 
4114
Available subfunctions:
4059
Available subfunctions:
4115
  * subfunction 0 - read file
4060
  * subfunction 0 - read file
4116
  * subfunction 1 - read folder
4061
  * subfunction 1 - read folder
4117
  * subfunction 2 - create/rewrite file
4062
  * subfunction 2 - create/rewrite file
4118
  * subfunction 3 - write to existing file
4063
  * subfunction 3 - write to existing file