Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 192 → Rev 193

/kernel/trunk/docs/sysfuncs.txt
379,7 → 379,7
to subfunction 4 of function 18).
* Beginning from slot 2, the normal applications are placed.
* The normal applications are placed in memory at the address
0x10000000 (kernel constand 'std_application_base_address').
0x60400000 (kernel constant 'std_application_base_address').
There is no intersection, as each process has its own page table.
* At creation of the thread it is assigned the slot
in the system table and identifier (Process/Thread IDentifier =
874,8 → 874,8
db a,b,c,d for version a.b.c.d
db UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2
db 'name',0 - ASCIIZ-string with the name
For Kolibri 0.6.0.0 kernel:
db 0,6,0,0
For Kolibri 0.5.8.1 kernel:
db 0,5,8,1
db 2
db 'Kolibri',0
 
1001,6 → 1001,30
screen.
 
======================================================================
======== Function 18, subfunction 20 - get information on RAM. =======
======================================================================
Parameters:
* eax = 18 - function number
* ebx = 20 - subfunction number
* ecx = pointer to the buffer for information (36 bytes)
Returned value:
* eax = total size of existing RAM in pages
or -1 if error has occured
* buffer pointed to by ecx contains the following information:
* +0: dword: total size of existing RAM in pages
* +4: dword: size of free RAM in pages
* +8: dword: number of page faults (exceptions #PF)
in applications
* +12: dword: size of kernel heap in bytes
* +16: dword: free in kernel heap in bytes
* +20: dword: total number of memory blocks in kernel heap
* +24: dword: number of free memory blocks in kernel heap
* +28: dword: size of maximum free block in kernel heap
(reserved)
* +32: dword: size of maximum allocated block in kernel heap
(reserved)
 
======================================================================
==================== Function 20 - MIDI interface. ===================
======================================================================
 
2874,7 → 2898,6
Existing subfunctions:
* subfunction 0 - read file/folder
* subfunction 1 - rewrite file
* subfunction 2 - delete file/folder
* subfunction 4 - make folder
* subfunction 5 - rename/move file/folder
* subfunction 8 - LBA-read from device
2966,30 → 2989,6
* This function is obsolete, use subfunction 2 of function 70.
 
======================================================================
========== Function 58, subfunction 2 - delete file/folder. ==========
======================================================================
Parameters:
* eax = 58 - function number
* ebx = pointer to the information structure
Format of the information structure:
* +0: dword: 2 = subfunction number
* +4: dword: ignored
* +8: dword: ignored
* +12 = +0xC: dword: ignored
* +16 = +0x10: dword: pointer to buffer for system operations
(4096 bytes)
* +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
given in the general description
Returned value:
* eax = 0 - success, otherwise file system error code
* ebx destroyed
Remarks:
* By operations with a floppy one should not delete not empty
folder. The code working with hard disk deletes not empty folders
correctly (i.e. recursively with all files and nested folders).
Function 58 does not support folders on ramdisk.
 
======================================================================
============== Function 58, subfunction 4 - make folder. =============
======================================================================
Parameters:
3458,8 → 3457,11
* eax = 0 - success
* eax = 1 - not enough memory
Remarks:
* At the moment this function is a sole resource for dynamic
allocation/free of application memory.
* There is another way to dynamically allocate/free memory -
subfunctions 11, 12, 13 of function 68.
* The function cannot be used together with 68.11, 68.12, 68.13.
The function call will be ignored after creation of process heap
with function 68.11.
 
======================================================================
================== Function 66 - work with keyboard. =================
3666,87 → 3668,133
kill the thread.
 
======================================================================
======= Function 68, subfunction 5 - allocate physical memory. =======
======= Function 68, subfunction 11 - initialize process heap. =======
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 5 - subfunction number
* ecx = size (in bytes)
* ebx = 11 - subfunction number
Returned value:
* eax = physical address of allocated memory
* eax = 0 - failed
* otherwise size of created heap
Remarks:
* Normal applications must not use this function, it is intended
for the case, when for some device it is required to place
data to the known physical address. (In effect, this function
was developed for AC97WAV.)
* The number of blocks of physical memory is limited (by constant
24, and this constant includes some blocks for kernel).
* To free a memory allocated by such way use
subfunction 6, to copy data there and back
use subfunctions 7 and 8.
* The function call initializes heap, from which one can in future
allocate and free memory blocks with subfunctions 12 and 13.
Heap size is equal to total amount of free application memory.
* The second function call from the same process results in
returning the size of the existing heap.
* After creation of the heap calls to function 64 will be ignored.
 
======================================================================
========= Function 68, subfunction 6 - free physical memory. =========
======== Function 68, subfunction 12 - allocate memory block. ========
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 6 - subfunction number
* ecx = physical address of memory
* ebx = 12 - subfunction number
* ecx = required size in bytes
Returned value:
* function does not return value
* eax = pointer to the allocated block
Remarks:
* Normal applications must not use this function, it is intended
for the case, when for some device it is required to place
data to the known physical address. (In effect, this function
was developed for AC97WAV.)
* The memory must be previously allocated by subfunction 5.
* Before this call one must initialize process heap by call to
subfunction 11.
* The function allocates an integer number of pages (4 Kb) in such
way that the real size of allocated block is more than or equal to
requested size.
 
======================================================================
===== Function 68, subfunction 7 - write data to physical memory. ====
========== Function 68, subfunction 13 - free memory block. ==========
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 7 - subfunction number
* ecx = physical address
* edx = pointer to the data (in the application)
* esi = size of the data (in bytes)
* ebx = 13 - subfunction number
* ecx = pointer to the memory block
Returned value:
* function does not return value
* eax = 1 - success
* eax = 0 - failed
Remarks:
* Normal applications must not use this function, it is intended
for the case, when for some device it is required to place
data to the known physical address. (In effect, this function
was developed for AC97WAV.)
* The range of physical addresses should lie inside of previously
allocated by subfunction 5 block of physical memory.
* There is no check for correctness.
* The memory block must have been allocated by subfunction 12.
 
======================================================================
==== Function 68, subfunction 8 - read data from physical memory. ====
======== Function 68, subfunction 14 - wait for driver notify. =======
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 8 - subfunction number
* ecx = physical address
* edx = pointer to buffer for data (in application)
* esi = size of data (in bytes)
* ebx = 14 - subfunction number
* ecx = pointer to the buffer for information (8 bytes)
Returned value:
* function does not return value
* buffer pointed to by ecx contains the following information:
* +0: dword: constant EV_INTR = 1
* +4: dword: driver data
Remarks:
* Normal applications must not use this function, it is intended
for the case, when for some device it is required to place
data to the known physical address. (In effect, this function
was developed for AC97WAV.)
* The range of physical addresses should lie inside of previously
allocated by subfunction 5 block of physical memory.
* There is no check for correctness.
* The current implementation at wait time uses "heavy" operations
of task switch.
 
======================================================================
====== Function 68, subfunction 15 - set FPU exception handler. ======
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 15 - subfunction number
* ecx = address of the new exception handler
Returned value:
* eax = address of the old exception handler (0, if it was not set)
 
======================================================================
============= Function 68, subfunction 16 - load driver. =============
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 16 - subfunction number
* ecx = pointer to ASCIIZ-string with driver name
Returned value:
* eax = 0 - failed
* otherwise eax = driver handle
Remarks:
* If the driver was not loaded yet, it is loaded;
if the driver was loaded yet, nothing happens.
* Driver name is case-sensitive.
Maximum length of the name is 16 characters, including
terminating null character, the rest is ignored.
* The function can load only drivers which are registered in the
system; the current implementation contains
exactly 2 such drivers:
* name SOUND, file /rd/1/unisound.obj
* name INFINITY, file /rd/1/infinity.obj
 
======================================================================
============ Function 68, subfunction 17 - driver control. ===========
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 17 - subfunction number
* ecx = pointer to the control structure:
* +0: dword: handle of driver
* +4: dword: code of driver function
* +8: dword: pointer to input data
* +12 = +0xC: dword: size of input data
* +16 = +0x10: dword: pointer to output data
* +20 = +0x14: dword: size of output data
Returned value:
* eax = determined by driver
Remarks:
* Function codes and the structure of input/output data
are defined by driver.
* Previously one must obtain driver handle by subfunction 16.
 
======================================================================
====== Function 68, subfunction 18 - set SSE exception handler. ======
======================================================================
Parameters:
* eax = 68 - function number
* ebx = 15 - subfunction number
* ecx = address of the new exception handler
Returned value:
* eax = address of the old exception handler (0, if it was not set)
 
======================================================================
====================== Fucntion 69 - debugging. ======================
======================================================================
A process can load other process as debugged by set of corresponding
bit by call to subfunction 16 of function 58
or subfunction 7 of function 70.
bit by call to subfunction 7 of function 70.
A process can have only one debugger; one process can debug some
others. The system notifies debugger on events occuring with
debugged process. Messages are written to the buffer defined by
4041,6 → 4089,7
* subfunction 5 - get attributes of file/folder
* subfunction 6 - set attributes of file/folder
* subfunction 7 - start application
* subfunction 8 - delete file/folder
For CD-drives due to hardware limitations only subfunctions
0,1,5 and 7 are available, other subfunctions return error
with code 2.
4349,6 → 4398,31
the suspended state; to run use subfunction 5 of function 69.
 
======================================================================
========== Function 70, subfunction 8 - delete file/folder. ==========
======================================================================
Parameters:
* eax = 70 - function number
* ebx = pointer to the information structure
Format of the information structure:
* +0: dword: 8 = subfunction number
* +4: dword: 0 (reserved)
* +8: dword: 0 (reserved)
* +12 = +0xC: dword: 0 (reserved)
* +16 = +0x10: dword: 0 (reserved)
* +20 = +0x14: ASCIIZ-name of file, the rules of names forming are
given in the general description
or
* +20 = +0x14: db 0
* +21 = +0x15: dd pointer to ASCIIZ-string with file name
Returned value:
* eax = 0 - success, otherwise file system error code
* ebx destroyed
Remarks:
* The function is not supported for CD (returns error code 2).
* The function can delete only empty folders (attempt to delete
nonempty folder results in error with code 10, "access denied").
 
======================================================================
========== Function 71, subfunction 1 - set window caption. ==========
======================================================================
Parameters:
/programs/fs/copy2/trunk/copy2.asm
1,4 → 1,7
; project name: SYSTREE FILE COPIER
; version: 1.2
; Mario79 23/10/06
;
; version: 1.1b
; last update: 18/07/2004
; compiler: FASM 1.52
7,6 → 10,7
; copying-policy: GPL
 
; History:
; 23/10/06 application use function 70
; 18/07/2004 strings using "lsz" macro + french language (not 100%!)
; 04/06/2004 Bugfix for memory - thanks to Ville
; ...
18,7 → 22,7
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd 0x20201 ; memory for app
dd 0x10000 ; memory for app
dd 0x10000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
 
69,11 → 73,11
jnz still
 
srcbtn:
mov [addr],dword source
mov [addr],dword source_info.name ;source
mov [ya],dword 36
jmp rk
dstbtn:
mov [addr],dword destination
mov [addr],dword dest_info.name ;destination
mov [ya],dword 36+16
 
rk:
150,32 → 154,18
;====================================================
copy_file:
; at first we must get the size of the source file
mov [source_info.blocks],1 ; load only 512 bytes
mov eax,58
mov ebx,source_info
int 0x40
mcall 70, get_param_info
 
; now eax contains error code
; and ebx contains file size in bytes
test eax,eax ; check if eax is equal to zero (success)
je .ok_getsize ; eax = 0 => continue
cmp eax,6
jna @f
mov eax,7 ; if error code is above 6, it will be 7
@@:
cmp eax,5 ; file might be copied successfully altrough
; the system reports an error 5
jne copy_error ; print error code now
.ok_getsize:
 
; allocate memory
push ebx ; save file size
mov ecx,ebx
add ecx,0x20000 ; size of memory needed = 0x20000+filesize
mov ecx,[param_info+32] ;ebx
add ecx,0x10000 ; size of memory needed = 0x10000+filesize
mov eax,64 ; func 64
mov ebx,1 ; resize application memory
int 0x40
pop ebx ; restore filesize
 
; check if alloc function failed
test eax,eax ; non-zero value means error
184,36 → 174,29
jmp copy_error ; print error code now
.ok_memory:
 
; save number of blocks to source_info
add ebx,511
shr ebx,9 ; round up to 512 boundary
mov [source_info.blocks],ebx
; read the source file
mov eax,58
mov ebx,source_info
int 0x40
; save size to source_info
mov ebx,[param_info+32]
mov [source_info.size],ebx ; read the source file
mcall 70,source_info
 
; ebx = file size
; now eax contains error code
test eax,eax ; check if eax is equal to zero (success)
jne copy_error ; print error code now
 
; file size in bytes
mov [dest_info.size],ebx
 
; save loaded file
mov [dest_info.bytes2write],ebx ; file size in bytes
mov eax,58
mov ebx,dest_info
int 0x40
mcall 70,dest_info
 
; check if 58 function failed
; now eax contains error code
test eax,eax
je .ok_write
add eax,7 ; error number += 7
cmp eax,6+7
jna copy_error
mov eax,7+7
jmp copy_error
.ok_write:
jne copy_error
 
; return to the initial amount of memory
mov eax,64
mov ebx,1
mov ecx,0x20201
mov ecx,0x10000
int 0x40
 
xor eax,eax ; eax = message number (0-OK)
297,12 → 280,12
mov esi, 0xEBEBEB
int 0x40
 
mov esi, source
mov esi, source_info.name ;source
mov edi, text+14
mov ecx, STRLEN
rep movsb
 
mov esi, destination
mov esi, dest_info.name ;destination
mov edi, text+STRLEN+59-45+14
mov ecx, STRLEN
rep movsb
327,25 → 310,59
 
 
; DATA AREA
align 4
get_param_info:
.subfunction dd 5 ; 5 - get parameters of file
.start dd 0 ; rezerved
.size_high dd 0 ; rezerved
.size dd 0 ; rezerved
.return dd param_info
.name:
db 0
dd source_info.name
 
source_info: ; SOURCE FILEINFO
.mode dd 0 ; read file
.start_block dd 0x0 ; block to read
.blocks dd 0x700 ; num of blocks
.address dd 0x20000
.workarea dd 0x10000
source db '/HD/1/KERNEL/KERNEL.MNT',0
times (STRLEN-23) db 0
.subfunction dd 0 ; 0=READ
.start dd 0
.size_high dd 0
.size dd 0
.return dd 0x10000
.name:
db '/hd0/1/kernel/kernel.mnt',0 ; ASCIIZ dir & filename
times (STRLEN-24) db 0
 
dest_info: ; DESTINATION FILEINFO
.mode dd 1 ; write
.notused dd 0x0 ; not used
.bytes2write dd 0 ; bytes to write
.address dd 0x20000
.workarea dd 0x10000
destination db '/RD/1/KERNEL.MNT',0
.subfunction dd 2 ; 0=WRITE
.start dd 0
.size_high dd 0
.size dd 0
.return dd 0x10000
.name:
db '/rd/1/kernel.mnt',0 ; ASCIIZ dir & filename
times (STRLEN-16) db 0
 
param_info:
rb 40
 
 
;align 4
;source_info: ; SOURCE FILEINFO
; .mode dd 0 ; read file
; .start_block dd 0x0 ; block to read
; .blocks dd 0x700 ; num of blocks
; .address dd 0x20000
; .workarea dd 0x10000
; source db '/HD/1/KERNEL/KERNEL.MNT',0
; times (STRLEN-23) db 0
;
;dest_info: ; DESTINATION FILEINFO
; .mode dd 1 ; write
; .notused dd 0x0 ; not used
; .bytes2write dd 0 ; bytes to write
; .address dd 0x20000
; .workarea dd 0x10000
; destination db '/RD/1/KERNEL.MNT',0
; times (STRLEN-16) db 0
 
align 4
addr dd 0x0
ya dd 0x0