Sync net branch with trunk

git-svn-id: svn://kolibrios.org@2385 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-02-23 19:01:26 +00:00
parent e7bade16fe
commit 33ab203c14
16 changed files with 1109 additions and 1282 deletions

View File

@ -888,14 +888,14 @@ bd_write_cache_chain:
.writeerr: .writeerr:
popa popa
mov [hd_error], 1 mov [hd_error], 1
jmp hd_write_error jmp hd_write_error
uglobal uglobal
int13_regs_in rb v86_regs.size int13_regs_in rb sizeof.v86_regs
int13_regs_out rb v86_regs.size int13_regs_out rb sizeof.v86_regs
endg endg
int13_call: int13_call:
; Because this code uses fixed addresses, ; Because this code uses fixed addresses,
; it can not be run simultaniously by many threads. ; it can not be run simultaniously by many threads.
; In current implementation it is protected by common mutex 'hd1_status' ; In current implementation it is protected by common mutex 'hd1_status'
@ -904,13 +904,13 @@ int13_call:
mov dword [OS_BASE + 514h], 9A000000h ; buffer 9A00:0000 mov dword [OS_BASE + 514h], 9A000000h ; buffer 9A00:0000
mov dword [OS_BASE + 518h], eax mov dword [OS_BASE + 518h], eax
and dword [OS_BASE + 51Ch], 0 and dword [OS_BASE + 51Ch], 0
push ebx ecx esi edi push ebx ecx esi edi
mov ebx, int13_regs_in mov ebx, int13_regs_in
mov edi, ebx mov edi, ebx
mov ecx, v86_regs.size/4 mov ecx, sizeof.v86_regs/4
xor eax, eax xor eax, eax
rep stosd rep stosd
mov byte [ebx+v86_regs.eax+1], dl mov byte [ebx+v86_regs.eax+1], dl
mov eax, [hdpos] mov eax, [hdpos]
lea eax, [BiosDisksData+(eax-80h)*4] lea eax, [BiosDisksData+(eax-80h)*4]
mov dl, [eax] mov dl, [eax]

View File

@ -176,14 +176,12 @@ struct TSS
_io rw 1 _io rw 1
rb 24 rb 24
_io_map_0 rb 4096 _io_map_0 rb 4096
_io_map_1 rb 4096 _io_map_1 rb 4096
ends ends
TSS_SIZE equ (128+8192) OS_BASE equ 0x80000000
OS_BASE equ 0x80000000 window_data equ (OS_BASE+0x0001000)
window_data equ (OS_BASE+0x0001000)
CURRENT_TASK equ (OS_BASE+0x0003000) CURRENT_TASK equ (OS_BASE+0x0003000)
TASK_COUNT equ (OS_BASE+0x0003004) TASK_COUNT equ (OS_BASE+0x0003004)
@ -394,384 +392,259 @@ EVENT_IPC equ 0x00000040
EVENT_NETWORK equ 0x00000080 EVENT_NETWORK equ 0x00000080
EVENT_DEBUG equ 0x00000100 EVENT_DEBUG equ 0x00000100
EVENT_EXTENDED equ 0x00000200 EVENT_EXTENDED equ 0x00000200
EV_INTR equ 1 EV_INTR equ 1
struc THR_DATA struct THR_DATA
{ rb (8192-512)
rb (8192-512) ; pl0_stack
.pl0_stack: fpu_state rb 512
.fpu_state rb 512 tls_page rb 4096
.tls_page rb 4096 pdbr rb 4096
.pdbr rb 4096 ends
}
virtual at (OS_BASE-sizeof.THR_DATA)
THR_DATA_SIZE equ 4096*4 thr_data THR_DATA
end virtual
virtual at (OS_BASE-THR_DATA_SIZE)
thr_data THR_DATA struct SYS_VARS
end virtual bpp dd ?
scanline dd ?
struc SYS_VARS vesa_mode dd ?
{ .bpp dd ? x_res dd ?
.scanline dd ? y_res dd ?
.vesa_mode dd ? ends
.x_res dd ?
.y_res dd ? struct APPOBJ ; common object header
} magic dd ? ;
destroy dd ? ; internal destructor
struc APPOBJ ;common object header fd dd ? ; next object in list
{ bk dd ? ; prev object in list
.magic dd ? ; pid dd ? ; owner id
.destroy dd ? ;internal destructor ends
.fd dd ? ;next object in list
.bk dd ? ;prev object in list APP_OBJ_OFFSET equ 48
.pid dd ? ;owner id APP_EV_OFFSET equ 40
};
struct CURSOR APPOBJ
virtual at 0 base dd ? ;allocated memory
APPOBJ APPOBJ hot_x dd ? ;hotspot coords
end virtual hot_y dd ?
APP_OBJ_OFFSET equ 48 list_next dd ? ;next cursor in cursor list
APP_EV_OFFSET equ 40 list_prev dd ? ;prev cursor in cursor list
dev_obj dd ? ;device depended data
struc CURSOR ends
{
;common object header
.magic dd ? ;'CURS' struct EVENT APPOBJ
.destroy dd ? ;internal destructor id dd ? ;event uid
.fd dd ? ;next object in list state dd ? ;internal flags
.bk dd ? ;prev object in list code dd ?
.pid dd ? ;owner id rd 5
ends
;cursor data
.base dd ? ;allocated memory
.hot_x dd ? ;hotspot coords struct SMEM
.hot_y dd ? bk dd ?
fd dd ? ;+4
.list_next dd ? ;next cursor in cursor list base dd ? ;+8
.list_prev dd ? ;prev cursor in cursor list size dd ? ;+12
.dev_obj dd ? ;device depended data access dd ? ;+16
refcount dd ? ;+20
.sizeof: name rb 32 ;+24
} ends
virtual at 0
CURSOR CURSOR struct SMAP APPOBJ
end virtual base dd ? ;mapped base
parent dd ? ;SMEM
ends
struc EVENT
{ struct DLLDESCR
.magic dd ? ;'EVNT' bk dd ?
.destroy dd ? ;internal destructor fd dd ? ;+4
.fd dd ? ;next object in list data dd ? ;+8
.bk dd ? ;prev object in list size dd ? ;+12
.pid dd ? ;owner id timestamp dq ?
refcount dd ?
.id dd ? ;event uid defaultbase dd ?
.state dd ? ;internal flags coff_hdr dd ?
.code dd ? symbols_ptr dd ?
rd 5 symbols_num dd ?
.size = $ - .magic symbols_lim dd ?
.codesize = $ - .code exports dd ? ;export table
} name rb 260
ends
virtual at 0
EVENT EVENT struct HDLL
end virtual fd dd ? ;next object in list
bk dd ? ;prev object in list
pid dd ? ;owner id
struc SMEM
{ base dd ? ;mapped base
.bk dd ? size dd ? ;mapped size
.fd dd ? ;+4 refcount dd ? ;reference counter for this process and this lib
.base dd ? ;+8 parent dd ? ;DLLDESCR
.size dd ? ;+12 ends
.access dd ? ;+16
.refcount dd ? ;+20 struct display_t
.name rb 32 ;+24 x dd ?
.sizeof: y dd ?
} width dd ?
height dd ?
struc SMAP bpp dd ?
{ vrefresh dd ?
.magic dd ? ; SMAP pitch dd ?
.destroy dd ? ;internal destructor lfb dd ?
.fd dd ? ;next object in list
.bk dd ? ;prev object in list modes dd ?
.pid dd ? ;owner id ddev dd ?
connector dd ?
.base dd ? ;mapped base crtc dd ?
.parent dd ? ;SMEM
.sizeof: cr_list.next dd ?
} cr_list.prev dd ?
virtual at 0 cursor dd ?
SMEM SMEM
end virtual init_cursor dd ?
select_cursor dd ?
virtual at 0 show_cursor dd ?
SMAP SMAP move_cursor dd ?
end virtual restore_cursor dd ?
disable_mouse dd ?
struc DLLDESCR ends
{
.bk dd ? struct BOOT_DATA
.fd dd ? ;+4 bpp dd ?
.data dd ? ;+8 scanline dd ?
.size dd ? ;+12 vesa_mode dd ?
.timestamp dq ? x_res dd ?
.refcount dd ? y_res dd ?
.defaultbase dd ? mouse_port dd ?
.coff_hdr dd ? bank_switch dd ?
.symbols_ptr dd ? lfb dd ?
.symbols_num dd ? vesa_mem dd ?
.symbols_lim dd ? log dd ?
.exports dd ? ;export table direct_lfb dd ?
.name: pci_data dd ?
.sizeof: dd ?
} vrr dd ?
ide_base dd ?
struc HDLL mem_amount dd ?
{ pages_count dd ?
.fd dd ? ;next object in list pagemap_size dd ?
.bk dd ? ;prev object in list kernel_max dd ?
.pid dd ? ;owner id kernel_pages dd ?
kernel_tables dd ?
.base dd ? ;mapped base
.size dd ? ;mapped size cpu_vendor dd ?
.refcount dd ? ;reference counter for this process and this lib dd ?
.parent dd ? ;DLLDESCR dd ?
.sizeof: cpu_sign dd ?
} cpu_info dd ?
cpu_caps dd ?
virtual at 0 dd ?
DLLDESCR DLLDESCR dd ?
end virtual ends
virtual at 0 struct LHEAD
HDLL HDLL next dd ? ;next object in list
end virtual prev dd ? ;prev object in list
ends
struc display_t
{ struct MUTEX
.x dd ? lhead LHEAD
.y dd ? count dd ?
.width dd ? ends
.height dd ?
.bpp dd ? struct MEM_STATE
.vrefresh dd ? mutex MUTEX
.pitch dd ? smallmap dd ?
.lfb dd ? treemap dd ?
topsize dd ?
.modes dd ? top dd ?
.ddev dd ? smallbins rd 4*32
.connector dd ? treebins rd 32
.crtc dd ? ends
.cr_list.next dd ? struct PG_DATA
.cr_list.prev dd ? mem_amount dd ?
vesa_mem dd ?
.cursor dd ? pages_count dd ?
pages_free dd ?
.init_cursor dd ? pages_faults dd ?
.select_cursor dd ? pagemap_size dd ?
.show_cursor dd ? kernel_pages dd ?
.move_cursor dd ? kernel_tables dd ?
.restore_cursor dd ? sys_page_dir dd ?
.disable_mouse dd ? mutex MUTEX
} ends
virtual at 0 struct SRV
display_t display_t srv_name rb 16 ;ASCIIZ string
end virtual magic dd ? ;+0x10 ;'SRV '
size dd ? ;+0x14 ;size of structure SRV
struc BOOT_DATA fd dd ? ;+0x18 ;next SRV descriptor
{ .bpp dd ? bk dd ? ;+0x1C ;prev SRV descriptor
.scanline dd ? base dd ? ;+0x20 ;service base address
.vesa_mode dd ? entry dd ? ;+0x24 ;service START function
.x_res dd ? srv_proc dd ? ;+0x28 ;user mode service handler
.y_res dd ? srv_proc_ex dd ? ;+0x2C ;kernel mode service handler
.mouse_port dd ? ends
.bank_switch dd ?
.lfb dd ? DRV_ENTRY equ 1
.vesa_mem dd ? DRV_EXIT equ -1
.log dd ?
.direct_lfb dd ? struct COFF_HEADER
.pci_data dd ? machine dw ?
; dd ? nSections dw ?
.vrr dd ? DataTime dd ?
.ide_base dd ? pSymTable dd ?
.mem_amount dd ? nSymbols dd ?
.pages_count dd ? optHeader dw ?
.pagemap_size dd ? flags dw ?
.kernel_max dd ? ends
.kernel_pages dd ?
.kernel_tables dd ? struct COFF_SECTION
Name rb 8
.cpu_vendor dd ? VirtualSize dd ?
dd ? VirtualAddress dd ?
dd ? SizeOfRawData dd ?
.cpu_sign dd ? PtrRawData dd ?
.cpu_info dd ? PtrReloc dd ?
.cpu_caps dd ? PtrLinenumbers dd ?
dd ? NumReloc dw ?
dd ? NumLinenum dw ?
} Characteristics dd ?
ends
virtual at 0
BOOT_DATA BOOT_DATA struct COFF_RELOC
end virtual VirtualAddress dd ?
SymIndex dd ?
struc MEM_STATE Type dw ?
{ .mutex MUTEX ends
.smallmap rd 1
.treemap rd 1 struct COFF_SYM
.topsize rd 1 Name rb 8
.top rd 1 Value dd ?
.smallbins rd 4*32 SectionNumber dw ?
.treebins rd 32 Type dw ?
} StorageClass db ?
NumAuxSymbols db ?
struc PG_DATA ends
{ .mem_amount dd ?
.vesa_mem dd ? struct IOCTL
.pages_count dd ? handle dd ?
.pages_free dd ? io_code dd ?
.pages_faults dd ? input dd ?
.pagemap_size dd ? inp_size dd ?
.kernel_pages dd ? output dd ?
.kernel_tables dd ? out_size dd ?
.sys_page_dir dd ? ends
.mutex MUTEX
} struct IRQH
list LHEAD
;struc LIB handler dd ? ;handler roututine
;{ .lib_name rb 16 data dd ? ;user-specific data
; .lib_base dd ? ends
; .lib_start dd ?
; .export dd ?
; .import dd ?
;}
struc SRV
{
.srv_name rb 16 ;ASCIIZ string
.magic dd ? ;+0x10 ;'SRV '
.size dd ? ;+0x14 ;size of structure SRV
.fd dd ? ;+0x18 ;next SRV descriptor
.bk dd ? ;+0x1C ;prev SRV descriptor
.base dd ? ;+0x20 ;service base address
.entry dd ? ;+0x24 ;service START function
.srv_proc dd ? ;+0x28 ;user mode service handler
.srv_proc_ex dd ? ;+0x2C ;kernel mode service handler
.sizeof:
}
SRV_FD_OFFSET equ 0x18
DRV_ENTRY equ 1
DRV_EXIT equ -1
struc COFF_HEADER
{ .machine dw ?
.nSections dw ?
.DataTime dd ?
.pSymTable dd ?
.nSymbols dd ?
.optHeader dw ?
.flags dw ?
};
struc COFF_SECTION
{ .Name rb 8
.VirtualSize dd ?
.VirtualAddress dd ?
.SizeOfRawData dd ?
.PtrRawData dd ?
.PtrReloc dd ?
.PtrLinenumbers dd ?
.NumReloc dw ?
.NumLinenum dw ?
.Characteristics dd ?
}
COFF_SECTION_SIZE equ 40
struc COFF_RELOC
{ .VirtualAddress dd ?
.SymIndex dd ?
.Type dw ?
}
struc COFF_SYM
{ .Name rb 8
.Value dd ?
.SectionNumber dw ?
.Type dw ?
.StorageClass db ?
.NumAuxSymbols db ?
}
CSYM_SIZE equ 18
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
;virtual at 0
; LIB LIB
;end virtual
virtual at 0
SRV SRV
end virtual
virtual at 0
CFH COFF_HEADER
end virtual
virtual at 0
CFS COFF_SECTION
end virtual
virtual at 0
CRELOC COFF_RELOC
end virtual
virtual at 0
CSYM COFF_SYM
end virtual
struc LHEAD
{
.next dd ? ;next object in list
.prev dd ? ;prev object in list
.sizeof:
}
virtual at 0
LHEAD LHEAD
end virtual
struc IRQH
{
.list LHEAD
.handler dd ? ;handler roututine
.data dd ? ;user-specific data
.sizeof:
}
virtual at 0
IRQH IRQH
end virtual

