Introduced new header version, that to serve STDIO through a IPC sockets mechanism. Some code cleanup and comments added.

git-svn-id: svn://kolibrios.org@3240 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
johnfound 2013-02-11 19:09:43 +00:00
parent f88cc7c1af
commit 0d1c86e7bb
3 changed files with 152 additions and 62 deletions

View File

@ -31,6 +31,24 @@ struct APP_HEADER_01_
ends ends
hdrVersion1 = 1 ; it is the old version of the header, without console fields
hdrVersionConsole = 2 ; it is the new version of the header, containing 2 mode dword fields
struct APP_HEADER_02_
banner dq ? ; 'MENUET01'
version dd ? ;+8 ; == hdrVersionConsole
start dd ? ;+12
i_end dd ? ;+16
mem_size dd ? ;+20
stack_top dd ? ;+24
i_param dd ? ;+28
i_icon dd ? ;+32
stdio dd ?
stderr dd ?
ends
struct APP_PARAMS struct APP_PARAMS
app_cmdline dd ? ;0x00 app_cmdline dd ? ;0x00
app_path dd ? ;0x04 app_path dd ? ;0x04
@ -39,28 +57,31 @@ struct APP_PARAMS
app_mem dd ? ;0x10 app_mem dd ? ;0x10
ends ends
macro _clear_ op ; not needed
{ mov ecx, op/4 ;macro _clear_ op
xor eax, eax ;{ mov ecx, op/4
cld ; xor eax, eax
rep stosd ; cld
} ; rep stosd
;}
fs_execute_from_sysdir: fs_execute_from_sysdir:
xor ebx, ebx xor ebx, ebx ; command line arguments.
fs_execute_from_sysdir_param: fs_execute_from_sysdir_param:
xor edx, edx xor eax, eax ; no STDIO
xor ecx, ecx ; no STDERR
xor edx, edx ; flags (currently only debug flag).
mov esi, sysdir_path mov esi, sysdir_path
align 4 align 4
proc fs_execute proc fs_execute
; eax - STDIO handle
;fn_read:dword, file_size:dword, cluster:dword ; ecx - STDERR handle
; ebx - cmdline ; ebx - cmdline
; edx - flags ; edx - flags
; ebp - full filename ; ebp - full filename
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
locals locals
cmdline rd 64 ;256/4 cmdline rd 64 ;256/4
@ -80,22 +101,30 @@ proc fs_execute
hdr_esp dd ? ;0x0C hdr_esp dd ? ;0x0C
hdr_mem dd ? ;0x10 hdr_mem dd ? ;0x10
hdr_i_end dd ? ;0x14 hdr_i_end dd ? ;0x14
hdr_stdio dd ?
hdr_stderr dd ?
endl endl
pushad pushad
cmp [SCR_MODE], word 0x13 mov [hdr_stdio], eax
jbe @f mov [hdr_stderr], ecx
pushad
stdcall set_cursor, [def_cursor_clock] cmp [SCR_MODE], word 0x13
mov [handle], eax jbe @f
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer pushad
popad stdcall set_cursor, [def_cursor_clock]
@@: mov [handle], eax
mov [flags], edx mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
; [ebp] pointer to filename popad
@@:
mov [flags], edx
; [ebp] pointer to filename
lea edi, [filename] lea edi, [filename]
lea ecx, [edi+1024] lea ecx, [edi+1024]
@ -148,10 +177,28 @@ proc fs_execute
lea ebx, [hdr_cmdline] lea ebx, [hdr_cmdline]
call test_app_header call test_app_header
mov esi, -0x1F mov esi, -ERROR_INVALID_HEADER
test eax, eax test eax, eax
jz .err_hdr jz .err_hdr
; The header is OK, so check for the version and if == hdrVersionConsole, patch the header with
; the handles of the console IO socket handlers.
mov edx, [hdr_stdio]
mov ecx, [hdr_stderr]
cmp [eax+APP_HEADER_02_.version], hdrVersionConsole
jae .patch_header
or edx, ecx
jz .wait_lock
mov esi, -ERROR_WRONG_HEADER_VERSION
jmp .err_hdr
.patch_header:
mov [eax+APP_HEADER_02_.stdio], edx
mov [eax+APP_HEADER_02_.stderr], ecx
.wait_lock: .wait_lock:
cmp [application_table_status], 0 cmp [application_table_status], 0
je .get_lock je .get_lock
@ -168,7 +215,7 @@ proc fs_execute
call get_new_process_place call get_new_process_place
test eax, eax test eax, eax
mov esi, -0x20 ; too many processes mov esi, -ERROR_TOO_MANY_PROCESSES
jz .err jz .err
mov [slot], eax mov [slot], eax
@ -176,7 +223,12 @@ proc fs_execute
add eax, SLOT_BASE add eax, SLOT_BASE
mov [slot_base], eax mov [slot_base], eax
mov edi, eax mov edi, eax
_clear_ 256 ;clean extended information about process
;_clear_ 256 ;clean extended information about process
mov ecx, 256/4
xor eax, eax
cld
rep stosd
; write application name ; write application name
lea eax, [filename] lea eax, [filename]
@ -184,13 +236,13 @@ proc fs_execute
lea esi, [eax+1] lea esi, [eax+1]
test eax, eax test eax, eax
jnz @F jnz @F
lea esi, [filename] lea esi, [filename]
@@: @@:
mov ecx, 11 ; 11 chars for name! 8 - is old value! mov ecx, 11 ; 11 chars for name! 8 - is old value!
mov edi, [slot_base] mov edi, [slot_base]
.copy_process_name_loop: .copy_process_name_loop:
lodsb lodsb
cmp al, '.' cmp al, '.'
jz .copy_process_name_done jz .copy_process_name_done
test al, al test al, al
@ -203,7 +255,7 @@ proc fs_execute
mov [save_cr3], ebx mov [save_cr3], ebx
stdcall create_app_space, [hdr_mem], [file_base], [file_size] stdcall create_app_space, [hdr_mem], [file_base], [file_size]
mov esi, -30; no memory mov esi, -ERROR_MEMORY_NOT_ENOUGH ; no memory
test eax, eax test eax, eax
jz .failed jz .failed
@ -255,25 +307,26 @@ end if
.failed: .failed:
mov eax, [save_cr3] mov eax, [save_cr3]
call set_cr3 call set_cr3
.err: .err:
.err_hdr: .err_hdr:
stdcall kernel_free, [file_base] stdcall kernel_free, [file_base]
.err_file: .err_file:
xor eax, eax xor eax, eax
mov [application_table_status], eax mov [application_table_status], eax
mov eax, esi mov eax, esi
.final: .final:
cmp [SCR_MODE], word 0x13 cmp [SCR_MODE], word 0x13
jbe @f jbe @f
pushad pushad
stdcall set_cursor, [handle] stdcall set_cursor, [handle]
mov [redrawmouse_unconditional], 1 mov [redrawmouse_unconditional], 1
call __sys_draw_pointer call __sys_draw_pointer
popad popad
@@: @@:
ret ret
endp endp
align 4 align 4
test_app_header: test_app_header:
virtual at eax virtual at eax

