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
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
app_cmdline dd ? ;0x00
app_path dd ? ;0x04
@ -39,28 +57,31 @@ struct APP_PARAMS
app_mem dd ? ;0x10
ends
macro _clear_ op
{ mov ecx, op/4
xor eax, eax
cld
rep stosd
}
; not needed
;macro _clear_ op
;{ mov ecx, op/4
; xor eax, eax
; cld
; rep stosd
;}
fs_execute_from_sysdir:
xor ebx, ebx
xor ebx, ebx ; command line arguments.
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
align 4
proc fs_execute
;fn_read:dword, file_size:dword, cluster:dword
; eax - STDIO handle
; ecx - STDERR handle
; ebx - cmdline
; edx - flags
; ebp - full filename
; [esp+4] = procedure DoRead, [esp+8] = filesize & [esp+12]... - arguments for it
locals
cmdline rd 64 ;256/4
@ -80,22 +101,30 @@ proc fs_execute
hdr_esp dd ? ;0x0C
hdr_mem dd ? ;0x10
hdr_i_end dd ? ;0x14
hdr_stdio dd ?
hdr_stderr dd ?
endl
pushad
cmp [SCR_MODE], word 0x13
jbe @f
pushad
stdcall set_cursor, [def_cursor_clock]
mov [handle], eax
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
popad
@@:
mov [flags], edx
; [ebp] pointer to filename
pushad
mov [hdr_stdio], eax
mov [hdr_stderr], ecx
cmp [SCR_MODE], word 0x13
jbe @f
pushad
stdcall set_cursor, [def_cursor_clock]
mov [handle], eax
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
popad
@@:
mov [flags], edx
; [ebp] pointer to filename
lea edi, [filename]
lea ecx, [edi+1024]
@ -148,10 +177,28 @@ proc fs_execute
lea ebx, [hdr_cmdline]
call test_app_header
mov esi, -0x1F
mov esi, -ERROR_INVALID_HEADER
test eax, eax
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:
cmp [application_table_status], 0
je .get_lock
@ -168,7 +215,7 @@ proc fs_execute
call get_new_process_place
test eax, eax
mov esi, -0x20 ; too many processes
mov esi, -ERROR_TOO_MANY_PROCESSES
jz .err
mov [slot], eax
@ -176,7 +223,12 @@ proc fs_execute
add eax, SLOT_BASE
mov [slot_base], 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
lea eax, [filename]
@ -184,13 +236,13 @@ proc fs_execute
lea esi, [eax+1]
test eax, eax
jnz @F
lea esi, [filename]
@@:
mov ecx, 11 ; 11 chars for name! 8 - is old value!
mov edi, [slot_base]
.copy_process_name_loop:
lodsb
jnz @F
lea esi, [filename]
@@:
mov ecx, 11 ; 11 chars for name! 8 - is old value!
mov edi, [slot_base]
.copy_process_name_loop:
lodsb
cmp al, '.'
jz .copy_process_name_done
test al, al
@ -203,7 +255,7 @@ proc fs_execute
mov [save_cr3], ebx
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
jz .failed
@ -255,25 +307,26 @@ end if
.failed:
mov eax, [save_cr3]
call set_cr3
.err:
.err_hdr:
stdcall kernel_free, [file_base]
.err_file:
xor eax, eax
mov [application_table_status], eax
mov eax, esi
.final:
cmp [SCR_MODE], word 0x13
jbe @f
pushad
stdcall set_cursor, [handle]
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
popad
@@:
ret
endp
mov [application_table_status], eax
mov eax, esi
.final:
cmp [SCR_MODE], word 0x13
jbe @f
pushad
stdcall set_cursor, [handle]
mov [redrawmouse_unconditional], 1
call __sys_draw_pointer
popad
@@:
ret
endp
align 4
test_app_header:
virtual at eax

View File

@ -21,9 +21,39 @@ ERROR_FS_FAIL = 9
ERROR_ACCESS_DENIED = 10
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_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)
; diamond, 2006
@ -103,6 +133,8 @@ fs_additional_handlers:
dd 0
endg
file_system_lfn:
; in: ebx->fileinfo block
; operation codes:
@ -118,11 +150,11 @@ file_system_lfn:
; 9 : create directory
; parse file name
lea esi, [ebx+20]
lea esi, [ebx+FileInfoBlock.filename]
lodsb
test al, al
jnz @f
mov esi, [esi]
mov esi, [esi] ; FileInfoBlock.pFilename actually.
lodsb
@@:
cmp al, '/'
@ -142,13 +174,18 @@ file_system_lfn:
call process_replace_file_name
.parse_normal:
cmp dword [ebx], 7
jne @F
mov edx, [ebx+4]
mov ebx, [ebx+8]
call fs_execute; esi+ebp, ebx, edx
jne .not_execute
mov eax, [ebx+FileInfoBlock.execStdIO] ; or NULL if not needed.
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
ret
@@:
.not_execute:
mov edi, rootdirs-8
xor ecx, ecx
push esi
@ -181,8 +218,8 @@ file_system_lfn:
cmp dword [ebx], 1
jnz .access_denied
xor eax, eax
mov ebp, [ebx+12] ;количество блоков для считывания
mov edx, [ebx+16] ;куда записывать рузельтат
mov ebp, [ebx+12] ; block count to be read.
mov edx, [ebx+16] ; where to write the result.
; add edx, std_application_base_address
push dword [ebx+4] ; first block
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
; 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 "kglobals.inc"
@ -414,7 +414,7 @@ high_code:
call calculate_fast_getting_offset_for_WinMapAddress
; for Qemu or non standart video cards
; Unfortunately [BytesPerScanLine] does not always
; Unfortunately [BytesPerScanLine] does not always
; equal to [_display.width] * [ScreenBPP] / 8
call calculate_fast_getting_offset_for_LFB