View File

@ -136,13 +136,13 @@ proc srv_handler stdcall, ioctl:dword
jz .err jz .err
mov edi, [esi+handle] mov edi, [esi+handle]
cmp [edi+SRV.magic], ' SRV' cmp [edi+SRV.magic], ' SRV'
jne .fail jne .fail
cmp [edi+SRV.size], SRV.sizeof cmp [edi+SRV.size], sizeof.SRV
jne .fail jne .fail
stdcall [edi+SRV.srv_proc], esi stdcall [edi+SRV.srv_proc], esi
ret ret
.fail: .fail:
xor eax, eax xor eax, eax
@ -168,13 +168,13 @@ srv_handlerEx:
jae .fail jae .fail
mov eax, [ecx+handle] mov eax, [ecx+handle]
cmp [eax+SRV.magic], ' SRV' cmp [eax+SRV.magic], ' SRV'
jne .fail jne .fail
cmp [eax+SRV.size], SRV.sizeof cmp [eax+SRV.size], sizeof.SRV
jne .fail jne .fail
stdcall [eax+SRV.srv_proc], ecx stdcall [eax+SRV.srv_proc], ecx
ret ret
.fail: .fail:
or eax, -1 or eax, -1
@ -193,13 +193,13 @@ proc get_service stdcall, sz_name:dword
test eax, eax test eax, eax
jnz @F jnz @F
ret ret
@@: @@:
mov edx, [srv.fd] mov edx, [srv.fd]
@@: @@:
cmp edx, srv.fd-SRV_FD_OFFSET cmp edx, srv.fd-SRV.fd
je .not_load je .not_load
stdcall strncmp, edx, [sz_name], 16 stdcall strncmp, edx, [sz_name], 16
test eax, eax test eax, eax
je .ok je .ok
@ -223,13 +223,13 @@ proc reg_service stdcall, name:dword, handler:dword
cmp [name], eax cmp [name], eax
je .fail je .fail
cmp [handler], eax cmp [handler], eax
je .fail je .fail
mov eax, SRV.sizeof mov eax, sizeof.SRV
call malloc call malloc
test eax, eax test eax, eax
jz .fail jz .fail
push esi push esi
push edi push edi
@ -240,15 +240,15 @@ proc reg_service stdcall, name:dword, handler:dword
movsd movsd
movsd movsd
pop edi pop edi
pop esi pop esi
mov [eax+SRV.magic], ' SRV' mov [eax+SRV.magic], ' SRV'
mov [eax+SRV.size], SRV.sizeof mov [eax+SRV.size], sizeof.SRV
mov ebx, srv.fd-SRV_FD_OFFSET mov ebx, srv.fd-SRV.fd
mov edx, [ebx+SRV.fd] mov edx, [ebx+SRV.fd]
mov [eax+SRV.fd], edx mov [eax+SRV.fd], edx
mov [eax+SRV.bk], ebx mov [eax+SRV.bk], ebx
mov [ebx+SRV.fd], eax mov [ebx+SRV.fd], eax
mov [edx+SRV.bk], eax mov [edx+SRV.bk], eax
@ -511,16 +511,16 @@ proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\
retval dd ? retval dd ?
endl endl
mov edi, [symbols] mov edi, [symbols]
mov [retval], 1 mov [retval], 1
.fix: .fix:
movzx ebx, [edi+CSYM.SectionNumber] movzx ebx, [edi+COFF_SYM.SectionNumber]
test ebx, ebx test ebx, ebx
jnz .internal jnz .internal
mov eax, dword [edi+CSYM.Name] mov eax, dword [edi+COFF_SYM.Name]
test eax, eax test eax, eax
jnz @F jnz @F
mov edi, [edi+4] mov edi, [edi+4]
add edi, [strings] add edi, [strings]
@@: @@:
@ -539,29 +539,29 @@ proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
mov [retval], 0 mov [retval], 0
@@: @@:
mov edi, [symbols] mov edi, [symbols]
mov [edi+CSYM.Value], eax mov [edi+COFF_SYM.Value], eax
jmp .next jmp .next
.internal: .internal:
cmp bx, -1 cmp bx, -1
je .next je .next
cmp bx, -2 cmp bx, -2
je .next je .next
dec ebx dec ebx
shl ebx, 3 shl ebx, 3
lea ebx, [ebx+ebx*4] lea ebx, [ebx+ebx*4]
add ebx, [sec] add ebx, [sec]
mov eax, [ebx+CFS.VirtualAddress] mov eax, [ebx+COFF_SECTION.VirtualAddress]
add [edi+CSYM.Value], eax add [edi+COFF_SYM.Value], eax
.next: .next:
add edi, CSYM_SIZE add edi, sizeof.COFF_SYM
mov [symbols], edi mov [symbols], edi
dec [sym_count] dec [sym_count]
jnz .fix jnz .fix
mov eax, [retval] mov eax, [retval]
ret ret
endp endp
@ -571,53 +571,53 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword delta:dword
locals locals
n_sec dd ? n_sec dd ?
endl endl
mov eax, [coff] mov eax, [coff]
movzx ebx, [eax+CFH.nSections] movzx ebx, [eax+COFF_HEADER.nSections]
mov [n_sec], ebx mov [n_sec], ebx
lea esi, [eax+20] lea esi, [eax+20]
.fix_sec: .fix_sec:
mov edi, [esi+CFS.PtrReloc] mov edi, [esi+COFF_SECTION.PtrReloc]
add edi, [coff] add edi, [coff]
movzx ecx, [esi+CFS.NumReloc] movzx ecx, [esi+COFF_SECTION.NumReloc]
test ecx, ecx test ecx, ecx
jz .next jz .next
.reloc_loop: .reloc_loop:
mov ebx, [edi+CRELOC.SymIndex] mov ebx, [edi+COFF_RELOC.SymIndex]
add ebx, ebx add ebx, ebx
lea ebx, [ebx+ebx*8] lea ebx, [ebx+ebx*8]
add ebx, [sym] add ebx, [sym]
mov edx, [ebx+CSYM.Value] mov edx, [ebx+COFF_SYM.Value]
cmp [edi+CRELOC.Type], 6 cmp [edi+COFF_RELOC.Type], 6
je .dir_32 je .dir_32
cmp [edi+CRELOC.Type], 20 cmp [edi+COFF_RELOC.Type], 20
jne .next_reloc jne .next_reloc
.rel_32: .rel_32:
mov eax, [edi+CRELOC.VirtualAddress] mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress] add eax, [esi+COFF_SECTION.VirtualAddress]
sub edx, eax sub edx, eax
sub edx, 4 sub edx, 4
jmp .fix jmp .fix
.dir_32: .dir_32:
mov eax, [edi+CRELOC.VirtualAddress] mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress] add eax, [esi+COFF_SECTION.VirtualAddress]
.fix: .fix:
add eax, [delta] add eax, [delta]
add [eax], edx add [eax], edx
.next_reloc: .next_reloc:
add edi, 10 add edi, 10
dec ecx dec ecx
jnz .reloc_loop jnz .reloc_loop
.next: .next:
add esi, COFF_SECTION_SIZE add esi, sizeof.COFF_SECTION
dec [n_sec] dec [n_sec]
jnz .fix_sec jnz .fix_sec
.exit: .exit:
ret ret
endp endp
@ -626,36 +626,36 @@ proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword delta:dword
locals locals
n_sec dd ? n_sec dd ?
endl endl
mov eax, [coff] mov eax, [coff]
movzx ebx, [eax+CFH.nSections] movzx ebx, [eax+COFF_HEADER.nSections]
mov [n_sec], ebx mov [n_sec], ebx
lea esi, [eax+20] lea esi, [eax+20]
mov edx, [delta] mov edx, [delta]
.fix_sec: .fix_sec:
mov edi, [esi+CFS.PtrReloc] mov edi, [esi+COFF_SECTION.PtrReloc]
add edi, [coff] add edi, [coff]
movzx ecx, [esi+CFS.NumReloc] movzx ecx, [esi+COFF_SECTION.NumReloc]
test ecx, ecx test ecx, ecx
jz .next jz .next
.reloc_loop: .reloc_loop:
cmp [edi+CRELOC.Type], 6 cmp [edi+COFF_RELOC.Type], 6
jne .next_reloc jne .next_reloc
.dir_32: .dir_32:
mov eax, [edi+CRELOC.VirtualAddress] mov eax, [edi+COFF_RELOC.VirtualAddress]
add eax, [esi+CFS.VirtualAddress] add eax, [esi+COFF_SECTION.VirtualAddress]
add [eax+edx], edx add [eax+edx], edx
.next_reloc: .next_reloc:
add edi, 10 add edi, 10
dec ecx dec ecx
jnz .reloc_loop jnz .reloc_loop
.next: .next:
add esi, COFF_SECTION_SIZE add esi, sizeof.COFF_SECTION
dec [n_sec] dec [n_sec]
jnz .fix_sec jnz .fix_sec
.exit: .exit:
ret ret
endp endp
@ -697,21 +697,21 @@ proc load_driver stdcall, driver_name:dword
test eax, eax test eax, eax
jz .exit jz .exit
mov [coff], eax mov [coff], eax
movzx ecx, [eax+CFH.nSections] movzx ecx, [eax+COFF_HEADER.nSections]
xor ebx, ebx xor ebx, ebx
lea edx, [eax+20] lea edx, [eax+20]
@@: @@:
add ebx, [edx+CFS.SizeOfRawData] add ebx, [edx+COFF_SECTION.SizeOfRawData]
add ebx, 15 add ebx, 15
and ebx, not 15 and ebx, not 15
add edx, COFF_SECTION_SIZE add edx, sizeof.COFF_SECTION
dec ecx dec ecx
jnz @B jnz @B
mov [img_size], ebx mov [img_size], ebx
stdcall kernel_alloc, ebx stdcall kernel_alloc, ebx
test eax, eax test eax, eax
@ -725,70 +725,70 @@ proc load_driver stdcall, driver_name:dword
and ecx, not 4095 and ecx, not 4095
shr ecx, 2 shr ecx, 2
cld cld
rep stosd rep stosd
mov edx, [coff] mov edx, [coff]
movzx ebx, [edx+CFH.nSections] movzx ebx, [edx+COFF_HEADER.nSections]
mov edi, [img_base] mov edi, [img_base]
lea eax, [edx+20] lea eax, [edx+20]
@@: @@:
mov [eax+CFS.VirtualAddress], edi mov [eax+COFF_SECTION.VirtualAddress], edi
mov esi, [eax+CFS.PtrRawData] mov esi, [eax+COFF_SECTION.PtrRawData]
test esi, esi test esi, esi
jnz .copy jnz .copy
add edi, [eax+CFS.SizeOfRawData] add edi, [eax+COFF_SECTION.SizeOfRawData]
jmp .next jmp .next
.copy: .copy:
add esi, edx add esi, edx
mov ecx, [eax+CFS.SizeOfRawData] mov ecx, [eax+COFF_SECTION.SizeOfRawData]
cld cld
rep movsb rep movsb
.next: .next:
add edi, 15 add edi, 15
and edi, not 15 and edi, not 15
add eax, COFF_SECTION_SIZE add eax, sizeof.COFF_SECTION
dec ebx dec ebx
jnz @B jnz @B
mov ebx, [edx+CFH.pSymTable] mov ebx, [edx+COFF_HEADER.pSymTable]
add ebx, edx add ebx, edx
mov [sym], ebx mov [sym], ebx
mov ecx, [edx+CFH.nSymbols] mov ecx, [edx+COFF_HEADER.nSymbols]
add ecx, ecx add ecx, ecx
lea ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE lea ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
add ecx, [sym] add ecx, [sym]
mov [strings], ecx mov [strings], ecx
lea ebx, [exports] lea ebx, [exports]
mov dword [ebx], kernel_export mov dword [ebx], kernel_export
mov dword [ebx+4], 0 mov dword [ebx+4], 0
lea eax, [edx+20] lea eax, [edx+20]
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols], \ stdcall fix_coff_symbols, eax, [sym], [edx+COFF_HEADER.nSymbols], \
[strings], ebx [strings], ebx
test eax, eax test eax, eax
jz .link_fail jz .link_fail
mov ebx, [coff]
stdcall fix_coff_relocs, ebx, [sym], 0
stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szVersion
test eax, eax
jz .link_fail
mov ebx, [coff]
stdcall fix_coff_relocs, ebx, [sym], 0
stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szVersion
test eax, eax
jz .link_fail
mov eax, [eax] mov eax, [eax]
shr eax, 16 shr eax, 16
cmp eax, DRV_COMPAT cmp eax, DRV_COMPAT
jb .ver_fail jb .ver_fail
cmp eax, DRV_CURRENT cmp eax, DRV_CURRENT
ja .ver_fail ja .ver_fail
mov ebx, [coff] mov ebx, [coff]
stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szSTART stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szSTART
mov [start], eax mov [start], eax
stdcall kernel_free, [coff] stdcall kernel_free, [coff]
mov ebx, [start] mov ebx, [start]
stdcall ebx, DRV_ENTRY stdcall ebx, DRV_ENTRY
@ -848,13 +848,13 @@ endp
coff_get_align: coff_get_align:
; Rules: ; Rules:
; - if alignment is not given, use default = 4K; ; - if alignment is not given, use default = 4K;
; - if alignment is given and is no more than 4K, use it; ; - if alignment is given and is no more than 4K, use it;
; - if alignment is more than 4K, revert to 4K. ; - if alignment is more than 4K, revert to 4K.
push ecx push ecx
mov cl, byte [edx+CFS.Characteristics+2] mov cl, byte [edx+COFF_SECTION.Characteristics+2]
mov eax, 1 mov eax, 1
shr cl, 4 shr cl, 4
dec cl dec cl
js .default js .default
cmp cl, 12 cmp cl, 12
jbe @f jbe @f
@ -952,13 +952,13 @@ proc load_library stdcall, file_name:dword
; allocate DLLDESCR struct; size is DLLDESCR.sizeof plus size of DLL name ; allocate DLLDESCR struct; size is DLLDESCR.sizeof plus size of DLL name
mov esi, edi mov esi, edi
mov ecx, -1 mov ecx, -1
xor eax, eax xor eax, eax
repnz scasb repnz scasb
not ecx not ecx
lea eax, [ecx+DLLDESCR.sizeof] lea eax, [ecx+sizeof.DLLDESCR]
push ecx push ecx
call malloc call malloc
pop ecx pop ecx
test eax, eax test eax, eax
jz .fail_and_free_coff jz .fail_and_free_coff
; save timestamp ; save timestamp
@ -976,23 +976,23 @@ proc load_library stdcall, file_name:dword
mov [dll_list.bk], esi mov [dll_list.bk], esi
mov [esi+DLLDESCR.bk], eax mov [esi+DLLDESCR.bk], eax
mov [eax+DLLDESCR.fd], esi mov [eax+DLLDESCR.fd], esi
; calculate size of loaded DLL ; calculate size of loaded DLL
mov edx, [coff] mov edx, [coff]
movzx ecx, [edx+CFH.nSections] movzx ecx, [edx+COFF_HEADER.nSections]
xor ebx, ebx xor ebx, ebx
add edx, 20 add edx, 20
@@: @@:
call coff_get_align call coff_get_align
add ebx, eax add ebx, eax
not eax not eax
and ebx, eax and ebx, eax
add ebx, [edx+CFS.SizeOfRawData] add ebx, [edx+COFF_SECTION.SizeOfRawData]
add edx, COFF_SECTION_SIZE add edx, sizeof.COFF_SECTION
dec ecx dec ecx
jnz @B jnz @B
; it must be nonzero and not too big ; it must be nonzero and not too big
mov [esi+DLLDESCR.size], ebx mov [esi+DLLDESCR.size], ebx
test ebx, ebx test ebx, ebx
jz .fail_and_free_dll jz .fail_and_free_dll
@ -1016,108 +1016,108 @@ proc load_library stdcall, file_name:dword
mov [esi+DLLDESCR.defaultbase], ecx mov [esi+DLLDESCR.defaultbase], ecx
mov [dll_cur_addr], edx mov [dll_cur_addr], edx
; copy sections and set correct values for VirtualAddress'es in headers ; copy sections and set correct values for VirtualAddress'es in headers
push esi push esi
mov edx, [coff] mov edx, [coff]
movzx ebx, [edx+CFH.nSections] movzx ebx, [edx+COFF_HEADER.nSections]
mov edi, eax mov edi, eax
add edx, 20 add edx, 20
cld cld
@@: @@:
call coff_get_align call coff_get_align
add ecx, eax add ecx, eax
add edi, eax add edi, eax
not eax not eax
and ecx, eax and ecx, eax
and edi, eax and edi, eax
mov [edx+CFS.VirtualAddress], ecx mov [edx+COFF_SECTION.VirtualAddress], ecx
add ecx, [edx+CFS.SizeOfRawData] add ecx, [edx+COFF_SECTION.SizeOfRawData]
mov esi, [edx+CFS.PtrRawData] mov esi, [edx+COFF_SECTION.PtrRawData]
push ecx push ecx
mov ecx, [edx+CFS.SizeOfRawData] mov ecx, [edx+COFF_SECTION.SizeOfRawData]
test esi, esi test esi, esi
jnz .copy jnz .copy
xor eax, eax xor eax, eax
rep stosb rep stosb
jmp .next jmp .next
.copy: .copy:
add esi, [coff] add esi, [coff]
rep movsb rep movsb
.next: .next:
pop ecx pop ecx
add edx, COFF_SECTION_SIZE add edx, sizeof.COFF_SECTION
dec ebx dec ebx
jnz @B jnz @B
pop esi pop esi
; save some additional data from COFF file ; save some additional data from COFF file
; later we will use COFF header, headers for sections and symbol table ; later we will use COFF header, headers for sections and symbol table
; and also relocations table for all sections ; and also relocations table for all sections
mov edx, [coff] mov edx, [coff]
mov ebx, [edx+CFH.pSymTable] mov ebx, [edx+COFF_HEADER.pSymTable]
mov edi, dword [fileinfo+32] mov edi, dword [fileinfo+32]
sub edi, ebx sub edi, ebx
jc .fail_and_free_data jc .fail_and_free_data
mov [esi+DLLDESCR.symbols_lim], edi mov [esi+DLLDESCR.symbols_lim], edi
add ebx, edx add ebx, edx
movzx ecx, [edx+CFH.nSections] movzx ecx, [edx+COFF_HEADER.nSections]
lea ecx, [ecx*5] lea ecx, [ecx*5]
lea edi, [edi+ecx*8+20] lea edi, [edi+ecx*8+20]
add edx, 20 add edx, 20
@@: @@:
movzx eax, [edx+CFS.NumReloc] movzx eax, [edx+COFF_SECTION.NumReloc]
lea eax, [eax*5] lea eax, [eax*5]
lea edi, [edi+eax*2] lea edi, [edi+eax*2]
add edx, COFF_SECTION_SIZE add edx, sizeof.COFF_SECTION
sub ecx, 5 sub ecx, 5
jnz @b jnz @b
stdcall kernel_alloc, edi stdcall kernel_alloc, edi
test eax, eax test eax, eax
jz .fail_and_free_data jz .fail_and_free_data
mov edx, [coff] mov edx, [coff]
movzx ecx, [edx+CFH.nSections] movzx ecx, [edx+COFF_HEADER.nSections]
lea ecx, [ecx*5] lea ecx, [ecx*5]
lea ecx, [ecx*2+5] lea ecx, [ecx*2+5]
mov [esi+DLLDESCR.coff_hdr], eax mov [esi+DLLDESCR.coff_hdr], eax
push esi push esi
mov esi, edx mov esi, edx
mov edi, eax mov edi, eax
rep movsd rep movsd
pop esi pop esi
mov [esi+DLLDESCR.symbols_ptr], edi mov [esi+DLLDESCR.symbols_ptr], edi
push esi push esi
mov ecx, [edx+CFH.nSymbols] mov ecx, [edx+COFF_HEADER.nSymbols]
mov [esi+DLLDESCR.symbols_num], ecx mov [esi+DLLDESCR.symbols_num], ecx
mov ecx, [esi+DLLDESCR.symbols_lim] mov ecx, [esi+DLLDESCR.symbols_lim]
mov esi, ebx mov esi, ebx
rep movsb rep movsb
pop esi pop esi
mov ebx, [esi+DLLDESCR.coff_hdr] mov ebx, [esi+DLLDESCR.coff_hdr]
push esi push esi
movzx eax, [edx+CFH.nSections] movzx eax, [edx+COFF_HEADER.nSections]
lea edx, [ebx+20] lea edx, [ebx+20]
@@: @@:
movzx ecx, [edx+CFS.NumReloc] movzx ecx, [edx+COFF_SECTION.NumReloc]
lea ecx, [ecx*5] lea ecx, [ecx*5]
mov esi, [edx+CFS.PtrReloc] mov esi, [edx+COFF_SECTION.PtrReloc]
mov [edx+CFS.PtrReloc], edi mov [edx+COFF_SECTION.PtrReloc], edi
sub [edx+CFS.PtrReloc], ebx sub [edx+COFF_SECTION.PtrReloc], ebx
add esi, [coff] add esi, [coff]
shr ecx, 1 shr ecx, 1
rep movsd rep movsd
adc ecx, ecx adc ecx, ecx
rep movsw rep movsw
add edx, COFF_SECTION_SIZE add edx, sizeof.COFF_SECTION
dec eax dec eax
jnz @b jnz @b
pop esi pop esi
; fixup symbols ; fixup symbols
mov edx, ebx mov edx, ebx
mov eax, [ebx+CFH.nSymbols] mov eax, [ebx+COFF_HEADER.nSymbols]
add edx, 20 add edx, 20
mov ecx, [esi+DLLDESCR.symbols_num] mov ecx, [esi+DLLDESCR.symbols_num]
lea ecx, [ecx*9] lea ecx, [ecx*9]
add ecx, ecx add ecx, ecx
add ecx, [esi+DLLDESCR.symbols_ptr] add ecx, [esi+DLLDESCR.symbols_ptr]
@ -1125,17 +1125,17 @@ proc load_library stdcall, file_name:dword
ecx, 0 ecx, 0
; test eax, eax ; test eax, eax
; jnz @F ; jnz @F
; ;
;@@: ;@@:
stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+CFH.nSymbols], szEXPORTS stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], szEXPORTS
test eax, eax test eax, eax
jnz @F jnz @F
stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+CFH.nSymbols], sz_EXPORTS stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], sz_EXPORTS
@@: @@:
mov [esi+DLLDESCR.exports], eax mov [esi+DLLDESCR.exports], eax
; fix relocs in the hidden copy in kernel memory to default address ; fix relocs in the hidden copy in kernel memory to default address
; it is first fix; usually this will be enough, but second fix ; it is first fix; usually this will be enough, but second fix
; can be necessary if real load address will not equal assumption ; can be necessary if real load address will not equal assumption
@ -1157,13 +1157,13 @@ proc load_library stdcall, file_name:dword
jnz @f jnz @f
stdcall user_alloc, edi stdcall user_alloc, edi
test eax, eax test eax, eax
jz .fail_and_dereference jz .fail_and_dereference
@@: @@:
mov [img_base], eax mov [img_base], eax
mov eax, HDLL.sizeof mov eax, sizeof.HDLL
call malloc call malloc
test eax, eax test eax, eax
jz .fail_and_free_user jz .fail_and_free_user
mov ebx, [CURRENT_TASK] mov ebx, [CURRENT_TASK]
shl ebx, 5 shl ebx, 5
mov edx, [CURRENT_TASK+ebx+TASKDATA.pid] mov edx, [CURRENT_TASK+ebx+TASKDATA.pid]
@ -1366,17 +1366,17 @@ destroy_all_hdlls:
align 4 align 4
stop_all_services: stop_all_services:
push ebp push ebp
mov edx, [srv.fd] mov edx, [srv.fd]
.next: .next:
cmp edx, srv.fd-SRV_FD_OFFSET cmp edx, srv.fd-SRV.fd
je .done je .done
cmp [edx+SRV.magic], ' SRV' cmp [edx+SRV.magic], ' SRV'
jne .next jne .next
cmp [edx+SRV.size], SRV.sizeof cmp [edx+SRV.size], sizeof.SRV
jne .next jne .next
mov ebx, [edx+SRV.entry] mov ebx, [edx+SRV.entry]
mov edx, [edx+SRV.fd] mov edx, [edx+SRV.fd]
test ebx, ebx test ebx, ebx
jz .next jz .next

