Subversion Repositories Kolibri OS

Rev

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

Rev 1494 Rev 1662
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 374... Line 374...
374
    * status of the slot is always 0 (running)
374
    * status of the slot is always 0 (running)
375
    * the execution time adds of time leaving on operations itself
375
    * the execution time adds of time leaving on operations itself
376
      and idle time in waiting for interrupt (which can be got by call
376
      and idle time in waiting for interrupt (which can be got by call
377
      to subfunction 4 of function 18).
377
      to subfunction 4 of function 18).
378
  * Beginning from slot 2, the normal applications are placed.
378
  * Beginning from slot 2, the normal applications are placed.
379
  * Applications are placed in memory at the address   0x0 
379
  * The normal applications are placed in memory at the address
380
    (kernel constant 'std_application_base_address').
380
    0 (kernel constant 'std_application_base_address').
381
    There is no intersection, as each process has its own page table.
381
    There is no intersection, as each process has its own page table.
382
  * At creation of the thread it is assigned the slot
382
  * At creation of the thread it is assigned the slot
383
    in the system table and identifier (Process/Thread IDentifier =
383
    in the system table and identifier (Process/Thread IDentifier =
384
    PID/TID), which do not vary with time for given thread.
384
    PID/TID), which do not vary with time for given thread.
385
    After completion of the thread its slot can be anew used
385
    After completion of the thread its slot can be anew used
Line 844... Line 844...
844
  * function does not return value
844
  * function does not return value
845
Structure of the buffer:
845
Structure of the buffer:
846
db a,b,c,d for version a.b.c.d
846
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
847
db UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2
848
dd REV - kernel SVN revision number
848
dd REV - kernel SVN revision number
849
For Kolibri 0.7.1.0 kernel:
849
For Kolibri 0.7.7.0 kernel:
850
db 0,7,0,0
850
db 0,7,7,0
851
db 2
851
db 2
852
dd 638
852
dd 1319
Line 853... Line 853...
853
 
853
 
854
======================================================================
854
======================================================================
855
======= Function 18, subfunction 14 - wait for screen retrace. =======
855
======= Function 18, subfunction 14 - wait for screen retrace. =======
856
======================================================================
856
======================================================================
Line 1656... Line 1656...
1656
Returned value:
1656
Returned value:
1657
  * eax = size of the current folder's name (including terminating 0)
1657
  * eax = size of the current folder's name (including terminating 0)
1658
Remarks:
1658
Remarks:
1659
  * If the buffer is too small to hold all data, only first (edx-1)
1659
  * If the buffer is too small to hold all data, only first (edx-1)
1660
    bytes are copied and than terminating 0 is inserted.
1660
    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
1661
  * 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.
1662
  * 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
1663
    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 1664...
1711
 
1664
 
1712
======================================================================
1665
======================================================================
1713
======= Function 35 - read the color of a pixel on the screen. =======
1666
======= Function 35 - read the color of a pixel on the screen. =======
1714
======================================================================
1667
======================================================================
Line 3259... Line 3212...
3259
    first type can be found e.g. in famous Interrupt List by
3212
    first type can be found e.g. in famous Interrupt List by
3260
    Ralf Brown; registers of the second type must be listed
3213
    Ralf Brown; registers of the second type must be listed
3261
    in the device documentation.
3214
    in the device documentation.
Line 3262... Line 3215...
3262
 
