* COPY2 rewritten to function 70 by Mario79.

* Updated english documentation.

git-svn-id: svn://kolibrios.org@193 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2006-10-24 14:39:29 +00:00
parent be5ccc0bc1
commit 1668ac9032
2 changed files with 229 additions and 138 deletions

View File

@ -379,7 +379,7 @@ Remarks:
to subfunction 4 of function 18). to subfunction 4 of function 18).
* Beginning from slot 2, the normal applications are placed. * Beginning from slot 2, the normal applications are placed.
* The normal applications are placed in memory at the address * 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. There is no intersection, as each process has its own page table.
* At creation of the thread it is assigned the slot * At creation of the thread it is assigned the slot
in the system table and identifier (Process/Thread IDentifier = in the system table and identifier (Process/Thread IDentifier =
@ -874,8 +874,8 @@ Structure of the buffer:
db a,b,c,d for version a.b.c.d 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 UID_xxx: one of UID_NONE=0, UID_MENUET=1, UID_KOLIBRI=2
db 'name',0 - ASCIIZ-string with the name db 'name',0 - ASCIIZ-string with the name
For Kolibri 0.6.0.0 kernel: For Kolibri 0.5.8.1 kernel:
db 0,6,0,0 db 0,5,8,1
db 2 db 2
db 'Kolibri',0 db 'Kolibri',0
@ -1000,6 +1000,30 @@ Remarks:
and check that the value of position is inside the limits of the and check that the value of position is inside the limits of the
screen. 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. =================== ==================== Function 20 - MIDI interface. ===================
====================================================================== ======================================================================
@ -2874,7 +2898,6 @@ Examples:
Existing subfunctions: Existing subfunctions:
* subfunction 0 - read file/folder * subfunction 0 - read file/folder
* subfunction 1 - rewrite file * subfunction 1 - rewrite file
* subfunction 2 - delete file/folder
* subfunction 4 - make folder * subfunction 4 - make folder
* subfunction 5 - rename/move file/folder * subfunction 5 - rename/move file/folder
* subfunction 8 - LBA-read from device * subfunction 8 - LBA-read from device
@ -2965,30 +2988,6 @@ Returned value:
Remarks: Remarks:
* This function is obsolete, use subfunction 2 of function 70. * 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. ============= ============== Function 58, subfunction 4 - make folder. =============
====================================================================== ======================================================================
@ -3458,8 +3457,11 @@ Returned value:
* eax = 0 - success * eax = 0 - success
* eax = 1 - not enough memory * eax = 1 - not enough memory
Remarks: Remarks:
* At the moment this function is a sole resource for dynamic * There is another way to dynamically allocate/free memory -
allocation/free of application 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. ================= ================== Function 66 - work with keyboard. =================
@ -3666,87 +3668,133 @@ Returned value:
kill the thread. kill the thread.
====================================================================== ======================================================================
======= Function 68, subfunction 5 - allocate physical memory. ======= ======= Function 68, subfunction 11 - initialize process heap. =======
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 68 - function number * eax = 68 - function number
* ebx = 5 - subfunction number * ebx = 11 - subfunction number
* ecx = size (in bytes)
Returned value: Returned value:
* eax = physical address of allocated memory * eax = 0 - failed
* otherwise size of created heap
Remarks: Remarks:
* Normal applications must not use this function, it is intended * The function call initializes heap, from which one can in future
for the case, when for some device it is required to place allocate and free memory blocks with subfunctions 12 and 13.
data to the known physical address. (In effect, this function Heap size is equal to total amount of free application memory.
was developed for AC97WAV.) * The second function call from the same process results in
* The number of blocks of physical memory is limited (by constant returning the size of the existing heap.
24, and this constant includes some blocks for kernel). * After creation of the heap calls to function 64 will be ignored.
* To free a memory allocated by such way use
subfunction 6, to copy data there and back
use subfunctions 7 and 8.
====================================================================== ======================================================================
========= Function 68, subfunction 6 - free physical memory. ========= ======== Function 68, subfunction 12 - allocate memory block. ========
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 68 - function number * eax = 68 - function number
* ebx = 6 - subfunction number * ebx = 12 - subfunction number
* ecx = physical address of memory * ecx = required size in bytes
Returned value: Returned value:
* function does not return value * eax = pointer to the allocated block
Remarks: Remarks:
* Normal applications must not use this function, it is intended * Before this call one must initialize process heap by call to
for the case, when for some device it is required to place subfunction 11.
data to the known physical address. (In effect, this function * The function allocates an integer number of pages (4 Kb) in such
was developed for AC97WAV.) way that the real size of allocated block is more than or equal to
* The memory must be previously allocated by subfunction 5. requested size.
====================================================================== ======================================================================
===== Function 68, subfunction 7 - write data to physical memory. ==== ========== Function 68, subfunction 13 - free memory block. ==========
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 68 - function number * eax = 68 - function number
* ebx = 7 - subfunction number * ebx = 13 - subfunction number
* ecx = physical address * ecx = pointer to the memory block
* edx = pointer to the data (in the application)
* esi = size of the data (in bytes)
Returned value: Returned value:
* function does not return value * eax = 1 - success
* eax = 0 - failed
Remarks: Remarks:
* Normal applications must not use this function, it is intended * The memory block must have been allocated by subfunction 12.
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.
====================================================================== ======================================================================
==== Function 68, subfunction 8 - read data from physical memory. ==== ======== Function 68, subfunction 14 - wait for driver notify. =======
====================================================================== ======================================================================
Parameters: Parameters:
* eax = 68 - function number * eax = 68 - function number
* ebx = 8 - subfunction number * ebx = 14 - subfunction number
* ecx = physical address * ecx = pointer to the buffer for information (8 bytes)
* edx = pointer to buffer for data (in application)
* esi = size of data (in bytes)
Returned value: 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: Remarks:
* Normal applications must not use this function, it is intended * The current implementation at wait time uses "heavy" operations
for the case, when for some device it is required to place of task switch.
data to the known physical address. (In effect, this function
was developed for AC97WAV.) ======================================================================
* The range of physical addresses should lie inside of previously ====== Function 68, subfunction 15 - set FPU exception handler. ======
allocated by subfunction 5 block of physical memory. ======================================================================
* There is no check for correctness. 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. ====================== ====================== Fucntion 69 - debugging. ======================
====================================================================== ======================================================================
A process can load other process as debugged by set of corresponding A process can load other process as debugged by set of corresponding
bit by call to subfunction 16 of function 58 bit by call to subfunction 7 of function 70.
or subfunction 7 of function 70.
A process can have only one debugger; one process can debug some A process can have only one debugger; one process can debug some
others. The system notifies debugger on events occuring with others. The system notifies debugger on events occuring with
debugged process. Messages are written to the buffer defined by debugged process. Messages are written to the buffer defined by
@ -4041,6 +4089,7 @@ Available subfunctions:
* subfunction 5 - get attributes of file/folder * subfunction 5 - get attributes of file/folder
* subfunction 6 - set attributes of file/folder * subfunction 6 - set attributes of file/folder
* subfunction 7 - start application * subfunction 7 - start application
* subfunction 8 - delete file/folder
For CD-drives due to hardware limitations only subfunctions For CD-drives due to hardware limitations only subfunctions
0,1,5 and 7 are available, other subfunctions return error 0,1,5 and 7 are available, other subfunctions return error
with code 2. with code 2.
@ -4348,6 +4397,31 @@ Remarks:
* If the process is started as debugged, it is created in * If the process is started as debugged, it is created in
the suspended state; to run use subfunction 5 of function 69. 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. ========== ========== Function 71, subfunction 1 - set window caption. ==========
====================================================================== ======================================================================

View File

@ -1,4 +1,7 @@
; project name: SYSTREE FILE COPIER ; project name: SYSTREE FILE COPIER
; version: 1.2
; Mario79 23/10/06
;
; version: 1.1b ; version: 1.1b
; last update: 18/07/2004 ; last update: 18/07/2004
; compiler: FASM 1.52 ; compiler: FASM 1.52
@ -7,6 +10,7 @@
; copying-policy: GPL ; copying-policy: GPL
; History: ; History:
; 23/10/06 application use function 70
; 18/07/2004 strings using "lsz" macro + french language (not 100%!) ; 18/07/2004 strings using "lsz" macro + french language (not 100%!)
; 04/06/2004 Bugfix for memory - thanks to Ville ; 04/06/2004 Bugfix for memory - thanks to Ville
; ... ; ...
@ -18,7 +22,7 @@
dd 0x01 ; header version dd 0x01 ; header version
dd START ; start of code dd START ; start of code
dd I_END ; size of image dd I_END ; size of image
dd 0x20201 ; memory for app dd 0x10000 ; memory for app
dd 0x10000 ; esp dd 0x10000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 , 0x0 ; I_Param , I_Icon
@ -69,11 +73,11 @@ still: ; main cycle of application begins here
jnz still jnz still
srcbtn: srcbtn:
mov [addr],dword source mov [addr],dword source_info.name ;source
mov [ya],dword 36 mov [ya],dword 36
jmp rk jmp rk
dstbtn: dstbtn:
mov [addr],dword destination mov [addr],dword dest_info.name ;destination
mov [ya],dword 36+16 mov [ya],dword 36+16
rk: rk:
@ -150,32 +154,18 @@ still: ; main cycle of application begins here
;==================================================== ;====================================================
copy_file: copy_file:
; at first we must get the size of the source file ; at first we must get the size of the source file
mov [source_info.blocks],1 ; load only 512 bytes mcall 70, get_param_info
mov eax,58
mov ebx,source_info
int 0x40
; now eax contains error code ; now eax contains error code
; and ebx contains file size in bytes
test eax,eax ; check if eax is equal to zero (success) 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 jne copy_error ; print error code now
.ok_getsize:
; allocate memory ; allocate memory
push ebx ; save file size mov ecx,[param_info+32] ;ebx
mov ecx,ebx add ecx,0x10000 ; size of memory needed = 0x10000+filesize
add ecx,0x20000 ; size of memory needed = 0x20000+filesize
mov eax,64 ; func 64 mov eax,64 ; func 64
mov ebx,1 ; resize application memory mov ebx,1 ; resize application memory
int 0x40 int 0x40
pop ebx ; restore filesize
; check if alloc function failed ; check if alloc function failed
test eax,eax ; non-zero value means error test eax,eax ; non-zero value means error
@ -184,36 +174,29 @@ copy_file:
jmp copy_error ; print error code now jmp copy_error ; print error code now
.ok_memory: .ok_memory:
; save number of blocks to source_info ; save size to source_info
add ebx,511 mov ebx,[param_info+32]
shr ebx,9 ; round up to 512 boundary mov [source_info.size],ebx ; read the source file
mov [source_info.blocks],ebx mcall 70,source_info
; read the source file
mov eax,58 ; now eax contains error code
mov ebx,source_info test eax,eax ; check if eax is equal to zero (success)
int 0x40 jne copy_error ; print error code now
; file size in bytes
mov [dest_info.size],ebx
; ebx = file size
; save loaded file ; save loaded file
mov [dest_info.bytes2write],ebx ; file size in bytes mcall 70,dest_info
mov eax,58
mov ebx,dest_info
int 0x40
; check if 58 function failed ; now eax contains error code
test eax,eax test eax,eax
je .ok_write jne copy_error
add eax,7 ; error number += 7
cmp eax,6+7
jna copy_error
mov eax,7+7
jmp copy_error
.ok_write:
; return to the initial amount of memory ; return to the initial amount of memory
mov eax,64 mov eax,64
mov ebx,1 mov ebx,1
mov ecx,0x20201 mov ecx,0x10000
int 0x40 int 0x40
xor eax,eax ; eax = message number (0-OK) xor eax,eax ; eax = message number (0-OK)
@ -297,12 +280,12 @@ draw_window:
mov esi, 0xEBEBEB mov esi, 0xEBEBEB
int 0x40 int 0x40
mov esi, source mov esi, source_info.name ;source
mov edi, text+14 mov edi, text+14
mov ecx, STRLEN mov ecx, STRLEN
rep movsb rep movsb
mov esi, destination mov esi, dest_info.name ;destination
mov edi, text+STRLEN+59-45+14 mov edi, text+STRLEN+59-45+14
mov ecx, STRLEN mov ecx, STRLEN
rep movsb rep movsb
@ -327,25 +310,59 @@ draw_window:
; DATA AREA ; 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 source_info: ; SOURCE FILEINFO
.mode dd 0 ; read file .subfunction dd 0 ; 0=READ
.start_block dd 0x0 ; block to read .start dd 0
.blocks dd 0x700 ; num of blocks .size_high dd 0
.address dd 0x20000 .size dd 0
.workarea dd 0x10000 .return dd 0x10000
source db '/HD/1/KERNEL/KERNEL.MNT',0 .name:
times (STRLEN-23) db 0 db '/hd0/1/kernel/kernel.mnt',0 ; ASCIIZ dir & filename
times (STRLEN-24) db 0
dest_info: ; DESTINATION FILEINFO dest_info: ; DESTINATION FILEINFO
.mode dd 1 ; write .subfunction dd 2 ; 0=WRITE
.notused dd 0x0 ; not used .start dd 0
.bytes2write dd 0 ; bytes to write .size_high dd 0
.address dd 0x20000 .size dd 0
.workarea dd 0x10000 .return dd 0x10000
destination db '/RD/1/KERNEL.MNT',0 .name:
db '/rd/1/kernel.mnt',0 ; ASCIIZ dir & filename
times (STRLEN-16) db 0 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 align 4
addr dd 0x0 addr dd 0x0
ya dd 0x0 ya dd 0x0