View File

@ -5,33 +5,27 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$ $Revision$
struc MEM_BLOCK struct MEM_BLOCK
{ list LHEAD
.list LHEAD next_block dd ? ;+8
.next_block dd ? ;+8 prev_block dd ? ;+4
.prev_block dd ? ;+4 base dd ? ;+16
.base dd ? ;+16 size dd ? ;+20
.size dd ? ;+20 flags dd ? ;+24
.flags dd ? ;+24 handle dd ? ;+28
.handle dd ? ;+28 ends
.sizeof:
} FREE_BLOCK equ 4
USED_BLOCK equ 8
FREE_BLOCK equ 4 DONT_FREE_BLOCK equ 10h
USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h
block_next equ MEM_BLOCK.next_block
virtual at 0 block_prev equ MEM_BLOCK.prev_block
MEM_BLOCK MEM_BLOCK list_fd equ MEM_BLOCK.list.next
end virtual
block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list.next
list_bk equ MEM_BLOCK.list.prev list_bk equ MEM_BLOCK.list.prev
block_base equ MEM_BLOCK.base block_base equ MEM_BLOCK.base
block_size equ MEM_BLOCK.size block_size equ MEM_BLOCK.size
@ -143,60 +137,60 @@ proc init_kernel_heap
add edi, 0x1000 add edi, 0x1000
add edx, 0x1000 add edx, 0x1000
dec ecx dec ecx
jnz .l1 jnz .l1
mov edi, HEAP_BASE ;descriptors mov edi, HEAP_BASE ;descriptors
mov ebx, HEAP_BASE+MEM_BLOCK.sizeof ;free space mov ebx, HEAP_BASE+sizeof.MEM_BLOCK ;free space
mov ecx, HEAP_BASE+MEM_BLOCK.sizeof*2 ;terminator mov ecx, HEAP_BASE+sizeof.MEM_BLOCK*2 ;terminator
xor eax, eax xor eax, eax
mov [edi+block_next], ebx mov [edi+block_next], ebx
mov [edi+block_prev], eax mov [edi+block_prev], eax
mov [edi+list_fd], eax mov [edi+list_fd], eax
mov [edi+list_bk], eax mov [edi+list_bk], eax
mov [edi+block_base], HEAP_BASE mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*MEM_BLOCK.sizeof mov [edi+block_size], 4096*sizeof.MEM_BLOCK
mov [edi+block_flags], USED_BLOCK mov [edi+block_flags], USED_BLOCK
mov [ecx+block_next], eax mov [ecx+block_next], eax
mov [ecx+block_prev], ebx mov [ecx+block_prev], ebx
mov [edi+list_fd], eax mov [edi+list_fd], eax
mov [edi+list_bk], eax mov [edi+list_bk], eax
mov [edi+block_base], eax mov [edi+block_base], eax
mov [edi+block_size], eax mov [edi+block_size], eax
mov [edi+block_flags], USED_BLOCK mov [edi+block_flags], USED_BLOCK
mov [ebx+block_next], ecx mov [ebx+block_next], ecx
mov [ebx+block_prev], edi mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK.sizeof mov [ebx+block_base], HEAP_BASE+4096*sizeof.MEM_BLOCK
mov ecx, [pg_data.kernel_pages] mov ecx, [pg_data.kernel_pages]
shl ecx, 12 shl ecx, 12
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof sub ecx, HEAP_BASE-OS_BASE+4096*sizeof.MEM_BLOCK
mov [heap_size], ecx mov [heap_size], ecx
mov [heap_free], ecx mov [heap_free], ecx
mov [ebx+block_size], ecx mov [ebx+block_size], ecx
mov [ebx+block_flags], FREE_BLOCK mov [ebx+block_flags], FREE_BLOCK
mov [mem_block_mask], eax mov [mem_block_mask], eax
mov [mem_block_mask+4], 0x80000000 mov [mem_block_mask+4], 0x80000000
mov ecx, mem_block_list+63*8 mov ecx, mem_block_list+63*8
list_add ebx, ecx list_add ebx, ecx
mov ecx, 4096-3-1 mov ecx, 4096-3-1
mov eax, HEAP_BASE+MEM_BLOCK.sizeof*4 mov eax, HEAP_BASE+sizeof.MEM_BLOCK*4
mov [next_memblock], HEAP_BASE+MEM_BLOCK.sizeof*3 mov [next_memblock], HEAP_BASE+sizeof.MEM_BLOCK *3
@@: @@:
mov [eax-MEM_BLOCK.sizeof], eax mov [eax-sizeof.MEM_BLOCK], eax
add eax, MEM_BLOCK.sizeof add eax, sizeof.MEM_BLOCK
loop @B loop @B
mov [eax-MEM_BLOCK.sizeof], dword 0 mov [eax-sizeof.MEM_BLOCK], dword 0
mov ecx, heap_mutex mov ecx, heap_mutex
call mutex_init call mutex_init
mov [heap_blocks], 4094 mov [heap_blocks], 4094
mov [free_blocks], 4093 mov [free_blocks], 4093
ret ret
@ -1289,13 +1283,13 @@ align 4
jz .fail jz .fail
add ecx, 4095 add ecx, 4095
and ecx, -4096 and ecx, -4096
mov [size], ecx mov [size], ecx
mov eax, SMEM.sizeof mov eax, sizeof.SMEM
call malloc call malloc
test eax, eax test eax, eax
mov esi, eax mov esi, eax
mov edx, E_NOMEM mov edx, E_NOMEM
jz .fail jz .fail
@ -1351,13 +1345,13 @@ align 4
mov edx, E_ACCESS mov edx, E_ACCESS
ja .fail ja .fail
mov ebx, [CURRENT_TASK] mov ebx, [CURRENT_TASK]
shl ebx, 5 shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4] mov ebx, [CURRENT_TASK+ebx+4]
mov eax, SMAP.sizeof mov eax, sizeof.SMAP
call create_kernel_object call create_kernel_object
test eax, eax test eax, eax
mov edi, eax mov edi, eax
mov edx, E_NOMEM mov edx, E_NOMEM
jz .fail jz .fail