3215
 
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
======================================================================
3216
======================================================================
3317
============== Function 63 - work with the debug board. ==============
3217
============== Function 63 - work with the debug board. ==============
3318
======================================================================
3218
======================================================================
3319
The debug board is the global system buffer (with the size
3219
The debug board is the global system buffer (with the size
3320
1024 bytes), to which any program can write (generally speaking,
3220
1024 bytes), to which any program can write (generally speaking,
Line 3419... Line 3319...
3419
======================================================================
3319
======================================================================
3420
================== Function 66 - work with keyboard. =================
3320
================== Function 66 - work with keyboard. =================
3421
======================================================================
3321
======================================================================
3422
The input mode influences results of reading keys by function 2.
3322
The input mode influences results of reading keys by function 2.
3423
When a program loads, ASCII input mode is set for it.
3323
When a program loads, ASCII input mode is set for it.
3424
If subfunction is not support then eax=-1.
-
 
Line 3425... Line 3324...
3425
 
3324
 
3426
-------------- Subfunction 1 - set keyboard input mode. --------------
3325
-------------- Subfunction 1 - set keyboard input mode. --------------
3427
Parameters:
3326
Parameters:
3428
  * eax = 66 - function number
3327
  * eax = 66 - function number
Line 3668... Line 3567...
3668
  * The memory block must have been allocated by subfunction 12
3567
  * The memory block must have been allocated by subfunction 12
3669
    or subfunction 20.
3568
    or subfunction 20.
Line 3670... Line 3569...
3670
 
3569
 
3671
======================================================================
3570
======================================================================
3672
===================== Function 68, subfunction 14 ====================
3571
===================== Function 68, subfunction 14 ====================
3673
====== Waiting delivering of signal from another program/driver ======
3572
============ Wait for signal from another program/driver. ============
3674
======================================================================
3573
======================================================================
3675
Parameters:
3574
Parameters:
3676
  * eax = 68 - function number
3575
  * eax = 68 - function number
3677
  * ebx = 14 - subfunction number
3576
  * ebx = 14 - subfunction number
3678
  * ecx = pointer to the buffer for information (24 bytes)
3577
  * ecx = pointer to the buffer for information (24 bytes)
3679
Returned value:
3578
Returned value:
3680
  * buffer pointed to by ecx contains the following information:
3579
  * buffer pointed to by ecx contains the following information:
3681
    * +0: dword: identifier for underlying data of signal
3580
    * +0: dword: identifier for following data of signal
3682
    * +4: data of signal (20 bytes), format of which is defining by
3581
    * +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 3582...
3689
Using subfunctions 24, 25 is true.
3582
          by the first dword
3690
 
3583
 
3691
======================================================================
3584
======================================================================
3692
============= Function 68, subfunction 16 - load driver. =============
3585
============= Function 68, subfunction 16 - load driver. =============
Line 3718... Line 3611...
3718
    * +8: dword: pointer to input data
3611
    * +8: dword: pointer to input data
3719
    * +12 = +0xC: dword: size of input data
3612
    * +12 = +0xC: dword: size of input data
3720
    * +16 = +0x10: dword: pointer to output data
3613
    * +16 = +0x10: dword: pointer to output data
3721
    * +20 = +0x14: dword: size of output data
3614
    * +20 = +0x14: dword: size of output data
3722
Returned value:
3615
Returned value:
3723
  * eax =  error code
3616
  * 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:
3617
Remarks:
3729
  * Function codes and the structure of input/output data
3618
  * Function codes and the structure of input/output data
3730
    are defined by driver.
3619
    are defined by driver.
3731
  * Previously one must obtain driver handle by subfunction 16.
3620
  * Previously one must obtain driver handle by subfunction 16.
Line 3732... Line 3621...
3732
 
3621
 
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
======================================================================
3622
======================================================================
3740
=============== Function 68, subfunction 19 - load DLL. ==============
3623
=============== Function 68, subfunction 19 - load DLL. ==============
3741
======================================================================
3624
======================================================================
3742
Parameters:
3625
Parameters:
3743
  * eax = 68 - function number
3626
  * eax = 68 - function number
Line 3773... Line 3656...
3773
  * If ecx=0, the function frees memory block at edx and returns 0.
3656
  * 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
3657
  * The contents of the block are unchanged up to the shorter of
3775
    the new and old sizes.
3658
    the new and old sizes.
Line 3776... Line 3659...
3776
 
3659
 
-
 
3660
======================================================================
-
 
3661
======== Function 68, subfunction 22 - open named memory area. =======
-
 
3662
======================================================================
-
 
3663
Parameters:
-
 
3664
  * eax = 68 - function number
-
 
3665
  * ebx = 22 - subfunction number
-
 
3666
  * ecx = area name. Maximum of 31 characters with terminating zero
-
 
3667
  * edx = area size in bytes for SHM_CREATE and SHM_OPEN_ALWAYS
-
 
3668
  * esi = flags for open and access:
-
 
3669
    * SHM_OPEN        = 0x00 - open existing memory area. If an area
-
 
3670
                          with such name does not exist, the function
-
 
3671
                          will return error code 5.
-
 
3672
    * SHM_OPEN_ALWAYS = 0x04 - open existing or create new
-
 
3673
                          memory area.
-
 
3674
    * SHM_CREATE      = 0x08 - create new memory area. If an area
-
 
3675
                          with such name already exists, the function
-
 
3676
                          will return error code 10.
-
 
3677
    * SHM_READ        = 0x00 - only read access
-
 
3678
    * SHM_WRITE       = 0x01 - read and write access
-
 
3679
Returned value:
-
 
3680
  * eax = pointer to memory area, 0 if error has occured
-
 
3681
  * if new area is created (SHM_CREATE or SHM_OPEN_ALWAYS):
-
 
3682
    edx = 0 - success, otherwise - error code
-
 
3683
  * if existing area is opened (SHM_OPEN or SHM_OPEN_ALWAYS):
-
 
3684
    edx = error code (if eax=0) or area size in bytes
-
 
3685
Error codes:
-
 
3686
  * E_NOTFOUND = 5
-
 
3687
  * E_ACCESS = 10
-
 
3688
  * E_NOMEM = 30
-
 
3689
  * E_PARAM = 33
-
 
3690
Remarks:
-
 
3691
  * Before this call one must initialize process heap by call to
-
 
3692
    subfunction 11.
-
 
3693
  * If a new area is created, access flags set maximal rights
-
 
3694
    for other processes. An attempt from other process to open
-
 
3695
    with denied rights will fail with error code E_ACCESS.
-
 
3696
  * The process which has created an area always has write access.
-
 
3697
 
-
 
3698
======================================================================
-
 
3699
======= Function 68, subfunction 23 - close named memory area. =======
-
 
3700
======================================================================
-
 
3701
Parameters:
-
 
3702
  * eax = 68 - function number
-
 
3703
  * ebx = 23 - subfunction number
-
 
3704
  * ecx = area name. Maximum of 31 characters with terminating zero
-
 
3705
Returned value:
-
 
3706
  * eax destroyed
-
 
3707
Remarks:
-
 
3708
  * A memory area is physically freed (with deleting all data and
-
 
3709
    freeing physical memory), when all threads which have opened
-
 
3710
    this area will close it.
-
 
3711
  * When thread is terminating, all opened by it areas are closed.
-
 
3712
 
3777
======================================================================
3713
======================================================================
3778
====== Function 68, subfunction 24 - set new exceptions handler ======
3714
======== Function 68, subfunction 24 - set exception handler. ========
3779
======================================================================
3715
======================================================================
3780
Parameters:
3716
Parameters:
3781
  * eax = 68 - function number
3717
  * eax = 68 - function number
3782
  * ebx = 24 - subfunction number
3718
  * ebx = 24 - subfunction number
3783
  * ecx = address of the new exception handler
3719
  * ecx = address of the new exception handler
3784
  * edx = the mask of processing exceptions
3720
  * edx = the mask of handled exceptions
3785
Returned value:
3721
Returned value:
3786
  * eax = address of the old exception handler (0, if it was not set)
3722
  * eax = address of the old exception handler (0, if it was not set)
3787
  * ebx = the old mask of exception handler
3723
  * ebx = the old mask of handled exceptions
3788
Remarks:
3724
Remarks:
3789
  * Bit number in mask of exceptions is correspond to exception number
3725
  * Bit number in mask of exceptions corresponds to exception number
3790
    by CPU-specification (Intel-PC). For example, FPU-exception have
3726
    in CPU-specification (Intel-PC). For example, FPU exceptions have
3791
    number 16 (#MF), and SSE-exception - 19 (#XF)
3727
    number 16 (#MF), and SSE exceptions - 19 (#XF).
3792
  * The current implementation ignore the inquiry for hook of 7
3728
  * The current implementation ignores the inquiry for hook of 7
3793
    exception - system process #NM by one's own.
3729
    exception - the system handles #NM by its own.
3794
  * User handler get exception number in stack parameter. So, correct
3730
  * The exception handler is called with exception number as first
3795
    exit from handler is: RET 4. Return from handler is to the same
3731
    (and only) stack parameter. So, correct exit from the handler is
-
 
3732
    RET 4. It returns to the instruction, that caused the exception,
-
 
3733
    for faults, and to the next instruction for traps (see
3796
    instruction, that was cause the exception
3734
    classification of exceptions in CPU specification).
3797
  * When control is transfering to user handler, corresponding bit in
3735
  * When user handler receives control, the corresponding bit in
3798
    exception mask is clearing. Rising this exception in consequence
3736
    the exception mask is cleared. Raising this exception
-
 
3737
    in consequence leads to default handling, that is,
3799
    - reduce to default-handling. Exactly: terminating the application,
3738
    terminating the application in absence of debugger or
3800
    or suspending with debug-notify to owner.
3739
    suspend with notification of debugger otherwise.
3801
  * After completion of critical operations in user handler, it may be
3740
  * After user handler completes critical operations, it can set
3802
    rising corresponding bit in exception mask by using subfunction 25
3741
    the corresponding bit in the exception mask with subfunction 25.
3803
    Clearing exceptions flags in FPU and/or XMM modules - is
3742
    Also user handler is responsible for clearing exceptions flags in
Line 3804... Line 3743...
3804
    responsibility of user handler too.
3743
    FPU and/or SSE.
3805
 
3744
 
3806
======================================================================
3745
======================================================================
3807
==== Function 68, subfunction 25 - change state of signal activity ===
3746
====== Function 68, subfunction 25 - set FPU exception handler. ======
3808
======================================================================
3747
======================================================================
3809
Parameters:
3748
Parameters:
3810
  * eax = 68 - function number
3749
  * eax = 68 - function number
3811
  * ebx = 25 - subfunction number
3750
  * ebx = 25 - subfunction number
3812
  * ecx = signal number
3751
  * ecx = signal number
-
 
3752
  * edx = value of activity (0/1)
3813
  * edx = value of activity (0/1)
3753
Returned value:
3814
Returned value:
3754
  * eax = -1 - invalid signal number
3815
  * eax = value of old activity for this signal (0/1)
3755
  * otherwise eax = old value of activity for this signal (0/1)
3816
Remarks:
3756
Remarks:
3817
  * In current implementation, it is changed only exception mask for
3757
  * In current implementation only mask for user excepton handler,
Line 3818... Line 3758...
3818
    user exception handler, wich was previously set by subfunction 24.
3758
    which has been previously set by subfunction 24,
3819
    At that, number of signal correspond to exception number.
3759
    is changed. Signal number corresponds to exception number.
3820
 
3760
 
3821
======================================================================
3761
======================================================================
3822
====================== Fucntion 69 - debugging. ======================
3762
====================== Function 69 - debugging. ======================
3823
======================================================================
3763
======================================================================
3824
A process can load other process as debugged by set of corresponding
3764
A process can load other process as debugged by set of corresponding
Line 4109... Line 4049...
4109
  * '/rd/1/kernel.asm',0
4049
  * '/rd/1/kernel.asm',0
4110
  * '/HD0/1/kernel.asm',0
4050
  * '/HD0/1/kernel.asm',0
4111
  * '/hd0/2/menuet/pics/tanzania.bmp',0
4051
  * '/hd0/2/menuet/pics/tanzania.bmp',0
4112
  * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
4052
  * '/hd0/1/Program files/NameOfProgram/SomeFile.SomeExtension',0
4113
  * '/sys/MySuperApp.ini',0
4053
  * '/sys/MySuperApp.ini',0
-
 
4054
Also function supports relative names.  If the path begins not 
-
 
4055
with '/', it is considered relative to a current folder. To get or 
-
 
4056
set a current folder, use the function 30.
-
 
4057
 
4114
Available subfunctions:
4058
Available subfunctions:
4115
  * subfunction 0 - read file
4059
  * subfunction 0 - read file
4116
  * subfunction 1 - read folder
4060
  * subfunction 1 - read folder
4117
  * subfunction 2 - create/rewrite file
4061
  * subfunction 2 - create/rewrite file
4118
  * subfunction 3 - write to existing file
4062
  * subfunction 3 - write to existing file