diff --git a/kernel/trunk/core/dll.inc b/kernel/trunk/core/dll.inc index 68c7bf9129..d9951d2584 100644 --- a/kernel/trunk/core/dll.inc +++ b/kernel/trunk/core/dll.inc @@ -23,7 +23,7 @@ proc attach_int_handler stdcall, irq:dword, handler:dword test eax, eax jz .err mov [irq_tab+ebx*4], eax - stdcall enable_irq, [irq] + stdcall enable_irq, [irq] ret .err: xor eax, eax @@ -38,17 +38,17 @@ endp align 4 proc enable_irq stdcall, irq_line:dword - mov ebx, [irq_line] - mov edx, 0x21 - cmp ebx, 8 - jb @F - mov edx, 0xA1 - sub ebx,8 + mov ebx, [irq_line] + mov edx, 0x21 + cmp ebx, 8 + jb @F + mov edx, 0xA1 + sub ebx,8 @@: - in al,dx - btr eax, ebx - out dx, al - ret + in al,dx + btr eax, ebx + out dx, al + ret endp align 16 @@ -134,7 +134,7 @@ align 4 align 16 .main: save_ring3_context - mov bx, app_data ;os_data + mov bx, app_data ;os_data mov ds, bx mov es, bx @@ -142,33 +142,33 @@ align 16 test ebx, ebx jz .exit - call ebx - mov [check_idle_semaphore],5 + call ebx + mov [check_idle_semaphore],5 .exit: restore_ring3_context - cmp eax, 8 + cmp eax, 8 mov al, 0x20 - jb @f + jb @f out 0xa0, al @@: - out 0x20, al + out 0x20, al - pop eax + pop eax iret align 4 proc get_notify stdcall, p_ev:dword .wait: - mov ebx,[current_slot] - test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY + mov ebx,[current_slot] + test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY jz @f - and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY + and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY mov edi, [p_ev] mov dword [edi], EV_INTR - mov eax, [ebx+APPDATA.event] + mov eax, [ebx+APPDATA.event] mov dword [edi+4], eax ret @@: @@ -181,7 +181,7 @@ proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword xor eax, eax xor ebx, ebx mov ah, byte [bus] - mov al, 6 + mov al, 6 mov bh, byte [devfn] mov bl, byte [reg] call pci_read_reg @@ -193,7 +193,7 @@ proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword xor eax, eax xor ebx, ebx mov ah, byte [bus] - mov al, 5 + mov al, 5 mov bh, byte [devfn] mov bl, byte [reg] call pci_read_reg @@ -205,7 +205,7 @@ proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword xor eax, eax xor ebx, ebx mov ah, byte [bus] - mov al, 4 + mov al, 4 mov bh, byte [devfn] mov bl, byte [reg] call pci_read_reg @@ -217,11 +217,11 @@ proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword xor eax, eax xor ebx, ebx mov ah, byte [bus] - mov al, 8 + mov al, 8 mov bh, byte [devfn] mov bl, byte [reg] - mov ecx, [val] - call pci_write_reg + mov ecx, [val] + call pci_write_reg ret endp @@ -230,47 +230,60 @@ proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword xor eax, eax xor ebx, ebx mov ah, byte [bus] - mov al, 9 + mov al, 9 mov bh, byte [devfn] mov bl, byte [reg] - mov ecx, [val] - call pci_write_reg + mov ecx, [val] + call pci_write_reg ret endp -handle equ IOCTL.handle -io_code equ IOCTL.io_code -input equ IOCTL.input -inp_size equ IOCTL.inp_size -output equ IOCTL.output -out_size equ IOCTL.out_size +align 4 +proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword + xor eax, eax + xor ebx, ebx + mov ah, byte [bus] + mov al, 10 + mov bh, byte [devfn] + mov bl, byte [reg] + mov ecx, [val] + call pci_write_reg + ret +endp + +handle equ IOCTL.handle +io_code equ IOCTL.io_code +input equ IOCTL.input +inp_size equ IOCTL.inp_size +output equ IOCTL.output +out_size equ IOCTL.out_size align 4 proc srv_handler stdcall, ioctl:dword - mov esi, [ioctl] - test esi, esi - jz .err + mov esi, [ioctl] + test esi, esi + jz .err - mov edi, [esi+handle] - cmp [edi+SRV.magic], ' SRV' + mov edi, [esi+handle] + cmp [edi+SRV.magic], ' SRV' jne .fail - cmp [edi+SRV.size], SRV_SIZE + cmp [edi+SRV.size], SRV_SIZE jne .fail - stdcall [edi+SRV.srv_proc], esi - ret + stdcall [edi+SRV.srv_proc], esi + ret .fail: - xor eax, eax - not eax - mov [esi+output], eax - mov [esi+out_size], 4 - ret + xor eax, eax + not eax + mov [esi+output], eax + mov [esi+out_size], 4 + ret .err: - xor eax, eax - not eax - ret + xor eax, eax + not eax + ret endp ; param @@ -281,21 +294,21 @@ endp align 4 srv_handlerEx: - cmp ebx, OS_BASE - jae .fail + cmp ebx, OS_BASE + jae .fail - mov eax, [ebx+handle] - cmp [eax+SRV.magic], ' SRV' + mov eax, [ebx+handle] + cmp [eax+SRV.magic], ' SRV' jne .fail - cmp [eax+SRV.size], SRV_SIZE + cmp [eax+SRV.size], SRV_SIZE jne .fail - stdcall [eax+SRV.srv_proc], ebx - ret + stdcall [eax+SRV.srv_proc], ebx + ret .fail: - or eax, -1 - ret + or eax, -1 + ret restore handle restore io_code @@ -306,90 +319,90 @@ restore out_size align 4 proc get_service stdcall, sz_name:dword - mov eax, [sz_name] - test eax, eax - jnz @F - ret + mov eax, [sz_name] + test eax, eax + jnz @F + ret @@: - mov edx, [srv.fd] + mov edx, [srv.fd] @@: - cmp edx, srv.fd-SRV_FD_OFFSET - je .not_load + cmp edx, srv.fd-SRV_FD_OFFSET + je .not_load - stdcall strncmp, edx, [sz_name], 16 - test eax, eax - je .ok + stdcall strncmp, edx, [sz_name], 16 + test eax, eax + je .ok - mov edx, [edx+SRV.fd] - jmp @B + mov edx, [edx+SRV.fd] + jmp @B .not_load: - pop ebp - jmp load_driver + pop ebp + jmp load_driver .ok: - mov eax, edx - ret + mov eax, edx + ret endp align 4 reg_service: .sz_name equ esp+4 .handler equ esp+8 - mov eax, [.sz_name] + mov eax, [.sz_name] test eax, eax jz .fail - mov ebx, [.handler] + mov ebx, [.handler] test ebx, ebx jz .fail - mov eax, SRV_SIZE - call malloc ;call alloc_service + mov eax, SRV_SIZE + call malloc ;call alloc_service test eax, eax jz .fail mov edi, eax - mov esi, [.sz_name] - mov ecx, 16/4 - rep movsd + mov esi, [.sz_name] + mov ecx, 16/4 + rep movsd - mov [eax+SRV.magic], ' SRV' - mov [eax+SRV.size], SRV_SIZE + mov [eax+SRV.magic], ' SRV' + mov [eax+SRV.size], SRV_SIZE - mov ebx, srv.fd-SRV_FD_OFFSET - mov edx, [ebx+SRV.fd] - mov [eax+SRV.fd], edx - mov [eax+SRV.bk], ebx - mov [ebx+SRV.fd], eax - mov [edx+SRV.bk], eax + mov ebx, srv.fd-SRV_FD_OFFSET + mov edx, [ebx+SRV.fd] + mov [eax+SRV.fd], edx + mov [eax+SRV.bk], ebx + mov [ebx+SRV.fd], eax + mov [edx+SRV.bk], eax - mov ecx, [.handler] - mov [eax+SRV.srv_proc], ecx - ret 8 + mov ecx, [.handler] + mov [eax+SRV.srv_proc], ecx + ret 8 .fail: xor eax, eax - ret 8 + ret 8 align 4 proc get_proc stdcall, exp:dword, sz_name:dword - mov edx, [exp] + mov edx, [exp] .next: - mov eax, [edx] - test eax, eax - jz .end + mov eax, [edx] + test eax, eax + jz .end - push edx - stdcall strncmp, eax, [sz_name], 16 - pop edx - test eax, eax - jz .ok + push edx + stdcall strncmp, eax, [sz_name], 16 + pop edx + test eax, eax + jz .ok - add edx,8 - jmp .next + add edx,8 + jmp .next .ok: - mov eax, [edx+4] + mov eax, [edx+4] .end: - ret + ret endp align 4 @@ -412,75 +425,75 @@ endp align 4 proc get_curr_task - mov eax,[CURRENT_TASK] - shl eax, 8 - ret + mov eax,[CURRENT_TASK] + shl eax, 8 + ret endp align 4 proc get_fileinfo stdcall, file_name:dword, info:dword - locals - cmd dd ? - offset dd ? - dd ? - count dd ? - buff dd ? - db ? - name dd ? - endl + locals + cmd dd ? + offset dd ? + dd ? + count dd ? + buff dd ? + db ? + name dd ? + endl - xor eax, eax - mov ebx, [file_name] - mov ecx, [info] + xor eax, eax + mov ebx, [file_name] + mov ecx, [info] - mov [cmd], 5 - mov [offset], eax - mov [offset+4], eax - mov [count], eax - mov [buff], ecx - mov byte [buff+4], al - mov [name], ebx + mov [cmd], 5 + mov [offset], eax + mov [offset+4], eax + mov [count], eax + mov [buff], ecx + mov byte [buff+4], al + mov [name], ebx - mov eax, 70 - lea ebx, [cmd] - int 0x40 - ret + mov eax, 70 + lea ebx, [cmd] + int 0x40 + ret endp align 4 proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\ - bytes:dword - locals - cmd dd ? - offset dd ? - dd ? - count dd ? - buff dd ? - db ? - name dd ? - endl + bytes:dword + locals + cmd dd ? + offset dd ? + dd ? + count dd ? + buff dd ? + db ? + name dd ? + endl - xor eax, eax - mov ebx, [file_name] - mov ecx, [off] - mov edx, [bytes] - mov esi, [buffer] + xor eax, eax + mov ebx, [file_name] + mov ecx, [off] + mov edx, [bytes] + mov esi, [buffer] - mov [cmd], eax - mov [offset], ecx - mov [offset+4], eax - mov [count], edx - mov [buff], esi - mov byte [buff+4], al - mov [name], ebx + mov [cmd], eax + mov [offset], ecx + mov [offset+4], eax + mov [count], edx + mov [buff], esi + mov byte [buff+4], al + mov [name], ebx - pushad - push eax - lea eax, [cmd] - call file_system_lfn - pop eax - popad - ret + pushad + push eax + lea eax, [cmd] + call file_system_lfn + pop eax + popad + ret endp ; description @@ -499,527 +512,527 @@ endp align 4 proc load_file stdcall, file_name:dword - locals - attr dd ? - flags dd ? - cr_time dd ? - cr_date dd ? - acc_time dd ? - acc_date dd ? - mod_time dd ? - mod_date dd ? - file_size dd ? + locals + attr dd ? + flags dd ? + cr_time dd ? + cr_date dd ? + acc_time dd ? + acc_date dd ? + mod_time dd ? + mod_date dd ? + file_size dd ? - file dd ? - file2 dd ? - endl + file dd ? + file2 dd ? + endl - push esi - push edi + push esi + push edi - lea eax, [attr] - stdcall get_fileinfo, [file_name], eax - test eax, eax - jnz .fail + lea eax, [attr] + stdcall get_fileinfo, [file_name], eax + test eax, eax + jnz .fail - mov eax, [file_size] - cmp eax, 1024*1024*16 - ja .fail + mov eax, [file_size] + cmp eax, 1024*1024*16 + ja .fail - stdcall kernel_alloc, [file_size] - mov [file], eax + stdcall kernel_alloc, [file_size] + mov [file], eax - stdcall read_file, [file_name], eax, dword 0, [file_size] - cmp ebx, [file_size] - jne .cleanup + stdcall read_file, [file_name], eax, dword 0, [file_size] + cmp ebx, [file_size] + jne .cleanup - mov eax, [file] - cmp dword [eax], 0x4B43504B - jne .exit - mov ebx, [eax+4] - mov [file_size], ebx - stdcall kernel_alloc, ebx + mov eax, [file] + cmp dword [eax], 0x4B43504B + jne .exit + mov ebx, [eax+4] + mov [file_size], ebx + stdcall kernel_alloc, ebx - test eax, eax - jz .cleanup + test eax, eax + jz .cleanup - mov [file2], eax - stdcall unpack, [file], eax - stdcall kernel_free, [file] - mov eax, [file2] - mov ebx, [file_size] + mov [file2], eax + stdcall unpack, [file], eax + stdcall kernel_free, [file] + mov eax, [file2] + mov ebx, [file_size] .exit: - push eax - lea edi, [eax+ebx] ;cleanup remain space - mov ecx, 4096 ;from file end - and ebx, 4095 - jz @f - sub ecx, ebx - xor eax, eax - cld - rep stosb + push eax + lea edi, [eax+ebx] ;cleanup remain space + mov ecx, 4096 ;from file end + and ebx, 4095 + jz @f + sub ecx, ebx + xor eax, eax + cld + rep stosb @@: - mov ebx, [file_size] - pop eax - pop edi - pop esi - ret + mov ebx, [file_size] + pop eax + pop edi + pop esi + ret .cleanup: - stdcall kernel_free, [file] + stdcall kernel_free, [file] .fail: - xor eax, eax - xor ebx, ebx - pop edi - pop esi - ret + xor eax, eax + xor ebx, ebx + pop edi + pop esi + ret endp align 4 proc get_proc_ex stdcall, proc_name:dword, imports:dword .look_up: - mov edx, [imports] - test edx, edx - jz .end - mov edx, [edx] - test edx, edx - jz .end + mov edx, [imports] + test edx, edx + jz .end + mov edx, [edx] + test edx, edx + jz .end .next: - mov eax, [edx] - test eax, eax - jz .next_table + mov eax, [edx] + test eax, eax + jz .next_table - push edx - stdcall strncmp, eax, [proc_name], 16 - pop edx - test eax, eax - jz .ok + push edx + stdcall strncmp, eax, [proc_name], 16 + pop edx + test eax, eax + jz .ok - add edx,8 - jmp .next + add edx,8 + jmp .next .next_table: - add [imports], 4 - jmp .look_up + add [imports], 4 + jmp .look_up .ok: - mov eax, [edx+4] - ret + mov eax, [edx+4] + ret .end: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc fix_coff_symbols stdcall, sec:dword, symbols:dword,\ - sym_count:dword, strings:dword, imports:dword - locals - retval dd ? - endl + sym_count:dword, strings:dword, imports:dword + locals + retval dd ? + endl - mov edi, [symbols] - mov [retval], 1 + mov edi, [symbols] + mov [retval], 1 .fix: - movzx ebx, [edi+CSYM.SectionNumber] - test ebx, ebx - jnz .internal - mov eax, dword [edi+CSYM.Name] - test eax, eax - jnz @F + movzx ebx, [edi+CSYM.SectionNumber] + test ebx, ebx + jnz .internal + mov eax, dword [edi+CSYM.Name] + test eax, eax + jnz @F - mov edi, [edi+4] - add edi, [strings] + mov edi, [edi+4] + add edi, [strings] @@: - push edi - stdcall get_proc_ex, edi,[imports] - pop edi + push edi + stdcall get_proc_ex, edi,[imports] + pop edi - xor ebx, ebx - test eax, eax - jnz @F + xor ebx, ebx + test eax, eax + jnz @F - mov esi, msg_unresolved - call sys_msg_board_str - mov esi, edi - call sys_msg_board_str - mov esi, msg_CR - call sys_msg_board_str + mov esi, msg_unresolved + call sys_msg_board_str + mov esi, edi + call sys_msg_board_str + mov esi, msg_CR + call sys_msg_board_str - mov [retval],0 + mov [retval],0 @@: - mov edi, [symbols] - mov [edi+CSYM.Value], eax - jmp .next + mov edi, [symbols] + mov [edi+CSYM.Value], eax + jmp .next .internal: - cmp bx, -1 - je .next - cmp bx, -2 - je .next + cmp bx, -1 + je .next + cmp bx, -2 + je .next - dec ebx - shl ebx, 3 - lea ebx, [ebx+ebx*4] - add ebx, [sec] + dec ebx + shl ebx, 3 + lea ebx, [ebx+ebx*4] + add ebx, [sec] - mov eax, [ebx+CFS.VirtualAddress] - add [edi+CSYM.Value], eax + mov eax, [ebx+CFS.VirtualAddress] + add [edi+CSYM.Value], eax .next: - add edi, CSYM_SIZE - mov [symbols], edi - dec [sym_count] - jnz .fix - mov eax, [retval] - ret + add edi, CSYM_SIZE + mov [symbols], edi + dec [sym_count] + jnz .fix + mov eax, [retval] + ret endp align 4 proc fix_coff_relocs stdcall, coff:dword, sec:dword, sym:dword locals - n_sec dd ? + n_sec dd ? endl - mov eax, [coff] - movzx ebx, [eax+CFH.nSections] - mov [n_sec], ebx + mov eax, [coff] + movzx ebx, [eax+CFH.nSections] + mov [n_sec], ebx .fix_sec: - mov esi, [sec] + mov esi, [sec] mov edi, [esi+CFS.PtrReloc] - add edi, [coff] + add edi, [coff] - movzx ecx, [esi+CFS.NumReloc] - test ecx, ecx - jz .next + movzx ecx, [esi+CFS.NumReloc] + test ecx, ecx + jz .next .next_reloc: mov ebx, [edi+CRELOC.SymIndex] add ebx,ebx lea ebx,[ebx+ebx*8] - add ebx, [sym] + add ebx, [sym] - mov edx, [ebx+CSYM.Value] + mov edx, [ebx+CSYM.Value] - cmp [edi+CRELOC.Type], 6 - je .dir_32 + cmp [edi+CRELOC.Type], 6 + je .dir_32 - cmp [edi+CRELOC.Type], 20 - jne .next_reloc + cmp [edi+CRELOC.Type], 20 + jne .next_reloc .rel_32: mov eax, [edi+CRELOC.VirtualAddress] - add eax, [esi+CFS.VirtualAddress] - sub edx, eax - sub edx, 4 - jmp .fix + add eax, [esi+CFS.VirtualAddress] + sub edx, eax + sub edx, 4 + jmp .fix .dir_32: mov eax, [edi+CRELOC.VirtualAddress] - add eax, [esi+CFS.VirtualAddress] + add eax, [esi+CFS.VirtualAddress] .fix: - add [eax], edx - add edi, 10 - dec ecx - jnz .next_reloc + add [eax], edx + add edi, 10 + dec ecx + jnz .next_reloc .next: - add [sec], COFF_SECTION_SIZE - dec [n_sec] - jnz .fix_sec + add [sec], COFF_SECTION_SIZE + dec [n_sec] + jnz .fix_sec .exit: ret endp align 4 proc load_driver stdcall, driver_name:dword - locals - coff dd ? - sym dd ? - strings dd ? - img_size dd ? - img_base dd ? - start dd ? + locals + coff dd ? + sym dd ? + strings dd ? + img_size dd ? + img_base dd ? + start dd ? - exports dd ? ;fake exports table - dd ? - file_name rb 13+16+4+1 ; '/sys/drivers/.obj' - endl + exports dd ? ;fake exports table + dd ? + file_name rb 13+16+4+1 ; '/sys/drivers/.obj' + endl - lea edx, [file_name] - mov dword [edx], '/sys' - mov dword [edx+4], '/dri' - mov dword [edx+8], 'vers' - mov byte [edx+12], '/' - mov esi, [driver_name] - lea edi, [edx+13] - mov ecx, 16 + lea edx, [file_name] + mov dword [edx], '/sys' + mov dword [edx+4], '/dri' + mov dword [edx+8], 'vers' + mov byte [edx+12], '/' + mov esi, [driver_name] + lea edi, [edx+13] + mov ecx, 16 @@: - lodsb - test al, al - jz @f - stosb - loop @b + lodsb + test al, al + jz @f + stosb + loop @b @@: - mov dword [edi], '.obj' - mov byte [edi+4], 0 - stdcall load_file, edx + mov dword [edi], '.obj' + mov byte [edi+4], 0 + stdcall load_file, edx - test eax, eax - jz .exit + test eax, eax + jz .exit - mov [coff], eax + mov [coff], eax - movzx ecx, [eax+CFH.nSections] - xor ebx, ebx + movzx ecx, [eax+CFH.nSections] + xor ebx, ebx - lea edx, [eax+20] + lea edx, [eax+20] @@: - add ebx, [edx+CFS.SizeOfRawData] - add ebx, 15 - and ebx, not 15 - add edx, COFF_SECTION_SIZE - dec ecx - jnz @B - mov [img_size], ebx + add ebx, [edx+CFS.SizeOfRawData] + add ebx, 15 + and ebx, not 15 + add edx, COFF_SECTION_SIZE + dec ecx + jnz @B + mov [img_size], ebx - stdcall kernel_alloc, ebx - test eax, eax - jz .fail - mov [img_base], eax + stdcall kernel_alloc, ebx + test eax, eax + jz .fail + mov [img_base], eax - mov edi, eax - xor eax, eax - mov ecx, [img_size] - add ecx, 4095 - and ecx, not 4095 - shr ecx, 2 - cld - rep stosd + mov edi, eax + xor eax, eax + mov ecx, [img_size] + add ecx, 4095 + and ecx, not 4095 + shr ecx, 2 + cld + rep stosd - mov edx, [coff] - movzx ebx, [edx+CFH.nSections] - mov edi, [img_base] - lea eax, [edx+20] + mov edx, [coff] + movzx ebx, [edx+CFH.nSections] + mov edi, [img_base] + lea eax, [edx+20] @@: - mov [eax+CFS.VirtualAddress], edi - mov esi, [eax+CFS.PtrRawData] - test esi, esi - jnz .copy - add edi, [eax+CFS.SizeOfRawData] - jmp .next + mov [eax+CFS.VirtualAddress], edi + mov esi, [eax+CFS.PtrRawData] + test esi, esi + jnz .copy + add edi, [eax+CFS.SizeOfRawData] + jmp .next .copy: - add esi, edx - mov ecx, [eax+CFS.SizeOfRawData] - cld - rep movsb + add esi, edx + mov ecx, [eax+CFS.SizeOfRawData] + cld + rep movsb .next: - add edi, 15 - and edi, not 15 - add eax, COFF_SECTION_SIZE - dec ebx - jnz @B + add edi, 15 + and edi, not 15 + add eax, COFF_SECTION_SIZE + dec ebx + jnz @B - mov ebx, [edx+CFH.pSymTable] - add ebx, edx - mov [sym], ebx - mov ecx, [edx+CFH.nSymbols] - add ecx,ecx - lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE - add ecx, [sym] - mov [strings], ecx + mov ebx, [edx+CFH.pSymTable] + add ebx, edx + mov [sym], ebx + mov ecx, [edx+CFH.nSymbols] + add ecx,ecx + lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE + add ecx, [sym] + mov [strings], ecx - lea ebx, [exports] - mov dword [ebx], kernel_export - mov dword [ebx+4], 0 - lea eax, [edx+20] + lea ebx, [exports] + mov dword [ebx], kernel_export + mov dword [ebx+4], 0 + lea eax, [edx+20] - stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ - [strings], ebx - test eax, eax - jz .link_fail + stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ + [strings], ebx + test eax, eax + jz .link_fail - mov ebx, [coff] - add ebx, 20 - stdcall fix_coff_relocs, [coff], ebx, [sym] + mov ebx, [coff] + add ebx, 20 + stdcall fix_coff_relocs, [coff], ebx, [sym] - mov ebx, [coff] - stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion - test eax, eax - jz .link_fail + mov ebx, [coff] + stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion + test eax, eax + jz .link_fail - mov eax, [eax] - shr eax, 16 - cmp eax, DRV_COMPAT - jb .ver_fail + mov eax, [eax] + shr eax, 16 + cmp eax, DRV_COMPAT + jb .ver_fail - cmp eax, DRV_CURRENT - ja .ver_fail + cmp eax, DRV_CURRENT + ja .ver_fail - mov ebx, [coff] - stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART - mov [start], eax + mov ebx, [coff] + stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART + mov [start], eax - stdcall kernel_free, [coff] + stdcall kernel_free, [coff] - mov ebx, [start] - stdcall ebx, DRV_ENTRY - test eax, eax - jnz .ok + mov ebx, [start] + stdcall ebx, DRV_ENTRY + test eax, eax + jnz .ok - stdcall kernel_free, [img_base] - xor eax, eax - ret + stdcall kernel_free, [img_base] + xor eax, eax + ret .ok: - mov ebx, [img_base] - mov [eax+SRV.base], ebx - mov ecx, [start] - mov [eax+SRV.entry], ecx - ret + mov ebx, [img_base] + mov [eax+SRV.base], ebx + mov ecx, [start] + mov [eax+SRV.entry], ecx + ret .ver_fail: - mov esi, msg_CR - call sys_msg_board_str - mov esi, [driver_name] - call sys_msg_board_str - mov esi, msg_CR - call sys_msg_board_str - mov esi, msg_version - call sys_msg_board_str - mov esi, msg_www - call sys_msg_board_str - jmp .cleanup + mov esi, msg_CR + call sys_msg_board_str + mov esi, [driver_name] + call sys_msg_board_str + mov esi, msg_CR + call sys_msg_board_str + mov esi, msg_version + call sys_msg_board_str + mov esi, msg_www + call sys_msg_board_str + jmp .cleanup .link_fail: - mov esi, msg_module - call sys_msg_board_str - mov esi, [driver_name] - call sys_msg_board_str - mov esi, msg_CR - call sys_msg_board_str + mov esi, msg_module + call sys_msg_board_str + mov esi, [driver_name] + call sys_msg_board_str + mov esi, msg_CR + call sys_msg_board_str .cleanup: - stdcall kernel_free,[img_base] + stdcall kernel_free,[img_base] .fail: - stdcall kernel_free, [coff] + stdcall kernel_free, [coff] .exit: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc load_library stdcall, file_name:dword - locals - coff dd ? - sym dd ? - strings dd ? - img_size dd ? - img_base dd ? - exports dd ? - endl + locals + coff dd ? + sym dd ? + strings dd ? + img_size dd ? + img_base dd ? + exports dd ? + endl - cli + cli - stdcall load_file, [file_name] - test eax, eax - jz .fail + stdcall load_file, [file_name] + test eax, eax + jz .fail - mov [coff], eax - movzx ecx, [eax+CFH.nSections] - xor ebx, ebx + mov [coff], eax + movzx ecx, [eax+CFH.nSections] + xor ebx, ebx - lea edx, [eax+20] + lea edx, [eax+20] @@: - add ebx, [edx+CFS.SizeOfRawData] - add ebx, 15 - and ebx, not 15 - add edx, COFF_SECTION_SIZE - dec ecx - jnz @B - mov [img_size], ebx + add ebx, [edx+CFS.SizeOfRawData] + add ebx, 15 + and ebx, not 15 + add edx, COFF_SECTION_SIZE + dec ecx + jnz @B + mov [img_size], ebx - call init_heap - stdcall user_alloc, [img_size] + call init_heap + stdcall user_alloc, [img_size] - test eax, eax - jz .fail - mov [img_base], eax + test eax, eax + jz .fail + mov [img_base], eax - mov edx, [coff] - movzx ebx, [edx+CFH.nSections] - mov edi, [img_base] - lea eax, [edx+20] + mov edx, [coff] + movzx ebx, [edx+CFH.nSections] + mov edi, [img_base] + lea eax, [edx+20] @@: - mov [eax+CFS.VirtualAddress], edi - mov esi, [eax+CFS.PtrRawData] - test esi, esi - jnz .copy - add edi, [eax+CFS.SizeOfRawData] - jmp .next + mov [eax+CFS.VirtualAddress], edi + mov esi, [eax+CFS.PtrRawData] + test esi, esi + jnz .copy + add edi, [eax+CFS.SizeOfRawData] + jmp .next .copy: - add esi, edx + add esi, edx ; add edi, new_app_base - mov ecx, [eax+CFS.SizeOfRawData] - cld - rep movsb + mov ecx, [eax+CFS.SizeOfRawData] + cld + rep movsb .next: - add edi, 15 ;-new_app_base - and edi, -16 - add eax, COFF_SECTION_SIZE - dec ebx - jnz @B + add edi, 15 ;-new_app_base + and edi, -16 + add eax, COFF_SECTION_SIZE + dec ebx + jnz @B - mov ebx, [edx+CFH.pSymTable] - add ebx, edx - mov [sym], ebx - mov ecx, [edx+CFH.nSymbols] - add ecx,ecx - lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE - add ecx, [sym] - mov [strings], ecx + mov ebx, [edx+CFH.pSymTable] + add ebx, edx + mov [sym], ebx + mov ecx, [edx+CFH.nSymbols] + add ecx,ecx + lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE + add ecx, [sym] + mov [strings], ecx - lea eax, [edx+20] + lea eax, [edx+20] - stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ - [strings], dword 0 - test eax, eax - jnz @F + stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ + [strings], dword 0 + test eax, eax + jnz @F @@: - mov edx, [coff] - movzx ebx, [edx+CFH.nSections] - mov edi, new_app_base - lea eax, [edx+20] + mov edx, [coff] + movzx ebx, [edx+CFH.nSections] + mov edi, new_app_base + lea eax, [edx+20] @@: - add [eax+CFS.VirtualAddress], edi ;patch user space offset - add eax, COFF_SECTION_SIZE - dec ebx - jnz @B + add [eax+CFS.VirtualAddress], edi ;patch user space offset + add eax, COFF_SECTION_SIZE + dec ebx + jnz @B - add edx, 20 - stdcall fix_coff_relocs, [coff], edx, [sym] + add edx, 20 + stdcall fix_coff_relocs, [coff], edx, [sym] - mov ebx, [coff] - stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS - mov [exports], eax + mov ebx, [coff] + stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS + mov [exports], eax - stdcall kernel_free, [coff] - mov eax, [exports] - ret + stdcall kernel_free, [coff] + mov eax, [exports] + ret .fail: - xor eax, eax - ret + xor eax, eax + ret endp align 4 proc stop_all_services - mov edx, [srv.fd] + mov edx, [srv.fd] .next: - cmp edx, srv.fd-SRV_FD_OFFSET - je .done - cmp [edx+SRV.magic], ' SRV' - jne .next - cmp [edx+SRV.size], SRV_SIZE - jne .next - mov ebx, [edx+SRV.entry] - mov edx, [edx+SRV.fd] - push edx - stdcall ebx, dword -1 - pop edx - jmp .next + cmp edx, srv.fd-SRV_FD_OFFSET + je .done + cmp [edx+SRV.magic], ' SRV' + jne .next + cmp [edx+SRV.size], SRV_SIZE + jne .next + mov ebx, [edx+SRV.entry] + mov edx, [edx+SRV.fd] + push edx + stdcall ebx, dword -1 + pop edx + jmp .next .done: - ret + ret endp ; param @@ -1029,27 +1042,27 @@ endp align 4 create_kernel_object: - push ebx - call malloc - pop ebx - test eax, eax - jz .fail + push ebx + call malloc + pop ebx + test eax, eax + jz .fail - mov ecx,[current_slot] - add ecx, APP_OBJ_OFFSET + mov ecx,[current_slot] + add ecx, APP_OBJ_OFFSET - pushfd - cli - mov edx, [ecx+APPOBJ.fd] - mov [eax+APPOBJ.fd], edx - mov [eax+APPOBJ.bk], ecx - mov [eax+APPOBJ.pid], ebx + pushfd + cli + mov edx, [ecx+APPOBJ.fd] + mov [eax+APPOBJ.fd], edx + mov [eax+APPOBJ.bk], ecx + mov [eax+APPOBJ.pid], ebx - mov [ecx+APPOBJ.fd], eax - mov [edx+APPOBJ.bk], eax - popfd + mov [ecx+APPOBJ.fd], eax + mov [edx+APPOBJ.bk], eax + popfd .fail: - ret + ret ; param ; eax= object @@ -1057,23 +1070,23 @@ create_kernel_object: align 4 destroy_kernel_object: - pushfd - cli - mov ebx, [eax+APPOBJ.fd] - mov ecx, [eax+APPOBJ.bk] - mov [ebx+APPOBJ.bk], ecx - mov [ecx+APPOBJ.fd], ebx - popfd + pushfd + cli + mov ebx, [eax+APPOBJ.fd] + mov ecx, [eax+APPOBJ.bk] + mov [ebx+APPOBJ.bk], ecx + mov [ecx+APPOBJ.fd], ebx + popfd - xor edx, edx ;clear common header - mov [eax], edx - mov [eax+4], edx - mov [eax+8], edx - mov [eax+12], edx - mov [eax+16], edx + xor edx, edx ;clear common header + mov [eax], edx + mov [eax+4], edx + mov [eax+8], edx + mov [eax+12], edx + mov [eax+16], edx - call free ;release object memory - ret + call free ;release object memory + ret @@ -1082,59 +1095,59 @@ if 0 irq: .irq0: - pusfd - pushad - push IRQ_0 - jmp .master + pusfd + pushad + push IRQ_0 + jmp .master .irq_1: - pusfd - pushad - push IRQ_1 - jmp .master + pusfd + pushad + push IRQ_1 + jmp .master .master: - mov ax, app_data - mov ds, eax - mov es, eax - mov ebx, [esp+4] ;IRQ_xx - mov eax, [irq_handlers+ebx+4] - call intr_handler - mov ecx, [esp+4] - cmp [irq_actids+ecx*4], 0 - je @F - in al, 0x21 - bts eax, ecx - out 0x21, al - mov al, 0x20 - out 0x20, al - jmp .restart + mov ax, app_data + mov ds, eax + mov es, eax + mov ebx, [esp+4] ;IRQ_xx + mov eax, [irq_handlers+ebx+4] + call intr_handler + mov ecx, [esp+4] + cmp [irq_actids+ecx*4], 0 + je @F + in al, 0x21 + bts eax, ecx + out 0x21, al + mov al, 0x20 + out 0x20, al + jmp .restart .slave: - mov ax, app_data - mov ds, eax - mov es, eax - mov ebx, [esp+4] ;IRQ_xx - mov eax, [irq_handlers+ebx+4] - call intr_handler - mov ecx, [esp+4] - sub ecx, 8 - cmp [irq_actids+ecx*4], 0 - je @F - in al, 0xA1 - bts eax, ecx - out 0xA1, al - mov al, 0x20 - out 0xA0, al - out 0x20, al + mov ax, app_data + mov ds, eax + mov es, eax + mov ebx, [esp+4] ;IRQ_xx + mov eax, [irq_handlers+ebx+4] + call intr_handler + mov ecx, [esp+4] + sub ecx, 8 + cmp [irq_actids+ecx*4], 0 + je @F + in al, 0xA1 + bts eax, ecx + out 0xA1, al + mov al, 0x20 + out 0xA0, al + out 0x20, al .restart: - mov ebx, [next_slot] - test ebx, ebx - jz @F - mov [next_task],0 - mov esi, [prev_slot] - call do_change_task - add esp, 4 - iretd + mov ebx, [next_slot] + test ebx, ebx + jz @F + mov [next_task],0 + mov esi, [prev_slot] + call do_change_task + add esp, 4 + iretd end if diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index a63e483544..1ec7416334 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -9,52 +9,53 @@ $Revision$ iglobal - szKernel db 'KERNEL', 0 - szVersion db 'version',0 + szKernel db 'KERNEL', 0 + szVersion db 'version',0 - szRegService db 'RegService',0 - szGetService db 'GetService',0 + szRegService db 'RegService',0 + szGetService db 'GetService',0 szServiceHandler db 'ServiceHandler',0 szAttachIntHandler db 'AttachIntHandler',0 - szFpuSave db 'FpuSave',0 - szFpuRestore db 'FpuRestore',0 + szFpuSave db 'FpuSave',0 + szFpuRestore db 'FpuRestore',0 - szPciApi db 'PciApi', 0 - szPciRead32 db 'PciRead32', 0 - szPciRead16 db 'PciRead16', 0 - szPciRead8 db 'PciRead8', 0 - szPciWrite8 db 'PciWrite8',0 - szPciWrite16 db 'PciWrite16',0 + szPciApi db 'PciApi', 0 + szPciRead32 db 'PciRead32', 0 + szPciRead16 db 'PciRead16', 0 + szPciRead8 db 'PciRead8', 0 + szPciWrite8 db 'PciWrite8',0 + szPciWrite16 db 'PciWrite16',0 + szPciWrite32 db 'PciWrite32',0 - szAllocPage db 'AllocPage',0 - szAllocPages db 'AllocPages',0 - szFreePage db 'FreePage',0 - szGetPgAddr db 'GetPgAddr',0 - szMapPage db 'MapPage',0 - szMapSpace db 'MapSpace',0 + szAllocPage db 'AllocPage',0 + szAllocPages db 'AllocPages',0 + szFreePage db 'FreePage',0 + szGetPgAddr db 'GetPgAddr',0 + szMapPage db 'MapPage',0 + szMapSpace db 'MapSpace',0 szCommitPages db 'CommitPages',0 szReleasePages db 'ReleasePages',0 szAllocKernelSpace db 'AllocKernelSpace',0 szFreeKernelSpace db 'FreeKernelSpace',0 szKernelAlloc db 'KernelAlloc',0 - szKernelFree db 'KernelFree',0 - szUserAlloc db 'UserAlloc',0 - szUserFree db 'UserFree',0 - szKmalloc db 'Kmalloc',0 - szKfree db 'Kfree',0 + szKernelFree db 'KernelFree',0 + szUserAlloc db 'UserAlloc',0 + szUserFree db 'UserFree',0 + szKmalloc db 'Kmalloc',0 + szKfree db 'Kfree',0 szCreateRingBuffer db 'CreateRingBuffer',0 - szGetPid db 'GetPid',0 + szGetPid db 'GetPid',0 szCreateObject db 'CreateObject',0 szDestroyObject db 'DestroyObject',0 szCreateEvent db 'CreateEvent',0 - szRaiseEvent db 'RaiseEvent',0 - szWaitEvent db 'WaitEvent',0 + szRaiseEvent db 'RaiseEvent',0 + szWaitEvent db 'WaitEvent',0 szDestroyEvent db 'DestroyEvent',0 - szClearEvent db 'ClearEvent',0 + szClearEvent db 'ClearEvent',0 - szLoadCursor db 'LoadCursor',0 + szLoadCursor db 'LoadCursor',0 szSelectHwCursor db 'SelectHwCursor',0 szSetHwCursor db 'SetHwCursor',0 szHwCursorRestore db 'HwCursorRestore', 0 @@ -62,19 +63,19 @@ iglobal szSysMsgBoardStr db 'SysMsgBoardStr', 0 szGetCurrentTask db 'GetCurrentTask',0 - szLFBAddress db 'LFBAddress',0 - szLoadFile db 'LoadFile',0 - szSendEvent db 'SendEvent',0 + szLFBAddress db 'LFBAddress',0 + szLoadFile db 'LoadFile',0 + szSendEvent db 'SendEvent',0 szSetMouseData db 'SetMouseData',0 - szSleep db 'Sleep',0 + szSleep db 'Sleep',0 szGetTimerTicks db 'GetTimerTicks',0 - szStrncat db 'strncat',0 - szStrncpy db 'strncpy',0 - szstrncmp db 'strncmp',0 - szStrnlen db 'strnlen',0 - szStrchr db 'strchr',0 - szStrrchr db 'strrchr',0 + szStrncat db 'strncat',0 + szStrncpy db 'strncpy',0 + szstrncmp db 'strncmp',0 + szStrnlen db 'strnlen',0 + szStrchr db 'strchr',0 + szStrrchr db 'strrchr',0 align 16 @@ -83,36 +84,37 @@ kernel_export: dd szGetService , get_service dd szServiceHandler , srv_handler dd szAttachIntHandler, attach_int_handler - dd szFpuSave , fpu_save + dd szFpuSave , fpu_save dd szFpuRestore , fpu_restore - dd szPciApi , pci_api + dd szPciApi , pci_api dd szPciRead32 , pci_read32 dd szPciRead16 , pci_read16 dd szPciRead8 , pci_read8 dd szPciWrite8 , pci_write8 dd szPciWrite16 , pci_write16 + dd szPciWrite32 , pci_write32 - dd szAllocPage , alloc_page ;stdcall - dd szAllocPages , alloc_pages ;stdcall + dd szAllocPage , alloc_page ;stdcall + dd szAllocPages , alloc_pages ;stdcall dd szFreePage , free_page - dd szMapPage , map_page ;stdcall + dd szMapPage , map_page ;stdcall dd szMapSpace , map_space dd szGetPgAddr , get_pg_addr - dd szCommitPages , commit_pages ;not implemented + dd szCommitPages , commit_pages ;not implemented dd szReleasePages , release_pages dd szAllocKernelSpace, alloc_kernel_space ;stdcall dd szFreeKernelSpace , free_kernel_space ;stdcall - dd szKernelAlloc , kernel_alloc ;stdcall - dd szKernelFree , kernel_free ;stdcall - dd szUserAlloc , user_alloc ;stdcall - dd szUserFree , user_free ;stdcall - dd szKmalloc , malloc - dd szKfree , free + dd szKernelAlloc , kernel_alloc ;stdcall + dd szKernelFree , kernel_free ;stdcall + dd szUserAlloc , user_alloc ;stdcall + dd szUserFree , user_free ;stdcall + dd szKmalloc , malloc + dd szKfree , free dd szCreateRingBuffer, create_ring_buffer - dd szGetPid , get_pid + dd szGetPid , get_pid dd szCreateObject , create_kernel_object dd szDestroyObject , destroy_kernel_object dd szCreateEvent , create_event @@ -121,31 +123,31 @@ kernel_export: dd szDestroyEvent , destroy_event dd szClearEvent , clear_event - dd szLoadCursor , load_cursor ;stdcall + dd szLoadCursor , load_cursor ;stdcall dd szSelectHwCursor , select_hw_cursor ;import - dd szSetHwCursor , set_hw_cursor ;import - dd szHwCursorRestore , hw_restore ;import - dd szHwCursorCreate , create_cursor ;import + dd szSetHwCursor , set_hw_cursor ;import + dd szHwCursorRestore , hw_restore ;import + dd szHwCursorCreate , create_cursor ;import dd szSysMsgBoardStr , sys_msg_board_str dd szGetCurrentTask , get_curr_task - dd szLoadFile , load_file ;retval eax, ebx + dd szLoadFile , load_file ;retval eax, ebx dd szSendEvent , send_event dd szSetMouseData , set_mouse_data ;stdcall - dd szSleep , delay_ms + dd szSleep , delay_ms dd szGetTimerTicks , get_timer_ticks - dd szStrncat , strncat - dd szStrncpy , strncpy - dd szstrncmp , strncmp - dd szStrnlen , strnlen - dd szStrchr , strchr - dd szStrrchr , strrchr + dd szStrncat , strncat + dd szStrncpy , strncpy + dd szstrncmp , strncmp + dd szStrnlen , strnlen + dd szStrchr , strchr + dd szStrrchr , strrchr exp_lfb: dd szLFBAddress , 0 - dd 0 ;terminator, must be zero + dd 0 ;terminator, must be zero endg diff --git a/kernel/trunk/drivers/imports.inc b/kernel/trunk/drivers/imports.inc index 5472211254..596ed6c592 100644 --- a/kernel/trunk/drivers/imports.inc +++ b/kernel/trunk/drivers/imports.inc @@ -28,6 +28,7 @@ kernel_export \ PciRead8,\ PciWrite8,\ PciWrite16,\ + PciWrite32,\ \ AllocPage,\ AllocPages,\