View File

@ -9,15 +9,15 @@ IRQ_RESERVED equ 24
IRQ_POOL_SIZE equ 48 IRQ_POOL_SIZE equ 48
uglobal uglobal
align 16 align 16
irqh_tab rd LHEAD.sizeof * IRQ_RESERVED / 4 irqh_tab rd sizeof.LHEAD * IRQ_RESERVED / 4
irqh_pool rd IRQH.sizeof * IRQ_POOL_SIZE /4 irqh_pool rd sizeof.IRQH * IRQ_POOL_SIZE /4
next_irqh rd 1 next_irqh rd 1
irq_active_set rd 1 irq_active_set rd 1
irq_failed rd IRQ_RESERVED irq_failed rd IRQ_RESERVED
endg endg
@ -31,20 +31,20 @@ init_irqs:
mov eax, edi mov eax, edi
stosd stosd
stosd stosd
loop @B loop @B
mov ecx, IRQ_POOL_SIZE-1 mov ecx, IRQ_POOL_SIZE-1
mov eax, irqh_pool+IRQH.sizeof mov eax, irqh_pool+sizeof.IRQH
mov [next_irqh], irqh_pool mov [next_irqh], irqh_pool
@@: @@:
mov [eax-IRQH.sizeof], eax mov [eax-sizeof.IRQH], eax
add eax, IRQH.sizeof add eax, sizeof.IRQH
loop @B loop @B
mov [eax-IRQH.sizeof], dword 0 mov [eax-sizeof.IRQH], dword 0
ret ret
align 4 align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
locals locals