View File

@ -21,9 +21,39 @@ ERROR_FS_FAIL = 9
ERROR_ACCESS_DENIED = 10 ERROR_ACCESS_DENIED = 10
ERROR_DEVICE = 11 ERROR_DEVICE = 11
; Errors specific to fn.70.7 - program start
ERROR_MEMORY_NOT_ENOUGH = 30
ERROR_INVALID_HEADER = 31
ERROR_TOO_MANY_PROCESSES = 32
ERROR_WRONG_HEADER_VERSION = 33 ; the version of the header is lower than needed for specific feature.
image_of_eax EQU esp+32 image_of_eax EQU esp+32
image_of_ebx EQU esp+20 image_of_ebx EQU esp+20
struc FileInfoBlock {
.sub_fn dd ?
.offset dd ?
.flags dd ?
.size dd ?
.ptr_buff dd ?
.filename rb 1
.pFilename dd ?
; variants
label .execFlags dword at .offset
label .execPtrArg dword at .flags
label .execStdIO dword at .size
label .execStdErr dword at .ptr_buff
}
virtual at 0
FileInfoBlock FileInfoBlock
end virtual
; System function 70 - files with long names (LFN) ; System function 70 - files with long names (LFN)
; diamond, 2006 ; diamond, 2006
@ -103,6 +133,8 @@ fs_additional_handlers:
dd 0 dd 0
endg endg
file_system_lfn: file_system_lfn:
; in: ebx->fileinfo block ; in: ebx->fileinfo block
; operation codes: ; operation codes:
@ -118,11 +150,11 @@ file_system_lfn:
; 9 : create directory ; 9 : create directory
; parse file name ; parse file name
lea esi, [ebx+20] lea esi, [ebx+FileInfoBlock.filename]
lodsb lodsb
test al, al test al, al
jnz @f jnz @f
mov esi, [esi] mov esi, [esi] ; FileInfoBlock.pFilename actually.
lodsb lodsb
@@: @@:
cmp al, '/' cmp al, '/'
@ -142,13 +174,18 @@ file_system_lfn:
call process_replace_file_name call process_replace_file_name
.parse_normal: .parse_normal:
cmp dword [ebx], 7 cmp dword [ebx], 7
jne @F jne .not_execute
mov edx, [ebx+4]
mov ebx, [ebx+8] mov eax, [ebx+FileInfoBlock.execStdIO] ; or NULL if not needed.
call fs_execute; esi+ebp, ebx, edx mov ecx, [ebx+FileInfoBlock.execStdErr] ; or NULL if not needed.
mov edx, [ebx+FileInfoBlock.execFlags] ; now only debug flag
mov ebx, [ebx+FileInfoBlock.execPtrArg] ; pointer to string with command line arguments.
call fs_execute ; esi+ebp, ebx, edx
mov [image_of_eax], eax mov [image_of_eax], eax
ret ret
@@:
.not_execute:
mov edi, rootdirs-8 mov edi, rootdirs-8
xor ecx, ecx xor ecx, ecx
push esi push esi
@ -181,8 +218,8 @@ file_system_lfn:
cmp dword [ebx], 1 cmp dword [ebx], 1
jnz .access_denied jnz .access_denied
xor eax, eax xor eax, eax
mov ebp, [ebx+12] ;количество блоков для считывания mov ebp, [ebx+12] ; block count to be read.
mov edx, [ebx+16] ;куда записывать рузельтат mov edx, [ebx+16] ; where to write the result.
; add edx, std_application_base_address ; add edx, std_application_base_address
push dword [ebx+4] ; first block push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags mov ebx, [ebx+8] ; flags

View File

@ -77,7 +77,7 @@ $Revision $
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
; Enabling the next line will enable serial output console ; Enabling the next line will enable serial output console
;debug_com_base equ 0x2f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
include "proc32.inc" include "proc32.inc"
include "kglobals.inc" include "kglobals.inc"
@ -414,7 +414,7 @@ high_code:
call calculate_fast_getting_offset_for_WinMapAddress call calculate_fast_getting_offset_for_WinMapAddress
; for Qemu or non standart video cards ; for Qemu or non standart video cards
; Unfortunately [BytesPerScanLine] does not always ; Unfortunately [BytesPerScanLine] does not always
; equal to [_display.width] * [ScreenBPP] / 8 ; equal to [_display.width] * [ScreenBPP] / 8
call calculate_fast_getting_offset_for_LFB call calculate_fast_getting_offset_for_LFB