View File

@ -7,40 +7,40 @@
$Revision$ $Revision$
GREEDY_KERNEL equ 0 GREEDY_KERNEL equ 0
struc APP_HEADER_00 struct APP_HEADER_00_
{ .banner dq ? banner dq ?
.version dd ? ;+8 version dd ? ;+8
.start dd ? ;+12 start dd ? ;+12
.i_end dd ? ;+16 i_end dd ? ;+16
.mem_size dd ? ;+20 mem_size dd ? ;+20
.i_param dd ? ;+24 i_param dd ? ;+24
} ends
struc APP_HEADER_01 struct APP_HEADER_01_
{ .banner dq ? banner dq ?
.version dd ? ;+8 version dd ? ;+8
.start dd ? ;+12 start dd ? ;+12
.i_end dd ? ;+16 i_end dd ? ;+16
.mem_size dd ? ;+20 mem_size dd ? ;+20
.stack_top dd ? ;+24 stack_top dd ? ;+24
.i_param dd ? ;+28 i_param dd ? ;+28
.i_icon dd ? ;+32 i_icon dd ? ;+32
} ends
struc APP_PARAMS struct APP_PARAMS
{ .app_cmdline ;0x00 app_cmdline dd ? ;0x00
.app_path ;0x04 app_path dd ? ;0x04
.app_eip ;0x08 app_eip dd ? ;0x08
.app_esp ;0x0C app_esp dd ? ;0x0C
.app_mem ;0x10 app_mem dd ? ;0x10
} ends
macro _clear_ op macro _clear_ op
{ mov ecx, op/4 { mov ecx, op/4
xor eax, eax xor eax, eax
cld cld
rep stosd rep stosd
@ -251,16 +251,16 @@ end if
ret ret
endp endp
align 4 align 4
test_app_header: test_app_header:
virtual at eax virtual at eax
APP_HEADER_00 APP_HEADER_00 APP_HEADER_00 APP_HEADER_00_
end virtual end virtual
virtual at eax virtual at eax
APP_HEADER_01 APP_HEADER_01 APP_HEADER_01 APP_HEADER_01_
end virtual end virtual
cmp dword [eax], 'MENU' cmp dword [eax], 'MENU'
jne .fail jne .fail
cmp word [eax+4], 'ET' cmp word [eax+4], 'ET'
jne .fail jne .fail

View File

@ -9,36 +9,31 @@ $Revision$
; Virtual-8086 mode manager ; Virtual-8086 mode manager
; diamond, 2007, 2008 ; diamond, 2007, 2008
DEBUG_SHOW_IO = 0 DEBUG_SHOW_IO = 0
struc V86_machine struct V86_machine
{ ; page directory
; page directory pagedir dd ?
.pagedir dd ? ; translation table: V86 address -> flat linear address
; translation table: V86 address -> flat linear address pages dd ?
.pages dd ? ; mutex to protect all data from writing by multiple threads at one time
; mutex to protect all data from writing by multiple threads at one time mutex dd ?
.mutex dd ? ; i/o permission map
; i/o permission map iopm dd ?
.iopm dd ? ends
.size = $
} ; Create V86 machine
virtual at 0 ; in: nothing
V86_machine V86_machine
end virtual
; Create V86 machine
; in: nothing
; out: eax = handle (pointer to struc V86_machine) ; out: eax = handle (pointer to struc V86_machine)
; eax = NULL => failure ; eax = NULL => failure
; destroys: ebx, ecx, edx (due to malloc) ; destroys: ebx, ecx, edx (due to malloc)
v86_create: v86_create:
; allocate V86_machine structure ; allocate V86_machine structure
mov eax, V86_machine.size mov eax, sizeof.V86_machine
call malloc call malloc
test eax, eax test eax, eax
jz .fail jz .fail
; initialize mutex ; initialize mutex
and dword [eax+V86_machine.mutex], 0 and dword [eax+V86_machine.mutex], 0
; allocate tables ; allocate tables
@ -242,37 +237,32 @@ if ~DEBUG_SHOW_IO
mov ecx, 10000h/8/4 mov ecx, 10000h/8/4
rep stosd rep stosd
end if end if
.ret: .ret:
ret ret
struc v86_regs struct v86_regs
{ ; don't change the order, it is important
; don't change the order, it is important edi dd ?
.edi dd ? esi dd ?
.esi dd ? ebp dd ?
.ebp dd ? dd ? ; ignored
dd ? ; ignored ebx dd ?
.ebx dd ? edx dd ?
.edx dd ? ecx dd ?
.ecx dd ? eax dd ?
.eax dd ? eip dd ?
.eip dd ? cs dd ?
.cs dd ? eflags dd ? ; VM flag must be set!
.eflags dd ? ; VM flag must be set! esp dd ?
.esp dd ? ss dd ?
.ss dd ? es dd ?
.es dd ? ds dd ?
.ds dd ? fs dd ?
.fs dd ? gs dd ?
.gs dd ? ends
.size = $
} ; Run V86 machine
virtual at 0 ; in: ebx -> registers for V86 (two structures: in and out)
v86_regs v86_regs
end virtual
; Run V86 machine
; in: ebx -> registers for V86 (two structures: in and out)
; esi = handle ; esi = handle
; ecx = expected end address (CS:IP) ; ecx = expected end address (CS:IP)
; edx = IRQ to hook or -1 if not required ; edx = IRQ to hook or -1 if not required
@ -316,16 +306,16 @@ v86_start:
; We do not enable interrupts, because V86 IRQ redirector assumes that ; We do not enable interrupts, because V86 IRQ redirector assumes that
; machine is running ; machine is running
; They will be enabled by IRET. ; They will be enabled by IRET.
; sti ; sti
mov eax, esi mov eax, esi
sub esp, v86_regs.size sub esp, sizeof.v86_regs
mov esi, ebx mov esi, ebx
mov edi, esp mov edi, esp
mov ecx, v86_regs.size/4 mov ecx, sizeof.v86_regs/4
rep movsd rep movsd
cmp edx, -1 cmp edx, -1
jz .noirqhook jz .noirqhook
uglobal uglobal
v86_irqhooks rd IRQ_RESERVED * 2 v86_irqhooks rd IRQ_RESERVED * 2
@ -369,13 +359,13 @@ v86_exc_c:
; Did we all that we have wanted to do? ; Did we all that we have wanted to do?
cmp bl, 1 cmp bl, 1
jne @f jne @f
xor eax, eax xor eax, eax
mov dr6, eax mov dr6, eax
@@: @@:
mov eax, [esp+v86_regs.size+10h+18h] mov eax, [esp+sizeof.v86_regs+10h+18h]
cmp word [esp+v86_regs.eip], ax cmp word [esp+v86_regs.eip], ax
jnz @f jnz @f
shr eax, 16 shr eax, 16
cmp word [esp+v86_regs.cs], ax cmp word [esp+v86_regs.cs], ax
jz .done jz .done
@@: @@:
@ -441,13 +431,13 @@ v86_exc_c:
shl edx, 4 shl edx, 4
push eax push eax
movzx eax, word [esp+4+v86_regs.esp] movzx eax, word [esp+4+v86_regs.esp]
sub eax, 6 sub eax, 6
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+4+v86_regs.size+10h+4] mov esi, [esp+4+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 ; #PF exception mov bl, 14 ; #PF exception
jmp .nogp jmp .nogp
@@: @@:
@ -489,13 +479,13 @@ v86_exc_c:
@@: @@:
movzx edx, word [esp+v86_regs.ss] movzx edx, word [esp+v86_regs.ss]
shl edx, 4 shl edx, 4
movzx eax, word [esp+v86_regs.esp] movzx eax, word [esp+v86_regs.esp]
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 mov bl, 14
jmp .nogp jmp .nogp
@@: @@:
@ -525,13 +515,13 @@ v86_exc_c:
shl edx, 4 shl edx, 4
mov eax, [esp+v86_regs.esp] mov eax, [esp+v86_regs.esp]
sub eax, 2 sub eax, 2
movzx eax, ax movzx eax, ax
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 ; #PF exception mov bl, 14 ; #PF exception
jmp .nogp jmp .nogp
@@: @@:
@ -557,13 +547,13 @@ v86_exc_c:
movzx edx, word [esp+v86_regs.ss] movzx edx, word [esp+v86_regs.ss]
shl edx, 4 shl edx, 4
movzx eax, word [esp+v86_regs.esp] movzx eax, word [esp+v86_regs.esp]
sub eax, 4 sub eax, 4
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 ; #PF exception mov bl, 14 ; #PF exception
jmp .nogp jmp .nogp
@@: @@:
@ -588,13 +578,13 @@ v86_exc_c:
@@: @@:
movzx edx, word [esp+v86_regs.ss] movzx edx, word [esp+v86_regs.ss]
shl edx, 4 shl edx, 4
movzx eax, word [esp+v86_regs.esp] movzx eax, word [esp+v86_regs.esp]
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 ; #PF exception mov bl, 14 ; #PF exception
jmp .nogp jmp .nogp
@@: @@:
@ -619,13 +609,13 @@ v86_exc_c:
@@: @@:
movzx edx, word [esp+v86_regs.ss] movzx edx, word [esp+v86_regs.ss]
shl edx, 4 shl edx, 4
movzx eax, word [esp+v86_regs.esp] movzx eax, word [esp+v86_regs.esp]
add edx, eax add edx, eax
mov eax, edx mov eax, edx
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jae @f jae @f
mov bl, 14 mov bl, 14
jmp .nogp jmp .nogp
@@: @@:
@ -745,13 +735,13 @@ end if
call sys_msg_board_str call sys_msg_board_str
mov ecx, 8 mov ecx, 8
movzx edx, word [esp+32+4] movzx edx, word [esp+32+4]
shl edx, 4 shl edx, 4
add edx, [esp+32] add edx, [esp+32]
@@: @@:
mov esi, [esp+v86_regs.size+10h+4] mov esi, [esp+sizeof.v86_regs+10h+4]
mov eax, edx mov eax, edx
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jb .nopage jb .nopage
mov esi, v86_exc_str3-2 mov esi, v86_exc_str3-2
call sys_msg_board_str call sys_msg_board_str
@ -770,27 +760,27 @@ end if
jmp .exit jmp .exit
.done: .done:
xor eax, eax xor eax, eax
.exit: .exit:
mov [esp+v86_regs.size+10h+1Ch], eax mov [esp+sizeof.v86_regs+10h+1Ch], eax
mov [esp+v86_regs.size+10h+18h], ebx mov [esp+sizeof.v86_regs+10h+18h], ebx
mov edx, [esp+v86_regs.size+10h+14h] mov edx, [esp+sizeof.v86_regs+10h+14h]
cmp edx, -1 cmp edx, -1
jz @f jz @f
dec [v86_irqhooks+edx*8+4] dec [v86_irqhooks+edx*8+4]
jnz @f jnz @f
and [v86_irqhooks+edx*8], 0 and [v86_irqhooks+edx*8], 0
@@: @@:
mov esi, esp mov esi, esp
mov edi, [esi+v86_regs.size+10h+10h] mov edi, [esi+sizeof.v86_regs+10h+10h]
add edi, v86_regs.size add edi, sizeof.v86_regs
mov ecx, v86_regs.size/4 mov ecx, sizeof.v86_regs/4
rep movsd rep movsd
mov esp, esi mov esp, esi
cli cli
mov ecx, [CURRENT_TASK] mov ecx, [CURRENT_TASK]
shl ecx, 8 shl ecx, 8
@ -871,18 +861,18 @@ v86_irq2:
mov ecx, [TASK_COUNT] mov ecx, [TASK_COUNT]
.scan: .scan:
cmp [ebx+APPDATA.dir_table], eax cmp [ebx+APPDATA.dir_table], eax
jnz .cont jnz .cont
push ecx push ecx
mov ecx, [ebx+APPDATA.saved_esp0] mov ecx, [ebx+APPDATA.saved_esp0]
cmp word [ecx-v86_regs.size+v86_regs.esp], 6 cmp word [ecx-sizeof.v86_regs+v86_regs.esp], 6
jb .cont2 jb .cont2
movzx edx, word [ecx-v86_regs.size+v86_regs.ss] movzx edx, word [ecx-sizeof.v86_regs+v86_regs.ss]
shl edx, 4 shl edx, 4
push eax push eax
movzx eax, word [ecx-v86_regs.size+v86_regs.esp] movzx eax, word [ecx-sizeof.v86_regs+v86_regs.esp]
sub eax, 6 sub eax, 6
add edx, eax add edx, eax
mov eax, edx mov eax, edx
call v86_get_lin_addr call v86_get_lin_addr
cmp eax, 0x1000 cmp eax, 0x1000
jb .cont3 jb .cont3
@ -902,29 +892,29 @@ v86_irq2:
mov ecx, edi mov ecx, edi
call irq_eoi call irq_eoi
popad popad
iretd iretd
.found: .found:
mov cr3, eax mov cr3, eax
sub word [esi-v86_regs.size+v86_regs.esp], 6 sub word [esi-sizeof.v86_regs+v86_regs.esp], 6
mov ecx, [esi-v86_regs.size+v86_regs.eip] mov ecx, [esi-sizeof.v86_regs+v86_regs.eip]
mov word [edx], cx mov word [edx], cx
mov ecx, [esi-v86_regs.size+v86_regs.cs] mov ecx, [esi-sizeof.v86_regs+v86_regs.cs]
mov word [edx+2], cx mov word [edx+2], cx
mov ecx, [esi-v86_regs.size+v86_regs.eflags] mov ecx, [esi-sizeof.v86_regs+v86_regs.eflags]
mov word [edx+4], cx mov word [edx+4], cx
lea eax, [edi+8] lea eax, [edi+8]
cmp al, 10h cmp al, 10h
jb @f jb @f
add al, 60h add al, 60h
@@: @@:
mov cx, [eax*4] mov cx, [eax*4]
mov word [esi-v86_regs.size+v86_regs.eip], cx mov word [esi-sizeof.v86_regs+v86_regs.eip], cx
mov cx, [eax*4+2] mov cx, [eax*4+2]
mov word [esi-v86_regs.size+v86_regs.cs], cx mov word [esi-sizeof.v86_regs+v86_regs.cs], cx
and byte [esi-v86_regs.size+v86_regs.eflags+1], not 3 and byte [esi-sizeof.v86_regs+v86_regs.eflags+1], not 3
call update_counters call update_counters
lea edi, [ebx + 0x100000000 - SLOT_BASE] lea edi, [ebx + 0x100000000 - SLOT_BASE]
shr edi, 3 shr edi, 3
add edi, TASK_DATA add edi, TASK_DATA
call find_next_task.found call find_next_task.found
call do_change_task call do_change_task

View File

@ -272,13 +272,13 @@ graph_data_l:
dw 0x7ff dw 0x7ff
dw 0x0000 dw 0x0000
db 0x00 db 0x00
dw 11010000b *256 +11110010b dw 11010000b *256 +11110010b
db 0x00 db 0x00
tss0_l: tss0_l:
dw TSS_SIZE-1 dw sizeof.TSS-1
dw tss and 0xFFFF dw tss and 0xFFFF
db (tss shr 16) and 0xFF db (tss shr 16) and 0xFF
db 10001001b db 10001001b
dw (tss shr 16) and 0xFF00 dw (tss shr 16) and 0xFF00
tls_data_l: tls_data_l:

View File

@ -14,21 +14,16 @@ $Revision$
button.MAX_BUTTONS = 4095 button.MAX_BUTTONS = 4095
struc SYS_BUTTON struct SYS_BUTTON
{ pslot dw ?
.pslot dw ? id_lo dw ?
.id_lo dw ? left dw ?
.left dw ? width dw ?
.width dw ? top dw ?
.top dw ? height dw ?
.height dw ? id_hi dw ?
.id_hi dw ? dw ?
dw ? ends
.sizeof:
}
virtual at 0
SYS_BUTTON SYS_BUTTON
end virtual
align 4 align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -216,18 +211,18 @@ syscall_button.remove_button:
mov edi, [BTN_ADDR] mov edi, [BTN_ADDR]
mov ebx, [edi] mov ebx, [edi]
inc ebx inc ebx
imul esi, ebx, SYS_BUTTON.sizeof imul esi, ebx, sizeof.SYS_BUTTON
add esi, edi add esi, edi
xor ecx, ecx xor ecx, ecx
add ecx, -SYS_BUTTON.sizeof add ecx, -sizeof.SYS_BUTTON
add esi, SYS_BUTTON.sizeof add esi, sizeof.SYS_BUTTON
.next_button: .next_button:
dec ebx dec ebx
jz .exit jz .exit
add ecx, SYS_BUTTON.sizeof add ecx, sizeof.SYS_BUTTON
add esi, -SYS_BUTTON.sizeof add esi, -sizeof.SYS_BUTTON
; does it belong to our process? ; does it belong to our process?
mov ax, [CURRENT_TASK] mov ax, [CURRENT_TASK]
@ -244,10 +239,10 @@ syscall_button.remove_button:
; okay, undefine it ; okay, undefine it
push ebx push ebx
mov ebx, esi mov ebx, esi
lea eax, [esi + SYS_BUTTON.sizeof] lea eax, [esi + sizeof.SYS_BUTTON]
call memmove call memmove
dec dword[edi] dec dword[edi]
add ecx, -SYS_BUTTON.sizeof add ecx, -sizeof.SYS_BUTTON
pop ebx pop ebx
jmp .next_button jmp .next_button
@ -334,16 +329,16 @@ button._.find_button: ;////////////////////////////////////////////////////////
mov edi, [BTN_ADDR] mov edi, [BTN_ADDR]
mov ecx, [edi] mov ecx, [edi]
imul esi, ecx, SYS_BUTTON.sizeof imul esi, ecx, sizeof.SYS_BUTTON
add esi, edi add esi, edi
inc ecx inc ecx
add esi, SYS_BUTTON.sizeof add esi, sizeof.SYS_BUTTON
.next_button: .next_button:
dec ecx dec ecx
jz .not_found jz .not_found
add esi, -SYS_BUTTON.sizeof add esi, -sizeof.SYS_BUTTON
; does it belong to our process? ; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot] cmp dx, [esi + SYS_BUTTON.pslot]

View File

@ -22,24 +22,24 @@ align 4
endg endg
EV_SPACE = 512 EV_SPACE = 512
FreeEvents = event_start-EVENT.fd ; "âèðòóàëüíûé" event, èñïîëüçóþòñÿ òîëüêî ïîëÿ: FreeEvents = event_start-EVENT.fd ; "âèðòóàëüíûé" event, èñïîëüçóþòñÿ òîëüêî ïîëÿ:
; FreeEvents.fd=event_start è FreeEvents.bk=event_end ; FreeEvents.fd=event_start è FreeEvents.bk=event_end
align 4 align 4
init_events: ;; used from kernel.asm init_events: ;; used from kernel.asm
stdcall kernel_alloc, EV_SPACE*EVENT.size stdcall kernel_alloc, EV_SPACE*sizeof.EVENT
or eax, eax or eax, eax
jz .fail jz .fail
; eax - current event, ebx - previos event below ; eax - current event, ebx - previos event below
mov ecx, EV_SPACE ; current - in allocated space mov ecx, EV_SPACE ; current - in allocated space
mov ebx, FreeEvents ; previos - íà÷àëî ñïèñêà mov ebx, FreeEvents ; previos - íà÷àëî ñïèñêà
push ebx ; îíî æå è êîíåö ïîòîì áóäåò push ebx ; îíî æå è êîíåö ïîòîì áóäåò
@@: @@:
mov [ebx+EVENT.fd], eax mov [ebx+EVENT.fd], eax
mov [eax+EVENT.bk], ebx mov [eax+EVENT.bk], ebx
mov ebx, eax ; previos <- current mov ebx, eax ; previos <- current
add eax, EVENT.size ; new current add eax, sizeof.EVENT ; new current
loop @b loop @b
pop eax ; âîò îíî êîíöîì è ñòàëî pop eax ; âîò îíî êîíöîì è ñòàëî
mov [ebx+EVENT.fd], eax mov [ebx+EVENT.fd], eax
mov [eax+EVENT.bk], ebx mov [eax+EVENT.bk], ebx
.fail: .fail:
ret ret
@ -97,13 +97,13 @@ set_event: ;; INTERNAL use !!! don't use
mov [eax+EVENT.pid], edx mov [eax+EVENT.pid], edx
inc [event_uid] inc [event_uid]
Mov [eax+EVENT.id],edx,[event_uid] Mov [eax+EVENT.id],edx,[event_uid]
or esi, esi or esi, esi
jz RemoveEventTo jz RemoveEventTo
lea edi, [eax+EVENT.code] lea edi, [eax+EVENT.code]
mov ecx, EVENT.codesize/4 mov ecx, (sizeof.EVENT -EVENT.code)/4
cld cld
rep movsd rep movsd
RemoveEventTo: ;; INTERNAL use !!! don't use for Call RemoveEventTo: ;; INTERNAL use !!! don't use for Call
;param: ;param:
; eax - óêàçàòåëü íà event, ÊÎÒÎÐÛÉ âñòàâëÿåì ; eax - óêàçàòåëü íà event, ÊÎÒÎÐÛÉ âñòàâëÿåì
@ -152,13 +152,13 @@ raise_event: ;; EXPORT use
; esi - event data (=0 => skip) ; esi - event data (=0 => skip)
;scratched: ebx,ecx,esi,edi ;scratched: ebx,ecx,esi,edi
call NotDummyTest ; not returned for fail !!! call NotDummyTest ; not returned for fail !!!
or esi, esi or esi, esi
jz @f jz @f
lea edi, [ebx+EVENT.code] lea edi, [ebx+EVENT.code]
mov ecx, EVENT.codesize/4 mov ecx, (sizeof.EVENT -EVENT.code)/4
cld cld
rep movsd rep movsd
@@: @@:
test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
jnz RemoveEventTo.break ; POPF+RET jnz RemoveEventTo.break ; POPF+RET
bt edx, 28 ;EVENT_WATCHED bt edx, 28 ;EVENT_WATCHED
@ -296,16 +296,16 @@ get_event_ex: ;; f68:14
;retval: ;retval:
; eax - ñîáñòâåííî EVENT (áóäåì íàçûâàòü ýòî åãî õýíäëîì) ; eax - ñîáñòâåííî EVENT (áóäåì íàçûâàòü ýòî åãî õýíäëîì)
;scratched: ebx,ecx,edx,esi,edi ;scratched: ebx,ecx,edx,esi,edi
mov edx, get_event_queue ; wait_test mov edx, get_event_queue ; wait_test
call Wait_events ; timeout ignored call Wait_events ; timeout ignored
lea esi, [eax+EVENT.code] lea esi, [eax+EVENT.code]
mov ecx, EVENT.codesize/4 mov ecx, (sizeof.EVENT-EVENT.code)/4
cld cld
rep movsd rep movsd
mov [edi-EVENT.codesize+2], cl;clear priority field mov byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field
wait_finish: wait_finish:
test byte[eax+EVENT.state+3], MANUAL_RESET shr 24 test byte[eax+EVENT.state+3], MANUAL_RESET shr 24
jnz get_event_queue.ret ; RET jnz get_event_queue.ret ; RET
and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24 test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
jz destroy_event.internal jz destroy_event.internal

View File

@ -565,22 +565,22 @@ mouse._.find_sys_button_under_cursor: ;////////////////////////////////////////
call mouse._.find_sys_window_under_cursor call mouse._.find_sys_window_under_cursor
mov edx, esi mov edx, esi
; check if any process button contains cursor ; check if any process button contains cursor
mov eax, [BTN_ADDR] mov eax, [BTN_ADDR]
mov ecx, [eax] mov ecx, [eax]
imul esi, ecx, SYS_BUTTON.sizeof imul esi, ecx, sizeof.SYS_BUTTON
add esi, eax add esi, eax
inc ecx inc ecx
add esi, SYS_BUTTON.sizeof add esi, sizeof.SYS_BUTTON
.next_button: .next_button:
dec ecx dec ecx
jz .not_found jz .not_found
add esi, -SYS_BUTTON.sizeof add esi, -sizeof.SYS_BUTTON
; does it belong to our process? ; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot] cmp dx, [esi + SYS_BUTTON.pslot]
jne .next_button jne .next_button
; does it contain cursor coordinates? ; does it contain cursor coordinates?

View File

@ -563,13 +563,13 @@ high_code:
stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \
(unpack.lc+unpack.lp)))*4 (unpack.lc+unpack.lp)))*4
mov [unpack.p], eax mov [unpack.p], eax
call init_events call init_events
mov eax, srv.fd-SRV_FD_OFFSET mov eax, srv.fd-SRV.fd
mov [srv.fd], eax mov [srv.fd], eax
mov [srv.bk], eax mov [srv.bk], eax
;Set base of graphic segment to linear address of LFB ;Set base of graphic segment to linear address of LFB
mov eax, [LFBAddress] ; set for gs mov eax, [LFBAddress] ; set for gs
mov [graph_data_l+2], ax mov [graph_data_l+2], ax

View File

@ -145,22 +145,12 @@ struct APPDATA
wnd_caption dd ? wnd_caption dd ?
wnd_clientbox BOX wnd_clientbox BOX
ends ends
; Core functions
include "core/sync.inc" ; macros for synhronization objects
;// mike.dld, 2006-29-01 ] include "core/sys32.inc" ; process management
struct MUTEX
lhead LHEAD
count dd ?
ends
; Core functions
include "core/sync.inc" ; macros for synhronization objects
include "core/sys32.inc" ; process management
include "core/sched.inc" ; process scheduling include "core/sched.inc" ; process scheduling
include "core/syscall.inc" ; system call include "core/syscall.inc" ; system call
include "core/fpu.inc" ; all fpu/sse support include "core/fpu.inc" ; all fpu/sse support

View File

@ -124,10 +124,8 @@ UDP_input:
jz .no_checksum ; if checksum is zero, it is considered valid and we continue processing jz .no_checksum ; if checksum is zero, it is considered valid and we continue processing
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct ; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
push esi
UDP_checksum (edi), (edi+4) UDP_checksum (edi), (edi+4)
pop esi ;;; jnz .checksum_mismatch
jnz .checksum_mismatch
.no_checksum: .no_checksum:
DEBUGF 1,"UDP Checksum is correct\n" DEBUGF 1,"UDP Checksum is correct\n"

View File

@ -1,39 +1,30 @@
struct BLITTER_BLOCK
xmin dd ?
struc BLITTER ymin dd ?
{ xmax dd ?
.dc.xmin rd 1 ; 0 ymax dd ?
.dc.ymin rd 1 ; 4 ends
.dc.xmax rd 1 ; 8
.dc.ymax rd 1 ; 12
struct BLITTER
.sc: dc BLITTER_BLOCK
.sc.xmin rd 1 ; 16 sc BLITTER_BLOCK
.sc.ymin rd 1 ; 20 dst_x dd ? ; 32
.sc.xmax rd 1 ; 24 dst_y dd ? ; 36
.sc.ymax rd 1 ; 28 src_x dd ? ; 40
src_y dd ? ; 44
.dst_x rd 1 ; 32 w dd ? ; 48
.dst_y rd 1 ; 36 h dd ? ; 52
.src_x rd 1 ; 40
.src_y rd 1 ; 44 bitmap dd ? ; 56
.w rd 1 ; 48 stride dd ? ; 60
.h rd 1 ; 52 ends
.bitmap rd 1 ; 56
.stride rd 1 ; 60 align 4
} __L1OutCode:
virtual at 0
BLITTER BLITTER
end virtual
align 4
__L1OutCode:
push ebx push ebx
mov ebx, 8 mov ebx, 8
cmp edx, [eax] cmp edx, [eax]

View File

@ -10,30 +10,26 @@ $Revision$
LOAD_FROM_FILE equ 0 LOAD_FROM_FILE equ 0
LOAD_FROM_MEM equ 1 LOAD_FROM_MEM equ 1
LOAD_INDIRECT equ 2 LOAD_INDIRECT equ 2
LOAD_SYSTEM equ 3 LOAD_SYSTEM equ 3
struc BITMAPINFOHEADER { struct BITMAPINFOHEADER
.biSize dd ? ; DWORD Size dd ?
.biWidth dd ? ; LONG Width dd ?
.biHeight dd ? ; LONG Height dd ?
.biPlanes dw ? ; WORD Planes dw ?
.biBitCount dw ? ; WORD BitCount dw ?
.biCompression dd ? ; DWORD Compression dd ?
.biSizeImage dd ? ; DWORD SizeImage dd ?
.biXPelsPerMeter dd ? ; LONG XPelsPerMeter dd ?
.biYPelsPerMeter dd ? ; LONG YPelsPerMeter dd ?
.biClrUsed dd ? ; DWORD ClrUsed dd ?
.biClrImportant dd ? ; DWORD ClrImportant dd ?
} ends
virtual at 0 align 4
BI BITMAPINFOHEADER proc init_cursor stdcall, dst:dword, src:dword
end virtual locals
align 4
proc init_cursor stdcall, dst:dword, src:dword
locals
rBase dd ? rBase dd ?
pQuad dd ? pQuad dd ?
pBits dd ? pBits dd ?
@ -44,17 +40,17 @@ proc init_cursor stdcall, dst:dword, src:dword
endl endl
mov esi, [src] mov esi, [src]
add esi, [esi+18] add esi, [esi+18]
mov eax, esi mov eax, esi
cmp [esi+BI.biBitCount], 24 cmp [esi+BITMAPINFOHEADER.BitCount], 24
je .img_24 je .img_24
cmp [esi+BI.biBitCount], 8 cmp [esi+BITMAPINFOHEADER.BitCount], 8
je .img_8 je .img_8
cmp [esi+BI.biBitCount], 4 cmp [esi+BITMAPINFOHEADER.BitCount], 4
je .img_4 je .img_4
.img_2: .img_2:
add eax, [esi] add eax, [esi]
mov [pQuad], eax mov [pQuad], eax
add eax, 8 add eax, 8
@ -223,15 +219,15 @@ proc init_cursor stdcall, dst:dword, src:dword
ret ret
.img_24: .img_24:
add eax, [esi] add eax, [esi]
mov [pQuad], eax mov [pQuad], eax
add eax, 0xC00 add eax, 0xC00
mov [pAnd], eax mov [pAnd], eax
mov eax, [esi+BI.biWidth] mov eax, [esi+BITMAPINFOHEADER.Width]
mov [width], eax mov [width], eax
mov ebx, [esi+BI.biHeight] mov ebx, [esi+BITMAPINFOHEADER.Height]
shr ebx, 1 shr ebx, 1
mov [height], ebx mov [height], ebx
mov edi, [dst] mov edi, [dst]
add edi, 32*31*4 add edi, 32*31*4
mov [rBase], edi mov [rBase], edi
@ -297,13 +293,13 @@ create_cursor:
sub esp, 4 ;space for .hcursor sub esp, 4 ;space for .hcursor
push ecx push ecx
push ebx push ebx
mov ebx, eax mov ebx, eax
mov eax, CURSOR.sizeof mov eax, sizeof.CURSOR
call create_kernel_object call create_kernel_object
test eax, eax test eax, eax
jz .fail jz .fail
mov [.hcursor], eax mov [.hcursor], eax