kolibri-acpi: update

git-svn-id: svn://kolibrios.org@5596 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2015-07-22 12:08:35 +00:00
parent 1888797ed4
commit 80a2140a64
83 changed files with 460 additions and 25362 deletions

View File

@ -1132,22 +1132,21 @@ check_ATAPI_device_event:
mov [ignore_CD_eject_wait], 0
ret
;-----------------------------------------------------------------------------
uglobal
align 4
timer_ATAPI_check dd ?
ATAPI_IDE0_lock db ?
ATAPI_IDE1_lock db ?
ATAPI_IDE2_lock db ?
ATAPI_IDE3_lock db ?
ATAPI_IDE4_lock db ?
ATAPI_IDE5_lock db ?
ATAPI_IDE6_lock db ?
ATAPI_IDE7_lock db ?
ATAPI_IDE8_lock db ?
ATAPI_IDE9_lock db ?
ATAPI_IDE10_lock db ?
ATAPI_IDE11_lock db ?
ignore_CD_eject_wait db ?
iglobal
timer_ATAPI_check dd 0
ATAPI_IDE0_lock db 0
ATAPI_IDE1_lock db 0
ATAPI_IDE2_lock db 0
ATAPI_IDE3_lock db 0
ATAPI_IDE4_lock db 0
ATAPI_IDE5_lock db 0
ATAPI_IDE6_lock db 0
ATAPI_IDE7_lock db 0
ATAPI_IDE8_lock db 0
ATAPI_IDE9_lock db 0
ATAPI_IDE10_lock db 0
ATAPI_IDE11_lock db 0
ignore_CD_eject_wait db 0
endg
;-----------------------------------------------------------------------------
;*************************************************

View File

@ -1,271 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
sys_cd_audio:
cmp word [cdbase], word 0
jnz @f
mov eax, 1
ret
@@:
; eax=1 cdplay at ebx 0x00FFSSMM
; eax=2 get tracklist size of ecx to [ebx]
; eax=3 stop/pause playing
cmp eax, 1
jnz nocdp
call sys_cdplay
ret
nocdp:
cmp eax, 2
jnz nocdtl
mov edi, [TASK_BASE]
add edi, TASKDATA.mem_start
add ebx, [edi]
call sys_cdtracklist
ret
nocdtl:
cmp eax, 3
jnz nocdpause
call sys_cdpause
ret
nocdpause:
mov eax, 0xffffff01
ret
sys_cd_atapi_command:
pushad
mov dx, word [cdbase]
add dx, 6
mov ax, word [cdid]
out dx, al
mov esi, 10
call delay_ms
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x80
cmp al, 0
jnz res
jmp cdl6
res:
mov dx, word [cdbase]
add dx, 7
mov al, 0x8
out dx, al
mov dx, word [cdbase]
add dx, 0x206
mov al, 0xe
out dx, al
mov esi, 1
call delay_ms
mov dx, word [cdbase]
add dx, 0x206
mov al, 0x8
out dx, al
mov esi, 30
call delay_ms
xor cx, cx
cdl5:
inc cx
cmp cx, 10
jz cdl6
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x88
cmp al, 0x00
jz cdl5
mov esi, 100
call delay_ms
jmp cdl5
cdl6:
mov dx, word [cdbase]
add dx, 4
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 5
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 7
mov al, 0xec
out dx, al
mov esi, 5
call delay_ms
mov dx, word [cdbase]
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 128
out dx, al
add dx, 2
mov al, 0xa0
out dx, al
xor cx, cx
mov dx, word [cdbase]
add dx, 7
cdl1:
inc cx
cmp cx, 100
jz cdl2
in al, dx
and ax, 0x88
cmp al, 0x8
jz cdl2
mov esi, 2
call delay_ms
jmp cdl1
cdl2:
popad
ret
sys_cdplay:
mov ax, 5
push ax
push ebx
cdplay:
call sys_cd_atapi_command
cli
mov dx, word [cdbase]
mov ax, 0x0047
out dx, ax
mov al, 1
mov ah, [esp+0]; min xx
out dx, ax
mov ax, [esp+1]; fr sec
out dx, ax
mov ax, 256+99
out dx, ax
mov ax, 0x0001
out dx, ax
mov ax, 0x0000
out dx, ax
mov esi, 10
call delay_ms
sti
add dx, 7
in al, dx
test al, 1
jz cdplayok
mov ax, [esp+4]
dec ax
mov [esp+4], ax
cmp ax, 0
jz cdplayfail
jmp cdplay
cdplayfail:
cdplayok:
pop ebx
pop ax
xor eax, eax
ret
sys_cdtracklist:
push ebx
tcdplay:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x43+2*256
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 200
out dx, ax
mov ax, 0x0
out dx, ax
in al, dx
mov cx, 1000
mov dx, word [cdbase]
add dx, 7
cld
cdtrnwewait:
mov esi, 10
call delay_ms
in al, dx
and al, 128
cmp al, 0
jz cdtrl1
loop cdtrnwewait
cdtrl1:
; read the result
mov ecx, [esp+0]
mov dx, word [cdbase]
cdtrread:
add dx, 7
in al, dx
and al, 8
cmp al, 8
jnz cdtrdone
sub dx, 7
in ax, dx
mov [ecx], ax
add ecx, 2
jmp cdtrread
cdtrdone:
pop ecx
xor eax, eax
ret
sys_cdpause:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x004B
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov esi, 10
call delay_ms
add dx, 7
in al, dx
xor eax, eax
ret

View File

@ -166,8 +166,6 @@ pci_read_reg:
call pci_make_config_cmd
mov ebx, eax
mov dx, 0xcf8
in eax, dx
push eax
; set up addressing to config data
mov eax, ebx
and al, 0xfc; make address dword-aligned
@ -193,14 +191,7 @@ pci_read_word1:
jmp pci_fin_read1
pci_read_dword1:
in eax, dx
jmp pci_fin_read1
pci_fin_read1:
; restore configuration control
xchg eax, [esp]
mov dx, 0xcf8
out dx, eax
pop eax
pop esi ebx
ret
pci_read_reg_2:
@ -211,15 +202,8 @@ pci_read_reg_2:
mov esi, eax ; save register size into ESI
and esi, 3
push eax
;store current state of config space
mov dx, 0xcf8
in al, dx
mov ah, al
mov dl, 0xfa
in al, dx
mov dx, 0xcfa
xchg eax, [esp]
; out 0xcfa,bus
mov al, ah
out dx, al
@ -248,18 +232,8 @@ pci_read_word2:
jmp pci_fin_read2
pci_read_dword2:
in eax, dx
; jmp pci_fin_read2
pci_fin_read2:
; restore configuration space
xchg eax, [esp]
mov dx, 0xcfa
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
pop eax
pop esi ebx
ret
@ -295,10 +269,7 @@ pci_write_reg:
call pci_make_config_cmd
mov ebx, eax
; get current state into ecx
mov dx, 0xcf8
in eax, dx
push eax
; set up addressing to config data
mov eax, ebx
and al, 0xfc; make address dword-aligned
@ -325,14 +296,8 @@ pci_write_word1:
jmp pci_fin_write1
pci_write_dword1:
out dx, eax
jmp pci_fin_write1
pci_fin_write1:
; restore configuration control
pop eax
mov dl, 0xf8
out dx, eax
xor eax, eax
pop ebx esi
@ -346,14 +311,7 @@ pci_write_reg_2:
mov esi, eax ; save register size into ESI
and esi, 3
push eax
;store current state of config space
mov dx, 0xcf8
in al, dx
mov ah, al
mov dl, 0xfa
in al, dx
xchg eax, [esp]
mov dx, 0xcfa
; out 0xcfa,bus
mov al, ah
out dx, al
@ -384,15 +342,7 @@ pci_write_word2:
jmp pci_fin_write2
pci_write_dword2:
out dx, eax
jmp pci_fin_write2
pci_fin_write2:
; restore configuration space
pop eax
mov dx, 0xcfa
out dx, al
mov dl, 0xf8
mov al, ah
out dx, al
xor eax, eax
pop ebx esi
@ -658,12 +608,6 @@ sys_pcibios:
mov dword[esp + 32], eax
ret
PCI_VENDOR_ID equ 0x00
PCI_CLASS_REVISION equ 0x08
PCI_HEADER_TYPE equ 0x0E
PCI_SUBSYSTEM_VENDOR_ID equ 0x2c
PCI_IRQ_LINE equ 0x3C
proc pci_enum
push ebp
mov ebp, esp
@ -676,7 +620,7 @@ end virtual
mov ah, [.bus]
mov al, 2
mov bh, [.devfn]
mov bl, PCI_VENDOR_ID
mov bl, 0
call pci_read_reg
cmp eax, 0xFFFFFFFF
jnz .has_device
@ -692,37 +636,27 @@ end virtual
jz .nomemory
mov edi, eax
mov [edi+PCIDEV.vendor_device_id], ecx
mov edx, pcidev_list
list_add_tail edi, edx
mov eax, pcidev_list
mov ecx, [eax+PCIDEV.bk]
mov [edi+PCIDEV.bk], ecx
mov [edi+PCIDEV.fd], eax
mov [ecx+PCIDEV.fd], edi
mov [eax+PCIDEV.bk], edi
mov eax, dword [.devfn]
mov word [edi+PCIDEV.devfn], ax
mov dword [edi+PCIDEV.devfn], eax
mov dword [edi+PCIDEV.owner], 0
mov bh, al
mov al, 2
mov bl, PCI_CLASS_REVISION
mov bl, 8
call pci_read_reg
shr eax, 8 ;FIXME use byte mask
shr eax, 8
mov [edi+PCIDEV.class], eax
; mov ah, [.bus]
; mov bh, byte [.devfn]
; mov al, 2
; mov bl, PCI_SUBSYSTEM_VENDOR_ID
; call pci_read_reg
; mov [edi+PCIDEV.svid_sdid], eax
; mov ah, [.bus]
; mov al, 0
; mov bh, [.devfn]
; mov bl, PCI_IRQ_LINE
; call pci_read_reg
; mov [edi+PCIDEV.irq_line], al
test byte [.devfn], 7
jnz .next_func
mov ah, [.bus]
mov al, 0
mov bh, [.devfn]
mov bl, PCI_HEADER_TYPE
mov bl, 0Eh
call pci_read_reg
test al, al
js .next_func
@ -743,334 +677,3 @@ proc get_pcidev_list
mov eax, pcidev_list
ret
endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;internal functions
;ecx (bus << 8)|devfn
;edx register
align 4
pci_bus:
.conf1_index:
; dword CF8 = (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) | (devfn << 8) | (reg & 0xFC))
push edx
mov eax, edx ; eax = reg
shl eax, 16 ; eax = reg << 16
shl ecx, 8 ; ecx = (bus << 16)|(devfn<<8)
mov al, dl ; eax = (reg << 16)|reg
and eax, 0x0F0000FC ; eax = ((reg & 0xF00) << 16)|(reg & 0xFC)
lea eax, [0x80000000+eax+ecx]
mov dx, 0xCF8
out dx, eax
pop edx
xor eax, eax
ret
align 4
.conf2_index:
; byte CF8 = 0xF0 | (fn << 1)
; byte CFA = bus
push edx
mov eax, ecx ; (bus << 8)|devfn
and al, 7 ; fn
lea eax, [0xF0+eax+eax]
mov dx, 0xCF8
out dx, al
mov al, ch ; bus
mov dx, 0xCFA
out dx, al
pop edx
xor eax, eax
ret
align 4
.conf1_read8:
call .conf1_index
and dx, 3
add dx, 0xCFC
in al, dx
ret
align 4
.conf1_read16:
call .conf1_index
and dx, 2
add dx, 0xCFC
in ax, dx
ret
align 4
.conf1_read32:
call .conf1_index
mov dx, 0xCFC
in eax, dx
ret
align 4
.conf1_write8:
call .conf1_index
mov eax, [esp+4]
and dx, 3
add dx, 0xCFC
out dx, al
ret 4
align 4
.conf1_write16:
call .conf1_index
mov eax, [esp+4]
and dx, 2
add dx, 0xCFC
out dx, ax
ret 4
align 4
.conf1_write32:
call .conf1_index
mov eax, [esp+4]
mov dx, 0xCFC
out dx, eax
ret 4
align 4
.conf2_read8:
; in (0xC000 | (dev << 8) | reg)
call .conf2_index
and ecx, 0xF1 ;ecx = dev << 3
shl ecx, 5 ;ecx = dev << 8
lea edx, [0xC000+edx+ecx]
in al, dx
ret
align 4
.conf2_read16:
call .conf2_index
and ecx, 0xF1
shl ecx, 5
lea edx, [0xC000+edx+ecx]
in ax, dx
ret
align 4
.conf2_read32:
call .conf2_index
and ecx, 0xF1
shl ecx, 5
lea edx, [0xC000+edx+ecx]
in eax, dx
ret
PCI_R8 equ 0
PCI_R16 equ 4
PCI_R32 equ 8
PCI_W8 equ 12
PCI_W16 equ 16
PCI_W32 equ 20
align 4
pci_conf1_rw:
;internal function
;eax accessor
;ecx (bus << 8)|devfn
.val equ esp+4
; dword CF8 = (0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) | (devfn << 8) | (reg & 0xFC))
pushfd
cli
push edx
push eax
mov eax, edx ; eax = reg
shl eax, 16 ; eax = reg << 16
shl ecx, 8 ; ecx = (bus << 16)|(devfn<<8)
mov al, dl ; eax = (reg << 16)|reg
and eax, 0x0F0000FC ; eax = ((reg & 0xF00) << 16)|(reg & 0xFC)
lea eax, [0x80000000+eax+ecx]
mov dx, 0xCF8
out dx, eax
pop eax
pop edx
jmp dword [.fntab+eax]
.r32:
mov dx, 0xCFC
in eax, dx
.rdone:
popfd
ret
.r16:
and dx, 2
add dx, 0xCFC
in al, dx
jmp .rdone
.r8:
and dx, 3
add dx, 0xCFC
in al, dx
jmp .rdone
.w32:
mov eax, [esp+8]
mov dx, 0xCFC
out dx, eax
.wdone:
popfd
ret 4
.w16:
mov eax, [esp+8]
and dx, 2
add dx, 0xCFC
out dx, ax
jmp .wdone
.w8:
mov eax, [esp+8]
and dx, 3
add dx, 0xCFC
out dx, al
jmp .wdone
align 4
.fntab:
dd .r8
dd .r16
dd .r32
dd .w8
dd .w16
dd .w32
align 4
pci_fn_rw dd pci_conf1_rw
;proc pci_bus_read8 fastcall, busaddr:dword, reg:dword
;proc pci_bus_read16 fastcall, busaddr:dword, reg:dword
;proc pci_bus_read32 fastcall, busaddr:dword, reg:dword
align 4
pci_bus_read8:
xor eax, eax
jmp dword [pci_fn_rw]
align 4
pci_bus_read16:
mov eax, PCI_R16
jmp dword [pci_fn_rw]
align 4
pci_bus_read32:
mov eax, PCI_R32
jmp dword [pci_fn_rw]
;proc pci_bus_write8 fastcall, busaddr:dword, reg:dword, val: dword
;proc pci_bus_write16 fastcall, busaddr:dword, reg:dword, val: dword
;proc pci_bus_write32 fastcall, busaddr:dword, reg:dword, val: dword
align 4
pci_bus_write8:
mov eax, PCI_W8
jmp dword [pci_fn_rw]
align 4
pci_bus_write16:
mov eax, PCI_W16
jmp dword [pci_fn_rw]
align 4
pci_bus_write32:
mov eax, PCI_W32
jmp dword [pci_fn_rw]
;deprecated proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
;deprecated proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
;deprecated proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
align 4
pci_read8:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
call pci_bus_read8
ret 12
align 4
pci_read16:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
call pci_bus_read16
ret 12
align 4
pci_read32:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
call pci_bus_read32
ret 12
;deprecated proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
;deprecated proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
;deprecated proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
align 4
pci_write8:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
push dword [esp+16]
call pci_bus_write8
ret 16
align 4
pci_write16:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
push dword [esp+16]
call pci_bus_write16
ret 16
align 4
pci_write32:
.bus equ esp+4
.devfn equ esp+8
.pci_reg equ esp+12
.val equ esp+16
movzx ecx, byte [.devfn]
mov ch, [.bus]
movzx edx, word [.pci_reg]
push dword [esp+16]
call pci_bus_write32
ret 16

View File

@ -34,6 +34,92 @@ proc get_notify stdcall, p_ev:dword
jmp .wait
endp
align 4
proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 6
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
ret
endp
align 4
proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 5
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
ret
endp
align 4
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
push ebx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 4
mov bh, byte [devfn]
mov bl, byte [reg]
call pci_read_reg
pop ebx
ret
endp
align 4
proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 8
mov bh, byte [devfn]
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
pop ebx
ret
endp
align 4
proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 9
mov bh, byte [devfn]
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
pop ebx
ret
endp
align 4
proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx
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
pop ebx
ret
endp
handle equ IOCTL.handle
io_code equ IOCTL.io_code
@ -1341,10 +1427,8 @@ destroy_kernel_object:
call free ;release object memory
ret
; param
; eńő= size
; ecx= size
align 4
create_object:
@ -1391,5 +1475,3 @@ create_object:
xor eax, eax
ret

View File

@ -321,11 +321,11 @@ proc alloc_kernel_space stdcall, size:dword
sub [edi+block_size], edx
mov eax, [edi+block_size]
calc_index eax
calc_index eax
cmp eax, [block_ind]
je .add_used
list_del edi
list_del edi
mov ecx, [block_ind]
lea edx, [mem_block_list+ecx*8]
@ -335,7 +335,7 @@ proc alloc_kernel_space stdcall, size:dword
@@:
bts [mem_block_mask], eax
lea edx, [mem_block_list+eax*8] ;edx= list head
list_add edi, edx
list_add edi, edx
.add_used:
call md.add_to_used
@ -348,7 +348,7 @@ proc alloc_kernel_space stdcall, size:dword
ret
.m_eq_size:
list_del edi
list_del edi
lea edx, [mem_block_list+ebx*8]
cmp edx, [edx]
jnz @f

View File

@ -126,7 +126,7 @@ align 4
;proc map_page stdcall,lin_addr:dword,phis_addr:dword,flags:dword
map_page:
push ebx
mov eax, [esp+12] ; phis_addr
mov eax, [esp+12] ; phis_addr
or eax, [esp+16] ; flags
and eax, [pte_valid_mask]
mov ebx, [esp+8] ; lin_addr
@ -487,7 +487,7 @@ proc init_LFB
loop @B
mov dword [LFBAddress], LFB_BASE
mov eax, cr3 ;flush TLB
mov eax, cr3 ;flush TLB
mov cr3, eax
ret
@ -1313,9 +1313,10 @@ f68:
mov [esp+32], eax
ret
iglobal
align 4
f68call:
f68call: ; keep this table closer to main code
dd f68.11 ; init_heap
dd f68.12 ; user_alloc
dd f68.13 ; user_free
@ -1333,7 +1334,7 @@ f68call:
dd f68.25 ; unmask exception
dd f68.26 ; user_unmap
dd f68.27 ; load_file_umode
endg
align 4
proc load_pe_driver stdcall, file:dword, cmdline:dword

View File

@ -5,9 +5,6 @@
;; ;;
;; Synhronization for MenuetOS. ;;
;; Author: Halyavin Andrey, halyavin@land.ru ;;
;; ;;
;; ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
@ -389,7 +386,6 @@ up_write:
ret
purge MUTEX_WAITER
purge RWSEM_WAITING_FOR_WRITE
purge RWSEM_WAITING_FOR_READ

View File

@ -1,249 +0,0 @@
Когда ядро ​​обнаруживает подключенное устройство USB, оно настраивает его
согласно USB-протокола - SET_ADDRESS + SET_CONFIGURATION. Всегда
устанавливается первая конфигурация. Ядро также читает дескриптор
устройства, чтобы показать некоторую информацию, читает и анализирует
дескриптор конфигурации. Для каждого интерфейса ядро будет искать класс этого
интерфейса и попытается загрузить соответствующий драйвер COFF. В настоящее
время соответствие кодов классов и имен драйверов жестко прописано в коде ядра
и выглядит следующим образом:
3 = usbhid.obj,
7 = usbprint.obj,
8 = usbstor.obj,
9 = поддерживаются самим ядром,
другие = usbother.obj.
Драйвер должен быть стандартным драйвером в формате COFF, экспортирующим
процедуру под названием "START" и переменную "version". Загрузчик вызывает
процедуру "START" как STDCALL с одним параметром DRV_ENTRY = 1. При завершении
работы системы, если инициализация драйвера была успешна, "START" процедуру
также вызывает код остановки системы с одним параметром DRV_EXIT = -1.
Драйвер должен зарегистрировать себя в качестве драйвера USB в процедуре
"START". Это делается путем вызова экспортируемой ядром функции RegUSBDriver и
возврата её результата в качестве результата "START" процедуры.
void* __stdcall RegUSBDriver(
const char* name,
void* handler,
const USBFUNC* usbfunc
);
Параметр 'name' должен совпадать с именем драйвера, например "usbhid" для
usbhid.obj.
Параметр 'handler' является необязательным. Если он не NULL, то он должен
указывать на стандартный обработчик IOCTL интерфейса, как в обычном (не-USB)
драйвере.
Параметр "Usbfunc" представляет собой указатель на следующую структуру:
struc USBFUNC
{
.strucsize dd ? ; размер структуры, включая это поле
.add_device dd ? ; указатель на AddDevice процедуру в драйвере
; (необходимо)
.device_disconnect dd ? ; указатель на DeviceDisconnected процедуру в драйвере
; опционально, может быть NULL
; В будущем могут быть добавлены другие функции
}
Драйвер ДОЛЖЕН реализовать функцию:
void* __stdcall AddDevice(
void* pipe0,
void* configdescr,
void* interfacedescr
);
Параметр "Pipe0" - хэндл контрольного канала для нулевой конечной точки
устройства. Он может быть использован в качестве аргумента для
USBControlTransferAsync (см. далее).
Параметр 'configdescr' указывает на дескриптор конфигурации и все связанные с
ним данные, представленные так, как их возвращает запрос GET_DESCRIPTOR.
Полный размер данных содержится в поле Length самого дескриптора.
(см. USB2.0 spec.)
Параметр 'interfacedescr' указывает на дескриптор интерфейса инициализируемого
в данный момент. Это указатель на данные находящиеся внутри структуры
"configdescr". (Помним, что структура INTERFACE_DESCRIPTOR, находится внутри
структуры CONFIGURATION_DESCRIPTOR. См. USB2.0 Spec.) Обратите внимание, что
одно устройство может реализовывать много интерфейсов и AddDevice может быть
вызвана несколько раз с одним "configdescr" но разными "interfacedescr".
Возвращенное значение NULL показывает, что инициализация не была успешной.
Любое другое значение означает инициализацию устройства. Ядро не делает попыток
как-то интерпретировать это значение. Это может быть, например, указатель на
внутренние данные драйвера в памяти, выделенной с помощью Kmalloc или индексом
в какой-то своей таблице. (Помните, что Kmalloc() НЕ stdcall-функция! Она
портит регистр ebx!)
Драйвер МОЖЕТ реализовать функцию:
void __stdcall DeviceDisconnected(
void* devicedata
);
Если данная функция реализована, то ядро вызывает её, когда устройство
отключено, посылая ей в качестве параметра "devicedata" то, что было возвращено
ему функцией "AddDevice" при старте драйвера.
Драйвер может использовать следующие функции экспортируемые ядром:
void* __stdcall USBOpenPipe(
void* pipe0,
int endpoint,
int maxpacketsize,
int type,
int interval
);
Параметр "Pipe0" - хэндл контрольного канала для нулевой конечной точки
устройства. Используется для идентификации устройства.
Параметр "endpoint" номер конечной точки USB. Младшие 4 бита, собственно, номер
точки, а бит 7 имеет следующее значение: 0 - для OUT точки, 1 - для IN точки.
Остальные биты должны быть равны нулю.
Параметр "maxpacketsize" устанавливает максимальный размер пакета для канала.
Параметр "type" устанавливает тип передачи для конечной точки, как это прописано
в USB спецификации:
0 = control,
1 = isochronous (сейчас не поддерживается),
2 = bulk,
3 = interrupt.
Параметр "interval" игнорируется для control и bulk передач. Для конечных точек
по прерываниям устанавливает периодичность опроса в миллисекундах.
Функция возвращает хэндл канала при успешном его открытии либо NULL при ошибке.
Хэндл канала обращается в NULL когда:
а) канал будет явно закрыт функцией USBClosePipe (см. ниже);
б) была выполнена предоставленная драйвером функция "DeviceDisconnected".
void __stdcall USBClosePipe(
void* pipe
);
Освобождает все ресурсы, связанные с выбранным каналом. Единственный параметр -
указатель на хэндл, который был возвращен функцией USBOpenPipe при открытии
канала. Когда устройство отключается, все связанные с ним каналы закрываются
ядром; нет необходимости в самостоятельном вызове этой функции.
void* __stdcall USBNormalTransferAsync(
void* pipe,
void* buffer,
int size,
void* callback,
void* calldata,
int flags
);
void* __stdcall USBControlTransferAsync(
void* pipe,
void* setup,
void* buffer,
int size,
void* callback,
void* calldata,
int flags
);
Первая функция ставит в очередь bulk или interrupt передачу для выбранного
канала. Тип и направление передачи фиксированы для bulk и interrupt типов
конечных точек, как это было выбрано функцией USBOpenPipe.
Вторая функция ставит в очередь control передачу для выбранного канала.
Направление этой передачи определяется битом 7 байта 0 пакета "setup"
(0 - для OUT, 1 - для IN передачи). Эта функция возвращает управление немедленно.
По окончании передачи вызывается функция "callback" заданная как аргумент
USB______TransferAsync.
Параметр "pipe" - хэндл, возвращенный функцией USBOpenPipe.
Параметр 'setup' функции USBControlTransferAsync указывает на 8-байтный
конфигурационный пакет (см. USB2.0 Spec).
Параметр "buffer" - это указатель на буфер. Для IN передач он будет заполнен
принятыми данными. Для OUT передач он должен быть заполнен данными, которые мы
хотим передать. Указатель может быть NULL для пустых передач, либо для передач
control, если дополнительных данных не требуется.
Параметр "size" - это размер данных для передачи. Он может быть равен 0 для
пустых передач, либо для передач control, если дополнительных данных не требуется.
Параметр "callback" - это указатель на функцию, которая будет вызвана по
окончании передачи.
Параметр "calldata" будет передан функции "callback" вызываемой по окончании
передачи. Например, он может быть NULL или указывать на данные устройства или
указывать на данные используемые как дополнительные параметры, передаваемые от
вызывающей USB_____TransferAsync функции в callback функцию.
Другие данные, связанные с передачей, могут быть помещены до буфера (по смещению)
или после него. Они могут быть использованы из callback-функции, при необходимости.
Параметр "flags" - это битовое поле. Бит 0 игнорируется для OUT передач. Для IN
передач он означает, может ли устройство передать меньше данных (бит=1), чем
определено в "size" или нет (бит=0). Остальные биты не используются и должны
быть равны 0.
Возвращаемое функциями значение равно NULL в случае ошибки и не NULL если
передача успешно поставлена в очередь. Если происходит ошибка при передаче, то
callback функция будет об этом оповещена.
void __stdcall CallbackFunction(
void* pipe,
int status,
void* buffer,
int length,
void* calldata
);
Параметры 'pipe', 'buffer', 'calldata' значат то же, что и для
USB_____TransferAsync.
Параметр "length" это счетчик переданных байт. Для control передач он отражает
дополнительные 8 байт этапа SETUP. Т.е. 0 означает ошибку на этапе SETUP, а
"size"+8 успешную передачу.
Параметр "status" не равен 0 в случае ошибки:
USB_STATUS_OK = 0 ; без ошибок
USB_STATUS_CRC = 1 ; ошибка контрольной суммы
USB_STATUS_BITSTUFF = 2 ; ошибка инверсии битов (bitstuffing)
USB_STATUS_TOGGLE = 3 ; data toggle mismatch
; (Нарушение последовательности DAT0/DAT1)
USB_STATUS_STALL = 4 ; устройство возвратило STALL статус (остановлено)
USB_STATUS_NORESPONSE = 5 ; устройство не отвечает
USB_STATUS_PIDCHECK = 6 ; ошибка в поле PacketID (PID)
USB_STATUS_WRONGPID = 7 ; неожидаемое PacketID (PID) значение
USB_STATUS_OVERRUN = 8 ; слишком много данных от конечной точки
USB_STATUS_UNDERRUN = 9 ; слишком мало данных от конечной точки
USB_STATUS_BUFOVERRUN = 12 ; переполнение внутреннего буфера контроллера
; возможна только для изохронных передач
USB_STATUS_BUFUNDERRUN = 13 ; опустошение внутреннего буфера контроллера
; возможна только для изохронных передач
USB_STATUS_CLOSED = 16 ; канал закрыт либо через ClosePipe, либо в
; результате отключения устройства
Если несколько передач были поставлены в очередь для одного канала, то callback
функции для них будут вызываться в порядке постановки передач в очередь.
Если канал был закрыт ввиду USBClosePipe или отключения устройства, то callback
функции (если очередь передач не пуста) получат USB_STATUS_CLOSED.
Вызов DeviceDisconnected() последует после отработки всех оставшихся в очереди
callback функций.
void* __stdcall USBGetParam(void* pipe0, int param);
Возвращает указатель на некоторые параметры устройства запомненные ядром при
инициализации первой конфигурации. Не передает ничего устройству по шине.
pipe0 - хэндл контрольного канала для нулевой конечной точки устройства.
param - выбор возвращаемого параметра:
0 - возвратить указатель на дескриптор устройства;
1 - возвратить указатель на дескриптор конфигурации;
2 - возвратить режим шины устройства:
USB_SPEED_FS = 0 ; full-speed
USB_SPEED_LS = 1 ; low-speed
USB_SPEED_HS = 2 ; high-speed

View File

@ -1,310 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; simple AGP driver for KolibriOS ;;
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
DEBUG equ 1
FAST_WRITE equ 0 ; may cause problems with some motherboards
include 'proc32.inc'
include 'imports.inc'
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public service_proc
public version
DRV_ENTRY equ 1
DRV_EXIT equ -1
SRV_GETVERSION equ 0
SRV_DETECT equ 1
API_VERSION equ 1
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .exit
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
stdcall RegService, my_service, service_proc
ret
.fail:
.exit:
xor eax, eax
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 service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_DETECT
jne @F
call detect
@@:
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
align 4
proc detect
locals
last_bus dd ?
endl
mov esi, msgSearch
call SysMsgBoardStr
xor eax, eax
mov [bus], eax
inc eax
call PciApi ; get last bus
cmp eax, -1
je .error
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead16, [bus], [devfn], dword 0x0a ; read class/subclass
cmp ax, 0x0300 ; display controller - vga compatable controller
je .found
cmp ax, 0x0302 ; display controller - 3d controller
je .found
cmp ax, 0x0380 ; display controller - other display controller
je .found
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
.error:
mov esi, msgFail
call SysMsgBoardStr
xor eax, eax
inc eax
ret
.found:
stdcall PciRead8, [bus], [devfn], dword 0x06 ; read prog IF
test al, 1 shl 4 ; got capabilities list?
jnz .got_capabilities_list
; TODO: Do it the old way: detect device and check with a list of known capabilities
; stupid pre PCI 2.2 board....
jmp .next
.got_capabilities_list:
stdcall PciRead8, [bus], [devfn], dword 0x34 ; read capabilities offset
and eax, 11111100b ; always dword aligned
mov edi, eax
.read_capability:
stdcall PciRead32, [bus], [devfn], edi ; read capability
cmp al, 0x02 ; AGP
je .got_agp
movzx edi, ah ; pointer to next capability
test edi, edi
jnz .read_capability
jmp .next
.got_agp:
shr eax, 16
mov [revision], al ; high nibble = major revision
; low nibble = minor revision
add edi, 4
and al, 0xf0
cmp al, 0x30
je .agp_3
.agp_2:
mov esi, msgAGP2
call SysMsgBoardStr
stdcall PciRead32, [bus], [devfn], edi ; read AGP status
.agp_2_:
test al, 100b
jnz .100b
test al, 10b
jnz .010b
test al, 1b
jz .error
.001b:
mov [cmd], 001b
mov esi, msg1
call SysMsgBoardStr
jmp .agp_go
.010b:
mov [cmd], 010b
mov esi, msg2
call SysMsgBoardStr
jmp .agp_go
.100b:
mov [cmd], 100b
mov esi, msg4
call SysMsgBoardStr
jmp .agp_go
.agp_2m:
mov esi, msgAGP2m
call SysMsgBoardStr
jmp .agp_2_
.agp_3:
mov esi, msgAGP3
call SysMsgBoardStr
stdcall PciRead32, [bus], [devfn], edi ; read AGP status
test al, 1 shl 3
jz .agp_2m
test eax, 10b
jnz .8x
mov [cmd], 01b
mov esi, msg4
call SysMsgBoardStr
jmp .agp_go
.8x:
mov [cmd], 10b
mov esi, msg8
call SysMsgBoardStr
.agp_go:
if FAST_WRITE
test ax, 1 shl 4
jz @f
or [cmd], 1 shl 4
mov esi, msgfast
call SysMsgBoardStr
@@:
end if
test ax, 1 shl 9 ; Side band addressing
jz @f
or [cmd], 1 shl 9
mov esi, msgside
call SysMsgBoardStr
@@:
add edi, 4
mov eax, [cmd]
or eax, 1 shl 8 ; enable AGP
stdcall PciWrite32, [bus], [devfn], edi, eax ; write AGP cmd
mov esi, msgOK
call SysMsgBoardStr
ret
endp
; initialized data
align 4
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'AGP', 0 ; max 16 chars include zero
msgInit db 'AGP driver loaded.', 13, 10, 0
msgSearch db 'Searching for AGP card...', 13, 10, 0
msgFail db 'device not found', 13, 10, 0
msgOK db 'AGP device enabled', 13, 10, 0
msgAGP2 db 'AGP2 device found', 13, 10, 0
msgAGP3 db 'AGP3 device found', 13, 10, 0
msgAGP2m db 'Running in AGP2 mode', 13, 10, 0
msg8 db '8x speed', 13, 10, 0
msg4 db '4x speed', 13, 10, 0
msg2 db '2x speed', 13, 10, 0
msg1 db '1x speed', 13, 10, 0
msgfast db 'Fast Write', 13, 10, 0
msgside db 'Side band addressing', 13, 10, 0
section '.data' data readable writable align 16
; uninitialized data
revision db ?
cmd dd ?
bus dd ?
devfn dd ?

View File

@ -1,350 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2009-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 11.09.2009 staper@inbox.ru
; see kernel\docs\apm.txt
use32
org 0x0
db 'MENUET01'
dd 0x1
dd START
dd I_END
dd (I_END+100) and not 3
dd (I_END+100) and not 3
dd 0x0,0x0
include 'macros.inc'
START:
mcall 40,0x7
mcall 49,0x0001,0x0001,0x5308 ;CX = FFFFh APM v1.0
; mcall 49,0x0001,0x0001,0x530d
; mcall 49,0x0001,0x0001,0x530f
; mcall 49,0x0000,,0x5310 ;bl - number of batteries
redraw:
mcall 49,0x0000,,0x530c
dec cl
jz still
mcall 49,0x0001,0x0001,0x5308
mcall 49,0x01ff,,0x530c
test cl, cl
jz @f
mcall 49,0x0000,0x0001,0x530d
mcall 49,0x0000,0x0000,0x5307
mcall 49,0x0000,0x0001,0x5308
@@:
mcall 12,1
mcall 0,100*65536+235,100*65536+90,0x34ffffff,0x000000,title
mcall 49,0x0000,,0x5300
jnc @f
mcall 4,10*65536+3,0x80000000,text.4
bts [flags], 1
jmp .end
@@:
cmp al, 0
jne @f
mov edx, text.1
jmp .0
@@:
cmp al, 1
jne @f
mov edx, text.2
jmp .0
@@:
mov edx, text.3
.0:
push edx
mcall 4,169*65536+3,0x80dddddd,text.0
pop edx
add ebx, 47*65536
mcall
mcall 49,0x0001,,0x530a
jc .error
push si dx cx bx ;time of battery life, b. flag, b. status, AC line status
;AC line status
cmp bh, 0
jne @f
mov edx, text.01
jmp .1
@@:
cmp bh, 1
jne @f
mov edx, text.02
jmp .1
@@:
cmp bh, 2
jne @f
mov edx, text.03
jmp .1
@@:
mov edx, text.04
.1:
push edx
mcall 4,10*65536+10,0x80000000,text.00
pop edx
mcall ,100*65536+10,;0x80000000
;battery status
pop bx
cmp bl, 0
jne @f
mov edx, text.11
jmp .2
@@:
cmp bl, 1
jne @f
mov edx, text.12
jmp .2
@@:
cmp bl, 2
jne @f
mov edx, text.13
jmp .2
@@:
cmp bl, 3
jne @f
mov edx, text.14
jmp .2
@@:
mov edx, text.04
.2:
push edx
mcall 4,10*65536+20,0x80000000,text.10
pop edx
mcall ,100*65536+20,
;battery life, percentage and minutes/seconds
mcall ,10*65536+30,,text.20
pop cx
cmp cl, 0xff
jne @f
mcall ,100*65536+30,0x80000000,text.04
pop eax
jmp .end
@@:
shl ecx, 24
shr ecx, 24
mcall 47,0x80030000,,100*65536+30,0x347636
.3:
mcall 4,115*65536+30,0x80000000,text.15
mov dx, [esp]
shl edx, 17
shr edx, 17
mov ecx, edx
mcall 47,0x80030000,,140*65536+30
pop cx
mov edx, text.21
bt cx, 15
jc @f
mov edx, text.22
@@:
mcall 4,160*65536+30,0x80000000
pop si
.error:
.end:
;buttons
mcall 8,148*65536+16,45*65536+15,3,0x00677ab0
mcall ,166*65536+16,,4,
mcall ,184*65536+16,,5,
mcall ,202*65536+16,,6,
bt [flags], 1
jc @f
mcall ,65*65536+45,,2,
@@:
mcall 4,10*65536+50,0x80564242,text.30
mcall 12,2
still:
; mcall 10
mcall 23,12000
test eax, eax
jz redraw
dec al
jz redraw
dec al
jz key
dec al
jz button
jmp still
key:
mcall 2
jmp still
button:
mcall 17
cmp ah, 1
jne @f
mcall -1
@@:
cmp ah, 2
jne @f
mcall 5,50
mcall 49,0x0001,0x0001,0x5307
jmp redraw
@@:
cmp ah, 4
jg @f
mov edx, 0x01f7 ;primary chan.
call reserv_ports
jc redraw
sub bh, 3
.1:
call set_drive
btc [flags], 2
jnc .2
call device_reset
jmp .3
.2:
call standby_hdd
.3:
call free_ports
jmp redraw
@@:
cmp ah, 6
jg redraw
mov edx, 0x0177 ;secondary chan.
call reserv_ports
jc redraw
sub bh, 5
jmp .1
set_drive:
dec dx
in al, dx
test bh, bh
jnz @f
btr ax, 4
.1:
out dx, al
inc dx
ret
@@:
bts ax, 4
jmp .1
standby_hdd:
; 94h E0h nondata standby immediate
; 95h E1h nondata idle immediate
; 96h E2h nondata standby
; 97h E3h nondata idle
; 98h E5h nondata check power mode
; 99h E6h nondata set sleep mode
xor ecx, ecx
@@:
in al, dx
dec cx
jz @f
bt ax, 6
jnc @b
mov al, 0x96
out dx, al
mov al, 0xe2
out dx, al
@@:
ret
reserv_ports:
mov ecx, edx
dec ecx
push ax
mcall 46,0
test al, al
jnz @f
pop bx
clc
ret
@@:
pop bx
stc
ret
device_reset:
xor ecx, ecx
@@:
in al, dx
dec cx
jz @f
bt ax, 6
jnc @b
mov al, 0x10
out dx, al
@@:
ret
free_ports:
mov ecx, edx
dec ecx
mcall 46,1
ret
; ДАННЫЕ ПРОГРАММЫ
title db '',0
flags dw 0
text:
.0:
db 'APM v.1.',0
.1:
db '0',0
.2:
db '1',0
.3:
db '2',0
.4:
db 'APM not supported',0
.00:
db 'power status:',0
.01:
db 'off-line',0
.02:
db 'on-line',0
.03:
db 'on backup power',0
.04:
db 'unknown',0
.10:
db 'battery flag:',0
.11:
db 'high',0
.12:
db 'low',0
.13:
db 'critical',0
.14:
db 'charging',0
.15:
db ' % ,',0
.20:
db 'battery life:',0
.21:
db 'min',0
.22:
db 'sec',0
.30:
db 'STAND-BY: SYSTEM HDD: 0 1 2 3',0
I_END:

View File

@ -1,326 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AD_LOSEL equ BIT5
AD_HPSEL equ BIT10
align 4
proc detect_codec
locals
codec_id dd ?
endl
stdcall codec_read, dword 0x7C
shl eax, 16
mov [codec_id], eax
stdcall codec_read, dword 0x7E
or eax, [codec_id]
mov [codec.chip_id], eax
and eax, 0xFFFFFF00
mov edi, codecs
@@:
mov ebx, [edi]
test ebx, ebx
jz .unknown
cmp eax, ebx
jne .next
mov eax, [edi+4]
mov [codec.ac_vendor_ids], eax
mov esi, eax
call SysMsgBoardStr
stdcall detect_chip, [edi+8]
ret
.next:
add edi, 12
jmp @B
.unknown:
mov [codec.ac_vendor_ids], ac_unknown
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
ret
endp
align 4
proc detect_chip stdcall, chip_tab:dword
mov eax, [codec.chip_id]
and eax, 0xFF
mov edi, [chip_tab]
@@:
mov ebx, [edi]
cmp ebx, 0xFF
je .unknown
cmp eax, ebx
jne .next
mov eax, [edi+4]
mov [codec.chip_ids], eax
mov esi, eax
call SysMsgBoardStr
ret
.next:
add edi, 8
jmp @b
.unknown:
mov [codec.chip_ids], chip_unknown
mov esi, chip_unknown
call SysMsgBoardStr
mov eax, [codec.chip_id]
call dword2str
call SysMsgBoardStr
ret
endp
align 4
proc setup_codec
xor eax, eax
stdcall codec_write, dword CODEC_AUX_VOL
mov eax, 0x0B0B
stdcall codec_write, dword CODEC_MASTER_VOL_REG
mov ax, 0x08
stdcall codec_write, dword 0x0C
mov ax, 0x0808
stdcall codec_write, dword CODEC_PCM_OUT_REG
mov ax, 0x0808
stdcall codec_write, dword 0x10
mov ax, 0x0808
stdcall codec_write, dword 0x12
mov ax, 0x0808
stdcall codec_write, dword 0x16
stdcall codec_read, dword CODEC_EXT_AUDIO_CTRL_REG
and eax, 0FFFFh - BIT1 ; clear DRA (BIT1)
or eax, BIT0 ; set VRA (BIT0)
stdcall codec_write, dword CODEC_EXT_AUDIO_CTRL_REG
stdcall set_sample_rate, dword 48000
.init_error:
xor eax, eax ; exit with error
ret
endp
; param
; eax= volume -10000 - 0 for both channels
align 4
set_master_vol:
cmp eax, 0
jl @F
xor eax, eax
jmp .set
@@:
cmp eax, -9450
jg .set
mov eax, -9450 ;clamp into 6 bits
.set:
cdq
mov ebx, -150
idiv ebx
mov ah, al
stdcall codec_write, dword CODEC_MASTER_VOL_REG
xor eax, eax
ret
align 4
proc get_master_vol stdcall, pvol:dword
stdcall codec_read, dword CODEC_MASTER_VOL_REG
and eax, 0x3F
imul eax, -150
mov ebx, [pvol]
mov [ebx], eax
xor eax, eax
ret
endp
align 4
proc set_sample_rate stdcall, rate:dword
mov eax, [rate]
stdcall codec_write, dword CODEC_PCM_FRONT_DACRATE_REG
ret
endp
patch_AD:
stdcall codec_read, 0x76
or ax, BIT5+BIT10
stdcall codec_write, 0x76
ret
align 16
ac_unknown db 'unknown manufacturer',13,10,0
ac_Realtek db 'Realtek Semiconductor',13,10,0
ac_Analog db 'Analog Devices',13,10,0
ac_CMedia db 'C-Media Electronics',13,10,0
ac_Cirrus db 'Cirrus Logic',13,10,0
ac_Wolfson db 'Wolfson Microelectronics',13,10,0
ac_VIA db 'VIA Technologies',13,10,0
ac_SigmaTel db 'SigmaTel',13,10,0
ac_eMicro db 'eMicro',13,10,0
chip_unknown db 'unknown codec id ', 0
CHIP_ANALOG equ 0x41445300
CHIP_REALTEK equ 0x414C4700
CHIP_CMEDIA equ 0x434D4900
CHIP_CIRRUS equ 0x43525900
CHIP_WOLFSON equ 0x574D4C00
CHIP_VIA equ 0x56494100
CHIP_SIGMATEL equ 0x83847600
CHIP_EMICRO equ 0x454D4300
align 16
codecs dd CHIP_ANALOG, ac_Analog, chips_Analog
dd CHIP_CMEDIA, ac_CMedia, chips_CMedia
dd CHIP_REALTEK,ac_Realtek, chips_Realtek
dd CHIP_CIRRUS, ac_Cirrus, chips_Cirrus
dd CHIP_WOLFSON,ac_Wolfson, chips_Wolfson
dd CHIP_VIA, ac_VIA, chips_VIA
dd CHIP_SIGMATEL, ac_SigmaTel, chips_SigmaTel
dd CHIP_EMICRO, ac_eMicro, chips_eMicro
dd 0
align 16
chips_Analog dd 0x03, chip_AD1819
dd 0x40, chip_AD1881
dd 0x48, chip_AD1881A
dd 0x60, chip_AD1884
dd 0x61, chip_AD1886
dd 0x62, chip_AD1887
dd 0x63, chip_AD1886A
dd 0x70, chip_AD1980
dd 0x72, chip_AD1981A
dd 0x74, chip_AD1981B
dd 0x75, chip_AD1985
dd 0xFF
chips_Realtek:
dd 0x10, chip_ALC201a
dd 0x20, chip_ALC650
dd 0x21, chip_ALC650D
dd 0x22, chip_ALC650E
dd 0x23, chip_ALC650F
dd 0x60, chip_ALC655
dd 0x80, chip_ALC658
dd 0x81, chip_ALC658D
dd 0x90, chip_ALC850
dd 0xFF
chips_CMedia dd 0x41, chip_CM9738
dd 0x61, chip_CM9739
dd 0x69, chip_CM9780
dd 0x78, chip_CM9761
dd 0x82, chip_CM9761
dd 0x83, chip_CM9761
dd 0xFF
chips_Cirrus dd 0x00, chip_CS4297
dd 0x10, chip_CS4297A
dd 0x20, chip_CS4298
dd 0x28, chip_CS4294
dd 0x30, chip_CS4299
dd 0x34, chip_CS4299D
dd 0x48, chip_CS4201
dd 0x58, chip_CS4205
dd 0x60, chip_CS4291
dd 0x70, chip_CS4202
dd 0xFF
chips_Wolfson dd 0x00, chip_WM9700
dd 0x03, chip_WM9703
dd 0x04, chip_WM9704
dd 0xFF
chips_VIA dd 0x61, chip_VIA1612A
dd 0xFF
chips_SigmaTel dd 0x58, chip_STAC9758
dd 0xFF
chips_eMicro dd 0x28, chip_EM28028
dd 0xFF
align 16
;Analog Devices
chip_AD1819 db 'AD1819 ',0dh,0ah,00h
chip_AD1881 db 'AD1881 ',0dh,0ah,00h
chip_AD1881A db 'AD1881A',0dh,0ah,00h
chip_AD1884 db 'AD1885 ',0dh,0ah,00h
chip_AD1885 db 'AD1885 ',0dh,0ah,00h
chip_AD1886 db 'AD1886 ',0dh,0ah,00h
chip_AD1886A db 'AD1886A',0dh,0ah,00h
chip_AD1887 db 'AD1887 ',0dh,0ah,00h
chip_AD1980 db 'AD1980 ',0dh,0ah,00h
chip_AD1981A db 'AD1981A',0dh,0ah,00h
chip_AD1981B db 'AD1981B',0dh,0ah,00h
chip_AD1985 db 'AD1985 ',0dh,0ah,00h
;Realtek
chip_ALC201a db 'ALC201a',0dh,0ah,00h
chip_ALC650 db 'ALC650 ',0dh,0ah,00h
chip_ALC650D db 'ALC650D',0dh,0ah,00h
chip_ALC650E db 'ALC650E',0dh,0ah,00h
chip_ALC650F db 'ALC650F',0dh,0ah,00h
chip_ALC655 db 'ALC655 ',0dh,0ah,00h
chip_ALC658 db 'ALC658 ',0dh,0ah,00h
chip_ALC658D db 'ALC658D',0dh,0ah,00h
chip_ALC850 db 'ALC850 ',0dh,0ah,00h
;CMedia
chip_CM9738 db 'CMI9738', 0dh,0ah,0
chip_CM9739 db 'CMI9739', 0dh,0ah,0
chip_CM9780 db 'CMI9780', 0dh,0ah,0
chip_CM9761 db 'CMI9761', 0dh,0ah,0
;Cirrus
chip_CS4297 db 'CS4297',13,10,0
chip_CS4297A db 'CS4297A',13,10,0
chip_CS4298 db 'CS4298',13,10,0
chip_CS4294 db 'CS4294',13,10,0
chip_CS4299 db 'CS4299',13,10,0
chip_CS4299D db 'CS4299D',13,10,0
chip_CS4201 db 'CS4201',13,10,0
chip_CS4205 db 'CS4205',13,10,0
chip_CS4291 db 'CS4291',13,10,0
chip_CS4202 db 'CS4202',13,10,0
;Wolfson
chip_WM9700 db 'WM9704',13,10,0
chip_WM9703 db 'WM9703/9704',13,10,0
chip_WM9704 db 'WM9704 (quad)',13,10,0
;VIA
chip_VIA1612A db 'VIA1612A',13,10,0
;SigmaTel
chip_STAC9758 db 'STAC9758,59',13,10,0
;eMicro
chip_EM28028 db 'EM28028',13,10,0

View File

@ -1,382 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Includes source code by Kulakov Vladimir Gennadievich. ;;
;; Modified by Mario79 and Rus. ;;
;; 02.12.2009 <Lrz> ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;driver sceletone
format MS COFF
DEBUG equ 0
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 5 ;debug
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public version
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
SRV_GETVERSION equ 0
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .exit
.entry:
;Detect_COM_Mouse:
if DEBUG
mov esi, msgInit
call Boot_Log
end if
mov bx, 0x3f8
call MSMouseSearch
cmp AL, 'M'
jne @f
;mov [com1_mouse_detected],1
;mov [irq_owner+4*4], 1 ; IRQ4 owner is System
mov dx, bx
inc dx ; 0x3f8 + 1
mov al, 1
out dx, al
stdcall AttachIntHandler, 4, irq4_handler, dword 0
if DEBUG
test eax, eax
jne .label1
mov esi, msg_error_attach_int_handler
call Boot_Log
end if
.label1:
; mov eax, 0
; mov ebx, 0x3F8
; mov ecx, 0x3FF
xor ebx, ebx
mov ecx, 0x3F8
mov edx, 0x3FF
call ReservePortArea
if DEBUG
cmp eax, 1
jne .go
mov esi, msg_error_reserve_ports
call Boot_Log
.go:
mov esi, boot_setmouse_type
call Boot_Log
end if
@@:
mov bx, 0x2f8
call MSMouseSearch
cmp AL, 'M'
jne .resume
;mov [com2_mouse_detected],1
;mov [irq_owner+3*4], 1 ; IRQ3 owner is System
stdcall AttachIntHandler, 3, irq3_handler, dword 0
; mov eax, 0
; mov ebx, 0x2F8
; mov ecx, 0x3F8
xor ebx, ebx
mov ecx, 0x2F8
mov edx, 0x3F8
call ReservePortArea
if DEBUG
cmp eax, 1
jne @f
mov esi, msg_error_reserve_ports
call Boot_Log
@@:
mov esi, boot_setmouse_type + 22
call Boot_Log
end if
.resume:
stdcall RegService, my_service, service_proc
if DEBUG
test eax, eax
jne @f
mov esi, msg_exit
call Boot_Log
end if
@@:
ret
.fail:
.exit:
if DEBUG
mov esi, msg_exit
call Boot_Log
end if
xor eax, eax
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 service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
.fail:
or eax, -1
ret
endp
align 4
MSMouseSearch:
; ПОИСК МЫШИ ЧЕРЕЗ COM-ПОРТЫ
MouseSearch:
; Устанавливаем скорость
; приема/передачи 1200 бод
; in bx COM Port Base Address
mov DX, bx
add DX, 3
in AL, DX
or AL, 80h ;установить бит DLAB
out DX, AL
mov DX, bx
mov AL, 60h ;1200 бод
out DX, AL
inc DX
mov AL, 0
out DX, AL
; Установить длину слова 7 бит, 1 стоповый бит,
; четность не контролировать
mov DX, bx
add DX, 3
mov AL, 00000010b
out DX, AL
; Запретить все прерывани
mov dx, bx
inc dx
mov AL, 0
out DX, AL
; Проверить, что устройство подключено и являетс
; мышью типа MSMouse
; Отключить питание мыши и прерывани
mov DX, bx
add EDX, 4 ;регистр управления модемом
mov AL, 0 ;сбросить DTR, RTS и OUT2
out DX, AL
; Ожидать 5 "тиков" (0,2 с)
mov ecx, 0xFFFF
loop $
; Включить питание мыши
mov al, 1
out dx, al
mov ecx, 0xFFFF
loop $
; Очистить регистр данных
mov dx, bx
in AL, DX
add edx, 4
mov AL, 1011b ;установить DTR и RTS и OUT2
out DX, AL
mov ecx, 0x1FFFF
; Цикл опроса порта
WaitData:
; Ожидать еще 10 "тиков"
dec ecx
; cmp ecx,0
jz NoMouse
; Проверить наличие идентификационного байта
mov DX, bx
add DX, 5
in AL, DX
test AL, 1 ;Данные готовы?
jz WaitData
; Ввести данные
mov DX, bx
in AL, DX
NoMouse:
ret
align 4
irq3_handler:
mov dx, 0x2f8
mov esi, com2_mouse
jmp irq_handler
align 4
irq4_handler:
mov dx, 0x3f8
mov esi, com1_mouse
irq_handler:
; in: esi -> COM_MOUSE_DATA struc, dx = base port (xF8h)
add edx, 5 ; xFDh
in al, dx
test al, 1 ; Данные готовы?
jz .Error
; Ввести данные
sub edx, 5
in al, dx
; Сбросить старший незначащий бит
and al, 01111111b
; Определить порядковый номер принимаемого байта
cmp [esi+COM_MOUSE_DATA.MouseByteNumber], 2
ja .Error
jz .ThirdByte
jp .SecondByte
; Сохранить первый байт данных
.FirstByte:
test al, 1000000b ; Первый байт посылки?
jz .Error
mov [esi+COM_MOUSE_DATA.FirstByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Сохранить второй байт данных
.SecondByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.SecondByte], al
inc [esi+COM_MOUSE_DATA.MouseByteNumber]
jmp .EndMouseInterrupt
; Сохранить третий байт данных
.ThirdByte:
test al, 1000000b
jnz .Error
mov [esi+COM_MOUSE_DATA.ThirdByte], al
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0
; (Пакет данных от мыши принят полностью).
; Записать новое значение состояния кнопок мыши
mov al, [esi+COM_MOUSE_DATA.FirstByte]
mov ah, al
shr al, 3
and al, 2
shr ah, 5
and ah, 1
add al, ah
movzx eax, al
mov [BTN_DOWN], eax
; Прибавить перемещение по X к координате X
mov al, [esi+COM_MOUSE_DATA.FirstByte]
shl al, 6
or al, [esi+COM_MOUSE_DATA.SecondByte]
cbw
movzx eax, ax
mov [MOUSE_X], eax
; Прибавить перемещение по Y к координате Y
mov al, [esi+COM_MOUSE_DATA.FirstByte]
and al, 00001100b
shl al, 4
or al, [esi+COM_MOUSE_DATA.ThirdByte]
cbw
movzx eax, ax
neg eax
mov [MOUSE_Y], eax
stdcall SetMouseData, [BTN_DOWN], [MOUSE_X], [MOUSE_Y], 0, 0
jmp .EndMouseInterrupt
.Error:
; Произошел сбой в порядке передачи информации от
; мыши, обнулить счетчик байтов пакета данных
mov [esi+COM_MOUSE_DATA.MouseByteNumber], 0
.EndMouseInterrupt:
mov al, 1
ret
;all initialized data place here
align 4
struc COM_MOUSE_DATA {
; Номер принимаемого от мыши байта
.MouseByteNumber db ?
; Трехбайтовая структура данных, передаваемая мышью
.FirstByte db ?
.SecondByte db ?
.ThirdByte db ?
;.timer_ticks_com dd ?
}
virtual at 0
COM_MOUSE_DATA COM_MOUSE_DATA
end virtual
com1_mouse COM_MOUSE_DATA
com2_mouse COM_MOUSE_DATA
MOUSE_X dd 0
MOUSE_Y dd 0
BTN_DOWN dd 0
COMPortBaseAddr dw 3F8h
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'COM_Mouse',0 ;max 16 chars include zero
if DEBUG
msgInit db 'Preved bugoga!',13,10,0
boot_setmouse_type db 'Detected - COM1 mouse',13,10,0
db 'Detected - COM2 mouse',13,10,0
msg_error_reserve_ports db 'Error reserving ports!',13,10,0
msg_error_attach_int_handler db 'Error attach interrupt handler!',13,10,0
msg_exit db 'Exit!',13,10,0
end if
section '.data' data readable writable align 16
;all uninitialized data place here

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,453 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_esp equ esp
;
; Formatted Debug Output (FDO)
; Copyright (c) 2005-2006, mike.dld
; Created: 2005-01-29, Changed: 2006-11-10
;
; For questions and bug reports, mail to mike.dld@gmail.com
;
; Available format specifiers are: %s, %d, %u, %x (with partial width support)
;
; to be defined:
; __DEBUG__ equ 1
; __DEBUG_LEVEL__ equ 5
; MOV Immediate.
; Useful for things like movi eax,10:
; shorter than regular mov, but slightly slower,
; do not use it in performance-critical places.
macro movi dst, imm
{
if imm >= -0x80 & imm <= 0x7F
push imm
pop dst
else
mov dst, imm
end if
}
macro debug_func name {
if used name
name@of@func equ name
}
macro debug_beginf {
align 4
name@of@func:
}
debug_endf fix end if
macro DEBUGS _sign,[_str] {
common
local tp
tp equ 0
match _arg:_num,_str \{
DEBUGS_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _str \{
DEBUGS_N _sign,,_arg
\}
}
macro DEBUGS_N _sign,_num,[_str] {
common
pushf
pushad
local ..str,..label,is_str
is_str = 0
forward
if _str eqtype ''
is_str = 1
end if
common
if is_str = 1
jmp ..label
..str db _str,0
..label:
mov edx, ..str
else
esp equ esp+4*8+4
mov edx, _str
esp equ _esp
end if
if ~_num eq
if _num eqtype eax
if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
mov esi, _num
else if ~_num eq esi
movzx esi, _num
end if
else if _num eqtype 0
mov esi, _num
else
local tp
tp equ 0
match [_arg],_num \{
mov esi, dword[_arg]
tp equ 1
\}
match =0 =dword[_arg],tp _num \{
mov esi, dword[_arg]
tp equ 1
\}
match =0 =word[_arg],tp _num \{
movzx esi, word[_arg]
tp equ 1
\}
match =0 =byte[_arg],tp _num \{
movzx esi, byte[_arg]
tp equ 1
\}
match =0,tp \{
'Error: specified string width is incorrect'
\}
end if
else
mov esi, 0x7FFFFFFF
end if
call fdo_debug_outstr
popad
popf
}
macro DEBUGD _sign,_dec {
local tp
tp equ 0
match _arg:_num,_dec \{
DEBUGD_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _dec \{
DEBUGD_N _sign,,_arg
\}
}
macro DEBUGD_N _sign,_num,_dec {
pushf
pushad
if (~_num eq)
if (_dec eqtype eax | _dec eqtype 0)
'Error: precision allowed only for in-memory variables'
end if
if (~_num in <1,2,4>)
if _sign
'Error: 1, 2 and 4 are only allowed for precision in %d'
else
'Error: 1, 2 and 4 are only allowed for precision in %u'
end if
end if
end if
if _dec eqtype eax
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
mov eax, _dec
else if ~_dec eq eax
if _sign = 1
movsx eax, _dec
else
movzx eax, _dec
end if
end if
else if _dec eqtype 0
mov eax, _dec
else
esp equ esp+4*8+4
if _num eq
mov eax, dword _dec
else if _num = 1
if _sign = 1
movsx eax, byte _dec
else
movzx eax, byte _dec
end if
else if _num = 2
if _sign = 1
movsx eax, word _dec
else
movzx eax, word _dec
end if
else
mov eax, dword _dec
end if
esp equ _esp
end if
mov cl, _sign
call fdo_debug_outdec
popad
popf
}
macro DEBUGH _sign,_hex {
local tp
tp equ 0
match _arg:_num,_hex \{
DEBUGH_N _sign,_num,_arg
tp equ 1
\}
match =0 _arg,tp _hex \{
DEBUGH_N _sign,,_arg
\}
}
macro DEBUGH_N _sign,_num,_hex {
pushf
pushad
if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>)
'Error: 1..8 are only allowed for precision in %x'
end if
if _hex eqtype eax
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
if ~_hex eq eax
mov eax, _hex
end if
mov edx, 8
else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
if ~_hex eq ax
movzx eax, _hex
end if
if (_num eq)
mov edx, 4
end if
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
if ~_hex eq al
movzx eax, _hex
end if
if (_num eq)
mov edx, 2
end if
end if
else if _hex eqtype 0
mov eax, _hex
else
esp equ esp+4*8+4
mov eax, dword _hex
esp equ _esp
end if
if ~_num eq
mov edx, _num
else
if ~_hex eqtype eax
mov edx, 8
end if
end if
call fdo_debug_outhex
popad
popf
}
;-----------------------------------------------------------------------------
debug_func fdo_debug_outchar
debug_beginf
pushad
movzx ecx, al
mov ebx, 1
; mov ecx,sys_msg_board
; call ecx ; sys_msg_board
stdcall SysMsgBoard
popad
ret
debug_endf
debug_func fdo_debug_outstr
debug_beginf
mov ebx, 1
.l1:
dec esi
js .l2
movzx ecx, byte[edx]
or cl, cl
jz .l2
; mov ecx,sys_msg_board
; call ecx ; sys_msg_board
stdcall SysMsgBoard
inc edx
jmp .l1
.l2:
ret
debug_endf
debug_func fdo_debug_outdec
debug_beginf
or cl, cl
jz @f
or eax, eax
jns @f
neg eax
push eax
mov al, '-'
call fdo_debug_outchar
pop eax
@@:
movi ecx, 10
push -'0'
.l1:
xor edx, edx
div ecx
push edx
test eax, eax
jnz .l1
.l2:
pop eax
add al, '0'
jz .l3
call fdo_debug_outchar
jmp .l2
.l3:
ret
debug_endf
debug_func fdo_debug_outhex
__fdo_hexdigits db '0123456789ABCDEF'
debug_beginf
mov cl, dl
neg cl
add cl, 8
shl cl, 2
rol eax, cl
.l1:
rol eax, 4
push eax
and eax, 0x0000000F
mov al, [__fdo_hexdigits+eax]
call fdo_debug_outchar
pop eax
dec edx
jnz .l1
ret
debug_endf
;-----------------------------------------------------------------------------
macro DEBUGF _level,_format,[_arg] {
common
if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__
local ..f1,f2,a1,a2,c1,c2,c3,..lbl
_debug_str_ equ __debug_str_ # a1
a1 = 0
c2 = 0
c3 = 0
f2 = 0
repeat ..lbl-..f1
virtual at 0
db _format,0,0
load c1 word from %-1
end virtual
if c1 = '%s'
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER S,a1,0,_arg
else if c1 = '%x'
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER H,a1,0,_arg
else if c1 = '%d' | c1 = '%u'
local c4
if c1 = '%d'
c4 = 1
else
c4 = 0
end if
virtual at 0
db _format,0,0
store word 0 at %-1
load c1 from f2-c2
end virtual
if c1 <> 0
DEBUGS 0,_debug_str_+f2-c2
end if
c2 = c2 + 1
f2 = %+1
DEBUGF_HELPER D,a1,c4,_arg
else if c1 = '\n'
c3 = c3 + 1
end if
end repeat
virtual at 0
db _format,0,0
load c1 from f2-c2
end virtual
if (c1<>0)&(f2<>..lbl-..f1-1)
DEBUGS 0,_debug_str_+f2-c2
end if
virtual at 0
..f1 db _format,0
..lbl:
__debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3
end virtual
end if
}
macro __include_debug_strings dummy,[_id,_fmt,_len] {
common
local c1,a1,a2
forward
if defined _len & ~_len eq
_id:
a1 = 0
a2 = 0
repeat _len
virtual at 0
db _fmt,0,0
load c1 word from %+a2-1
end virtual
if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u')
db 0
a2 = a2 + 1
else if (c1='\n')
dw $0A0D
a1 = a1 + 1
a2 = a2 + 1
else
db c1 and 0x0FF
end if
end repeat
db 0
end if
}
macro DEBUGF_HELPER _letter,_num,_sign,[_arg] {
common
local num
num = 0
forward
if num = _num
DEBUG#_letter _sign,_arg
end if
num = num+1
common
_num = _num+1
}
macro include_debug_strings {
if __DEBUG__ = 1
match dbg_str,__debug_strings \{
__include_debug_strings dbg_str
\}
end if
}

File diff suppressed because it is too large Load Diff

View File

@ -1,112 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro kernel_export [name]{
forward
if used name
if DEBUG
display 'uses: ',`name,#13,#10
end if
extrn name
end if
}
; all exported kernel functions and data
kernel_export \
RegService,\
GetService,\
ServiceHandler,\
AttachIntHandler,\
GetIntHandler,\
FpuSave,\
FpuRestore,\
ReservePortArea,\
Boot_Log,\
\
MutexInit,\
MutexLock,\
MutexUnlock,\
\
PciApi,\
PciRead32,\
PciRead16,\
PciRead8,\
PciWrite8,\
PciWrite16,\
PciWrite32,\
\
AllocPage,\
AllocPages,\
FreePage,\
MapPage,\
MapSpace,\
MapIoMem,\
GetPgAddr,\
CommitPages,\
ReleasePages,\
\
AllocKernelSpace,\
FreeKernelSpace,\
KernelAlloc,\
KernelFree,\
UserAlloc,\
UserFree,\
Kmalloc,\
Kfree,\
CreateRingBuffer,\
\
GetPid,\
CreateThread,\
CreateObject,\
DestroyObject,\
CreateEvent,\
RaiseEvent,\
WaitEvent,\
DestroyEvent,\
ClearEvent,\
\
LoadCursor,\
SelectHwCursor,\
SetHwCursor,\
HwCursorRestore,\
HwCursorCreate,\
\
SysMsgBoardStr,\
SysMsgBoard,\
GetCurrentTask,\
LoadFile,\
SendEvent,\
SetMouseData,\
SetKeyboardData,\
RegKeyboard,\
DelKeyboard,\
Sleep,\
GetTimerTicks,\
\
strncat,\
strncpy,\
strncmp,\
strnlen,\
strchr,\
strrchr,\
\
LFBAddress,\
GetDisplay,\
SetScreen,\
\
RegUSBDriver,\
USBOpenPipe,\
USBNormalTransferAsync,\
USBControlTransferAsync,\
USBGetParam,\
\
DiskAdd,\
DiskMediaChanged,\
DiskDel,\
\
TimerHS,\
CancelTimerHS

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,173 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2006-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Serge 2006-2008
; email: infinity_sound@mail.ru
PLAY_SYNC equ 0x80000000
PCM_ALL equ 0
PCM_OUT equ 0x08000000
PCM_RING equ 0x10000000
PCM_STATIC equ 0x20000000
PCM_FLOAT equ 0x40000000 ;reserved
PCM_FILTER equ 0x80000000 ;reserved
PCM_2_16_48 equ 1
PCM_1_16_48 equ 2
PCM_2_16_44 equ 3
PCM_1_16_44 equ 4
PCM_2_16_32 equ 5
PCM_1_16_32 equ 6
PCM_2_16_24 equ 7
PCM_1_16_24 equ 8
PCM_2_16_22 equ 9
PCM_1_16_22 equ 10
PCM_2_16_16 equ 11
PCM_1_16_16 equ 12
PCM_2_16_12 equ 13
PCM_1_16_12 equ 14
PCM_2_16_11 equ 15
PCM_1_16_11 equ 16
PCM_2_16_8 equ 17
PCM_1_16_8 equ 18
PCM_2_8_48 equ 19
PCM_1_8_48 equ 20
PCM_2_8_44 equ 21
PCM_1_8_44 equ 22
PCM_2_8_32 equ 23
PCM_1_8_32 equ 24
PCM_2_8_24 equ 25
PCM_1_8_24 equ 26
PCM_2_8_22 equ 27
PCM_1_8_22 equ 28
PCM_2_8_16 equ 29
PCM_1_8_16 equ 30
PCM_2_8_12 equ 31
PCM_1_8_12 equ 32
PCM_2_8_11 equ 33
PCM_1_8_11 equ 34
PCM_2_8_8 equ 35
PCM_1_8_8 equ 36
SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3
SND_GETFORMAT equ 4
SND_RESET equ 5
SND_SETPOS equ 6
SND_GETPOS equ 7
SND_SETBUFF equ 8
SND_OUT equ 9
SND_PLAY equ 10
SND_STOP equ 11
SND_SETVOLUME equ 12
SND_GETVOLUME equ 13
SND_SETPAN equ 14
SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16
SND_GETFREESPACE equ 17
SND_SETTIMEBASE equ 18
SND_GETTIMESTAMP equ 19
struc STREAM
{
.magic dd ? ;'WAVE'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
.size dd ?
.str_fd dd ?
.str_bk dd ?
.device dd ?
.format dd ?
.flags dd ?
.out_base dd ?
.out_wp dd ?
.out_rp dd ?
.out_count dd ?
.out_top dd ? ;16*4
.in_base dd ?
.in_size dd ?
.in_wp dd ?
.in_rp dd ?
.in_count dd ?
.in_free dd ?
.in_top dd ?
align 8
.time_base dq ?
.time_stamp dq ?
.last_ts dd ?
.notify_event dd ?
.notify_id dd ?
.r_size dd ?
.r_dt dd ?
.r_silence dd ?
.resample dd ?
.l_vol dd ?
.r_vol dd ?
.l_amp dw ?
.r_amp dw ?
.pan dd ?
.l_amp_f dd ? ;float point left
.r_amp_f dd ? ;float point right
.sizeof:
}
FD_OFFSET equ 24
virtual at 0
STREAM STREAM
end virtual
struc WAVE_HEADER
{ .riff_id dd ?
.riff_size dd ?
.riff_format dd ?
.fmt_id dd ?
.fmt_size dd ?
.format_tag dw ?
.channels dw ?
.freq dd ?
.bytes_sec dd ?
.block_align dw ?
.bits_sample dw ?
.data_id dd ?
.data_size dd ?
}

View File

@ -1,247 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; params
; edi= output
; eax= input stream 1
; ebx= input stream 2
if used mmx_mix_2
align 4
mmx_mix_2:
movq mm0, [eax]
movq mm1, [eax+8]
movq mm2, [eax+16]
movq mm3, [eax+24]
movq mm4, [eax+32]
movq mm5, [eax+40]
movq mm6, [eax+48]
movq mm7, [eax+56]
paddsw mm0, [ebx]
movq [edi], mm0
paddsw mm1, [ebx+8]
movq [edi+8], mm1
paddsw mm2, [ebx+16]
movq [edi+16], mm2
paddsw mm3, [ebx+24]
movq [edi+24], mm3
paddsw mm4, [ebx+32]
movq [edi+32], mm4
paddsw mm5, [ebx+40]
movq [edi+40], mm5
paddsw mm6, [ebx+48]
movq [edi+48], mm6
paddsw mm7, [ebx+56]
movq [edi+56], mm7
movq mm0, [eax+64]
movq mm1, [eax+72]
movq mm2, [eax+80]
movq mm3, [eax+88]
movq mm4, [eax+96]
movq mm5, [eax+104]
movq mm6, [eax+112]
movq mm7, [eax+120]
paddsw mm0, [ebx+64]
movq [edi+64], mm0
paddsw mm1, [ebx+72]
movq [edi+72], mm1
paddsw mm2, [ebx+80]
movq [edi+80], mm2
paddsw mm3, [ebx+88]
movq [edi+88], mm3
paddsw mm4, [ebx+96]
movq [edi+96], mm4
paddsw mm5, [ecx+104]
movq [edx+104], mm5
paddsw mm6, [ebx+112]
movq [edi+112], mm6
paddsw mm7, [ebx+120]
movq [edi+120], mm7
ret
align 4
mmx_mix_3:
movq mm0, [eax]
movq mm1, [eax+8]
movq mm2, [eax+16]
movq mm3, [eax+24]
movq mm4, [eax+32]
movq mm5, [eax+40]
movq mm6, [eax+48]
movq mm7, [eax+56]
paddsw mm0, [ebx]
paddsw mm1, [ebx+8]
paddsw mm2, [ebx+16]
paddsw mm3, [ebx+24]
paddsw mm4, [ebx+32]
paddsw mm5, [ebx+40]
paddsw mm6, [ebx+48]
paddsw mm7, [ebx+56]
paddsw mm0, [ecx]
movq [edi], mm0
paddsw mm1, [ecx+8]
movq [edi+8], mm1
paddsw mm2, [ecx+16]
movq [edi+16], mm2
paddsw mm3, [ecx+24]
movq [edi+24], mm3
paddsw mm4, [ecx+32]
movq [edi+32], mm4
paddsw mm5, [ecx+40]
movq [edi+40], mm5
paddsw mm6, [ecx+48]
movq [edi+48], mm6
paddsw mm7, [ecx+56]
movq [edi+56], mm7
movq mm0, [eax+64]
movq mm1, [eax+72]
movq mm2, [eax+80]
movq mm3, [eax+88]
movq mm4, [eax+96]
movq mm5, [eax+104]
movq mm6, [eax+112]
movq mm7, [eax+120]
paddsw mm0, [ebx+64]
paddsw mm1, [ebx+72]
paddsw mm2, [ebx+80]
paddsw mm3, [ebx+88]
paddsw mm4, [ebx+96]
paddsw mm5, [ebx+104]
paddsw mm6, [ebx+112]
paddsw mm7, [ebx+120]
paddsw mm0, [ecx+64]
movq [edi+64], mm0
paddsw mm1, [ecx+72]
movq [edi+72], mm1
paddsw mm2, [ecx+80]
movq [edi+80], mm2
paddsw mm3, [ecx+88]
movq [edi+88], mm3
paddsw mm4, [ecx+96]
movq [edi+96], mm4
paddsw mm5, [ecx+104]
movq [edi+104], mm5
paddsw mm6, [ecx+112]
movq [edi+112], mm6
paddsw mm7, [ecx+120]
movq [edi+120], mm7
ret
align 4
mmx_mix_4:
movq mm0, [eax]
movq mm2, [eax+8]
movq mm4, [eax+16]
movq mm6, [eax+24]
movq mm1, [ebx]
movq mm3, [ebx+8]
movq mm5, [ebx+16]
movq mm7, [ebx+24]
paddsw mm0, [ecx]
paddsw mm2, [ecx+8]
paddsw mm4, [ecx+16]
paddsw mm6, [ecx+24]
paddsw mm1, [edx]
paddsw mm3, [edx+8]
paddsw mm5, [edx+16]
paddsw mm7, [edx+24]
paddsw mm0, mm1
movq [edi], mm0
paddsw mm2, mm3
movq [edi+8], mm2
paddsw mm4, mm5
movq [edi+16], mm4
paddsw mm5, mm6
movq [edi+24], mm6
movq mm0, [eax+32]
movq mm2, [eax+40]
movq mm4, [eax+48]
movq mm6, [eax+56]
movq mm1, [ebx+32]
movq mm3, [ebx+40]
movq mm5, [ebx+48]
movq mm7, [ebx+56]
paddsw mm0, [ecx+32]
paddsw mm2, [ecx+40]
paddsw mm4, [ecx+48]
paddsw mm6, [ecx+56]
paddsw mm1, [edx+32]
paddsw mm3, [edx+40]
paddsw mm5, [edx+48]
paddsw mm7, [edx+56]
paddsw mm0, mm1
movq [edi+32], mm0
paddsw mm2, mm2
movq [edi+40], mm2
paddsw mm4, mm5
movq [edi+48], mm4
paddsw mm6, mm7
movq [edi+56], mm6
movq mm0, [eax+64]
movq mm2, [eax+72]
movq mm4, [eax+80]
movq mm6, [eax+88]
movq mm1, [ebx+64]
movq mm3, [ebx+72]
movq mm5, [ebx+80]
movq mm7, [ebx+88]
paddsw mm0, [ecx+64]
paddsw mm2, [ecx+72]
paddsw mm4, [ecx+80]
paddsw mm6, [ecx+88]
paddsw mm1, [edx+64]
paddsw mm3, [edx+72]
paddsw mm5, [edx+80]
paddsw mm7, [edx+88]
paddsw mm0, mm1
movq [edi+64], mm0
paddsw mm2, mm3
movq [edi+72], mm2
paddsw mm4, mm5
movq [edi+80], mm4
paddsw mm6, mm5
movq [edi+88], mm7
movq mm0, [eax+96]
movq mm2, [eax+104]
movq mm4, [eax+112]
movq mm6, [eax+120]
movq mm1, [ebx+96]
movq mm3, [ebx+104]
movq mm5, [ebx+112]
movq mm7, [ebx+120]
paddsw mm0, [ecx+96]
paddsw mm2, [ecx+104]
paddsw mm4, [ecx+112]
paddsw mm6, [ecx+120]
paddsw mm1, [edx+96]
paddsw mm3, [edx+104]
paddsw mm5, [edx+112]
paddsw mm7, [edx+120]
paddsw mm0, mm1
movq [eax+96], mm0
paddsw mm2, mm3
movq [edi+104], mm2
paddsw mm4, mm5
movq [edi+112], mm4
paddsw mm6, mm7
movq [edi+120], mm6
ret
end if

View File

@ -1,145 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if used mmx128_mix_2
align 4
mmx128_mix_2:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
movaps xmm0, [eax]
movaps xmm1, [eax+16]
movaps xmm2, [eax+32]
movaps xmm3, [eax+48]
movaps xmm4, [eax+64]
movaps xmm5, [eax+80]
movaps xmm6, [eax+96]
movaps xmm7, [eax+112]
paddsw xmm0, [ebx]
movaps [edi], xmm0
paddsw xmm1, [ebx+16]
movaps [edi+16], xmm1
paddsw xmm2, [ebx+32]
movaps [edi+32], xmm2
paddsw xmm3, [ebx+48]
movaps [edi+48], xmm3
paddsw xmm4, [ebx+64]
movaps [edi+64], xmm4
paddsw xmm5, [ebx+80]
movaps [edi+80], xmm5
paddsw xmm6, [ebx+96]
movaps [edi+96], xmm6
paddsw xmm7, [ebx+112]
movaps [edi+112], xmm7
ret
align 4
mmx128_mix_3:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
prefetcht1 [ecx+128]
movaps xmm0, [eax]
movaps xmm1, [eax+16]
movaps xmm2, [eax+32]
movaps xmm3, [eax+48]
movaps xmm4, [eax+64]
movaps xmm5, [eax+80]
movaps xmm6, [eax+96]
movaps xmm7, [eax+112]
paddsw xmm0, [ebx]
paddsw xmm1, [ebx+16]
paddsw xmm2, [ebx+32]
paddsw xmm3, [ebx+48]
paddsw xmm4, [ebx+64]
paddsw xmm5, [ebx+80]
paddsw xmm6, [ebx+96]
paddsw xmm7, [ebx+112]
paddsw xmm0, [ecx]
movaps [edi], xmm0
paddsw xmm1, [ecx+16]
movaps [edi+16], xmm1
paddsw xmm2, [ecx+32]
movaps [edi+32], xmm2
paddsw xmm3, [ecx+48]
movaps [edi+48], xmm3
paddsw xmm4, [ecx+64]
movaps [edi+64], xmm4
paddsw xmm5, [ecx+80]
movaps [edi+80], xmm5
paddsw xmm6, [ecx+96]
movaps [edi+96], xmm6
paddsw xmm7, [ecx+112]
movaps [edi+112], xmm7
ret
align 4
mmx128_mix_4:
prefetcht1 [eax+128]
prefetcht1 [ebx+128]
prefetcht1 [ecx+128]
prefetcht1 [edx+128]
movaps xmm0, [eax]
movaps xmm2, [eax+16]
movaps xmm4, [eax+32]
movaps xmm6, [eax+48]
movaps xmm1, [ebx]
movaps xmm3, [ebx+16]
movaps xmm5, [ebx+32]
movaps xmm7, [ebx+48]
paddsw xmm0, [ecx]
paddsw xmm2, [ecx+16]
paddsw xmm4, [ecx+32]
paddsw xmm6, [ecx+48]
paddsw xmm1, [edx]
paddsw xmm3, [edx+16]
paddsw xmm5, [edx+32]
paddsw xmm7, [edx+48]
paddsw xmm0, xmm1
movaps [edi], xmm0
paddsw xmm2, xmm3
movaps [edi+16], xmm2
paddsw xmm4, xmm5
movaps [edi+32], xmm4
paddsw xmm6, xmm7
movaps [edi+48], xmm6
movaps xmm0, [eax+64]
movaps xmm2, [eax+80]
movaps xmm4, [eax+96]
movaps xmm6, [eax+112]
movaps xmm1, [ebx+64]
movaps xmm3, [ebx+80]
movaps xmm5, [ebx+96]
movaps xmm7, [ebx+112]
paddsw xmm0, [ecx+64]
paddsw xmm2, [ecx+80]
paddsw xmm4, [ecx+96]
paddsw xmm6, [ecx+112]
paddsw xmm1, [edx+64]
paddsw xmm3, [edx+80]
paddsw xmm5, [edx+96]
paddsw xmm7, [edx+112]
paddsw xmm0, xmm1
movaps [edi+64], xmm0
paddsw xmm2, xmm3
movaps [edi+80], xmm2
paddsw xmm4, xmm5
movaps [edi+96], xmm4
paddsw xmm6, xmm7
movaps [edi+112], xmm6
ret
end if

File diff suppressed because it is too large Load Diff

View File

@ -1,267 +0,0 @@
; Macroinstructions for defining and calling procedures
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp, size@ccall
end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp, size@ccall
end if }
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
prologue@proc equ prologuedef
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push ebp
mov ebp, esp
if localbytes
sub esp, localbytes
end if
end if
irps reg, reglist \{ push reg \} }
epilogue@proc equ epiloguedef
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at ebp+8
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (ebp+8)
end virtual
name # % = parmbytes/4
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at ebp-localbytes+current
macro label . \\{ deflocal@proc .,:, \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
restruc byte,word,dword,pword,tword,qword
current = $-(ebp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dd ?,?,?,?
else if tbyte eq type
dd ?,?,?
else if qword eq type | pword eq type
dd ?,?
else
dd ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dd ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
..var def val
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal], byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal], word@initlocal
else
mov dword [name+position@initlocal], dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }

View File

@ -1,57 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;flags------------------------------------------------------------
DEBUG equ 1 ;show messages at debug board
use_cli_sti equ 1 ;driver become more stable (theoretically)
;constants--------------------------------------------------------
API_VERSION equ 0 ;debug
OS_BASE equ 0x80000000
new_app_base equ 0x0
PROC_BASE equ (OS_BASE+0x080000)
SB16Buffer equ (OS_BASE+0x2A0000)
SB16_Status equ (OS_BASE+0x2B0000)
DMAPage equ ((SB16Buffer-OS_BASE) shr 16)
SB16Buffer0 equ SB16Buffer
SB16Buffer1 equ (SB16Buffer+16384)
SB16Buffer2 equ (SB16Buffer+(2*16384))
SB16Buffer3 equ (SB16Buffer+(3*16384))
sb_irq_num equ 5 ;default values for SB16, may be overrided by autodetect
sb_dma_num equ 5 ;default values for SB16, may be overrided by autodetect
small_buffer equ 32768
full_buffer equ 65536
sb_buffer_size equ small_buffer ; FIX ring buffer overlapped events issue; full_buffer
__supported_buffer_sizes fix <small_buffer, full_buffer>
if ~(sb_buffer_size in __supported_buffer_sizes)
display 13,10,'unsupported buffer size was selected, check config.inc',13,10
stop
end if
sb_out_rate equ 48000
;time constant for cards older than SB16
sb_tc equ (256-(1000000/(sb_out_rate*2)))
SRV_GETVERSION equ 0
DEV_PLAY equ 1
DEV_STOP equ 2
DEV_CALLBACK equ 3
DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8
DRV_ENTRY equ 1
DRV_EXIT equ -1

View File

@ -1,72 +0,0 @@
Nable 21.05.2008.
This driver is my contribution (or donation) to KolibriOS. This is provided
AS IS in hope it'll be useful, but WITHOUT ANY WARRANTY! No responcibility
for any hardware damage or data loss. Use at your own risk!
;-------------------------------------------------------------------------------
;Changelog:
;-------------------------------------------------------------------------------
v0.2 - DEV_SET(GET)_MASTERVOL functions are unlocked and implemented.
v0.1 - first release.
;-------------------------------------------------------------------------------
;Tiny FAQ for sound driver by Nable for SB16 sound card.
;-------------------------------------------------------------------------------
;What is it?--------------------------------------------------------------------
As you may know there is a sound subsystem ('INFINITY') in KolibriOS.
This subsystem includes mixer and separate interface for soundplayer
program and driver, so player application don't need to know what soundcard
is installed and how to cope with it, all work with card do the driver.
Before this time there were drivers only for AC97 integrated sound, but I
don't have such at home and if I would upgrade my computer with a newest
hardware, with 100% probability integrated sound will be HD Codec, nowadays
AC97 is not actual (2008 year is at calendar). But I'm not planning to upgrade
my computer so much now (and in next 5-6 years), writing the driver for my PCI
ESS Maestro1 card is difficult for me (may be some time later), so I decided
to write a driver for SB16. At first it is easy, there are many working
examples for DOS, there are heaps of good documentation and as an ISA device
SB16 can be programmed through I/O ports (about 5 ports are used), that is
more easy than PCI access. Now, enough lirics, lets go to physics :-)
If you still don't understand what stuff is it, I'll tell this in brief:
with this driver you can play MP3 and WAV music (using AC97SND player) and
sounds (some games and DOSBOX can produce sound output through sound
subsystem) in KolibriOS.
;Yeah! I need sound in Kolibri and I have SB16 card. Whats then?----------------
At first copy my SOUND.OBJ to /sys/drivers at your Kolibri system. Note,
that if you have AC97 card and it's driver started - then new driver won't
run until reboot. Then run BOARD and go to 'user' tab. Then try to run
AC97SND player. At BOARD you will see the following (if you had a proper
card):
|----------------------------|
|detecting hardware... | <- detector startup message
|DSP found at port 220h | <- if you have a proper card, it'll be
|DSP version 4.13 - SB16 | autodetected. Numbers may be different.
|failed to attach IRQ5 | <- don't mention. Old kernels reserve IRQ5
|owner's handler: 0x80D74284 | see below how to fix it.
|----------------------------|
At first, note that DSP version must be 4.xx or higher. Older cards are not
supported in this first release, maybe some time later. If nothing detected
but PNP/BIOS or some other OS detects your card - I'm sorry, it's perverted
PNP card like OPTi16, that is like HD Codec - until you init it through
PCI->ISA bridge (HD Codec of course through PCI->PCI bridge), map it, etc,
you can't use it in any way. I'd rather write a PCI device driver, than
for this extreme perversion. If your card detected and has a proper version
but you see 'failed to attach IRQ' - delete stroke 'mov [irq_owner+4*5],1' from the
file kernel.asm of your kernel source, save it, rebuild kernel, copy new
kernel to /sys/ (did you rename 'kernel' to 'kernel.mnt'? You should do it),
restart kernel (Ctrl+Alt+F12, Home). THE EASIER WAY IS TO USE A NEWER KERNEL,
since SVN802 it's fixed.
Now everything should be OK.
;It works for a part of the second and then stops, but system doesn't hang------
Go to 'config.inc' of my driver and change 'sb_irq_num' value from 5 to 7.
Then save, rebuild driver (compile 'sound.asm'), put 'sound' to /sys/drivers/
(you need to rename file 'sound' to 'sound.obj'), restart kernel and try again
to produce sound.
;-------------------------------------------------------------------------------
Ask your questions at KolibriOS forum: board.kolibrios.org
I'll try to answer you if possible.

View File

@ -1,304 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--------------------------------
; program dma
;--------------------------------
sb_set_dma:
mov ebx, [sound_dma]
lea eax, [ebx+4];mask required channel
cmp bl, 4
ja .use_second_dma_controller
jb @f
.dma_setup_error:
if DEBUG
mov esi, msgErrDMAsetup
call SysMsgBoardStr
end if
mov dword[esp], START.stop
ret
@@:
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out 0xA, al;mask required channel
xor eax, eax
out 0xC, al;clear byte pointer flip-flop register
lea eax, [ebx+0x58];auto-init mode for channel (ebx)
out 0xB, al;DMA channel 0-3 mode register
movzx edx, byte[ebx+dma_table];page register
mov al, DMAPage
out dx, al
lea edx, [ebx*2];DMA channel 0-3 base address
mov al, 0;LSB is 0
out dx, al
; mov al,0 ;MSB is 0 too
out dx, al
inc edx ;DMA channel 0-3 byte count
mov al, ((sb_buffer_size-1) and 0xff)
out dx, al
mov al, ((sb_buffer_size-1) shr 8);it is the same
out dx, al
mov eax, ebx;unmask DMA channel
out 0xA, al
if use_cli_sti
sti
end if
ret
.use_second_dma_controller:
cmp bl, 7
ja .dma_setup_error
sub bl, 4
sub al, 4
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out 0xD4, al;mask required channel
xor eax, eax
out 0xD8, al;clear byte pointer flip-flop register
lea eax, [ebx+0x58];auto-init mode for channel (ebx+4)
out 0xD6, al;DMA channel 4-7 mode register
movzx edx, byte[ebx+dma_table+4];page register
mov al, DMAPage
out dx, al
lea edx, [ebx*4+0xC0];DMA channel 4-7 base address
mov al, 0;LSB is 0 ;for 16bit DMA this contains
out dx, al;A1-A8 lines of address bus, A0 is zero
; mov al,0 ;MSB is 0 too ;for 16bit DMA this contains
out dx, al;A9-A16 lines of address bus
inc edx
inc edx ;DMA channel 4-7 16bit word count
mov al, (((sb_buffer_size/2)-1) and 0xff)
out dx, al
mov al, (((sb_buffer_size/2)-1) shr 8)
out dx, al
mov eax, ebx;unmask DMA channel
out 0xD4, al
if use_cli_sti
sti
end if
ret
;-------------------------------------------------------------------------------
; out byte to SB DSP's write port
;-------------------------------------------------------------------------------
macro sb_out data_to_out {
@@:
in al, dx
test al, al;is DSP busy?
js @b ;it's busy
mov al, data_to_out;it's free
out dx, al
}
;-------------------------------------------------------------------------------
; stop playing
;-------------------------------------------------------------------------------
proc sb_stop
mov edx, [sb_base_port]
add dl, 0xC
sb_out 0xD3 ;turn the speaker off
sb_out 0xDA ;exit 8bit DMA
sb_out 0xD9 ;exit 16bit DMA
ret
endp
;-------------------------------------------------------------------------------
; start playing
;-------------------------------------------------------------------------------
proc sb_play
and [int_flip_flop], 0
mov edx, [sb_base_port]
add dl, 0xC
sb_out 0xD1 ;turn speaker on
; sb_out 0x48 ;set DSP transfer size ;for older cards, not supported
; ;in this version
; mov ax,32767 ;(64k)/2-1
;@@: ;out the low byte...
; in al,dx
; test al,al ;is DSP busy?
; js @b ;it's busy
; out dx,al
; mov al,ah ;...then the high byte
;@@:
; in al,dx
; test al,al ;is DSP busy?
; js @b ;it's busy
; out dx,al
; sb_out 0x1C ;auto-init 8bit playback
; 0xBXh - 16 bit DMA mode
; ||||
sb_out 10110110b ;bCommand
; ||||
; |||+-reserved
; ||+--turn FIFO on (0 for off)
; |+---auto-init mode on (0 for off)
; +----A/D: 0-output, 1-input
; +------stereo on
; |+-----unsigned (1 for signed)
; ||
sb_out 00110000b ;bMode
; || ||||
; ---------reserved
;wSize is a number of 16bit samples less 1. For auto-init mode each half
;buffer is (64k)/2 bytes long and, obviously, contains ((64k)/2)/2 samples
sb_out (((sb_buffer_size/2/2)-1) and 0xFF) ;wSize.LowByte
sb_out (((sb_buffer_size/2/2)-1) shr 8) ;wSize.HighByte
ret
endp
;-------------------------------------------------------------------------------
; reset DSP
;-------------------------------------------------------------------------------
proc sb_reset
and [int_flip_flop], 0
mov edx, [sb_base_port]
add dl, 6
mov al, 1;start DSP reset
if use_cli_sti
cli ;here to minimize time with disabled ints
end if
out dx, al
mov ecx, 40;wait at least 3 microsec.
@@:
in al, dx
loop @b
xor eax, eax;stop DSP reset
if use_cli_sti
sti
end if
out dx, al
ret
endp
;-------------------------------------------------------------------------------
; set the rate for playing, enable stereo
;-------------------------------------------------------------------------------
proc sb_setup
mov edx, [sb_base_port]
add dl, 0xC
sb_out 40h ;set time constant, this is for old cards
sb_out sb_tc
sb_out 41h ;set sound rate, this can only SB16
sb_out (sb_out_rate shr 8) ;first high byte (MSB)
sb_out (sb_out_rate and 0xff) ;then low byte (LSB)
; mov al,0xE ;for older cards, not supported in this version
; sub dl,(0xC-4) ;talk to SB's mixer
; out dx,al ;select this register of the mixer
; mov ecx,6 ;wait for the chip
;@@:
; in al,dx
; loop @b
; inc edx ;now read the data port
; in al,dx
; or al,22h ;turn on stereo
; mov ah,al
; mov al,0xE
; dec edx ;talk to SB's mixer
; out dx,al ;select this register of the mixer
; mov ecx,6 ;wait for the chip
;@@:
; in al,dx
; loop @b
; inc edx ;now send data to the data port
; mov al,ah
; out dx,al
; dec edx
; mov ecx,35 ;wait for the chip
;@@:
; in al,dx
; loop @b
ret
endp
;-------------------------------------------------------------------------------
; set master volume of SB mixer, note, not only SB16 but SBPro and older
; this is the first step to more full support for hardware
;-------------------------------------------------------------------------------
;in: eax in range [-10000;0] - master volume for _both_ channels
;note that x*3*17/2000 and x*3/2000*17 are not the same numbers,
;because we count in integers
proc sb_set_master_vol
mov [sb_master_vol], eax
add eax, 10000;SB sound level rise from 0 to MAX_LEVEL
lea eax, [eax+eax*2];*3
mov ebx, 2000;divisor
xor edx, edx
cmp byte[sb_DSP_version_int], 4
jae @f ;SBPro's MAX_LEVEL is 15, but we *11 because
;volume byte looks like that: 0xLR, where L - left
;channel volume, R - right, 0<=R,L<=15
div ebx
imul eax, 17
mov edx, [sb_base_port]
push eax ;here for optimisation
add dl, 4
mov al, 0x22;write mixer register 0x22
out dx, al
in al, dx;wait for the chip ;6
in al, dx;wait for the chip ;5
in al, dx;wait for the chip ;4
in al, dx;wait for the chip ;3
in al, dx;wait for the chip ;2
in al, dx;wait for the chip ;1
pop eax ;go!
inc edx
out dx, al
ret
@@: ;SB16's MAX_LEVEL is 255
imul eax, 17
div ebx
mov edx, [sb_base_port]
push eax ;here for optimisation
add dl, 4
mov al, 0x30;left speaker
out dx, al
pop eax ;<--+
inc edx ; \/
push eax ;here for optimisation
out dx, al;write
dec edx
mov al, 0x31;right speaker
out dx, al
pop eax
inc edx
out dx, al;write
ret
endp
;-------------------------------------------------------------------------------

View File

@ -1,398 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
include 'CONFIG.INC'
;structs----------------------------------------------------------
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
;something--------------------------------------------------------
public START
public service_proc
public version
include '..\proc32.inc'
include '..\imports.inc'
section '.flat' code readable align 16
include 'SB16.INC'
;-------------------------------------------------------------------------------
proc START stdcall, state:dword
cmp [state], 1
jne .stop
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
call detect ;returns DSP version or zero if
test eax, eax ;SB card not found
jz .exit
if DEBUG
movzx eax, al ;major version
mov esi, sb_DSP_description
dec eax
jz .sb_say_about_found_dsp
mov dword[esi], '2.x '
dec eax
jz .sb_say_about_found_dsp
mov dword[esi], 'Pro '
dec eax
jz .sb_say_about_found_dsp
mov dword[esi], '16 '
.sb_say_about_found_dsp:
mov esi, msgDSPFound
call SysMsgBoardStr
end if
; xor eax,eax
; mov ebx,[sb_base_port]
; lea ecx,[ebx+0xF]
xor ebx, ebx
mov ecx, [sb_base_port]
lea edx, [ebx+0xF]
call ReservePortArea ;these ports must be my!
if DEBUG
dec eax
jnz @f
mov esi, msgErrRsrvPorts
call SysMsgBoardStr
@@:
end if
call sb_setup ;clock it, etc
stdcall AttachIntHandler, sb_irq_num, sb_irq, 0
if DEBUG
test eax, eax
jnz @f
mov esi, msgErrAtchIRQ
call SysMsgBoardStr
; stdcall GetIntHandler, sb_irq_num
; call SysMsgBoardNum
jmp .stop
@@:
mov esi, msgSucAtchIRQ
call SysMsgBoardStr
end if
stdcall RegService, my_service, service_proc
ret
.stop:
call sb_reset
.exit:
if DEBUG
mov esi, msgExit
call SysMsgBoardStr
end if
xor eax, eax
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 service_proc stdcall, ioctl:dword
mov edi, [ioctl]
mov eax, [edi+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [edi+output]
cmp [edi+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
cmp eax, DEV_PLAY
jne @f
if DEBUG
mov esi, msgPlay
call SysMsgBoardStr
end if
call sb_stop ;to play smth new we must stop smth old
call pre_fill_data ;fill first and second half of the buffer
call pre_fill_data ;
call sb_set_dma ;is it really needed here? Paranoia.
call sb_play
xor eax, eax ;set maximum volume
call sb_set_master_vol
xor eax, eax
ret
;@@: ;all this commented stuff in service proc
; cmp eax,DEV_STOP ;is never used. Mixer do this virtually,
; jne @f ;e.g. instead of stopping driver it
;if DEBUG ;outputs silence
; mov esi,msgStop
; call SysMsgBoardStr
;end if
; call sb_stop
; xor eax,eax
; ret
@@:
cmp eax, DEV_CALLBACK
jne @f
if DEBUG
mov esi, msgCallback
call SysMsgBoardStr
end if
mov edi, [edi+input]
mov eax, [edi]
mov [callback], eax
if DEBUG
call SysMsgBoardNum
end if
xor eax, eax
ret
@@:
cmp eax, DEV_SET_MASTERVOL;Serge asked me to unlock
jne @F ;DEV_SET(GET)_MASTERVOL, although mixer doesn't use it.
;It doesn't use it _in current version_ - but in the future...
if DEBUG
mov esi, msgSetVol
call SysMsgBoardStr
end if
mov eax, [edi+input]
mov eax, [eax]
call sb_set_master_vol
xor eax, eax
ret
@@:
cmp eax, DEV_GET_MASTERVOL
jne @F
if DEBUG
mov esi, msgGetVol
call SysMsgBoardStr
end if
mov eax, [edi+output]
mov edx, [sb_master_vol]
mov [eax], edx
xor eax, eax
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
;-------------------------------------------------------------------------------
align 4
proc sb_irq
mov edx, [sb_base_port];tell the DSP that we have processed IRQ
add dl, 0xF ;0xF for 16 bit sound, 0xE for 8 bit sound
in al, dx ;for non-stop sound
pre_fill_data:
mov eax, int_flip_flop
not dword[eax]
mov eax, [eax]
test eax, eax
jns .fill_second_half
if sb_buffer_size eq small_buffer
stdcall [callback], SB16Buffer0 ;for 32k buffer
else if sb_buffer_size eq full_buffer
stdcall [callback], SB16Buffer0 ;for 64k buffer
stdcall [callback], SB16Buffer1 ;for 64k buffer
end if
xor eax, eax
not eax
ret
.fill_second_half:
if sb_buffer_size eq small_buffer
stdcall [callback], SB16Buffer1 ;for 32k buffer
else if sb_buffer_size eq full_buffer
stdcall [callback], SB16Buffer2 ;for 64k buffer
stdcall [callback], SB16Buffer3 ;for 64k buffer
end if
xor eax, eax
not eax
ret
endp
;-------------------------------------------------------------------------------
align 4
proc detect
.sb_detect_next_port:
if DEBUG
inc dword[port_second_digit_num]
end if
mov edx, sb_base_port
add byte[edx], 10h
cmp byte[edx], 80h
jbe .sb_try_to_detect_at_specified_port
;error - no SB card detected
.sb_not_found_err:
xor eax, eax
ret
.sb_try_to_detect_at_specified_port:
call sb_reset
add dl, 8
mov ecx, 100
.sb_check_port:
in al, dx
test al, al ;is DSP port ready to be read?
jns .sb_port_not_ready
sub dl, 4
in al, dx ;check for AAh response
add dl, 4
cmp al, 0xAA
jne .sb_port_not_ready
.sb_card_found:
and dl, 0xF0
add dl, 0xC
sb_out 0xE1 ;get DSP version
add dl, 2
@@:
in al, dx
test al, al ;is DSP port ready to be read?
jns @b
sub dl, 4
in al, dx ;get major version
ror eax, 16
add dl, 4
@@:
in al, dx
test al, al ;is DSP port ready to be read?
jns @b
sub dl, 4
in al, dx ;get minor version
xor edx, edx
mov dl, 10
div dl
ror eax, 16
xor ah, ah
mov [sb_DSP_version_int], eax;for internal usage
if DEBUG
add [sb_DSP_version], eax
end if
ret
.sb_port_not_ready:
loop .sb_check_port ;100 retries (~100 microsec.)
jmp .sb_detect_next_port
endp
;-------------------------------------------------------------------------------
if DEBUG
proc SysMsgBoardNum ;warning: destroys eax,ebx,ecx,esi
mov ebx, eax
mov ecx, 8
mov esi, (number_to_out+1)
.1:
mov eax, ebx
and eax, 0xF
add al, '0'
cmp al, (10+'0')
jb @f
add al, ('A'-'0'-10)
@@:
mov [esi+ecx], al
shr ebx, 4
loop .1
dec esi
call SysMsgBoardStr
ret
endp
end if
;all initialized data place here
align 4
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
sb_base_port:
dd 200h ;don't ask me why - see the code&docs
sound_dma dd sb_dma_num
;note that 4th DMA channel doesn't exist, it is used for cascade
;plugging the first DMA controler to the second
dma_table db 0x87,0x83,0x81,0x82,0xFF,0x8B,0x89,0x8A
my_service db 'SOUND',0 ;max 16 chars include zero
if DEBUG
number_to_out db '0x00000000',13,10,0
msgInit db 'detecting hardware...',13,10,0
msgExit db 'exiting... May be some problems found?',13,10,0
msgPlay db 'start play',13,10,0
;msgStop db 'stop play',13,10,0
msgCallback db 'set_callback received from the mixer!',13,10
db 'callback handler is: ',0
msgErrAtchIRQ db 'failed to attach IRQ',(sb_irq_num+'0'),13,10
db 'owner',39,'s handler: ',0
msgSucAtchIRQ db 'succesfully attached IRQ',(sb_irq_num+'0')
db ' as hardcoded',13,10,0
msgErrRsrvPorts db 'failed to reserve needed ports.',13,10
db 'Driver may work unstable',13,10,0
msgSetVol db 'DEV_SET_MASTERVOL call came',13,10,0
msgGetVol db 'DEV_GET_MASTERVOL call came',13,10,0
msgErrDMAsetup db 'failed to setup DMA - bad channel',13,10,0
;-------------------------------------------------------------------------------
msgDSPFound db 'DSP found at port 2'
label port_second_digit_num dword at $
db '00h',13,10,'DSP version '
sb_DSP_version:
db '0.00 - SB'
sb_DSP_description:
db 32,32,32,32,13,10,0
;-------------------------------------------------------------------------------
end if
section '.data' data readable writable align 16
;all uninitialized data place here
;pTempBuf rd 1
callback rd 1
int_flip_flop rd 1
sb_master_vol rd 1
sb_DSP_version_int rd 1

View File

@ -1,173 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;driver sceletone
format MS COFF
DEBUG equ 1
API_VERSION equ 0 ;debug
include 'proc32.inc'
include 'imports.inc'
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
public START
public service_proc
public version
DRV_ENTRY equ 1
DRV_EXIT equ -1
STRIDE equ 4 ;size of row in devices table
SRV_GETVERSION equ 0
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .exit
.entry:
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
stdcall RegService, my_service, service_proc
ret
.fail:
.exit:
xor eax, eax
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 service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword API_VERSION
xor eax, eax
ret
@@:
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
align 4
proc detect
locals
last_bus dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
add edi, STRIDE
jmp @B
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
xor eax, eax
inc eax
ret
.err:
xor eax, eax
ret
endp
DEVICE_ID equ 1234; pci device id
VENDOR_ID equ 5678; device vendor id
;all initialized data place here
align 4
devices dd (DEVICE_ID shl 16)+VENDOR_ID
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
my_service db 'MY_SERVICE',0 ;max 16 chars include zero
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgFail db 'device not found',13,10,0
section '.data' data readable writable align 16
;all uninitialized data place here

File diff suppressed because it is too large Load Diff

View File

@ -1,423 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
DEBUG = 1
include 'proc32.inc'
include 'imports.inc'
include '../struct.inc'
VID_INTEL = 0x8086
VID_NVIDIA = 0x10DE
VID_VIA = 0x1106
VID_SIS = 0x1039
VID_FM801 = 0x1319
VID_CREATIVE = 0x1102
VID_ATI = 0x1002
VID_AMD = 0x1022
VID_ULI = 0x10B9
VID_TERA = 0x6549
VID_RDC = 0x17F3
VID_VMWARE = 0x15AD
CTRL_ICH = 0x2415
CTRL_ICH0 = 0x2425
CTRL_ICH2 = 0x2435
CTRL_ICH3 = 0x2445
CTRL_ICH4 = 0x24C5
CTRL_ICH5 = 0x24D5
CTRL_ICH6 = 0x266E
CTRL_ICH7 = 0x27DE
CTRL_NFORCE = 0x01B1
CTRL_NFORCE2 = 0x006A
CTRL_NFORCE3 = 0x00DA
CTRL_MCP04 = 0x003A
CTRL_CK804 = 0x0059
CTRL_CK8 = 0x008A
CTRL_CK8S = 0x00EA
CTRL_MCP51 = 0x026B
CTRL_VT82C686 = 0x3058
CTRL_VT8233_5 = 0x3059
CTRL_SIS = 0x7012
CTRL_FM801 = 0x0801
CTRL_CT0200 = 0x0006 ; Dell OEM version (EMU10K1X)
CTRL_INTEL_SCH2 = 0x080a
CTRL_INTEL_HPT = 0x0c0c
CTRL_INTEL_CPT = 0x1c20
CTRL_INTEL_PGB = 0x1d20
CTRL_INTEL_PPT1 = 0x1e20
CTRL_INTEL_82801F = 0x2668
CTRL_INTEL_63XXESB = 0x269a
CTRL_INTEL_82801G = 0x27d8
CTRL_INTEL_82801H = 0x284b
CTRL_INTEL_82801_UNK1 = 0x2911
CTRL_INTEL_82801I = 0x293e
CTRL_INTEL_82801_UNK2 = 0x293f
CTRL_INTEL_82801JI = 0x3a3e
CTRL_INTEL_82801JD = 0x3a6e
CTRL_INTEL_PCH = 0x3b56
CTRL_INTEL_PCH2 = 0x3b57
CTRL_INTEL_SCH = 0x811b
CTRL_INTEL_LPT = 0x8c20
CTRL_NVIDIA_MCP51 = 0x026c
CTRL_NVIDIA_MCP55 = 0x0371
CTRL_NVIDIA_MCP61_1 = 0x03e4
CTRL_NVIDIA_MCP61_2 = 0x03f0
CTRL_NVIDIA_MCP65_1 = 0x044a
CTRL_NVIDIA_MCP65_2 = 0x044b
CTRL_NVIDIA_MCP67_1 = 0x055c
CTRL_NVIDIA_MCP67_2 = 0x055d
CTRL_NVIDIA_MCP78_1 = 0x0774
CTRL_NVIDIA_MCP78_2 = 0x0775
CTRL_NVIDIA_MCP78_3 = 0x0776
CTRL_NVIDIA_MCP78_4 = 0x0777
CTRL_NVIDIA_MCP73_1 = 0x07fc
CTRL_NVIDIA_MCP73_2 = 0x07fd
CTRL_NVIDIA_MCP79_1 = 0x0ac0
CTRL_NVIDIA_MCP79_2 = 0x0ac1
CTRL_NVIDIA_MCP79_3 = 0x0ac2
CTRL_NVIDIA_MCP79_4 = 0x0ac3
CTRL_NVIDIA_0BE2 = 0x0be2
CTRL_NVIDIA_0BE3 = 0x0be3
CTRL_NVIDIA_0BE4 = 0x0be4
CTRL_NVIDIA_GT100 = 0x0be5
CTRL_NVIDIA_GT106 = 0x0be9
CTRL_NVIDIA_GT108 = 0x0bea
CTRL_NVIDIA_GT104 = 0x0beb
CTRL_NVIDIA_GT116 = 0x0bee
CTRL_NVIDIA_MCP89_1 = 0x0d94
CTRL_NVIDIA_MCP89_2 = 0x0d95
CTRL_NVIDIA_MCP89_3 = 0x0d96
CTRL_NVIDIA_MCP89_4 = 0x0d97
CTRL_NVIDIA_GF119 = 0x0e08
CTRL_NVIDIA_GF110_1 = 0x0e09
CTRL_NVIDIA_GF110_2 = 0x0e0c
CTRL_ATI_SB450 = 0x437b
CTRL_ATI_SB600 = 0x4383
CTRL_ATI_RS600 = 0x793b
CTRL_ATI_RS690 = 0x7919
CTRL_ATI_RS780 = 0x960f
CTRL_ATI_RS_UNK1 = 0x970f
CTRL_ATI_R600 = 0xaa00
CTRL_ATI_RV630 = 0xaa08
CTRL_ATI_RV610 = 0xaa10
CTRL_ATI_RV670 = 0xaa18
CTRL_ATI_RV635 = 0xaa20
CTRL_ATI_RV620 = 0xaa28
CTRL_ATI_RV770 = 0xaa30
CTRL_ATI_RV730 = 0xaa38
CTRL_ATI_RV710 = 0xaa40
CTRL_ATI_RV740 = 0xaa48
CTRL_AMD_HUDSON = 0x780d
CTRL_VIA_VT82XX = 0x3288
CTRL_VIA_VT61XX = 0x9140
CTRL_VIA_VT71XX = 0x9170
CTRL_SIS_966 = 0x7502
CTRL_ULI_M5461 = 0x5461
CTRL_CREATIVE_CA0110_IBG = 0x0009
CTRL_CREATIVE_SOUND_CORE3D_1 = 0x0010
CTRL_CREATIVE_SOUND_CORE3D_2 = 0x0012
CTRL_TERA_UNK1 = 0x1200
CTRL_RDC_R3010 = 0x3010
CTRL_VMWARE_UNK1 = 0x1977
API_VERSION = 0x01000100
public START
public service_proc
public version
struct 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
ends
section '.flat' code readable align 16
proc START stdcall, state:dword
mov eax, [srv_entry]
cmp [state], 1
jne .stop
if DEBUG
mov esi, msgInit
call SysMsgBoardStr
end if
test eax, eax
jnz .done
call detect_controller
ret
.stop:
test eax, eax
jz .done
leave
jmp eax
.done:
xor eax, eax
ret
endp
align 4
proc service_proc stdcall, ioctl:dword
or eax, -1
ret
endp
align 4
proc detect_controller
locals
last_bus dd ?
bus dd ?
devfn dd ?
endl
xor eax, eax
mov [bus], eax
inc eax
call PciApi
cmp eax, -1
je .err
mov [last_bus], eax
.next_bus:
and [devfn], 0
.next_dev:
stdcall PciRead32, [bus], [devfn], dword 0
test eax, eax
jz .next
cmp eax, -1
je .next
mov edi, devices
@@:
mov ebx, [edi]
test ebx, ebx
jz .next
cmp eax, ebx
je .found
add edi, 8
jmp @B
.next:
inc [devfn]
cmp [devfn], 256
jb .next_dev
mov eax, [bus]
inc eax
mov [bus], eax
cmp eax, [last_bus]
jna .next_bus
xor eax, eax
ret
.found:
if DEBUG
mov esi, msgLoading
call SysMsgBoardStr
mov esi, dword[edi+4]
call SysMsgBoardStr
mov esi, msgNewline
call SysMsgBoardStr
end if
stdcall GetService, dword[edi+4]
test eax, eax
jz .err
mov edx, [eax+SRV.entry]
mov [srv_entry], edx
ret
.err:
if DEBUG
mov esi, msgFail
call SysMsgBoardStr
end if
xor eax, eax
ret
endp
align 4
devices dd (CTRL_ICH shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH0 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH2 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH3 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH4 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH5 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH6 shl 16)+VID_INTEL, intelac97
dd (CTRL_ICH7 shl 16)+VID_INTEL, intelac97
dd (CTRL_NFORCE shl 16)+VID_NVIDIA, intelac97
dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_MCP04 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_CK804 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_CK8 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_CK8S shl 16)+VID_NVIDIA, intelac97
dd (CTRL_MCP51 shl 16)+VID_NVIDIA, intelac97
dd (CTRL_VT82C686 shl 16)+VID_VIA, vt823x
dd (CTRL_VT8233_5 shl 16)+VID_VIA, vt823x
dd (CTRL_SIS shl 16)+VID_SIS, sis
dd (CTRL_FM801 shl 16)+VID_FM801, fm801
dd (0x5000 shl 16)+0x1274, ensoniq
dd (0x5880 shl 16)+0x1274, ensoniq
dd (CTRL_CT0200 shl 16)+VID_CREATIVE, emu10k1x
; Intel
dd (CTRL_INTEL_SCH2 shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_HPT shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_CPT shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_PGB shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_PPT1 shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801F shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_63XXESB shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801G shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801H shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801_UNK1 shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801I shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801_UNK2 shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801JI shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_82801JD shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_PCH shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_PCH2 shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_SCH shl 16)+VID_INTEL, intelhda
dd (CTRL_INTEL_LPT shl 16)+VID_INTEL, intelhda
; Nvidia
dd (CTRL_NVIDIA_MCP51 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP55 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP61_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP61_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP65_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP65_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP67_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP67_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP73_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP73_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP78_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP78_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP78_3 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP78_4 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP79_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP79_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP79_3 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP79_4 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_0BE2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_0BE3 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_0BE4 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GT100 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GT106 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GT108 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GT104 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GT116 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP89_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP89_2 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP89_3 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_MCP89_4 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GF119 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GF110_1 shl 16)+VID_NVIDIA, intelhda
dd (CTRL_NVIDIA_GF110_2 shl 16)+VID_NVIDIA, intelhda
; ATI
dd (CTRL_ATI_SB450 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_SB600 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RS600 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RS690 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RS780 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RS_UNK1 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_R600 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV610 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV620 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV630 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV635 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV670 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV710 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV730 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV740 shl 16)+VID_ATI, intelhda
dd (CTRL_ATI_RV770 shl 16)+VID_ATI, intelhda
; AMD
dd (CTRL_AMD_HUDSON shl 16)+VID_AMD, intelhda
; VIA
dd (CTRL_VIA_VT82XX shl 16)+VID_VIA, intelhda
dd (CTRL_VIA_VT61XX shl 16)+VID_VIA, intelhda
dd (CTRL_VIA_VT71XX shl 16)+VID_VIA, intelhda
; SiS
dd (CTRL_SIS_966 shl 16)+VID_SIS, intelhda
; ULI
dd (CTRL_ULI_M5461 shl 16)+VID_ULI, intelhda
; Teradici
dd (CTRL_TERA_UNK1 shl 16)+VID_ULI, intelhda
; Creative
dd (CTRL_CREATIVE_CA0110_IBG shl 16)+VID_CREATIVE, intelhda
dd (CTRL_CREATIVE_SOUND_CORE3D_1 shl 16)+VID_CREATIVE, intelhda
dd (CTRL_CREATIVE_SOUND_CORE3D_2 shl 16)+VID_CREATIVE, intelhda
; RDC Semiconductor
dd (CTRL_RDC_R3010 shl 16)+VID_RDC, intelhda
; VMware
dd (CTRL_VMWARE_UNK1 shl 16)+VID_VMWARE, intelhda
dd 0 ;terminator
version dd (5 shl 16) or (API_VERSION and 0xFFFF)
srv_entry dd 0
intelac97 db 'INTELAC97', 0
vt823x db 'VT823X', 0
sis db 'SIS', 0
fm801 db 'FM801', 0
ensoniq db 'ENSONIQ', 0
emu10k1x db 'EMU10K1X', 0
intelhda db 'INTEL_HDA', 0
msgInit db 'Detecting hardware...',13,10,0
msgFail db 'No compatible soundcard found!',13,10,0
msgLoading db 'Loading ',0
msgNewline db 13,10,0
section '.data' data readable writable align 16

View File

@ -1,295 +0,0 @@
; Disk driver to create FAT16/FAT32 memory-based temporary disk aka RAM disk.
; (c) CleverMouse
; Note: in the ideal world, a disk driver should not care about a file system
; on it. In the current world, however, there is no way to format a disk in
; FAT, so this part of file-system-specific operations is included in the
; driver.
; When this driver is loading, it registers itself in the system and does
; nothing more. When loaded, this driver controls pseudo-disk devices
; named /tmp#/, where # is a digit from 0 to 9. The driver does not create
; any device by itself, waiting for instructions from an application.
; The driver responds to the following IOCTLs from a control application:
SRV_GETVERSION equ 0 ; input ignored,
; output = dword API_VERSION
DEV_ADD_DISK equ 1 ; input = structure add_disk_struc,
; no output
DEV_DEL_DISK equ 2 ; input = structure del_disk_struc,
; no output
; For all IOCTLs the driver returns one of the following error codes:
NO_ERROR equ 0
ERROR_INVALID_IOCTL equ 1 ; unknown IOCTL code, wrong input/output size...
ERROR_INVALID_ID equ 2 ; .DiskId must be from 0 to 9
ERROR_SIZE_TOO_LARGE equ 3 ; .DiskSize is too large
ERROR_SIZE_TOO_SMALL equ 4 ; .DiskSize is too small
ERROR_NO_MEMORY equ 5 ; memory allocation failed
API_VERSION equ 1
; Input structures:
struc add_disk_struc
{
.DiskSize dd ? ; disk size in sectors, 1 sector = 512 bytes
; Note: .DiskSize is the full size, including FAT service data.
; Size for useful data is slightly less than this number.
.DiskId db ? ; from 0 to 9
.sizeof:
}
virtual at 0
add_disk_struc add_disk_struc
end virtual
struc del_disk_struc
{
.DiskId db ? ; from 0 to 9
.sizeof:
}
virtual at 0
del_disk_struc del_disk_struc
end virtual
max_num_disks equ 10
; standard driver stuff
format MS COFF
DEBUG equ 0
include 'proc32.inc'
include 'imports.inc'
public START
public version
struc IOCTL
{
.handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
section '.flat' code readable align 16
; the start procedure (see the description above)
proc START
; This procedure is called in two situations:
; when the driver is loading and when the system is shutting down.
; 1. Check that the driver is loading; do nothing unless so.
xor eax, eax ; set return value in case we will do nothing
cmp dword [esp+4], 1
jne .nothing
; 2. Register the driver in the system.
stdcall RegService, my_service, service_proc
; 3. Return the value returned by RegService back to the system.
.nothing:
retn 4
endp
; Service procedure for the driver - handle all IOCTL requests for the driver.
; The description of handled IOCTLs is located in the start of this file.
proc service_proc
; 1. Save used registers to be stdcall.
; Note: this shifts esp, so the first parameter [esp+4] becomes [esp+16].
; Note: edi is used not by this procedure itself, but by worker procedures.
push ebx esi edi
; 2. Get parameter from the stack: [esp+16] is the first parameter,
; pointer to IOCTL structure.
mov edx, [esp+16] ; edx -> IOCTL
; 3. Set the return value to 'invalid IOCTL'.
; Now, if one of conditions for IOCTL does not met, the code
; can simply return the value already loaded.
mov al, ERROR_INVALID_IOCTL
; 4. Get request code and select a handler for the code.
mov ecx, [edx+IOCTL.io_code]
test ecx, ecx ; check for SRV_GETVERSION
jnz .no.srv_getversion
; 4. This is SRV_GETVERSION request, no input, 4 bytes output, API_VERSION.
; 4a. Output size must be at least 4 bytes.
cmp [edx+IOCTL.out_size], 4
jl .return
; 4b. Write result to the output buffer.
mov eax, [edx+IOCTL.output]
mov dword [eax], API_VERSION
; 4c. Return success.
xor eax, eax
jmp .return
.no.srv_getversion:
dec ecx ; check for DEV_ADD_DISK
jnz .no.dev_add_disk
; 5. This is DEV_ADD_DISK request, input is add_disk_struc, output is 1 byte
; 5a. Input size must be exactly add_disk_struc.sizeof bytes.
cmp [edx+IOCTL.inp_size], add_disk_struc.sizeof
jnz .return
; 5b. Load input parameters and call the worker procedure.
mov eax, [edx+IOCTL.input]
movzx ebx, [eax+add_disk_struc.DiskId]
mov esi, [eax+add_disk_struc.DiskSize]
call add_disk
; 5c. Return back to the caller the value from the worker procedure.
jmp .return
.no.dev_add_disk:
dec ecx ; check for DEV_DEL_DISK
jnz .return
; 6. This is DEV_DEL_DISK request, input is del_disk_struc
; 6a. Input size must be exactly del_disk_struc.sizeof bytes.
cmp [edx+IOCTL.inp_size], del_disk_struc.sizeof
jnz .return
; 6b. Load input parameters and call the worker procedure.
mov eax, [edx+IOCTL.input]
movzx ebx, [eax+del_disk_struc.DiskId]
call del_disk
; 6c. Return back to the caller the value from the worker procedure.
.return:
; 7. Exit.
; 7a. The code above returns a value in al for efficiency,
; propagate it to eax.
movzx eax, al
; 7b. Restore used registers to be stdcall.
pop edi esi ebx
; 7c. Return, popping one argument.
retn 4
endp
; The worker procedure for DEV_ADD_DISK request.
; Creates a memory-based disk of given size and formats it in FAT16/32.
; Called with ebx = disk id, esi = disk size,
; returns error code in al.
proc add_disk
; 1. Check that disk id is correct and free.
; Otherwise, return the corresponding error code.
mov al, ERROR_INVALID_ID
cmp ebx, max_num_disks
jae .return
cmp [disk_pointers+ebx*4], 0
jnz .return
; 2. Check that the size is reasonable.
; Otherwise, return the corresponding error code.
mov al, ERROR_SIZE_TOO_LARGE
cmp esi, MAX_SIZE
ja .return
mov al, ERROR_SIZE_TOO_SMALL
cmp esi, MIN_FAT16_SIZE
jb .return
; 3. Allocate memory for the disk, store the pointer in edi.
; If failed, return the corresponding error code.
mov eax, esi
shl eax, 9
stdcall KernelAlloc, eax
mov edi, eax
test eax, eax
mov al, ERROR_NO_MEMORY
jz .return
; 4. Store the pointer and the size in the global variables.
; It is possible, though very unlikely, that two threads
; have called this function in parallel with the same id,
; so [disk_pointers+ebx*4] could be filled by another thread.
; Play extra safe and store new value only if old value is zero.
xor eax, eax
lock cmpxchg [disk_pointers+ebx*4], edi
jz @f
; Otherwise, free the allocated memory and return the corresponding error code.
stdcall KernelFree, edi
mov al, ERROR_INVALID_ID
jmp .return
@@:
mov [disk_sizes+ebx*4], esi
; 5. Call the worker procedure for formatting this disk.
; It should not fail.
call format_disk
; 6. Register the disk in the system.
; 6a. Generate name as /tmp#, where # = ebx + '0'. Use two dwords in the stack.
push 0
push 'tmp'
mov eax, esp ; eax points to 'tmp' + zero byte + zero dword
lea ecx, [ebx+'0'] ; ecx = digit
mov [eax+3], cl ; eax points to 'tmp#' + zero dword
; 6b. Call the kernel API. Use disk id as 'userdata' parameter for callbacks.
stdcall DiskAdd, disk_functions, eax, ebx, 0
; 6c. Restore the stack after 6a.
pop ecx ecx
; 6c. Check the result. If DiskAdd has failed, cleanup and return
; ERROR_NO_MEMORY, this is the most probable or even the only reason to fail.
test eax, eax
jnz @f
mov [disk_sizes+ebx*4], 0
mov [disk_pointers+ebx*4], 0
stdcall KernelFree, edi
mov al, ERROR_NO_MEMORY
jmp .return
@@:
push eax
; 6d. Notify the kernel that media is inserted.
stdcall DiskMediaChanged, eax, 1
; 6e. Disk is fully configured; store its handle in the global variable
; and return success.
pop [disk_handles+ebx*4]
xor eax, eax
; 7. Return.
.return:
retn
endp
; The worker procedure for DEV_DEL_DISK request.
; Deletes a previously created memory-based disk.
; Called with ebx = disk id,
; returns error code in al.
proc del_disk
; 1. Check that disk id is correct.
; Otherwise, return the corresponding error code.
mov al, ERROR_INVALID_ID
cmp ebx, max_num_disks
jae .return
; 2. Get the disk handle, simultaneously clearing the global variable.
xor edx, edx
xchg edx, [disk_handles+ebx*4]
; 3. Check that the handle is non-zero.
; Otherwise, return the corresponding error code.
test edx, edx
jz .return
; 4. Delete the disk from the system.
stdcall DiskDel, edx
; 5. Return success.
; Note that we can't free memory yet; it will be done in tmpdisk_close.
xor eax, eax
.return:
retn
endp
; Include implementation of tmpdisk_* callbacks.
include 'tmpdisk_work.inc'
; Include FAT-specific code.
include 'tmpdisk_fat.inc'
; initialized data
align 4
disk_functions:
dd disk_functions_end - disk_functions
dd tmpdisk_close
dd 0 ; no need in .closemedia
dd tmpdisk_querymedia
dd tmpdisk_read
dd tmpdisk_write
dd 0 ; no need in .flush
dd tmpdisk_adjust_cache_size
disk_functions_end:
; disk_handles = array of values for Disk* kernel functions
label disk_handles dword
times max_num_disks dd 0
; disk_pointers = array of pointers to disk data
label disk_pointers dword
times max_num_disks dd 0
; disk_sizes = array of disk sizes
label disk_sizes dword
times max_num_disks dd 0
version dd 0x00060006
my_service db 'tmpdisk',0
; uninitialized data
; actually, not used here
;section '.data' data readable writable align 16 ; standard driver stuff

View File

@ -1,327 +0,0 @@
; FAT-specific code for tmpdisk.asm.
; Formats a disk to FAT16 or FAT32, depending on size.
; Note: formatting is adjusted for memory-based disks. Although the resulting
; image is a valid FAT32 volume, it has no "spare" sectors, e.g. second copy
; of FAT or place for second sector of MS FAT32 bootloader.
; Some constants
FAT16_ROOTDIR_SECTORS = 16 ; can be changed, but why not?
; FAT16:
; 1 bootsector,
; min 0xFF5 sectors for data,
; min (0xFF5*2/512) = 16 sectors per FAT, we use only one copy,
; FAT16_ROOTDIR_SECTORS for root directory
MIN_FAT16_SIZE = 1 + 16 + FAT16_ROOTDIR_SECTORS + 0xFF5
; FAT32:
; 1 bootsector,
; 1 sector for fsinfo,
; min 0xFFF5 sectors for data,
; min (0xFFF5*4/512) = 512 sectors per FAT, we use only one copy
MIN_FAT32_SIZE = 1 + 1 + 512 + 0xFFF5
MAX_SIZE = 1 shl (30 - 9) ; 1G in 512-byte sectors
; Initializes FATxx structures on the disk.
; Called with edi = pointer to disk data, esi = size of disk.
proc format_disk
; Determine FAT type and jump to the corresponding handler.
cmp esi, MIN_FAT32_SIZE
jae format_disk_fat32
; Fall through to format_disk_fat16.
endp
; Structure of FAT16 bootsector. Field names are from MS spec.
struc FAT16BOOT
{
.BS_jmpBoot rb 3
.BS_OEMName rb 8
.BPB_BytsPerSec dw ?
.BPB_SecsPerClus db ?
.BPB_RsvdSecCnt dw ?
.BPB_NumFATs db ?
.BPB_RootEntCnt dw ?
.BPB_TotSec16 dw ?
.BPB_Media db ?
.BPB_FATSz16 dw ?
.BPB_SecPerTrk dw ?
.BPB_NumHeads dw ?
.BPB_HiddSec dd ?
.BPB_TotSec32 dd ?
.BS_DrvNum db ?
.BS_Reserved1 db ?
.BS_BootSig db ?
.BS_VolID dd ?
.BS_VolLab rb 11
.BS_FilSysType rb 8
}
virtual at 0
FAT16BOOT FAT16BOOT
end virtual
; Initializes FAT16 structures on the disk.
; Called with edi = pointer to disk data, esi = size of disk.
format_disk_fat16:
; 1. Calculate number of clusters.
; 1a. There are fixed-sized areas and there are data+FAT;
; every cluster uses 512 bytes in data area and 2 bytes in FAT area.
lea eax, [esi-1-FAT16_ROOTDIR_SECTORS]
; two following lines are equivalent to edx = floor(eax*512/514)
mov ecx, 0xFF00FF01
mul ecx ; edx = number of clusters
; 1b. Force the number be less than 0xfff5.
mov eax, 0xFFF4
cmp edx, eax
jb @f
mov edx, eax
@@:
; 2. Zero all system areas on the disk.
lea ecx, [256*(1+FAT16_ROOTDIR_SECTORS)+edx+255]
and ecx, not 255
shr ecx, 1
xor eax, eax
push edi
rep stosd
pop edi
; 3. Generate the bootsector.
; 3a. Copy static stub.
push esi edi
mov esi, fat16bootsector_stub
mov ecx, fat16bootsector_stub_size
rep movsb
pop edi esi
mov word [edi+510], 0xAA55
; 3b. Set fields which depend on size.
cmp esi, 0x10000
jae .size_is_32bit
mov [edi+FAT16BOOT.BPB_TotSec16], si
jmp .size_written
.size_is_32bit:
mov [edi+FAT16BOOT.BPB_TotSec32], esi
.size_written:
lea eax, [edx+255]
shr eax, 8
mov [edi+FAT16BOOT.BPB_FATSz16], ax
; 3c. Generate volume ID.
call generate_volume_id
mov [edi+FAT16BOOT.BS_VolID], eax
; 4. Initialize FAT.
mov dword [edi+512], 0xFFFFFFF8
; 5. Return.
ret
; Structure of FAT32 bootsector. Field names are from MS spec.
struc FAT32BOOT
{
.BS_jmpBoot rb 3
.BS_OEMName rb 8
.BPB_BytsPerSec dw ?
.BPB_SecsPerClus db ?
.BPB_RsvdSecCnt dw ?
.BPB_NumFATs db ?
.BPB_RootEntCnt dw ?
.BPB_TotSec16 dw ?
.BPB_Media db ?
.BPB_FATSz16 dw ?
.BPB_SecPerTrk dw ?
.BPB_NumHeads dw ?
.BPB_HiddSec dd ?
.BPB_TotSec32 dd ?
.BPB_FATSz32 dd ?
.BPB_ExtFlags dw ?
.BPB_FSVer dw ?
.BPB_RootClus dd ?
.BPB_FSInfo dw ?
.BPB_BkBootSec dw ?
.BPB_Reserved rb 12
.BS_DrvNum db ?
.BS_Reserved1 db ?
.BS_BootSig db ?
.BS_VolID dd ?
.BS_VolLab rb 11
.BS_FilSysType rb 8
}
virtual at 0
FAT32BOOT FAT32BOOT
end virtual
; Initializes FAT32 structures on the disk.
; Called with edi = pointer to disk data, esi = size of disk.
format_disk_fat32:
; 1. Calculate number of clusters.
; 1a. There is fixed-sized area and there are data+FAT;
; every cluster uses 512 bytes in data area and 4 bytes in FAT area.
lea eax, [esi-1-1]
; two following lines are equivalent to edx=floor(eax*512/516) if eax<10000000h
mov ecx, 0xFE03F810
mul ecx ; edx = number of clusters
; 2. Zero all system areas on the disk and first cluster of data,
; used for root directory.
lea ecx, [128*(1+1+1)+edx+127]
and ecx, not 127
xor eax, eax
push edi
rep stosd
pop edi
; 3. Generate the bootsector.
; 3a. Copy static stub.
push esi edi
mov esi, fat32bootsector_stub
mov ecx, fat32bootsector_stub_size
rep movsb
pop edi esi
mov word [edi+510], 0xAA55
; 3b. Set fields which depend on size.
mov [edi+FAT32BOOT.BPB_TotSec32], esi
lea eax, [edx+127]
shr eax, 7
mov [edi+FAT32BOOT.BPB_FATSz32], eax
; 3c. Generate volume ID.
call generate_volume_id
mov [edi+FAT32BOOT.BS_VolID], eax
; 4. Initialize fsinfo sector.
mov dword [edi+512], 'RRaA'
mov dword [edi+512+484], 'rrAa'
dec edx ; one cluster is occupied by root dir
mov dword [edi+512+488], edx ; free count
mov byte [edi+512+492], 3 ; first free cluster
mov word [edi+512+510], 0xAA55
; 5. Initialize FAT.
mov dword [edi+512*2], 0x0FFFFFF8
mov dword [edi+512*2+4], 0x0FFFFFFF
mov dword [edi+512*2+8], 0x0FFFFFFF
; 6. Return.
ret
; Generate volume serial number, which should try to be unique for each volume.
; Use CMOS date+time, copy-pasted from fat32.inc.
generate_volume_id:
call get_time_for_file
mov cx, ax
call get_date_for_file
shl eax, 16
mov ax, cx
ret
; Three following procedures are copy-pasted from fat32.inc.
bcd2bin:
;----------------------------------
; input : AL=BCD number (eg. 0x11)
; output : AH=0
; AL=decimal number (eg. 11)
;----------------------------------
xor ah, ah
shl ax, 4
shr al, 4
aad
ret
get_date_for_file:
;-----------------------------------------------------
; Get date from CMOS and pack day,month,year in AX
; DATE bits 0..4 : day of month 0..31
; 5..8 : month of year 1..12
; 9..15 : count of years from 1980
;-----------------------------------------------------
mov al, 0x7 ;day
out 0x70, al
in al, 0x71
call bcd2bin
ror eax, 5
mov al, 0x8 ;month
out 0x70, al
in al, 0x71
call bcd2bin
ror eax, 4
mov al, 0x9 ;year
out 0x70, al
in al, 0x71
call bcd2bin
add ax, 20 ;because CMOS return only the two last
;digit (eg. 2000 -> 00 , 2001 -> 01) and we
rol eax, 9 ;need the difference with 1980 (eg. 2001-1980)
ret
get_time_for_file:
;-----------------------------------------------------
; Get time from CMOS and pack hour,minute,second in AX
; TIME bits 0..4 : second (the low bit is lost)
; 5..10 : minute 0..59
; 11..15 : hour 0..23
;-----------------------------------------------------
mov al, 0x0 ;second
out 0x70, al
in al, 0x71
call bcd2bin
ror eax, 6
mov al, 0x2 ;minute
out 0x70, al
in al, 0x71
call bcd2bin
ror eax, 6
mov al, 0x4 ;hour
out 0x70, al
in al, 0x71
call bcd2bin
rol eax, 11
ret
; some data
fat16bootsector_stub:
db 0EBh, 3Ch, 90h ; BS_jmpBoot
db 'KOLIBRI ' ; BS_OEMName
dw 512 ; BPB_BytsPerSec
db 1 ; BPB_SecsPerClus
dw 1 ; BPB_RsvdSecCnt
db 1 ; BPB_NumFATs
dw FAT16_ROOTDIR_SECTORS*16 ; BPB_RootEntCnt
dw 0 ; BPB_TotSec16, filled in format_disk_fat16
db 0F8h ; BPB_Media
dw 0 ; BPB_FATSz16, filled in format_disk_fat16
dw 32 ; BPB_SecPerTrk
dw 128 ; BPB_NumHeads
dd 0 ; BPB_HiddSec
dd 0 ; BPB_TotSec32, filled in format_disk_fat16
db 80h ; BS_DrvNum
db 0 ; BS_Reserved1
db 29h ; BS_BootSig
dd 0 ; BS_VolID, filled in format_disk_fat16
db 'NO NAME ' ; BS_VolLab
db 'FAT16 ' ; BS_FilSysType
; just in case add some meaningful bytes if someone tries to boot
db 0CDh, 19h, 0EBh, 0FEh ; int 19h, jmp $
fat16bootsector_stub_size = $ - fat16bootsector_stub
fat32bootsector_stub:
db 0EBh, 58h, 90h ; BS_jmpBoot
db 'KOLIBRI ' ; BS_OEMName
dw 512 ; BPB_BytsPerSec
db 1 ; BPB_SecsPerClus
dw 2 ; BPB_RsvdSecCnt
db 1 ; BPB_NumFATs
dw 0 ; BPB_RootEntCnt
dw 0 ; BPB_TotSec16
db 0F8h ; BPB_Media
dw 0 ; BPB_FATSz16
dw 32 ; BPB_SecPerTrk
dw 128 ; BPB_NumHeads
dd 0 ; BPB_HiddSec
dd 0 ; BPB_TotSec32, filled in format_disk_fat32
dd 0 ; BPB_FATSz32, filled in format_disk_fat32
dw 0 ; BPB_ExtFlags
dw 0 ; BPB_FSVer
dd 2 ; BPB_RootClus
dw 1 ; BPB_FSInfo
dw 0 ; BPB_BkBootSec
rb 12 ; BPB_Reserved
db 80h ; BS_DrvNum
db 0 ; BS_Reserved1
db 29h ; BS_BootSig
dd 0 ; BS_VolID, filled in format_disk_fat32
db 'NO NAME ' ; BS_VolLab
db 'FAT32 ' ; BS_FilSysType
; same bytes as in fat16bootsector_stub
db 0CDh, 19h, 0EBh, 0FEh ; int 19h, jmp $
fat32bootsector_stub_size = $ - fat32bootsector_stub

View File

@ -1,144 +0,0 @@
; Callbacks which implement tmpdisk-specific disk functions for tmpdisk.asm.
; The first argument of every callback is .userdata = userdata arg of AddDisk.
; For tmpdisk, .userdata is the disk id, one of 0,...,max_num_disks-1.
DISK_STATUS_OK = 0 ; success
DISK_STATUS_GENERAL_ERROR = -1; if no other code is suitable
DISK_STATUS_INVALID_CALL = 1 ; invalid input parameters
DISK_STATUS_NO_MEDIA = 2 ; no media present
DISK_STATUS_END_OF_MEDIA = 3 ; end of media while reading/writing data
; The last function that is called for the given disk. The kernel calls it when
; the kernel has finished all operations with the disk and it is safe to free
; all driver-specific data identified by 'userdata'.
proc tmpdisk_close
virtual at esp+4
.userdata dd ?
end virtual
; Free the memory for disk and zero global variables.
mov edx, [.userdata]
mov [disk_sizes+edx*4], 0
xor eax, eax
xchg eax, [disk_pointers+edx*4]
stdcall KernelFree, eax
retn 4
endp
struc DISKMEDIAINFO
{
.flags dd ?
DISK_MEDIA_READONLY = 1
.sectorsize dd ?
.capacity dq ?
}
virtual at 0
DISKMEDIAINFO DISKMEDIAINFO
end virtual
; Returns information about disk media.
proc tmpdisk_querymedia
virtual at esp+4
.userdata dd ?
.info dd ?
end virtual
; Media is always present, sector size is always 512 bytes,
; the size of disk in sectors is stored in a global variable.
mov edx, [.userdata]
mov ecx, [.info]
mov [ecx+DISKMEDIAINFO.flags], 0
mov [ecx+DISKMEDIAINFO.sectorsize], 512
mov eax, [disk_sizes+edx*4]
mov dword [ecx+DISKMEDIAINFO.capacity], eax
mov dword [ecx+DISKMEDIAINFO.capacity+4], 0
; Return zero as an indicator of success.
xor eax, eax
retn 8
endp
; Reads one or more sectors from the device.
tmpdisk_read:
xor edx, edx ; 0 = reading
jmp tmpdisk_readwrite
; Writes one or more sectors to the device.
tmpdisk_write:
mov dl, 1 ; 1 = writing
; Fall through to tmpdisk_readwrite.
; Common procedure for reading and writing.
; dl = 0 for reading, dl = 1 for writing.
; Arguments of tmpdisk_read and tmpdisk_write are the same,
; they continue to be stack arguments of this procedure.
proc tmpdisk_readwrite \
userdata:dword, \
buffer:dword, \
start_sector:qword, \
numsectors_ptr:dword
; 1. Save used registers to be stdcall.
push esi edi
mov esi, [userdata]
mov edi, [numsectors_ptr]
; 1. Determine number of sectors to be transferred.
; This is either the requested number of sectors or number of sectors
; up to the disk boundary, depending of what is less.
xor ecx, ecx
; 1a. Test whether [start_sector] is less than [disk_sizes] for selected disk.
; If so, calculate number of sectors between [start_sector] and [disk_sizes].
; Otherwise, the actual number of sectors is zero.
cmp dword [start_sector+4], ecx
jnz .got_number
mov eax, [disk_sizes+esi*4]
sub eax, dword [start_sector]
jbe .got_number
; 1b. Get the requested number of sectors.
mov ecx, [edi]
; 1c. If it is greater than number of sectors calculated in 1a, use the value
; from 1a.
cmp ecx, eax
jb .got_number
mov ecx, eax
.got_number:
; 2. Compare the actual number of sectors with requested. If they are
; equal, set eax (it will be the returned value) to zero. Otherwise,
; use DISK_STATUS_END_OF_MEDIA.
xor eax, eax
cmp ecx, [edi]
jz @f
mov al, DISK_STATUS_END_OF_MEDIA
@@:
; 3. Store the actual number of sectors.
mov [edi], ecx
; 4. Calculate source and destination addresses.
mov edi, dword [start_sector]
shl edi, 9
add edi, [disk_pointers+esi*4]
mov esi, [buffer]
; 5. Calculate number of dwords to be transferred.
shl ecx, 9-2
; 6. Now esi = [buffer], edi = pointer inside disk.
; This is normal for write operations;
; exchange esi and edi for read operations.
test dl, dl
jnz @f
xchg esi, edi
@@:
; 7. Copy data.
rep movsd
; 8. Restore used registers to be stdcall and return.
; The value in eax was calculated in step 2.
pop edi esi
ret
endp
; The kernel calls this function when initializing cache subsystem for
; the media. This call allows the driver to adjust the cache size.
proc tmpdisk_adjust_cache_size
virtual at esp+4
.userdata dd ?
.suggested_size dd ?
end virtual
; Since tmpdisk does not need cache, just return 0.
xor eax, eax
retn 8
endp

View File

@ -1,976 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
format MS COFF
DEBUG equ 1
include 'proc32.inc'
include 'imports.inc'
API_VERSION equ 0
UART_VERSION equ API_VERSION
PG_SW equ 0x003
page_tabs equ 0xFDC00000 ;hack
OS_BASE equ 0x80000000
SLOT_BASE equ (OS_BASE+0x0080000)
TASK_COUNT equ (OS_BASE+0x0003004)
CURRENT_TASK equ (OS_BASE+0x0003000)
struc APPOBJ ;common object header
{
.magic dd ? ;
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
};
virtual at 0
APPOBJ APPOBJ
end virtual
struc IOCTL
{ .handle dd ?
.io_code dd ?
.input dd ?
.inp_size dd ?
.output dd ?
.out_size dd ?
}
virtual at 0
IOCTL IOCTL
end virtual
DEBUG equ 1
DRV_ENTRY equ 1
DRV_EXIT equ -1
THR_REG equ 0; x3f8 ;transtitter/reciever
IER_REG equ 1; x3f9 ;interrupt enable
IIR_REG equ 2; x3fA ;interrupt info
LCR_REG equ 3; x3FB ;line control
MCR_REG equ 4; x3FC ;modem control
LSR_REG equ 5; x3FD ;line status
MSR_REG equ 6; x3FE ;modem status
LCR_5BIT equ 0x00
LCR_6BIT equ 0x01
LCR_7BIT equ 0x02
LCR_8BIT equ 0x03
LCR_STOP_1 equ 0x00
LCR_STOP_2 equ 0x04
LCR_PARITY equ 0x08
LCR_EVEN equ 0x10
LCR_STICK equ 0x20
LCR_BREAK equ 0x40
LCR_DLAB equ 0x80
LSR_DR equ 0x01 ;data ready
LSR_OE equ 0x02 ;overrun error
LSR_PE equ 0x04 ;parity error
LSR_FE equ 0x08 ;framing error
LSR_BI equ 0x10 ;break interrupt
LSR_THRE equ 0x20 ;transmitter holding empty
LSR_TEMT equ 0x40 ;transmitter empty
LSR_FER equ 0x80 ;FIFO error
FCR_EFIFO equ 0x01 ;enable FIFO
FCR_CRB equ 0x02 ;clear reciever FIFO
FCR_CXMIT equ 0x04 ;clear transmitter FIFO
FCR_RDY equ 0x08 ;set RXRDY and TXRDY pins
FCR_FIFO_1 equ 0x00 ;1 byte trigger
FCR_FIFO_4 equ 0x40 ;4 bytes trigger
FCR_FIFO_8 equ 0x80 ;8 bytes trigger
FCR_FIFO_14 equ 0xC0 ;14 bytes trigger
IIR_INTR equ 0x01 ;1= no interrupts
IER_RDAI equ 0x01 ;reciever data interrupt
IER_THRI equ 0x02 ;transmitter empty interrupt
IER_LSI equ 0x04 ;line status interrupt
IER_MSI equ 0x08 ;modem status interrupt
MCR_DTR equ 0x01 ;0-> DTR=1, 1-> DTR=0
MCR_RTS equ 0x02 ;0-> RTS=1, 1-> RTS=0
MCR_OUT_1 equ 0x04 ;0-> OUT1=1, 1-> OUT1=0
MCR_OUT_2 equ 0x08 ;0-> OUT2=1, 1-> OUT2=0; enable intr
MCR_LOOP equ 0x10 ;lopback mode
MSR_DCTS equ 0x01 ;delta clear to send
MSR_DDSR equ 0x02 ;delta data set redy
MSR_TERI equ 0x04 ;trailinh edge of ring
MSR_DDCD equ 0x08 ;delta carrier detect
RATE_50 equ 0
RATE_75 equ 1
RATE_110 equ 2
RATE_134 equ 3
RATE_150 equ 4
RATE_300 equ 5
RATE_600 equ 6
RATE_1200 equ 7
RATE_1800 equ 8
RATE_2000 equ 9
RATE_2400 equ 10
RATE_3600 equ 11
RATE_4800 equ 12
RATE_7200 equ 13
RATE_9600 equ 14
RATE_19200 equ 15
RATE_38400 equ 16
RATE_57600 equ 17
RATE_115200 equ 18
COM_1 equ 1
COM_2 equ 2
COM_3 equ 3
COM_4 equ 4
COM_MAX equ 2 ;only two port supported
COM_1_BASE equ 0x3F8
COM_2_BASE equ 0x2F8
COM_1_IRQ equ 4
COM_2_IRQ equ 3
UART_CLOSED equ 0
UART_TRANSMIT equ 1
UART_STOP equ 2
struc UART
{
.lock dd ?
.base dd ?
.lcr_reg dd ?
.mcr_reg dd ?
.rate dd ?
.mode dd ?
.state dd ?
.rcvr_buff dd ?
.rcvr_rp dd ?
.rcvr_wp dd ?
.rcvr_count dd ?
.rcvr_top dd ?
.xmit_buff dd ?
.xmit_rp dd ?
.xmit_wp dd ?
.xmit_count dd ?
.xmit_free dd ?
.xmit_top dd ?
}
virtual at 0
UART UART
end virtual
UART_SIZE equ 18*4
struc CONNECTION
{
.magic dd ? ;'CNCT'
.destroy dd ? ;internal destructor
.fd dd ? ;next object in list
.bk dd ? ;prev object in list
.pid dd ? ;owner id
.id dd ? ;reserved
.uart dd ? ;uart pointer
}
virtual at 0
CONNECTION CONNECTION
end virtual
CONNECTION_SIZE equ 7*4
public START
public service_proc
public version
section '.flat' code readable align 16
proc START stdcall, state:dword
cmp [state], 1
jne .stop
mov eax, UART_SIZE
call Kmalloc
test eax, eax
jz .fail
mov [com1], eax
mov edi, eax
mov ecx, UART_SIZE/4
xor eax, eax
cld
rep stosd
mov eax, [com1]
mov [eax+UART.base], COM_1_BASE
stdcall AllocKernelSpace, 32768
mov edi, [com1]
mov edx, eax
mov [edi+UART.rcvr_buff], eax
add eax, 8192
mov [edi+UART.rcvr_top], eax
add eax, 8192
mov [edi+UART.xmit_buff], eax
add eax, 8192
mov [edi+UART.xmit_top], eax
call AllocPage
test eax, eax
jz .fail
shr edx, 12
or eax, PG_SW
mov [page_tabs+edx*4], eax
mov [page_tabs+edx*4+8], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+4], eax
mov [page_tabs+edx*4+12], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+16], eax
mov [page_tabs+edx*4+24], eax
call AllocPage
test eax, eax
jz .fail
or eax, PG_SW
mov [page_tabs+edx*4+20], eax
mov [page_tabs+edx*4+28], eax
mov eax, [edi+UART.rcvr_buff]
invlpg [eax]
invlpg [eax+0x1000]
invlpg [eax+0x2000]
invlpg [eax+0x3000]
invlpg [eax+0x4000]
invlpg [eax+0x5000]
invlpg [eax+0x6000]
invlpg [eax+0x7000]
mov eax, edi
call uart_reset.internal ;eax= uart
stdcall AttachIntHandler, COM_1_IRQ, com_1_isr, dword 0
stdcall RegService, sz_uart_srv, service_proc
ret
.fail:
.stop:
xor eax, eax
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
SRV_GETVERSION equ 0
PORT_OPEN equ 1
PORT_CLOSE equ 2
PORT_RESET equ 3
PORT_SETMODE equ 4
PORT_GETMODE equ 5
PORT_SETMCR equ 6
PORT_GETMCR equ 7
PORT_READ equ 8
PORT_WRITE equ 9
align 4
proc service_proc stdcall, ioctl:dword
mov ebx, [ioctl]
mov eax, [ebx+io_code]
cmp eax, PORT_WRITE
ja .fail
cmp eax, SRV_GETVERSION
jne @F
mov eax, [ebx+output]
cmp [ebx+out_size], 4
jne .fail
mov [eax], dword UART_VERSION
xor eax, eax
ret
@@:
cmp eax, PORT_OPEN
jne @F
cmp [ebx+out_size], 4
jne .fail
mov ebx, [ebx+input]
mov eax, [ebx]
call uart_open
mov ebx, [ioctl]
mov ebx, [ebx+output]
mov [ebx], ecx
ret
@@:
mov esi, [ebx+input] ;input buffer
mov edi, [ebx+output]
call [uart_func+eax*4]
ret
.fail:
or eax, -1
ret
endp
restore handle
restore io_code
restore input
restore inp_size
restore output
restore out_size
; param
; esi= input buffer
; +0 connection
;
; retval
; eax= error code
align 4
uart_reset:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
; set mode 2400 bod 8-bit
; disable DTR & RTS
; clear FIFO
; clear pending interrupts
;
; param
; eax= uart
align 4
.internal:
mov esi, eax
mov [eax+UART.state], UART_CLOSED
mov edx, [eax+UART.base]
add edx, MCR_REG
xor eax, eax
out dx, al ;clear DTR & RTS
mov eax, esi
mov ebx, RATE_2400
mov ecx, LCR_8BIT+LCR_STOP_1
call uart_set_mode.internal
mov edx, [esi+UART.base]
add edx, IIR_REG
mov eax, FCR_EFIFO+FCR_CRB+FCR_CXMIT+FCR_FIFO_14
out dx, al
.clear_RB:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
test eax, LSR_DR
jz @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_RB
@@:
mov edx, [esi+UART.base]
add edx, IER_REG
mov eax, IER_RDAI+IER_THRI+IER_LSI
out dx, al
.clear_IIR:
mov edx, [esi+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
jnz @F
mov edx, [esi+UART.base]
add edx, MSR_REG
in al, dx
jmp .clear_IIR
@@:
cmp eax, 1
je .clear_IIR
cmp eax, 2
jne @F
mov edx, [esi+UART.base]
in al, dx
jmp .clear_IIR
@@:
mov edx, [esi+UART.base]
add edx, LSR_REG
in al, dx
jmp .clear_IIR
.done:
mov edi, [esi+UART.rcvr_buff]
mov ecx, 8192/4
xor eax, eax
mov [esi+UART.rcvr_rp], edi
mov [esi+UART.rcvr_wp], edi
mov [esi+UART.rcvr_count], eax
cld
rep stosd
mov edi, [esi+UART.xmit_buff]
mov ecx, 8192/4
mov [esi+UART.xmit_rp], edi
mov [esi+UART.xmit_wp], edi
mov [esi+UART.xmit_count], eax
mov [esi+UART.xmit_free], 8192
rep stosd
ret ;eax= 0
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 rate
; +8 mode
;
; retval
; eax= error code
align 4
uart_set_mode:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov ecx, [esi+8]
; param
; eax= uart
; ebx= baud rate
; ecx= mode
align 4
.internal:
cmp ebx, RATE_115200
ja .fail
cmp ecx, LCR_BREAK
jae .fail
mov [eax+UART.rate], ebx
mov [eax+UART.mode], ecx
mov esi, eax
mov bx, [divisor+ebx*2]
mov edx, [esi+UART.base]
push edx
add edx, LCR_REG
in al, dx
or al, 0x80
out dx, al
pop edx
mov al, bl
out dx, al
inc dx
mov al, bh
out dx, al
add edx, LCR_REG-1
mov eax, ecx
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 modem control reg valie
;
; retval
; eax= error code
align 4
uart_set_mcr:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov [eax+UART.mcr_reg], ebx
mov edx, [eax+UART.base]
add edx, MCR_REG
mov al, bl
out dx, al
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= port
;
; retval
; ecx= connection
; eax= error code
align 4
uart_open:
dec eax
cmp eax, COM_MAX
jae .fail
mov esi, [com1+eax*4] ;uart
push esi
.do_wait:
cmp dword [esi+UART.lock], 0
je .get_lock
; call change_task
jmp .do_wait
.get_lock:
mov eax, 1
xchg eax, [esi+UART.lock]
test eax, eax
jnz .do_wait
mov eax, esi ;uart
call uart_reset.internal
mov ebx, [CURRENT_TASK]
shl ebx, 5
mov ebx, [CURRENT_TASK+ebx+4]
mov eax, CONNECTION_SIZE
call CreateObject
pop esi ;uart
test eax, eax
jz .fail
mov [eax+APPOBJ.magic], 'CNCT'
mov [eax+APPOBJ.destroy], uart_close.destroy
mov [eax+CONNECTION.uart], esi
mov ecx, eax
xor eax, eax
ret
.fail:
or eax, -1
ret
restore .uart
; param
; esi= input buffer
align 4
uart_close:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
.destroy:
push [eax+CONNECTION.uart]
call DestroyObject ;eax= object
pop eax ;eax= uart
test eax, eax
jz .fail
mov [eax+UART.state], UART_CLOSED
mov [eax+UART.lock], 0;release port
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; eax= uart
; ebx= baud rate
align 4
set_rate:
cmp ebx, RATE_115200
ja .fail
mov [eax+UART.rate], ebx
mov bx, [divisor+ebx*2]
mov edx, [eax+UART.base]
add edx, LCR_REG
in al, dx
push eax
or al, 0x80
out dx, al
sub edx, LCR_REG
mov al, bl
out dx, al
inc edx
mov al, bh
out dx, al
pop eax
add edx, LCR_REG-1
out dx, al
.fail:
ret
; param
; ebx= uart
align 4
transmit:
push esi
push edi
mov edx, [ebx+UART.base]
pushfd
cli
mov esi, [ebx+UART.xmit_rp]
mov ecx, [ebx+UART.xmit_count]
test ecx, ecx
je .stop
cmp ecx, 16
jbe @F
mov ecx, 16
@@:
sub [ebx+UART.xmit_count], ecx
add [ebx+UART.xmit_free], ecx
cld
@@:
lodsb
out dx, al
dec ecx
jnz @B
cmp esi, [ebx+UART.xmit_top]
jb @F
sub esi, 8192
@@:
mov [ebx+UART.xmit_rp], esi
cmp [ebx+UART.xmit_count], 0
je .stop
mov [ebx+UART.state], UART_TRANSMIT
jmp @F
.stop:
mov [ebx+UART.state], UART_STOP
@@:
popfd
pop edi
pop esi
ret
; param
; esi= input buffer
; +0 connection
; +4 dst buffer
; +8 dst size
; edi= output buffer
; +0 bytes read
; retval
; eax= error code
align 4
uart_read:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+8] ;dst size
mov ecx, [eax+UART.rcvr_count]
cmp ecx, ebx
jbe @F
mov ecx, ebx
@@:
mov [edi], ecx ;bytes read
test ecx, ecx
jz .done
push ecx
mov edi, [esi+4] ;dst
mov esi, [eax+UART.rcvr_rp]
cld
rep movsb
pop ecx
cmp esi, [eax+UART.rcvr_top]
jb @F
sub esi, 8192
@@:
mov [eax+UART.rcvr_rp], esi
sub [eax+UART.rcvr_count], ecx
.done:
xor eax, eax
ret
.fail:
or eax, -1
ret
; param
; esi= input buffer
; +0 connection
; +4 src buffer
; +8 src size
;
; retval
; eax= error code
align 4
uart_write:
mov eax, [esi]
cmp [eax+APPOBJ.magic], 'CNCT'
jne .fail
cmp [eax+APPOBJ.destroy], uart_close.destroy
jne .fail
mov eax, [eax+CONNECTION.uart]
test eax, eax
jz .fail
mov ebx, [esi+4]
mov edx, [esi+8]
; param
; eax= uart
; ebx= src
; edx= count
align 4
.internal:
mov esi, ebx
mov edi, [eax+UART.xmit_wp]
.write:
test edx, edx
jz .fail
.wait:
cmp [eax+UART.xmit_free], 0
jne .fill
cmp [eax+UART.state], UART_TRANSMIT
je .wait
mov ebx, eax
push edx
call transmit
pop edx
mov eax, ebx
jmp .write
.fill:
mov ecx, [eax+UART.xmit_free]
cmp ecx, edx
jbe @F
mov ecx, edx
@@:
push ecx
cld
rep movsb
pop ecx
sub [eax+UART.xmit_free], ecx
add [eax+UART.xmit_count], ecx
sub edx, ecx
jnz .wait
.done:
cmp edi, [eax+UART.xmit_top]
jb @F
sub edi, 8192
@@:
mov [eax+UART.xmit_wp], edi
cmp [eax+UART.state], UART_TRANSMIT
je @F
mov ebx, eax
call transmit
@@:
xor eax, eax
ret
.fail:
or eax, -1
ret
align 4
com_2_isr:
mov ebx, [com2]
jmp com_1_isr.get_info
align 4
com_1_isr:
mov ebx, [com1]
.get_info:
mov edx, [ebx+UART.base]
add edx, IIR_REG
in al, dx
test al, IIR_INTR
jnz .done
shr eax, 1
and eax, 3
call [isr_action+eax*4]
jmp .get_info
.done:
ret
align 4
isr_line:
mov edx, [ebx+UART.base]
add edx, LSR_REG
in al, dx
ret
align 4
isr_recieve:
mov esi, [ebx+UART.base]
add esi, LSR_REG
mov edi, [ebx+UART.rcvr_wp]
xor ecx, ecx
cld
.read:
mov edx, esi
in al, dx
test eax, LSR_DR
jz .done
mov edx, [ebx+UART.base]
in al, dx
stosb
inc ecx
jmp .read
.done:
cmp edi, [ebx+UART.rcvr_top]
jb @F
sub edi, 8192
@@:
mov [ebx+UART.rcvr_wp], edi
add [ebx+UART.rcvr_count], ecx
ret
align 4
isr_modem:
mov edx, [ebx+UART.base]
add edx, MSR_REG
in al, dx
ret
align 4
divisor dw 2304, 1536, 1047, 857, 768, 384
dw 192, 96, 64, 58, 48, 32
dw 24, 16, 12, 6, 3, 2, 1
align 4
uart_func dd 0 ;SRV_GETVERSION
dd 0 ;PORT_OPEN
dd uart_close ;PORT_CLOSE
dd uart_reset ;PORT_RESET
dd uart_set_mode ;PORT_SETMODE
dd 0 ;PORT_GETMODE
dd uart_set_mcr ;PORT_SETMODEM
dd 0 ;PORT_GETMODEM
dd uart_read ;PORT_READ
dd uart_write ;PORT_WRITE
isr_action dd isr_modem
dd transmit
dd isr_recieve
dd isr_line
version dd (5 shl 16) or (UART_VERSION and 0xFFFF)
sz_uart_srv db 'UART',0
align 4
com1 rd 1
com2 rd 1

View File

@ -1,475 +0,0 @@
; HID keyboard driver, part of USBHID driver.
; Global constants.
; They are assembled in a macro to separate code and data;
; the code is located at the point of "include 'keyboard.inc'",
; the data are collected when workers_globals is instantiated.
macro workers_globals
{
; include global constants from previous workers
workers_globals
align 4
; Callbacks for HID layer.
keyboard_driver:
dd keyboard_driver_add_device
dd keyboard_driver_disconnect
dd keyboard_driver_begin_packet
dd keyboard_driver_array_overflow?
dd keyboard_driver_input_field
dd keyboard_driver_end_packet
; Callbacks for keyboard layer.
kbd_functions:
dd 12
dd CloseKeyboard
dd SetKeyboardLights
; Kernel keyboard layer takes input in form of PS/2 scancodes.
; data for keyboard: correspondence between HID usage keys and PS/2 scancodes.
EX = 80h ; if set, precede the scancode with special scancode 0xE0
label control_keys byte
; Usages 700E0h ... 700E7h: LCtrl, LShift, LAlt, LWin, RCtrl, RShift, RAlt, RWin
db 1Dh, 2Ah, 38h, 5Bh+EX, 1Dh+EX, 36h, 38h+EX, 5Ch+EX
; Usages 70004h ... 70004h + normal_keys_number - 1
label normal_keys byte
db 1Eh, 30h, 2Eh, 20h, 12h, 21h, 22h, 23h, 17h, 24h, 25h, 26h, 32h, 31h, 18h, 19h
db 10h, 13h, 1Fh, 14h, 16h, 2Fh, 11h, 2Dh, 15h, 2Ch, 02h, 03h, 04h, 05h, 06h, 07h
db 08h, 09h, 0Ah, 0Bh, 1Ch, 01h, 0Eh, 0Fh, 39h, 0Ch, 0Dh, 1Ah, 1Bh, 2Bh, 0, 27h
db 28h, 29h, 33h, 34h, 35h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h, 41h, 42h, 43h, 44h
db 57h, 58h,37h+EX,46h,0,52h+EX,47h+EX,49h+EX,53h+EX,4Fh+EX,51h+EX,4Dh+EX,4Bh+EX,50h+EX,48h+EX,45h
db 35h+EX,37h,4Ah,4Eh,1Ch+EX,4Fh,50h, 51h, 4Bh, 4Ch, 4Dh, 47h, 48h, 49h, 52h, 53h
db 0,5Dh+EX,5Eh+EX
normal_keys_number = $ - normal_keys
}
; Data that are specific for one keyboard device.
struct keyboard_device_data
handle dd ? ; keyboard handle from RegKeyboard
timer dd ? ; auto-repeat timer handle
repeatkey db ? ; auto-repeat key code
rb 3 ; padding
usbdev dd ? ; pointer to device_data of USB and HID layers
modifiers dd ? ; state of LCtrl ... RWin
led_report dd ? ; output report for LEDs state
numlock_bit dd ? ; position of NumLock bit in LED output report
capslock_bit dd ?
scrolllock_bit dd ? ; guess what
ends
; This procedure is called when HID layer detects a new keyboard.
; in: ebx -> usb_device_data, edi -> collection
; out: eax = device-specific data or NULL on error
proc keyboard_driver_add_device
; 1. Allocate memory for keyboard_device_data. If failed, return NULL.
movi eax, sizeof.keyboard_device_data
call Kmalloc
test eax, eax
jz .nothing
; 2. Initialize keyboard_device_data: store pointer to USB layer data,
; zero some fields, initialize bit positions to -1.
mov [eax+keyboard_device_data.usbdev], ebx
xor ecx, ecx
mov [eax+keyboard_device_data.timer], ecx
mov [eax+keyboard_device_data.repeatkey], cl
mov [eax+keyboard_device_data.modifiers], ecx
mov [eax+keyboard_device_data.led_report], ecx
dec ecx
mov [eax+keyboard_device_data.numlock_bit], ecx
mov [eax+keyboard_device_data.capslock_bit], ecx
mov [eax+keyboard_device_data.scrolllock_bit], ecx
; 3. Look for LED report and bits corresponding to indicators.
; For now, assume that all LEDs are set by the same report.
; 3a. Save registers.
push ebx esi
; 3b. Prepare for loop over output reports: get the first output report.
; If there are no output records, skip step 3;
; default values of led_report and *_bit were set in step 2.
mov edx, [edi+collection.output.first_report]
test edx, edx
jz .led_report_set
.scan_led_report:
; Process one output report.
; 3c. Prepare for loop over field groups in the current report:
; get the first field group.
mov ecx, [edx+report.first_field]
.scan_led_field:
; Process one field group.
; 3d. If there are no more field groups, exit the loop over field groups.
test ecx, ecx
jz .next_led_report
; For now, assume that all LEDs are plain variable fields, not arrays.
; 3e. Ignore array field groups.
test byte [ecx+report_field_group.flags], HID_FIELD_VARIABLE
jz .next_led_field
; 3f. Loop over all fields in the current group.
push [ecx+report_field_group.count]
; esi = pointer to usage of the current field
lea esi, [ecx+report_field_group.common_sizeof]
; ebx = bit position of the current field
mov ebx, [ecx+report_field_group.offset]
; if report is numbered, add extra byte in the start of report
cmp [edx+report.id], 0
jz .scan_led_usage
add ebx, 8
.scan_led_usage:
; for USAGE_LED_*LOCK, store the current bit position in the corresponding field
; and store the current report as the LED report
cmp dword [esi], USAGE_LED_NUMLOCK
jz .numlock
cmp dword [esi], USAGE_LED_CAPSLOCK
jz .capslock
cmp dword [esi], USAGE_LED_SCROLLLOCK
jnz .next_field
.scrolllock:
mov [eax+keyboard_device_data.scrolllock_bit], ebx
jmp @f
.capslock:
mov [eax+keyboard_device_data.capslock_bit], ebx
jmp @f
.numlock:
mov [eax+keyboard_device_data.numlock_bit], ebx
@@:
mov [eax+keyboard_device_data.led_report], edx
.next_field:
add esi, 4
add ebx, [ecx+report_field_group.size]
dec dword [esp]
jnz .scan_led_usage
pop ebx
.next_led_field:
; 3g. Continue loop over field groups: get next field group.
mov ecx, [ecx+report_field_group.next]
jmp .scan_led_field
.next_led_report:
; 3h. If the LED report has been set, break from the loop over reports.
; Otherwise, get the next report and continue if the current report is not
; the last for this collection.
cmp [eax+keyboard_device_data.led_report], 0
jnz .led_report_set
cmp edx, [edi+collection.output.last_report]
mov edx, [edx+report.next]
jnz .scan_led_report
.led_report_set:
; 3i. Restore registers.
pop esi ebx
; 4. Register keyboard in the kernel.
; store pointer to keyboard_device_data in the stack
push eax
; call kernel API
stdcall RegKeyboard, kbd_functions, eax
; restore pointer to keyboard_device_data from the stack,
; putting keyboard handle from API to the stack
xchg eax, [esp]
; put keyboard handle from API from the stack to keyboard_device_data field
pop [eax+keyboard_device_data.handle]
; If failed, free keyboard_device_data and return NULL.
cmp [eax+keyboard_device_data.handle], 0
jz .fail_free
; 5. Return pointer to keyboard_device_data.
.nothing:
ret
.fail_free:
call Kfree
xor eax, eax
ret
endp
; This procedure is called when HID layer detects disconnect of a previously
; connected keyboard.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
proc keyboard_driver_disconnect
; 1. If an autorepeat timer is active, stop it.
cmp [edi+keyboard_device_data.timer], 0
jz @f
stdcall CancelTimerHS, [edi+keyboard_device_data.timer]
@@:
; 2. Unregister keyboard in the kernel.
stdcall DelKeyboard, [edi+keyboard_device_data.handle]
; We should free data in CloseKeyboard, not here.
ret
endp
; This procedure is called when HID layer starts processing a new input packet
; from a keyboard.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
proc keyboard_driver_begin_packet
; Nothing to do.
ret
endp
; This procedure is called when HID layer processes every non-empty array field group.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
; in: ecx = fields count (always nonzero), edx = pointer to fields values
; in: esi -> report_field_group
; out: CF set => group is ok, CF cleared => group should be ignored
proc keyboard_driver_array_overflow?
; The keyboard signals array overflow by filling the entire array with
; USAGE_KBD_ROLLOVER codes.
mov eax, [edx] ; eax = first field in the array
sub eax, USAGE_KBD_ROLLOVER ; eax = 0 if overflow, nonzero otherwise
neg eax ; CF cleared if eax was zero, CF set if eax was nonzero
ret
endp
; This procedure is called from HID layer for every field.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
; in: ecx = field usage, edx = value, esi -> report_field_group
proc keyboard_driver_input_field
if HID_DUMP_UNCLAIMED
.unclaimed = default_driver_input_field
end if
; 1. Process normal keys:
; from USAGE_KBD_FIRST_KEY to USAGE_KBD_FIRST_KEY + normal_keys_number - 1,
; excluding zeroes in [normal_keys].
; 1a. Test whether usage is in the range.
lea eax, [ecx-USAGE_KBD_FIRST_KEY]
cmp eax, normal_keys_number
jae .not_normal_key
; 1b. If the corresponding entry in [normal_keys] is zero,
; pass this field to the default handler - if HID_DUMP_UNCLAIMED is enabled,
; default handler is default_driver_input_field, otherwise just ignore the field.
cmp [normal_keys + eax], 0
jz .unclaimed
; 1c. Get the scancode.
movzx ecx, [normal_keys + eax]
; 1d. Further actions are slightly different for key press and key release.
; Decide what to do.
test edx, edx
jz .normal_key_released
.normal_key_pressed:
; The key is pressed.
; 1e. Store the last pressed key for autorepeat.
mov [edi+keyboard_device_data.repeatkey], cl
; 1f. Copy bit 7 to CF and send scancode with bit 7 cleared.
btr ecx, 7
call .send_key
; 1g. Stop the previous autorepeat timer, if any.
mov eax, [edi+keyboard_device_data.timer]
test eax, eax
jz @f
stdcall CancelTimerHS, eax
@@:
; 1h. Start the new autorepeat timer with 250 ms initial delay
; and 50 ms subsequent delays.
stdcall TimerHS, 25, 5, autorepeat_timer, edi
mov [edi+keyboard_device_data.timer], eax
if ~HID_DUMP_UNCLAIMED
.unclaimed:
end if
ret
.normal_key_released:
; The key is released.
; 1i. Stop the autorepeat timer if it is autorepeating the released key.
cmp [edi+keyboard_device_data.repeatkey], cl
jnz .no_stop_timer
push ecx
mov [edi+keyboard_device_data.repeatkey], 0
mov eax, [edi+keyboard_device_data.timer]
test eax, eax
jz @f
stdcall CancelTimerHS, eax
mov [edi+keyboard_device_data.timer], 0
@@:
pop ecx
.no_stop_timer:
; 1j. Copy bit 7 to CF and send scancode with bit 7 set.
bts ecx, 7
call .send_key
ret
.not_normal_key:
; 2. USAGE_KBD_NOEVENT is simply a filler for free array fields,
; ignore it.
cmp ecx, USAGE_KBD_NOEVENT
jz .nothing
; 3. Process modifiers: 8 keys starting at USAGE_KBD_LCTRL.
; 3a. Test whether usage is in range.
; If not, we don't know what this field means, so pass it to the default handler.
lea eax, [ecx-USAGE_KBD_LCTRL]
cmp eax, 8
jae .unclaimed
; 3b. Further actions are slightly different for modifier press
; and modifier release. Decide what to do.
test edx, edx
jz .modifier_not_pressed
.modifier_pressed:
; The modifier is pressed.
; 3c. Set the corresponding status bit.
; If it was not set, send the corresponding scancode to the kernel
; with bit 7 cleared.
bts [edi+keyboard_device_data.modifiers], eax
jc @f
movzx ecx, [control_keys+eax]
btr ecx, 7
call .send_key
@@:
.nothing:
ret
.modifier_not_pressed:
; The modifier is not pressed.
; 3d. Clear the correspodning status bit.
; If it was set, send the corresponding scancode to the kernel
; with bit 7 set.
btr [edi+keyboard_device_data.modifiers], eax
jnc @f
movzx ecx, [control_keys+eax]
bts ecx, 7
call .send_key
@@:
ret
; Helper procedure. Sends scancode from cl to the kernel.
; If CF is set, precede it with special code 0xE0.
.send_key:
jnc @f
push ecx
mov ecx, 0xE0
call SetKeyboardData
pop ecx
@@:
call SetKeyboardData
ret
endp
; This procedure is called when HID layer ends processing a new input packet
; from a keyboard.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
proc keyboard_driver_end_packet
; Nothing to do.
ret
endp
; Timer callback for SetTimerHS.
proc autorepeat_timer
virtual at esp
dd ? ; return address
.data dd ?
end virtual
; Just resend the last pressed key.
mov eax, [.data]
movzx ecx, [eax+keyboard_device_data.repeatkey]
; Copy bit 7 to CF and send scancode with bit 7 cleared.
btr ecx, 7
call keyboard_driver_input_field.send_key
ret 4
endp
; This function is called from the keyboard layer
; when it is safe to free keyboard data.
proc CloseKeyboard
virtual at esp
dd ? ; return address
.device_data dd ?
end virtual
mov eax, [.device_data]
call Kfree
ret 4
endp
; This function is called from the keyboard layer
; to update LED state on the keyboard.
proc SetKeyboardLights stdcall uses ebx esi edi, device_data, led_state
locals
size dd ?
endl
; 1. Get the pointer to the LED report.
; If there is no LED report, exit from the function.
mov ebx, [device_data]
mov esi, [ebx+keyboard_device_data.led_report]
test esi, esi
jz .nothing
; 2. Get report size in bytes.
; report.size is size in bits without possible report ID;
; if an ID is assigned, the size is one byte greater.
mov eax, [esi+report.size]
add eax, 7
shr eax, 3
cmp [esi+report.id], 0
jz @f
inc eax
@@:
mov [size], eax
; 3. Allocate memory for report + 8 bytes for setup packet.
; Dword-align size for subsequent rep stosd and bts.
; If failed, exit from the function.
add eax, 8 + 3
and eax, not 3
push eax
call Kmalloc
pop ecx
test eax, eax
jz .nothing
; 4. Zero-initialize output report.
push eax
mov edi, eax
shr ecx, 2
xor eax, eax
rep stosd
pop edi
add edi, 8
; 5. Store report ID, if assigned. If not assigned, that would just write zero
; over zeroes.
mov edx, [esi+report.id]
mov [edi], edx
; 6. Set report bits corresponding to active indicators.
mov eax, [led_state]
test al, 1 ; PS/2 Scroll Lock
jz @f
mov ecx, [ebx+keyboard_device_data.scrolllock_bit]
test ecx, ecx
js @f
bts [edi], ecx
@@:
test al, 2 ; PS/2 Num Lock
jz @f
mov ecx, [ebx+keyboard_device_data.numlock_bit]
test ecx, ecx
js @f
bts [edi], ecx
@@:
test al, 4 ; PS/2 Caps Lock
jz @f
mov ecx, [ebx+keyboard_device_data.capslock_bit]
test ecx, ecx
js @f
bts [edi], ecx
@@:
; 7. Fill setup packet.
shl edx, 16 ; move Report ID to byte 2
or edx, 21h + \ ; Class-specific request to Interface
(9 shl 8) + \ ; SET_REPORT
(2 shl 24) ; Report Type = Output
lea eax, [edi-8]
mov ebx, [ebx+keyboard_device_data.usbdev]
mov dword [eax], edx
mov edx, [size]
shl edx, 16 ; move Size to last word
or edx, [ebx+usb_device_data.interface_number]
mov [eax+4], edx
; 8. Submit output control request.
stdcall USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
eax, edi, [size], after_set_keyboard_lights, ebx, 0
; If failed, free the buffer now.
; If succeeded, the callback will free the buffer.
test eax, eax
jnz .nothing
lea eax, [edi-8]
call Kfree
.nothing:
ret
endp
; This procedure is called from the USB subsystem when the request initiated by
; SetKeyboardLights is completed, either successfully or unsuccessfully.
proc after_set_keyboard_lights
virtual at esp
dd ? ; return address
.pipe dd ?
.status dd ?
.buffer dd ?
.length dd ?
.calldata dd ?
end virtual
; Ignore status, just free the buffer allocated by SetKeyboardLights.
mov eax, [.buffer]
sub eax, 8
call Kfree
ret 20
endp

View File

@ -1,155 +0,0 @@
; HID mouse driver, part of USBHID driver.
; Global constants.
; They are assembled in a macro to separate code and data;
; the code is located at the point of "include 'mouse.inc'",
; the data are collected when workers_globals is instantiated.
macro workers_globals
{
; include global constants from previous workers
workers_globals
align 4
; Callbacks for HID layer.
mouse_driver:
dd mouse_driver_add_device
dd mouse_driver_disconnect
dd mouse_driver_begin_packet
dd mouse_driver_array_overflow?
dd mouse_driver_input_field
dd mouse_driver_end_packet
}
; Data that are specific for one mouse device.
struct mouse_device_data
buttons dd ? ; buttons that are currently pressed
dx dd ? ; current x moving
dy dd ? ; current y moving
wheel dd ? ; current wheel moving
hwheel dd ?
ends
; This procedure is called when HID layer detects a new mouse.
; in: ebx -> device_data from USB layer, edi -> collection
; out: eax = device-specific data or NULL on error
proc mouse_driver_add_device
; Just allocate memory; no initialization needed.
movi eax, sizeof.mouse_device_data
call Kmalloc
ret
endp
; This procedure is called when HID layer detects disconnect of a previously
; connected mouse.
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
proc mouse_driver_disconnect
; Free the allocated memory.
mov eax, edi
call Kfree
ret
endp
; This procedure is called when HID layer starts processing a new input packet
; from a mouse.
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
proc mouse_driver_begin_packet
; Zero all variables describing the current state.
mov [edi+mouse_device_data.buttons], 0
mov [edi+mouse_device_data.dx], 0
mov [edi+mouse_device_data.dy], 0
mov [edi+mouse_device_data.wheel], 0
mov [edi+mouse_device_data.hwheel], 0
ret
endp
; This procedure is called when HID layer processes every non-empty array field group.
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
; in: ecx = fields count (always nonzero), edx = pointer to fields values
; in: esi -> report_field_group
; out: CF set => array is ok, CF cleared => array should be ignored
proc mouse_driver_array_overflow?
; no array fields, no overflows
stc
ret
endp
; This procedure is called from HID layer for every field.
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
; in: ecx = field usage, edx = value, esi -> report_field_group
proc mouse_driver_input_field
; 1. Determine the handler. We process x/y moving, wheel and up to 32 buttons.
; Pass other fields to the default handler - default_driver_input_field if
; HID_DUMP_UNCLAIMED is enabled, just ignore otherwise.
cmp ecx, USAGE_GD_X
jz .x
cmp ecx, USAGE_GD_Y
jz .y
cmp ecx, USAGE_GD_WHEEL
jz .wheel
cmp ecx, 0xC0238
jz .hwheel
sub ecx, USAGE_BUTTON_PAGE + 1
jb .unclaimed
cmp ecx, 32
jae .unclaimed
; 2. This is a button.
; If a button is pressed, set the corresponding bit in the state.
; If a button is not pressed, do nothing.
test edx, edx
jz @f
bts [edi+mouse_device_data.buttons], ecx
@@:
if ~HID_DUMP_UNCLAIMED
.unclaimed:
end if
ret
if HID_DUMP_UNCLAIMED
.unclaimed:
add ecx, USAGE_BUTTON_PAGE + 1
jmp default_driver_input_field
end if
.x:
; 3. This is x moving. For relative fields, store the value in the state.
; Pass absolute field to the default handler.
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
jz .unclaimed
mov [edi+mouse_device_data.dx], edx
ret
.y:
; 4. This is y moving. For relative fields, store the value in the state,
; changing the sign: HID uses "mathematics" scheme with Y axis increasing from
; bottom to top, the kernel expects "programming" PS/2-style with Y axis
; increasing from top to bottom.
; Pass absolute fields to the default handler.
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
jz .unclaimed
neg edx
mov [edi+mouse_device_data.dy], edx
ret
.wheel:
; 5. This is wheel event. For relative fields, store the value in the state,
; changing the sign. Pass absolute fields to the default handler.
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
jz .unclaimed
neg edx
mov [edi+mouse_device_data.wheel], edx
ret
.hwheel:
test byte [esi+report_field_group.flags], HID_FIELD_RELATIVE
jz .unclaimed
mov [edi+mouse_device_data.hwheel], edx
ret
endp
; This procedure is called when HID layer ends processing a new input packet
; from a mouse.
; in: edi -> mouse_device_data (pointer returned from mouse_driver_add_device)
proc mouse_driver_end_packet
; Call the kernel, passing collected state.
stdcall SetMouseData, \
[edi+mouse_device_data.buttons], \
[edi+mouse_device_data.dx], \
[edi+mouse_device_data.dy], \
[edi+mouse_device_data.wheel], \
[edi+mouse_device_data.hwheel]
ret
endp

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +0,0 @@
; Sort array of unsigned dwords in non-decreasing order.
; ecx = array size, edx = array pointer.
; Destroys eax, ecx, esi, edi.
sort:
test ecx, ecx
jz .done
mov eax, ecx
@@:
push eax
call .restore
pop eax
dec eax
jnz @b
@@:
cmp ecx, 1
jz .done
mov esi, 1
mov edi, ecx
call .exchange
dec ecx
mov eax, 1
call .restore
jmp @b
.done:
ret
.exchange:
push eax ecx
mov eax, [edx+esi*4-4]
mov ecx, [edx+edi*4-4]
mov [edx+esi*4-4], ecx
mov [edx+edi*4-4], eax
pop ecx eax
ret
.restore:
lea esi, [eax+eax]
cmp esi, ecx
ja .doner
mov edi, [edx+eax*4-4]
cmp [edx+esi*4-4], edi
ja .need_xchg
cmp esi, ecx
jae .doner
mov edi, [edx+eax*4-4]
cmp [edx+esi*4], edi
jbe .doner
.need_xchg:
cmp esi, ecx
jz .do_xchg
mov edi, [edx+esi*4-4]
cmp [edx+esi*4], edi
sbb esi, -1
.do_xchg:
mov edi, eax
call .exchange
mov eax, esi
jmp .restore
.doner:
ret

View File

@ -1,60 +0,0 @@
; HID default driver, part of USBHID driver.
; Present only if compile-time setting HID_DUMP_UNCLAIMED is on.
; Active for those devices when we do not have a specialized driver.
; Just dumps everything to the debug board.
if HID_DUMP_UNCLAIMED
; Global constants.
; They are assembled in a macro to separate code and data;
; the code is located at the point of "include 'unclaimed.inc'",
; the data are collected when workers_globals is instantiated.
macro workers_globals
{
; include global constants from previous workers
workers_globals
align 4
; Callbacks for HID layer.
default_driver:
dd default_driver_add_device
dd default_driver_disconnect
dd default_driver_begin_packet
dd default_driver_array_overflow?
dd default_driver_input_field
dd default_driver_end_packet
}
; This procedure is called when HID layer detects a new driverless device.
; in: ebx -> usb_device_data, edi -> collection
; out: eax = device-specific data or NULL on error
default_driver_add_device:
; just return something nonzero, no matter what
xor eax, eax
inc eax
ret
; This procedure is called when HID layer processes every non-empty array field group.
; in: edi -> keyboard_device_data (pointer returned from keyboard_driver_add_device)
; in: ecx = fields count (always nonzero), edx = pointer to fields values
; in: esi -> report_field_group
; out: CF set => group is ok, CF cleared => group should be ignored
default_driver_array_overflow?:
; parse everything
stc
ret
; This procedure is called from HID layer for every field.
; in: ecx = field usage, edx = value, esi -> report_field_group
default_driver_input_field:
; Do not dump zero values in Variable fields,
; they are present even if the corresponding control is inactive.
test edx, edx
jnz @f
test byte [esi+report_field_group.flags], HID_FIELD_VARIABLE
jnz .nodump
@@:
DEBUGF 1,'K : unclaimed HID input: usage=%x, value=%x\n',ecx,edx
.nodump:
; pass through
; Three nothing-to-do procedures.
default_driver_disconnect:
default_driver_begin_packet:
default_driver_end_packet:
ret
end if

View File

@ -1,553 +0,0 @@
; standard driver stuff
format MS COFF
DEBUG = 1
; this is for DEBUGF macro from 'fdo.inc'
__DEBUG__ = 1
__DEBUG_LEVEL__ = 1
include '../proc32.inc'
include '../imports.inc'
include '../fdo.inc'
include '../../struct.inc'
public START
public version
; Compile-time settings.
; If set, the code will dump all descriptors as they are read to the debug board.
USB_DUMP_DESCRIPTORS = 1
; If set, the code will dump any unclaimed input to the debug board.
HID_DUMP_UNCLAIMED = 1
; USB constants
DEVICE_DESCR_TYPE = 1
CONFIG_DESCR_TYPE = 2
STRING_DESCR_TYPE = 3
INTERFACE_DESCR_TYPE = 4
ENDPOINT_DESCR_TYPE = 5
DEVICE_QUALIFIER_DESCR_TYPE = 6
CONTROL_PIPE = 0
ISOCHRONOUS_PIPE = 1
BULK_PIPE = 2
INTERRUPT_PIPE = 3
; USB HID constants
HID_DESCR_TYPE = 21h
REPORT_DESCR_TYPE = 22h
PHYSICAL_DESCR_TYPE = 23h
; USB structures
struct config_descr
bLength db ?
bDescriptorType db ?
wTotalLength dw ?
bNumInterfaces db ?
bConfigurationValue db ?
iConfiguration db ?
bmAttributes db ?
bMaxPower db ?
ends
struct interface_descr
bLength db ?
bDescriptorType db ?
bInterfaceNumber db ?
bAlternateSetting db ?
bNumEndpoints db ?
bInterfaceClass db ?
bInterfaceSubClass db ?
bInterfaceProtocol db ?
iInterface db ?
ends
struct endpoint_descr
bLength db ?
bDescriptorType db ?
bEndpointAddress db ?
bmAttributes db ?
wMaxPacketSize dw ?
bInterval db ?
ends
; USB HID structures
struct hid_descr
bLength db ?
bDescriptorType db ?
bcdHID dw ?
bCountryCode db ?
bNumDescriptors db ?
base_sizeof rb 0
; now two fields are repeated .bNumDescriptors times:
subDescriptorType db ?
subDescriptorLength dw ?
ends
; Include macro for parsing report descriptors/data.
macro workers_globals
{}
include 'report.inc'
; Driver data for all devices
struct usb_device_data
hid hid_data ; data of HID layer
epdescr dd ? ; endpoint descriptor
hiddescr dd ? ; HID descriptor
interface_number dd ? ; copy of interface_descr.bInterfaceNumber
configpipe dd ? ; config pipe handle
intpipe dd ? ; interrupt pipe handle
input_transfer_size dd ? ; input transfer size
input_buffer dd ? ; buffer for input transfers
control rb 8 ; control packet to device
ends
section '.flat' code readable align 16
; The start procedure.
proc START
virtual at esp
dd ? ; return address
.reason dd ?
end virtual
; 1. Test whether the procedure is called with the argument DRV_ENTRY.
; If not, return 0.
xor eax, eax ; initialize return value
cmp [.reason], 1 ; compare the argument
jnz .nothing
; 2. Register self as a USB driver.
; The name is my_driver = 'usbhid'; IOCTL interface is not supported;
; usb_functions is an offset of a structure with callback functions.
stdcall RegUSBDriver, my_driver, eax, usb_functions
; 3. Return the returned value of RegUSBDriver.
.nothing:
ret 4
endp
; This procedure is called when new HID device is detected.
; It initializes the device.
proc AddDevice
push ebx esi edi ; save used registers to be stdcall
virtual at esp
rd 3 ; saved registers
dd ? ; return address
.config_pipe dd ?
.config_descr dd ?
.interface dd ?
end virtual
DEBUGF 1,'K : USB HID device detected\n'
; 1. Allocate memory for device data.
movi eax, sizeof.usb_device_data
call Kmalloc
test eax, eax
jnz @f
mov esi, nomemory_msg
call SysMsgBoardStr
jmp .return0
@@:
; zero-initialize it
mov edi, eax
xchg eax, ebx
xor eax, eax
movi ecx, sizeof.usb_device_data / 4
rep stosd
mov edx, [.interface]
; HID devices use one IN interrupt endpoint for polling the device
; and an optional OUT interrupt endpoint. We do not use the later,
; but must locate the first. Look for the IN interrupt endpoint.
; Also, look for the HID descriptor; according to HID spec, it must be
; located before endpoint descriptors.
; 2. Get the upper bound of all descriptors' data.
mov eax, [.config_descr]
movzx ecx, [eax+config_descr.wTotalLength]
add eax, ecx
; 3. Loop over all descriptors until
; either end-of-data reached - this is fail
; or interface descriptor found - this is fail, all further data
; correspond to that interface
; or endpoint descriptor for IN endpoint is found
; (HID descriptor must be located before the endpoint descriptor).
; 3a. Loop start: edx points to the interface descriptor.
.lookep:
; 3b. Get next descriptor.
movzx ecx, byte [edx] ; the first byte of all descriptors is length
test ecx, ecx
jz .cfgerror
add edx, ecx
; 3c. Check that at least two bytes are readable. The opposite is an error.
inc edx
cmp edx, eax
jae .cfgerror
dec edx
; 3d. Check that this descriptor is not interface descriptor. The opposite is
; an error.
cmp [edx+endpoint_descr.bDescriptorType], INTERFACE_DESCR_TYPE
jz .cfgerror
; 3e. For HID descriptor, proceed to 4.
; For endpoint descriptor, go to 5.
; For other descriptors, continue the loop.
; Note: bDescriptorType is in the same place in all descriptors.
cmp [edx+endpoint_descr.bDescriptorType], ENDPOINT_DESCR_TYPE
jz .foundep
cmp [edx+endpoint_descr.bDescriptorType], HID_DESCR_TYPE
jnz .lookep
; 4a. Check that the descriptor contains all required data and all data are
; readable. The opposite is an error.
movzx ecx, [edx+hid_descr.bLength]
cmp ecx, hid_descr.base_sizeof + 3
jb .cfgerror
add ecx, edx
cmp ecx, eax
ja .cfgerror
; 4b. Store the pointer in usb_device_data structure for further references.
mov [ebx+usb_device_data.hiddescr], edx
; 4c. Continue the loop.
jmp .lookep
.foundep:
; 5a. Check that the descriptor contains all required data and all data are
; readable. The opposite is an error.
cmp byte [edx+endpoint_descr.bLength], sizeof.endpoint_descr
jb .cfgerror
lea ecx, [edx+sizeof.endpoint_descr]
cmp ecx, eax
jbe @f
; 6. An error occured during processing endpoint descriptor.
.cfgerror:
; 6a. Print a message.
mov esi, invalid_config_descr_msg
call SysMsgBoardStr
; 6b. Free memory allocated for device data.
.free:
xchg eax, ebx
call Kfree
.return0:
; 6c. Return an error.
xor eax, eax
.nothing:
pop edi esi ebx ; restore used registers to be stdcall
ret 12
@@:
; 5b. If this is not IN interrupt endpoint, ignore it and continue the loop.
test [edx+endpoint_descr.bEndpointAddress], 80h
jz .lookep
mov cl, [edx+endpoint_descr.bmAttributes]
and cl, 3
cmp cl, INTERRUPT_PIPE
jnz .lookep
; 5c. Store the pointer in usb_device_data structure for futher references.
mov [ebx+usb_device_data.epdescr], edx
; 5d. Check that HID descriptor was found. If not, go to 6.
cmp [ebx+usb_device_data.hiddescr], 0
jz .cfgerror
.descriptors_found:
; 6. Configuration descriptor seems to be ok.
; Send SET_IDLE command disabling auto-repeat feature (it is quite useless)
; and continue configuring in SET_IDLE callback.
lea edx, [ebx+usb_device_data.control]
mov eax, [.interface]
mov dword [edx], 21h + \ ; Class-specific request to Interface
(0Ah shl 8) + \ ; SET_IDLE
(0 shl 16) + \ ; apply to all input reports
(0 shl 24) ; disable auto-repeat
movzx eax, [eax+interface_descr.bInterfaceNumber]
mov [ebx+usb_device_data.interface_number], eax
mov [edx+4], eax ; set interface number, zero length
mov eax, [.config_pipe]
mov [ebx+usb_device_data.configpipe], eax
xor ecx, ecx
stdcall USBControlTransferAsync, eax, edx, ecx, ecx, idle_set, ebx, ecx
; 7. Return pointer to usb_device_data.
xchg eax, ebx
jmp .nothing
endp
; This procedure is called by USB stack when SET_IDLE request initiated by
; AddDevice is completed, either successfully or unsuccessfully.
proc idle_set
push ebx esi ; save used registers to be stdcall
virtual at esp
rd 2 ; saved registers
dd ? ; return address
.pipe dd ?
.status dd ?
.buffer dd ?
.length dd ?
.calldata dd ?
end virtual
; Ignore status. Support for SET_IDLE is optional, so the device is free to
; STALL the request; config pipe should remain functional without explicit cleanup.
mov ebx, [.calldata]
; 1. HID descriptor contains length of Report descriptor. Parse it.
mov esi, [ebx+usb_device_data.hiddescr]
movzx ecx, [esi+hid_descr.bNumDescriptors]
lea eax, [hid_descr.base_sizeof+ecx*3]
cmp eax, 100h
jae .cfgerror
cmp al, [esi+hid_descr.bLength]
jb .cfgerror
.look_report:
dec ecx
js .cfgerror
cmp [esi+hid_descr.subDescriptorType], REPORT_DESCR_TYPE
jz .found_report
add esi, 3
jmp .look_report
.cfgerror:
mov esi, invalid_config_descr_msg
.abort_with_msg:
call SysMsgBoardStr
jmp .nothing
.found_report:
; 2. Send request for the Report descriptor.
; 2a. Allocate memory.
movzx eax, [esi+hid_descr.subDescriptorLength]
test eax, eax
jz .cfgerror
push eax
call Kmalloc
pop ecx
; If failed, say a message and stop initialization.
mov esi, nomemory_msg
test eax, eax
jz .abort_with_msg
; 2b. Submit the request.
xchg eax, esi
lea edx, [ebx+usb_device_data.control]
mov eax, [ebx+usb_device_data.interface_number]
mov dword [edx], 81h + \ ; Standard request to Interface
(6 shl 8) + \ ; GET_DESCRIPTOR
(0 shl 16) + \ ; descriptor index: there is only one report descriptor
(REPORT_DESCR_TYPE shl 24); descriptor type
mov [edx+4], ax ; Interface number
mov [edx+6], cx ; descriptor length
stdcall USBControlTransferAsync, [ebx+usb_device_data.configpipe], \
edx, esi, ecx, got_report, ebx, 0
; 2c. If failed, free the buffer and stop initialization.
test eax, eax
jnz .nothing
xchg eax, esi
call Kfree
.nothing:
pop esi ebx ; restore used registers to be stdcall
ret 20
endp
; This procedure is called by USB stack when the report descriptor queried
; by idle_set is completed, either successfully or unsuccessfully.
proc got_report stdcall uses ebx esi edi, pipe, status, buffer, length, calldata
locals
parse_descr_locals
if ~HID_DUMP_UNCLAIMED
has_driver db ?
rb 3
end if
endl
; 1. Check the status; if the request has failed, say something to the debug board
; and stop initialization.
cmp [status], 0
jnz .generic_fail
; 2. Subtract size of setup packet from the total length;
; the rest is length of the descriptor, and it must be nonzero.
sub [length], 8
ja .has_something
.generic_fail:
push esi
mov esi, reportfail
call SysMsgBoardStr
pop esi
jmp .exit
.has_something:
; 3. Process descriptor.
; 3a. Dump it to the debug board, if enabled in compile-time setting.
if USB_DUMP_DESCRIPTORS
mov eax, [buffer]
mov ecx, [length]
DEBUGF 1,'K : report descriptor:'
@@:
DEBUGF 1,' %x',[eax]:2
inc eax
dec ecx
jnz @b
DEBUGF 1,'\n'
end if
; 3b. Call the HID layer.
parse_descr
cmp [report_ok], 0
jz got_report.exit
mov ebx, [calldata]
postprocess_descr
; 4. Stop initialization if no driver is assigned.
if ~HID_DUMP_UNCLAIMED
cmp [has_driver], 0
jz got_report.exit
end if
; 5. Open interrupt IN pipe. If failed, stop initialization.
mov edx, [ebx+usb_device_data.epdescr]
movzx ecx, [edx+endpoint_descr.bEndpointAddress]
movzx eax, [edx+endpoint_descr.bInterval]
movzx edx, [edx+endpoint_descr.wMaxPacketSize]
stdcall USBOpenPipe, [ebx+usb_device_data.configpipe], ecx, edx, INTERRUPT_PIPE, eax
test eax, eax
jz got_report.exit
mov [ebx+usb_device_data.intpipe], eax
; 6. Initialize buffer for input packet.
; 6a. Find the length of input packet.
; This is the maximal length of all input reports.
mov edx, [ebx+usb_device_data.hid.input.first_report]
xor eax, eax
.find_input_size:
test edx, edx
jz .found_input_size
cmp eax, [edx+report.size]
jae @f
mov eax, [edx+report.size]
@@:
mov edx, [edx+report.next]
jmp .find_input_size
.found_input_size:
; report.size is in bits, transform it to bytes
add eax, 7
shr eax, 3
; if reports are numbered, the first byte is report ID, include it
cmp [ebx+usb_device_data.hid.input.numbered], 0
jz @f
inc eax
@@:
mov [ebx+usb_device_data.input_transfer_size], eax
; 6b. Allocate memory for input packet: dword-align and add additional dword
; for extract_field_value.
add eax, 4+3
and eax, not 3
call Kmalloc
test eax, eax
jnz @f
mov esi, nomemory_msg
call SysMsgBoardStr
jmp got_report.exit
@@:
mov [ebx+usb_device_data.input_buffer], eax
; 7. Submit a request for input packet and wait for input.
call ask_for_input
got_report.exit:
mov eax, [buffer]
call Kfree
ret
endp
; Helper procedure for got_report and got_input.
; Submits a request for the next input packet.
proc ask_for_input
; just call USBNormalTransferAsync with correct parameters,
; allow short packets
stdcall USBNormalTransferAsync, \
[ebx+usb_device_data.intpipe], \
[ebx+usb_device_data.input_buffer], \
[ebx+usb_device_data.input_transfer_size], \
got_input, ebx, \
1
ret
endp
; This procedure is called by USB stack when a HID device responds with input
; data packet.
proc got_input stdcall uses ebx esi edi, pipe, status, buffer, length, calldata
locals
parse_input_locals
endl
; 1. Validate parameters: fail on error, ignore zero-length transfers.
mov ebx, [calldata]
cmp [status], 0
jnz .fail
cmp [length], 0
jz .done
; 2. Get pointer to report in esi.
; 2a. If there are no report IDs, use hid.input.data.
mov eax, [buffer]
mov esi, [ebx+usb_device_data.hid.input.data]
cmp [ebx+usb_device_data.hid.input.numbered], 0
jz .report_found
; 2b. Otherwise, the first byte of report is report ID;
; locate the report by its ID, advance buffer+length to one byte.
movzx eax, byte [eax]
mov esi, [esi+eax*4]
inc [buffer]
dec [length]
.report_found:
; 3. Validate: ignore transfers with unregistered report IDs
; and transfers which are too short for the corresponding report.
test esi, esi
jz .done
mov eax, [esi+report.size]
add eax, 7
shr eax, 3
cmp eax, [length]
ja .done
; 4. Pass everything to HID layer.
parse_input
.done:
; 5. Query the next input.
mov ebx, [calldata]
call ask_for_input
.nothing:
ret
.fail:
mov esi, transfer_error_msg
call SysMsgBoardStr
jmp .nothing
endp
; This function is called by the USB subsystem when a device is disconnected.
proc DeviceDisconnected
push ebx esi edi ; save used registers to be stdcall
virtual at esp
rd 3 ; saved registers
dd ? ; return address
.device_data dd ?
end virtual
; 1. Say a message.
mov ebx, [.device_data]
mov esi, disconnectmsg
stdcall SysMsgBoardStr
; 2. Ask HID layer to release all HID-related resources.
hid_cleanup
; 3. Free the device data.
xchg eax, ebx
call Kfree
; 4. Return.
.nothing:
pop edi esi ebx ; restore used registers to be stdcall
ret 4 ; purge one dword argument to be stdcall
endp
include 'sort.inc'
include 'unclaimed.inc'
include 'mouse.inc'
include 'keyboard.inc'
; strings
my_driver db 'usbhid',0
nomemory_msg db 'K : no memory',13,10,0
invalid_config_descr_msg db 'K : invalid config descriptor',13,10,0
reportfail db 'K : failed to read report descriptor',13,10,0
transfer_error_msg db 'K : USB transfer error, disabling HID device',13,10,0
disconnectmsg db 'K : USB HID device disconnected',13,10,0
invalid_report_msg db 'K : report descriptor is invalid',13,10,0
delimiter_note db 'K : note: alternate usage ignored',13,10,0
; Exported variable: kernel API version.
align 4
version dd 50005h
; Structure with callback functions.
usb_functions:
dd 12
dd AddDevice
dd DeviceDisconnected
; for DEBUGF macro
include_debug_strings
; Workers data
workers_globals
; for uninitialized data
;section '.data' data readable writable align 16

File diff suppressed because it is too large Load Diff

View File

@ -1,465 +0,0 @@
; Stub of videodriver for Intel videocards.
; (c) CleverMouse
; When the start procedure gots control,
; it tries to detect preferred resolution,
; sets the detected resolution assuming 32-bpp VESA mode and exits
; (without registering a service).
; Detection can be overloaded with compile-time settings
; use_predefined_mode/predefined_width/predefined_height.
; set predefined resolution here
use_predefined_mode = 0;1
predefined_width = 0;1366
predefined_height = 0;768
; standard driver stuff
format MS COFF
DEBUG = 1
include 'proc32.inc'
include 'imports.inc'
public START
public version
section '.flat' code readable align 16
; the start procedure (see the description above)
START:
; 1. Detect device. Abort if not found.
push esi
call DetectDevice
test esi, esi
jz .return0
; 2. Detect optimal mode unless the mode is given explicitly. Abort if failed.
if use_predefined_mode = 0
call DetectMode
end if
cmp [width], 0
jz .return0_cleanup
; 3. Set the detected mode.
call SetMode
; 4. Cleanup and return.
.return0_cleanup:
stdcall FreeKernelSpace, esi
.return0:
pop esi
xor eax, eax
ret 4
; check that there is Intel videocard
; if so, map MMIO registers and set internal variables
; esi points to MMIO block; NULL means no device
DetectDevice:
; 1. Sanity check: check that we are dealing with Intel videocard.
; Integrated video device for Intel is always at PCI:0:2:0.
xor esi, esi ; initialize return value to NULL
; 1a. Get PCI VendorID and DeviceID.
push esi
push 10h
push esi
call PciRead32
; 1b. loword(eax) = ax = VendorID, hiword(eax) = DeviceID.
; Test whether we have Intel chipset.
cmp ax, 8086h
jnz .return
; 1c. Say hi including DeviceID.
shr eax, 10h
push edi
pusha
mov edi, pciid_text
call WriteWord
mov esi, hellomsg
call SysMsgBoardStr
popa
; 1d. Test whether we know this DeviceID.
; If this is the case, remember the position of the device in line of Intel cards;
; this knowledge will be useful later.
; Tested on devices with id: 8086:0046, partially 8086:2A02.
mov ecx, pciids_num
mov edi, pciids
repnz scasw
pop edi
jnz .return_unknown_pciid
sub ecx, pciids_num - 1
neg ecx
mov [deviceType], ecx
; 1e. Continue saying hi with positive intonation.
pusha
mov esi, knownmsg
call SysMsgBoardStr
popa
; 2. Prepare MMIO region to control the card.
; 2a. Read MMIO physical address from PCI config space.
push 10h
cmp ecx, i9xx_start
jae @f
mov byte [esp], 14h
@@:
push 10h
push esi
call PciRead32
; 2b. Mask out PCI region type, lower 4 bits.
and al, not 0xF
; 2c. Create virtual mapping of the physical memory.
push 1Bh
push 100000h
push eax
call MapIoMem
; 3. Return.
xchg esi, eax
.return:
ret
; 1f. If we do not know DeviceID, continue saying hi with negative intonation.
.return_unknown_pciid:
pusha
mov esi, unknownmsg
call SysMsgBoardStr
popa
ret
; Convert word in ax to hexadecimal text in edi, advance edi.
WriteWord:
; 1. Convert high byte.
push eax
mov al, ah
call WriteByte
pop eax
; 2. Convert low byte.
; Fall through to WriteByte; ret from WriteByte is ret from WriteWord too.
; Convert byte in al to hexadecimal text in edi, advance edi.
WriteByte:
; 1. Convert high nibble.
push eax
shr al, 4
call WriteNibble
pop eax
; 2. Convert low nibble.
and al, 0xF
; Fall through to WriteNibble; ret from WriteNibble is ret from WriteByte too.
; Convert nibble in al to hexadecimal text in edi, advance edi.
WriteNibble:
; Obvious, isn't it?
cmp al, 10
sbb al, 69h
das
stosb
ret
if use_predefined_mode = 0
; detect resolution of the flat panel
DetectMode:
push esi edi
; 1. Get the location of block of GMBUS* registers.
; Starting with Ironlake, GMBUS* registers were moved.
add esi, 5100h
cmp [deviceType], ironlake_start
jb @f
add esi, 0xC0000
@@:
; 2. Initialize GMBUS engine.
mov edi, edid
mov ecx, 0x10000
@@:
test byte [esi+8+1], 80h
loopnz @b
jnz .fail
mov dword [esi], 3
test byte [esi+8+1], 4
jz .noreset
call ResetGMBus
jnz .fail
.noreset:
; 3. Send read command.
and dword [esi+20h], 0
mov dword [esi+4], 4E8000A1h
; 4. Wait for data, writing to the buffer as data arrive.
.getdata:
mov ecx, 0x10000
@@:
test byte [esi+8+1], 8
loopz @b
test byte [esi+8+1], 4
jz .dataok
call ResetGMBus
jmp .fail
.dataok:
mov eax, [esi+0Ch]
stosd
cmp edi, edid+80h
jb .getdata
; 5. Wait for bus idle.
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
; 6. We got EDID; dump it if DEBUG.
if DEBUG
pusha
xor ecx, ecx
mov esi, edid
mov edi, edid_text
.dumploop:
lodsb
call WriteByte
mov al, ' '
stosb
inc cl
test cl, 15
jnz @f
mov byte [edi-1], 13
mov al, 10
stosb
@@:
test cl, cl
jns .dumploop
mov esi, edidmsg
call SysMsgBoardStr
popa
end if
; 7. Test whether EDID is good.
; 7a. Signature: 00 FF FF FF FF FF FF 00.
mov esi, edid
cmp dword [esi], 0xFFFFFF00
jnz .fail
cmp dword [esi+4], 0x00FFFFFF
jnz .fail
; 7b. Checksum must be zero.
xor edx, edx
mov ecx, 80h
@@:
lodsb
add dl, al
loop @b
jnz .fail
; 8. Get width and height from EDID.
xor eax, eax
mov ah, [esi-80h+3Ah]
shr ah, 4
mov al, [esi-80h+38h]
mov [width], eax
mov ah, [esi-80h+3Dh]
shr ah, 4
mov al, [esi-80h+3Bh]
mov [height], eax
; 9. Return.
.fail:
pop edi esi
ret
; reset bus, clear all errors
ResetGMBus:
; look into the PRM
mov dword [esi+4], 80000000h
mov dword [esi+4], 0
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
ret
end if
; set resolution [width]*[height]
SetMode:
; 1. Program the registers of videocard.
; look into the PRM
cli
; or byte [esi+7000Ah], 0Ch ; PIPEACONF: disable Display+Cursor Planes
; or byte [esi+7100Ah], 0Ch ; PIPEBCONF: disable Display+Cursor Planes
xor eax, eax
xor edx, edx
cmp [deviceType], i965_start
jb @f
mov dl, 9Ch - 84h
@@:
; or byte [esi+71403h], 80h ; VGACNTRL: VGA Display Disable
and byte [esi+70080h], not 27h ; CURACNTR: disable cursor A
mov dword [esi+70084h], eax ; CURABASE: force write to CURA* regs
and byte [esi+700C0h], not 27h ; CURBCNTR: disable cursor B
mov dword [esi+700C4h], eax ; CURBBASE: force write to CURB* regs
and byte [esi+70183h], not 80h ; DSPACNTR: disable Primary A Plane
mov dword [esi+edx+70184h], eax ; DSPALINOFF/DSPASURF: force write to DSPA* regs
and byte [esi+71183h], not 80h ; DSPBCNTR: disable Primary B Plane
mov dword [esi+edx+71184h], eax ; DSPBLINOFF/DSPBSURF: force write to DSPB* regs
if 1
cmp [deviceType], ironlake_start
jae .disable_pipes
mov edx, 10000h
or byte [esi+70024h], 2 ; PIPEASTAT: clear VBLANK status
or byte [esi+71024h], 2 ; PIPEBSTAT: clear VBLANK status
.wait_vblank_preironlake1:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 80h ; PIPEACONF: pipe A active?
jz @f
test byte [esi+70024h], 2 ; PIPEASTAT: got VBLANK?
jz .wait_vblank_preironlake2
@@:
test byte [esi+7100Bh], 80h ; PIPEBCONF: pipe B active?
jz .disable_pipes
test byte [esi+71024h], 2 ; PIPEBSTAT: got VBLANK?
jnz .disable_pipes
.wait_vblank_preironlake2:
dec edx
jnz .wait_vblank_preironlake1
jmp .not_disabled
.disable_pipes:
end if
and byte [esi+7000Bh], not 80h ; PIPEACONF: disable pipe
and byte [esi+7100Bh], not 80h ; PIPEBCONF: disable pipe
cmp [deviceType], gen4_start
jb .wait_watching_scanline
; g45 and later: use special flag from PIPE*CONF
mov edx, 10000h
@@:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 40h ; PIPEACONF: wait until pipe disabled
jz @f
dec edx
jnz @b
jmp .not_disabled
@@:
test byte [esi+7100Bh], 40h ; PIPEBCONF: wait until pipe disabled
jz .disabled
mov ecx, 1000h
loop $
dec edx
jnz @b
jmp .not_disabled
; pineview and before: wait while scanline still changes
.wait_watching_scanline:
mov edx, 1000h
.dis1:
push dword [esi+71000h]
push dword [esi+70000h]
mov ecx, 10000h
loop $
pop eax
xor eax, [esi+70000h]
and eax, 1FFFh
pop eax
jnz .notdis1
xor eax, [esi+71000h]
and eax, 1FFFh
jz .disabled
.notdis1:
dec edx
jnz .dis1
.not_disabled:
sti
jmp .return
.disabled:
lea eax, [esi+61183h]
cmp [deviceType], ironlake_start
jb @f
add eax, 0xE0000 - 0x60000
@@:
lea edx, [esi+60000h]
test byte [eax], 40h
jz @f
add edx, 1000h
@@:
mov eax, [width]
dec eax
shl eax, 16
mov ax, word [height]
dec eax
mov dword [edx+1Ch], eax ; PIPEASRC: set source image size
ror eax, 16
mov dword [edx+10190h], eax ; for old cards
mov ecx, [width]
add ecx, 15
and ecx, not 15
shl ecx, 2
mov dword [edx+10188h], ecx ; DSPASTRIDE: set scanline length
mov dword [edx+10184h], 0 ; DSPALINOFF: force write to DSPA* registers
and byte [esi+61233h], not 80h ; PFIT_CONTROL: disable panel fitting
or byte [edx+1000Bh], 80h ; PIPEACONF: enable pipe
; and byte [edx+1000Ah], not 0Ch ; PIPEACONF: enable Display+Cursor Planes
or byte [edx+10183h], 80h ; DSPACNTR: enable Display Plane A
sti
; 2. Notify the kernel that resolution has changed.
call GetDisplay
mov edx, [width]
mov dword [eax+8], edx
mov edx, [height]
mov dword [eax+0Ch], edx
mov [eax+18h], ecx
mov eax, [width]
dec eax
dec edx
call SetScreen
.return:
ret
align 4
hellomsg db 'Intel videocard detected, PciId=8086:'
pciid_text db '0000'
db ', which is ', 0
knownmsg db 'known',13,10,0
unknownmsg db 'unknown',13,10,0
if DEBUG
edidmsg db 'EDID successfully read:',13,10
edid_text rb 8*(16*3+1)
db 0
end if
version:
dd 0x50005
width dd predefined_width
height dd predefined_height
pciids:
dw 0x3577 ; i830m
dw 0x2562 ; 845g
dw 0x3582 ; i855gm
i865_start = ($ - pciids) / 2
dw 0x2572 ; i865g
i9xx_start = ($ - pciids) / 2
dw 0x2582 ; i915g
dw 0x258a ; e7221g (i915g)
dw 0x2592 ; i915gm
dw 0x2772 ; i945g
dw 0x27a2 ; i945gm
dw 0x27ae ; i945gme
i965_start = ($ - pciids) / 2
dw 0x2972 ; i946qz (i965g)
dw 0x2982 ; g35g (i965g)
dw 0x2992 ; i965q (i965g)
dw 0x29a2 ; i965g
dw 0x29b2 ; q35g
dw 0x29c2 ; g33g
dw 0x29d2 ; q33g
dw 0xa001 ; pineview
dw 0xa011 ; pineview
gen4_start = ($ - pciids) / 2
dw 0x2a02 ; i965gm
dw 0x2a12 ; i965gm
dw 0x2a42 ; gm45
dw 0x2e02 ; g45
dw 0x2e12 ; g45
dw 0x2e22 ; g45
dw 0x2e32 ; g45
dw 0x2e42 ; g45
dw 0x2e92 ; g45
ironlake_start = ($ - pciids) / 2
dw 0x0042 ; ironlake_d
dw 0x0046 ; ironlake_m
dw 0x0102 ; sandybridge_d
dw 0x0112 ; sandybridge_d
dw 0x0122 ; sandybridge_d
dw 0x0106 ; sandybridge_m
dw 0x0116 ; sandybridge_m
dw 0x0126 ; sandybridge_m
dw 0x010A ; sandybridge_d
pciids_num = ($ - pciids) / 2
align 4
deviceType dd ?
edid rb 0x80

View File

@ -1,438 +0,0 @@
; Stub of videodriver for RDC Semiconductor Co. M2010/M2012 videocards (controller names: R3306/R3308).
; It is used in SoC produced by DMP Electronics Inc.:
; Vortex86MX (contains RDC M2010 graphics card, appears in eBox-3300MX)
; Vortex86MX+ (contains RDC M2012 graphics card, appears in eBox-3310MX)
; Link to manufacturers websites -
; RDC Semiconductor Co.: http://www.rdc.com.tw
; DM&P Electronics Inc.: http://www.dmp.com.tw and http://www.compactpc.com.tw
; Code stolen from vidintel.asm driver (c) by CleverMouse and adapted for RDC.
; When the start procedure gets control,
; it tries to detect preferred resolution,
; sets the detected resolution assuming 32-bpp VESA mode and exits
; (without registering a service).
; Detection can be overloaded with compile-time settings
; use_predefined_mode/predefined_width/predefined_height.
; set predefined resolution here
use_predefined_mode = 0;1
predefined_width = 0;1366
predefined_height = 0;768
; standard driver stuff
format MS COFF
DEBUG = 1
include 'proc32.inc'
include 'imports.inc'
public START
public version
section '.flat' code readable align 16
; the start procedure (see the description above)
START:
; 1. Detect device. Abort if not found.
push esi
call DetectDevice
test esi, esi
jz .return0
;{START}yogev_ezra: temporary exit after detection
pusha
mov esi, exitmsg
call SysMsgBoardStr
popa
jmp .return0
;{END}yogev_ezra: temporary exit after detection
; 2. Detect optimal mode unless the mode is given explicitly. Abort if failed.
if use_predefined_mode = 0
call DetectMode
end if
cmp [width], 0
jz .return0_cleanup
; 3. Set the detected mode.
call SetMode
; 4. Cleanup and return.
.return0_cleanup:
stdcall FreeKernelSpace, esi
.return0:
pop esi
xor eax, eax
ret 4
; check that there is RDC videocard
; if so, map MMIO registers and set internal variables
; esi points to MMIO block; NULL means no device
DetectDevice:
; 1. Sanity check: check that we are dealing with RDC videocard.
; Integrated video device for RDC is always at PCI:0:13:0 (bus:dev:fn=0:0d:0)
xor esi, esi ; initialize return value to NULL
; 1a. Get PCI VendorID and DeviceID.
push esi ; in: reg=0 (register) -> register 00 means return DeviceID (bits 16-31) + VendorID (bits 0-15)
push 68h ; in: devfn=13:0 | device:5bit (0Dh = 1101) + func:3bit (0 = 000) -> total:1byte (1101000b = 68h)
push esi ; in: bus=0
call PciRead32
; 1b. loword(eax) = ax = VendorID, hiword(eax) = DeviceID.
; Test whether we have RDC Semiconductor Co. chipset.
cmp ax, 17F3h ;VendorID 0x17F3, 'RDC Semiconductor Co.'
jnz .return
; 1c. Say hi including DeviceID.
shr eax, 10h ; now, ax = HIWORD(eax) = PCI DeviceID
push edi
pusha
mov edi, pciid_text ; edi='0000'
call WriteWord
mov esi, hellomsg
call SysMsgBoardStr
popa
; 1d. Test whether we know this DeviceID.
; If this is the case, remember the position of the device in line of RDC cards;
; this knowledge will be useful later.
; Tested on devices with id: 17F3:2010, 17F3:2012.
mov ecx, pciids_num
mov edi, pciids
repnz scasw
pop edi
jnz .return_unknown_pciid
sub ecx, pciids_num - 1
neg ecx
mov [deviceType], ecx
; 1e. Continue saying hi with positive intonation.
pusha
mov esi, knownmsg
call SysMsgBoardStr
popa
; 2. Prepare MMIO region to control the card.
; 2a. Read MMIO physical address from PCI config space.
; According to RDC M2010/M2012 registers manual, their memory-mapped I/O space is located at Base address #1
push 14h ; in: reg=14h (register) -> register 14h means Base address #1 (BAR1) in PCI configuration space
push 68h ; in: devfn=13:0 | device:5bit (0Dh = 1101) + func:3bit (0 = 000) -> total:1byte (1101000b = 68h)
push esi ; in: bus=0
call PciRead32
; 2b. Mask out PCI region type, lower 4 bits.
and al, not 0xF
; 2c. Create virtual mapping of the physical memory.
push 1Bh
push 100000h
push eax
call MapIoMem
; 3. Return.
xchg esi, eax
.return:
ret
; 1f. If we do not know DeviceID, continue saying hi with negative intonation.
.return_unknown_pciid:
pusha
mov esi, unknownmsg
call SysMsgBoardStr
popa
ret
; Convert word in ax to hexadecimal text in edi, advance edi.
WriteWord:
; 1. Convert high byte.
push eax
mov al, ah
call WriteByte
pop eax
; 2. Convert low byte.
; Fall through to WriteByte; ret from WriteByte is ret from WriteWord too.
; Convert byte in al to hexadecimal text in edi, advance edi.
WriteByte:
; 1. Convert high nibble.
push eax
shr al, 4
call WriteNibble
pop eax
; 2. Convert low nibble.
and al, 0xF
; Fall through to WriteNibble; ret from WriteNibble is ret from WriteByte too.
; Convert nibble in al to hexadecimal text in edi, advance edi.
WriteNibble:
; Obvious, isn't it?
cmp al, 10
sbb al, 69h
das
stosb ; This instruction uses EDI implicitly
ret
if use_predefined_mode = 0
; detect resolution of the flat panel
DetectMode:
push esi edi
; 1. Get the location of block of GMBUS* registers.
; Starting with Ironlake, GMBUS* registers were moved.
add esi, 5100h
cmp [deviceType], pciids_num ;ironlake_start
jb @f
add esi, 0xC0000
@@:
; 2. Initialize GMBUS engine.
mov edi, edid
mov ecx, 0x10000
@@:
test byte [esi+8+1], 80h
loopnz @b
jnz .fail
mov dword [esi], 3
test byte [esi+8+1], 4
jz .noreset
call ResetGMBus
jnz .fail
.noreset:
; 3. Send read command.
and dword [esi+20h], 0
mov dword [esi+4], 4E8000A1h
; 4. Wait for data, writing to the buffer as data arrive.
.getdata:
mov ecx, 0x10000
@@:
test byte [esi+8+1], 8
loopz @b
test byte [esi+8+1], 4
jz .dataok
call ResetGMBus
jmp .fail
.dataok:
mov eax, [esi+0Ch]
stosd
cmp edi, edid+80h
jb .getdata
; 5. Wait for bus idle.
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
; 6. We got EDID; dump it if DEBUG.
if DEBUG
pusha
xor ecx, ecx
mov esi, edid
mov edi, edid_text
.dumploop:
lodsb
call WriteByte
mov al, ' '
stosb
inc cl
test cl, 15
jnz @f
mov byte [edi-1], 13
mov al, 10
stosb
@@:
test cl, cl
jns .dumploop
mov esi, edidmsg
call SysMsgBoardStr
popa
end if
; 7. Test whether EDID is good.
; 7a. Signature: 00 FF FF FF FF FF FF 00.
mov esi, edid
cmp dword [esi], 0xFFFFFF00
jnz .fail
cmp dword [esi+4], 0x00FFFFFF
jnz .fail
; 7b. Checksum must be zero.
xor edx, edx
mov ecx, 80h
@@:
lodsb
add dl, al
loop @b
jnz .fail
; 8. Get width and height from EDID.
xor eax, eax
mov ah, [esi-80h+3Ah]
shr ah, 4
mov al, [esi-80h+38h]
mov [width], eax
mov ah, [esi-80h+3Dh]
shr ah, 4
mov al, [esi-80h+3Bh]
mov [height], eax
; 9. Return.
.fail:
pop edi esi
ret
; reset bus, clear all errors
ResetGMBus:
; look into the PRM
mov dword [esi+4], 80000000h
mov dword [esi+4], 0
mov ecx, 0x10000
@@:
test byte [esi+8+1], 2
loopnz @b
ret
end if
; set resolution [width]*[height]
SetMode:
; 1. Program the registers of videocard.
; look into the PRM
cli
; or byte [esi+7000Ah], 0Ch ; PIPEACONF: disable Display+Cursor Planes
; or byte [esi+7100Ah], 0Ch ; PIPEBCONF: disable Display+Cursor Planes
xor eax, eax
xor edx, edx
cmp [deviceType], pciids_num ;i965_start
jb @f
mov dl, 9Ch - 84h
@@:
; or byte [esi+71403h], 80h ; VGACNTRL: VGA Display Disable
and byte [esi+70080h], not 27h ; CURACNTR: disable cursor A
mov dword [esi+70084h], eax ; CURABASE: force write to CURA* regs
and byte [esi+700C0h], not 27h ; CURBCNTR: disable cursor B
mov dword [esi+700C4h], eax ; CURBBASE: force write to CURB* regs
and byte [esi+70183h], not 80h ; DSPACNTR: disable Primary A Plane
mov dword [esi+edx+70184h], eax ; DSPALINOFF/DSPASURF: force write to DSPA* regs
and byte [esi+71183h], not 80h ; DSPBCNTR: disable Primary B Plane
mov dword [esi+edx+71184h], eax ; DSPBLINOFF/DSPBSURF: force write to DSPB* regs
if 1
cmp [deviceType], pciids_num ;ironlake_start
jae .disable_pipes
mov edx, 10000h
or byte [esi+70024h], 2 ; PIPEASTAT: clear VBLANK status
or byte [esi+71024h], 2 ; PIPEBSTAT: clear VBLANK status
.wait_vblank_preironlake1:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 80h ; PIPEACONF: pipe A active?
jz @f
test byte [esi+70024h], 2 ; PIPEASTAT: got VBLANK?
jz .wait_vblank_preironlake2
@@:
test byte [esi+7100Bh], 80h ; PIPEBCONF: pipe B active?
jz .disable_pipes
test byte [esi+71024h], 2 ; PIPEBSTAT: got VBLANK?
jnz .disable_pipes
.wait_vblank_preironlake2:
dec edx
jnz .wait_vblank_preironlake1
jmp .not_disabled
.disable_pipes:
end if
and byte [esi+7000Bh], not 80h ; PIPEACONF: disable pipe
and byte [esi+7100Bh], not 80h ; PIPEBCONF: disable pipe
cmp [deviceType], pciids_num ;gen4_start
jb .wait_watching_scanline
; g45 and later: use special flag from PIPE*CONF
mov edx, 10000h
@@:
mov ecx, 1000h
loop $
test byte [esi+7000Bh], 40h ; PIPEACONF: wait until pipe disabled
jz @f
dec edx
jnz @b
jmp .not_disabled
@@:
test byte [esi+7100Bh], 40h ; PIPEBCONF: wait until pipe disabled
jz .disabled
mov ecx, 1000h
loop $
dec edx
jnz @b
jmp .not_disabled
; pineview and before: wait while scanline still changes
.wait_watching_scanline:
mov edx, 1000h
.dis1:
push dword [esi+71000h]
push dword [esi+70000h]
mov ecx, 10000h
loop $
pop eax
xor eax, [esi+70000h]
and eax, 1FFFh
pop eax
jnz .notdis1
xor eax, [esi+71000h]
and eax, 1FFFh
jz .disabled
.notdis1:
dec edx
jnz .dis1
.not_disabled:
sti
jmp .return
.disabled:
lea eax, [esi+61183h]
cmp [deviceType], pciids_num ;ironlake_start
jb @f
add eax, 0xE0000 - 0x60000
@@:
lea edx, [esi+60000h]
test byte [eax], 40h
jz @f
add edx, 1000h
@@:
mov eax, [width]
dec eax
shl eax, 16
mov ax, word [height]
dec eax
mov dword [edx+1Ch], eax ; PIPEASRC: set source image size
ror eax, 16
mov dword [edx+10190h], eax ; for old cards
mov ecx, [width]
add ecx, 15
and ecx, not 15
shl ecx, 2
mov dword [edx+10188h], ecx ; DSPASTRIDE: set scanline length
mov dword [edx+10184h], 0 ; DSPALINOFF: force write to DSPA* registers
and byte [esi+61233h], not 80h ; PFIT_CONTROL: disable panel fitting
or byte [edx+1000Bh], 80h ; PIPEACONF: enable pipe
; and byte [edx+1000Ah], not 0Ch ; PIPEACONF: enable Display+Cursor Planes
or byte [edx+10183h], 80h ; DSPACNTR: enable Display Plane A
sti
; 2. Notify the kernel that resolution has changed.
call GetDisplay
mov edx, [width]
mov dword [eax+8], edx
mov edx, [height]
mov dword [eax+0Ch], edx
mov [eax+18h], ecx
mov eax, [width]
dec eax
dec edx
call SetScreen
.return:
ret
align 4
hellomsg db 'RDC videocard detected, PciId=17F3:' ;VendorID 0x17F3, 'RDC Semiconductor Co.'
pciid_text db '0000'
db ', which is ', 0
knownmsg db 'known',13,10,0
unknownmsg db 'unknown',13,10,0
exitmsg db 'Card detected successfully, exiting driver...',13,10,0
if DEBUG
edidmsg db 'EDID successfully read:',13,10
edid_text rb 8*(16*3+1)
db 0
end if
version:
dd 0x50005
width dd predefined_width
height dd predefined_height
pciids:
dw 0x2010 ; M2010 - appears in eBox-3300MX (Vortex86MX SoC)
dw 0x2012 ; M2012 - appears in eBox-3310MX (Vortex86MX+ SoC)
pciids_num = ($ - pciids) / 2
align 4
deviceType dd ?
edid rb 0x80

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
$Revision: 5363 $
;---------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5089 $
$Revision: 5363 $
include 'ext2.inc'

View File

@ -7,7 +7,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
$Revision: 5363 $
; Future jobs for driver, in order of preference:

View File

@ -7,7 +7,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
$Revision: 5363 $
;---------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4891 $
$Revision: 5363 $
;---------------------------------------------------------------------

View File

@ -1,38 +1,38 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; FAT functions for KolibriOS ;;
;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;;
;; See file COPYING for details ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; FAT functions for KolibriOS ;;
;; ;;
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;;
;; See file COPYING for details ;;
;; 06.2015 fs_read64 - pathoswithin ;;
;; 04.02.2007 LFN create folder - diamond ;;
;; 08.10.2006 LFN delete file/folder - diamond ;;
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
;; 17.08.2006 LFN write/append to file - diamond ;;
;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 04.02.2007 LFN create folder - diamond ;;
;; 08.10.2006 LFN delete file/folder - diamond ;;
;; 20.08.2006 LFN set file size (truncate/extend) - diamond ;;
;; 17.08.2006 LFN write/append to file - diamond ;;
;; 23.06.2006 LFN start application - diamond ;;
;; 15.06.2006 LFN get/set file/folder info - diamond ;;
;; 27.05.2006 LFN create/rewrite file - diamond ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
;; 04.12.2004 skip volume label, file delete bug fixed - ATV ;;
;; 29.11.2004 get_free_FAT changed, append dir bug fixed - ATV ;;
;; 23.11.2004 don't allow overwrite dir with file - ATV ;;
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
;; 17.11.2004 set_FAT/get_FAT and disk cache rewritten - ATV ;;
;; 10.11.2004 removedir clear whole directory structure - ATV ;;
;; 08.11.2004 rename - ATV ;;
;; 30.10.2004 file_read return also dirsize in bytes - ATV ;;
;; 20.10.2004 Makedir/Removedir - ATV ;;
;; 14.10.2004 Partition chain/Fat16 - ATV (thanks drh3xx) ;;
;; 06.09.2004 Fix free space - Mario79 ;;
;; 24.05.2004 Write back buffer for File_write - VT ;;
;; 20.05.2004 File_read function to work with syscall 58 - VT ;;
@ -40,9 +40,10 @@
;; 29.06.2002 Improved fat32 verification - VT ;;
;; 20.05.2002 Hd status check - VT ;;
;; 01.05.2002 Bugfix in device write - VT ;;
;; ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5578 $
cache_max equ 1919 ; max. is 1919*512+0x610000=0x6ffe00
@ -60,7 +61,7 @@ fs_type db ?
fat16_root db 0 ; flag for fat16 rootdir
fat_change db 0 ; 1=fat has changed
rb 1
Lock MUTEX ? ; currently operations with one partition
Lock MUTEX ? ; currently operations with one partition
; can not be executed in parallel since the legacy code is not ready
SECTORS_PER_FAT dd 0x1f3a
NUMBER_OF_FATS dd 0x2

View File

@ -5,7 +5,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5089 $
$Revision: 5363 $
include 'xfs.inc'

View File

@ -5,7 +5,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
$Revision: 5363 $
; from stat.h

View File

@ -407,7 +407,7 @@ mouse._.move_handler: ;////////////////////////////////////////////////////////
@@:
add eax, [mouse.active_sys_window.new_box.height]
cmp eax, [_display.height]
jl .call_window_handler
jl .call_window_handler
sub eax, [_display.height]
sub [mouse.active_sys_window.new_box.top], eax
jmp .call_window_handler

View File

@ -35,10 +35,10 @@ endg
iglobal
;--------------------------------------
align 4
mouse_delay dd 10
mouse_delay dd 10
mouse_speed_factor:
dd 3
mouse_timer_ticks dd 0
dd 3
mouse_timer_ticks dd 0
endg
;-----------------------------------------------------------------------------
@ -175,7 +175,7 @@ drm:
add eax, ecx ; save picture under mouse
add ebx, edx
push ecx
or ecx, 0x04000000 ; don't load to mouseunder area
or ecx, 0x04000000 ; don't load to mouseunder area
push eax ebx edx edi
call [GETPIXEL]
pop edi edx ebx eax
@ -190,12 +190,12 @@ drm:
and ebx, 0xffffff
mov [eax], ebx
pop ecx
mov edi, edx ; y cycle
shl edi, 4 ; *16 bytes per row
add edi, ecx ; x cycle
mov edi, edx ; y cycle
shl edi, 4 ; *16 bytes per row
add edi, ecx ; x cycle
mov esi, edi
add edi, esi
add edi, esi ; *3
add edi, esi ; *3
add edi, [MOUSE_PICTURE] ; we have our str address
mov esi, edi
add esi, 16*24*3
@ -209,19 +209,19 @@ drm:
pop ecx
pop ebx
pop eax
add eax, ecx ; we have x coord+cycle
add ebx, edx ; and y coord+cycle
add eax, ecx ; we have x coord+cycle
add ebx, edx ; and y coord+cycle
push ecx
mov ecx, [MOUSE_COLOR_MEM]
mov edi, 1 ; force
or ecx, 0x04000000 ; don't save to mouseunder area
or ecx, 0x04000000 ; don't save to mouseunder area
; call [putpixel]
call __sys_putpixel
pop ecx
mov ebx, [esp+0] ; pure y coord again
mov eax, [esp+4] ; and x
inc ecx ; +1 cycle
cmp ecx, 16 ; if more than 16
inc ecx ; +1 cycle
cmp ecx, 16 ; if more than 16
jnz drm
xor ecx, ecx
inc edx
@ -314,11 +314,11 @@ check_mouse_area_for_getpixel:
push eax ebx
; check for Y
xor ecx, ecx
mov cx, [Y_UNDER] ; [MOUSE_Y]
mov cx, [Y_UNDER] ; [MOUSE_Y]
cmp ebx, ecx
jb .no_mouse_area
add ecx, 23 ; mouse cursor Y size
add ecx, 23 ; mouse cursor Y size
cmp ebx, ecx
ja .no_mouse_area
; offset Y
@ -329,7 +329,7 @@ check_mouse_area_for_getpixel:
mov cx, [X_UNDER] ; [MOUSE_X]
cmp eax, ecx
jb .no_mouse_area
add ecx, 15 ; mouse cursor X size
add ecx, 15 ; mouse cursor X size
cmp eax, ecx
ja .no_mouse_area
; offset X
@ -363,10 +363,10 @@ check_mouse_area_for_putpixel:
; eax = new color
push eax
; check for Y
mov ax, [Y_UNDER] ; [MOUSE_Y]
mov ax, [Y_UNDER] ; [MOUSE_Y]
cmp cx, ax
jb .no_mouse_area
add ax, 23 ; mouse cursor Y size
add ax, 23 ; mouse cursor Y size
cmp cx, ax
ja .no_mouse_area
; offset Y
@ -379,7 +379,7 @@ check_mouse_area_for_putpixel:
shr ecx, 16
cmp cx, ax
jb .no_mouse_area
add ax, 15 ; mouse cursor X size
add ax, 15 ; mouse cursor X size
cmp cx, ax
ja .no_mouse_area
; offset X
@ -407,10 +407,10 @@ check_mouse_area_for_putpixel:
push esi edi
rol eax, 16
movzx edi, ax ; y cycle
shl edi, 4 ; *16 bytes per row
movzx edi, ax ; y cycle
shl edi, 4 ; *16 bytes per row
shr eax, 16
add edi, eax ; x cycle
add edi, eax ; x cycle
lea edi, [edi*3]
add edi, [MOUSE_PICTURE] ; we have our str address
mov esi, edi

View File

@ -1688,8 +1688,8 @@ draw_num_text:
mov edi, [esp+64+4]
jmp dtext
;-----------------------------------------------------------------------------
uglobal
midi_base dw ?
iglobal
midi_base dw 0
endg
;-----------------------------------------------------------------------------
align 4

View File

@ -5,7 +5,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 4850 $
$Revision: 5363 $
; Éste archivo debe ser editado con codificación CP866

View File

@ -16,7 +16,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3386 $
$Revision: 5522 $
ARP_NO_ENTRY = 0
ARP_VALID_MAPPING = 1

View File

@ -16,7 +16,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5522 $
$Revision: 5584 $
IPv4_MAX_FRAGMENTS = 64
IPv4_MAX_ROUTES = 64

View File

@ -14,7 +14,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 3346 $
$Revision: 5522 $
ETH_FRAME_MINIMUM = 60
ETH_QUEUE_SIZE = 255
@ -69,7 +69,7 @@ macro ETH_init {
; This function is called by ethernet drivers,
; It pushes the received ethernet packets onto the ethernet input queue
;
; IN: [esp] = Pointer to buffer
; IN: [esp] = Pointer to buffer
;
; OUT: /
;
@ -241,7 +241,7 @@ ETH_output:
.adjust_size:
mov edx, ETH_FRAME_MINIMUM
test edx, edx ; clear zero flag
test edx, edx ; clear zero flag
jmp .done
.out_of_ram:

View File

@ -14,7 +14,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5522 $
$Revision: 5584 $
;-----------------------------------------------------------------
;

View File

@ -14,7 +14,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5522 $
$Revision: 5584 $
align 4
iglobal

View File

@ -1,98 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; booteng.asm the module for Secondary Loader ;;
;; ;;
;; KolibriOS 16-bit loader module, ;;
;; based on bootcode for KolibriOS ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;======================================================================
;
; BOOT DATA
;
;======================================================================
d80x25_bottom:
db 186,' KolibriOS is based on MenuetOS and comes with ABSOLUTELY '
db 'NO WARRANTY ',186
db 186,' See file COPYING for details '
db ' ',186
line_full_bottom
d80x25_bottom_num = 3
msg_apm db " APM x.x ", 0
vervesa db "Version of Vesa: Vesa x.x",13,10,0
novesa db "Display: EGA/CGA",13,10,0
s_vesa db "Version of VESA: "
.ver db "?.?",13,10,0
gr_mode db "Select a videomode: ",13,10,0
vrrmprint db "Apply VRR? (picture frequency greater than 60Hz"
db " only for transfers:",13,10
db 186," 1024*768->800*600 and 800*600->640*480) [1-yes,2-no]:",0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
bdev db "Load ramdisk from [1-floppy; 2-C:\kolibri.img (FAT32);"
db 13,10,186," "
db "3-use preloaded ram-image from kernel restart;"
db 13,10,186," "
db "4-create blank image]: ",0
probetext db 13,10,13,10,186," Use standart graphics mode? [1-yes, "
db "2-probe bios (Vesa 3.0)]: ",0
prnotfnd db "Fatal - Videomode not found.",0
not386 db "Fatal - CPU 386+ required.",0
btns db "Fatal - Can't determine color depth.",0
fatalsel db "Fatal - Graphics mode not supported by hardware.",0
pres_key db "Press any key to choose a new videomode.",0
badsect db 13,10,186," Fatal - Bad sector. Replace floppy.",0
memmovefailed db 13,10,186," Fatal - Int 0x15 move failed.",0
okt db " ... OK"
linef db 13,10,0
diskload db "Loading diskette: 00 %",8,8,8,8,0
pros db "00"
backspace2 db 8,8,0
boot_dev db 0 ; 0=floppy, 1=hd
start_msg db "Press [abc] to change settings, press [Enter] to continue booting",13,10,0
time_msg db " or wait "
time_str db " 5 seconds"
db " before automatical continuation",13,10,0
current_cfg_msg db "Current settings:",13,10,0
curvideo_msg db " [a] Videomode: ",0
mode0 db "320x200, EGA/CGA 256 colors",13,10,0
mode9 db "640x480, VGA 16 colors",13,10,0
usebd_msg db " [b] Add disks visible by BIOS:",0
on_msg db " on",13,10,0
off_msg db " off",13,10,0
;readonly_msg db " only for reading",13,10,0
vrrm_msg db " [c] Use VRR:",0
preboot_device_msg db " [d] Floppy image: ",0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "real floppy",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "use already loaded image",13,10,0
pdm4 db "create blank image",13,10,0
loading_msg db "Loading KolibriOS...",0
save_quest db "Remember current settings? [y/n]: ",0
loader_block_error db "Bootloader data invalid, I cannot continue. Stopped.",0
_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿',13,10,0
_r1 db 186,' ³ 320x200 EGA/CGA 256 colors ³ ³',13,10,0
_r2 db 186,' ³ 640x480 VGA 16 colors ³ ³',13,10,0
_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³',13,10,0
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ',13,10,0
remark1 db "Default values were selected to match most of configurations, but not all.",0
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
remark3 db "If the system does not boot, try to disable the item [b].",0
remarks dw remark1, remark2, remark3
num_remarks = 3

View File

@ -1,119 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; kolibri_ldm.asm the module for Secondary Loader ;;
;; ;;
;; KolibriOS 16-bit loader module, ;;
;; based on bootcode for KolibriOS ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;======================================================================
;
; BOOT DATA
;
;======================================================================
d80x25_bottom:
db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY '
db 'NO WARRANTY ',186
db 186,' See file COPYING for details '
db ' ',186
line_full_bottom
d80x25_bottom_num = 3
novesa db "Ekraan: EGA/CGA",13,10,0
vervesa db "Vesa versioon: Vesa x.x",13,10,0
vervesa_off=20
msg_apm db " APM x.x ", 0
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
db "[3] 1024x768, [4] 1280x1024",13,10
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
db "[7] 1024x768, [8] 1280x1024",13,10
db 186," EGA/CGA 256 värvi: [9] 320x200, "
db "VGA 16 värvi: [0] 640x480",13,10
db 186," Vali reziim: ",0
bt24 db "Bitti pikseli kohta: 24",13,10,0
bt32 db "Bitti pikseli kohta: 32",13,10,0
vrrmprint db "Kinnita VRR? (ekraani sagedus suurem kui 60Hz"
db " ainult:",13,10
db 186," 1024*768->800*600 ja 800*600->640*480) [1-jah,2-ei]:",0
;askmouse db " Hiir:"
; db " [1] PS/2 (USB), [2] Com1, [3] Com2."
; db " Vali port [1-3]: ",0
;no_com1 db 13,10,186, " No COM1 mouse",0
;no_com2 db 13,10,186, " No COM2 mouse",0
;ask_dma db "Use DMA for HDD access? [1-yes, 2-only for reading, 3-no]: ",0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
;gr_direct db 186," Use direct LFB writing? "
; db "[1-yes/2-no] ? ",0
;mem_model db 13,10,186," Motherboard memory [1-16 Mb / 2-32 Mb / "
; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0
;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0
bdev db "Paigalda mäluketas [1-diskett; 2-C:\kolibri.img (FAT32);"
db 13,10,186," "
db "3-kasuta eellaaditud mäluketast kerneli restardist;"
db 13,10,186," "
db "4-loo tühi pilt]: ",0
probetext db 13,10,13,10,186," Kasuta standartset graafika reziimi? [1-jah, "
db "2-leia biosist (Vesa 3.0)]: ",0
;memokz256 db 13,10,186," RAM 256 Mb",0
;memokz128 db 13,10,186," RAM 128 Mb",0
;memokz64 db 13,10,186," RAM 64 Mb",0
;memokz32 db 13,10,186," RAM 32 Mb",0
;memokz16 db 13,10,186," RAM 16 Mb",0
prnotfnd db "Fataalne - Videoreziimi ei leitud.",0
;modena db "Fataalne - VBE 0x112+ on vajalik.",0
not386 db "Fataalne - CPU 386+ on vajalik.",0
btns db "Fataalne - Ei suuda värvisügavust määratleda.",0
fatalsel db "Fataalne - Graafilist reziimi riistvara ei toeta.",0
badsect db 13,10,186," Fataalne - Vigane sektor. Asenda diskett.",0
memmovefailed db 13,10,186," Fataalne - Int 0x15 liigutamine ebaõnnestus.",0
okt db " ... OK"
linef db 13,10,0
diskload db "Loen disketti: 00 %",8,8,8,8,0
pros db "00"
backspace2 db 8,8,0
boot_dev db 0 ; 0=floppy, 1=hd
start_msg db "Vajuta [abcd] seadete muutmiseks, vajuta [Enter] laadimise jätkamiseks",13,10,0
time_msg db " või oota "
time_str db " 5 sekundit"
db " automaatseks jätkamiseks",13,10,0
current_cfg_msg db "Praegused seaded:",13,10,0
curvideo_msg db " [a] Videoreziim: ",0
mode1 db "640x480",0
mode2 db "800x600",0
mode3 db "1024x768",0
mode4 db "1280x1024",0
modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " koos LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 värvi",0
mode10 db "640x480, VGA 16 värvi",0
probeno_msg db " (standard reziim)",0
probeok_msg db " (kontrolli ebastandardseid reziime)",0
;dma_msg db " [b] Kasuta DMA'd HDD juurdepääsuks:",0
usebd_msg db " [b] Add disks visible by BIOS:",0
on_msg db " sees",13,10,0
off_msg db " väljas",13,10,0
;readonly_msg db " ainult lugemiseks",13,10,0
vrrm_msg db " [c] Kasuta VRR:",0
preboot_device_msg db " [d] Disketi kujutis: ",0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "reaalne diskett",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "kasuta juba laaditud kujutist",13,10,0
pdm4 db "loo tühi pilt",13,10,0
loading_msg db "Laadin KolibriOS...",0
save_quest db "Jäta meelde praegused seaded? [y/n]: ",0
loader_block_error db "Alglaaduri andmed vigased, ei saa jätkata. Peatatud.",0
remark1 db "Default values were selected to match most of configurations, but not all.",0
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
remark3 db "If the system does not boot, try to disable the item [b].",0
remarks dw remark1, remark2, remark3
num_remarks = 3

View File

@ -1,118 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;======================================================================
;
; BOOT DATA
;
;======================================================================
d80x25_bottom:
; db 186,' KolibriOS based on MenuetOS and comes with ABSOLUTELY '
; db 'NO WARRANTY ',186
; db 186,' See file COPYING for details '
; db ' ',186
db 186,' KolibriOS basiert auf MenuetOS und wird ohne jegliche '
db ' Garantie vertrieben ',186
db 186,' Details stehen in der Datei COPYING '
db ' ',186
line_full_bottom
d80x25_bottom_num = 3
novesa db "Anzeige: EGA/CGA ",13,10,0
vervesa db "Vesa-Version: Vesa ",13,10,0
vervesa_off=22
msg_apm db " APM x.x ", 0
gr_mode db 186," Vesa 2.0+ 16 M LFB: [1] 640x480, [2] 800x600, "
db "[3] 1024x768, [4] 1280x1024",13,10
db 186," Vesa 1.2 16 M Bnk: [5] 640x480, [6] 800x600, "
db "[7] 1024x768, [8] 1280x1024",13,10
db 186," EGA/CGA 256 Farben: [9] 320x200, "
db "VGA 16 Farben: [0] 640x480",13,10
db 186," Waehle Modus: ",0
bt24 db "Bits Per Pixel: 24",13,10,0
bt32 db "Bits Per Pixel: 32",13,10,0
vrrmprint db "VRR verwenden? (Monitorfrequenz groesser als 60Hz"
db " only for transfers:",13,10
db 186," 1024*768->800*600 und 800*600->640*480) [1-ja,2-nein]:",0
;askmouse db " Maus angeschlossen an:"
; db " [1] PS/2 (USB), [2] Com1, [3] Com2."
; db " Waehle Port [1-3]: ",0
;no_com1 db 13,10,186, " Keine COM1 Maus",0
;no_com2 db 13,10,186, " Keine COM2 Maus",0
;ask_dma db "Nutze DMA zum HDD Zugriff? [1-ja, 2-allein fur Lesen, 3-nein]: ",0
ask_bd db "Add disks visible by BIOS emulated in V86-mode? [1-yes, 2-no]: ",0
;gr_direct db 186," Benutze direct LFB? "
; db "[1-ja/2-nein] ? ",0
;mem_model db 13,10,186," Hauptspeicher [1-16 Mb / 2-32 Mb / "
; db "3-64Mb / 4-128 Mb / 5-256 Mb] ? ",0
;bootlog db 13,10,186," After bootlog display [1-continue/2-pause] ? ",0
bdev db "Lade die Ramdisk von [1-Diskette; 2-C:\kolibri.img (FAT32);"
db 13,10,186," "
db "3-benutze ein bereits geladenes Kernel image;"
db 13,10,186," "
db "4-create blank image]: ",0
probetext db 13,10,13,10,186," Nutze Standardgrafikmodi? [1-ja, "
db "2-BIOS Test (Vesa 3.0)]: ",0
;memokz256 db 13,10,186," RAM 256 Mb",0
;memokz128 db 13,10,186," RAM 128 Mb",0
;memokz64 db 13,10,186," RAM 64 Mb",0
;memokz32 db 13,10,186," RAM 32 Mb",0
;memokz16 db 13,10,186," RAM 16 Mb",0
prnotfnd db "Fatal - Videomodus nicht gefunden.",0
;modena db "Fatal - VBE 0x112+ required.",0
not386 db "Fatal - CPU 386+ benoetigt.",0
btns db "Fatal - konnte Farbtiefe nicht erkennen.",0
fatalsel db "Fatal - Grafikmodus nicht unterstuetzt.",0
badsect db 13,10,186," Fatal - Sektorfehler, Andere Diskette neutzen.",0
memmovefailed db 13,10,186," Fatal - Int 0x15 Fehler.",0
okt db " ... OK"
linef db 13,10,0
diskload db "Lade Diskette: 00 %",8,8,8,8,0
pros db "00"
backspace2 db 8,8,0
boot_dev db 0 ; 0=floppy, 1=hd
start_msg db "Druecke [abcd], um die Einstellungen zu aendern , druecke [Enter] zum starten",13,10,0
time_msg db " oder warte "
time_str db " 5 Sekunden"
db " bis zum automatischen Start",13,10,0
current_cfg_msg db "Aktuelle Einstellungen:",13,10,0
curvideo_msg db " [a] Videomodus: ",0
mode1 db "640x480",0
mode2 db "800x600",0
mode3 db "1024x768",0
mode4 db "1280x1024",0
modes_msg dw mode4,mode1,mode2,mode3
modevesa20 db " mit LFB",0
modevesa12 db ", VESA 1.2 Bnk",0
mode9 db "320x200, EGA/CGA 256 colors",0
mode10 db "640x480, VGA 16 colors",0
probeno_msg db " (Standard Modus)",0
probeok_msg db " (teste nicht-standard Modi)",0
;dma_msg db " [b] Nutze DMA zum HDD Aufschreiben:",0
usebd_msg db " [b] Add disks visible by BIOS:",0
on_msg db " an",13,10,0
off_msg db " aus",13,10,0
;readonly_msg db " fur Lesen",13,10,0
vrrm_msg db " [c] Nutze VRR:",0
preboot_device_msg db " [d] Diskettenimage: ",0
preboot_device_msgs dw 0,pdm1,pdm2,pdm3
pdm1 db "Echte Diskette",13,10,0
pdm2 db "C:\kolibri.img (FAT32)",13,10,0
pdm3 db "Nutze bereits geladenes Image",13,10,0
pdm4 db "create blank image",13,10,0
loading_msg db "Lade KolibriOS...",0
save_quest db "Aktuelle Einstellungen speichern? [y/n]: ",0
loader_block_error db "Bootloader Daten ungueltig, Kann nicht fortfahren. Angehalten.",0
remark1 db "Default values were selected to match most of configurations, but not all.",0
remark2 db "If you have LCD-monitor, disable VRR in the item [c] - you do not need it.",0
remark3 db "If the system does not boot, try to disable the item [b].",0
remarks dw remark1, remark2, remark3
num_remarks = 3

View File

@ -1,87 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;=================================================================
;
; BOOT DATA
;
;=================================================================
d80x25_bottom:
db 186,' Kolibri OS ®á­®¢ ­  ­  Menuet OS ¨ ­¥ ¯à¥¤®áâ ¢«ï¥â '
db '­¨ª ª¨å £ àa­â¨©. ',186
db 186,' <20>®¤à®¡­¥¥ ᬮâà¨â¥ ¢ ä ©«¥ COPYING.TXT '
db ' ',186
line_full_bottom
msg_apm db " APM x.x ", 0
novesa db "‚¨¤¥®ª àâ : EGA/CGA",13,10,0
s_vesa db "‚¥àá¨ï VESA: "
.ver db "?.?",13,10,0
gr_mode db "‚ë¡¥à¨â¥ ¢¨¤¥®à¥¦¨¬: ",13,10,0
vrrmprint db "ˆá¯®«ì§®¢ âì VRR? (ç áâ®â  ª ¤à®¢ ¢ëè¥ 60 ƒæ"
db " ⮫쪮 ¤«ï ¯¥à¥å®¤®¢:",13,10
db 186," 1024*768>800*600 ¨ 800*600>640*480) [1-¤ , 2-­¥â]: ",0
;ask_dma db "ˆá¯®«ì§®¢ âì DMA ¤«ï ¤®áâ㯠 ª HDD? [1-¤ , 2-⮫쪮 ç⥭¨¥, 3-­¥â]: ",0
ask_bd db "„®¡ ¢¨âì ¤¨áª¨, ¢¨¤¨¬ë¥ ç¥à¥§ BIOS ¢ ०¨¬¥ V86? [1-¤ , 2-­¥â]: ",0
bdev db "‡ £à㧨âì ®¡à § ¨§ [1-¤¨áª¥â ; 2-C:\kolibri.img (FAT32);"
db 13,10,186," "
db "3-¨á¯®«ì§®¢ âì 㦥 § £à㦥­­ë© ®¡à §;"
db 13,10,186," "
db "4-ᮧ¤ âì ç¨áâë© ®¡à §]: ",0
prnotfnd db "Žè¨¡ª  - ‚¨¤¥®à¥¦¨¬ ­¥ ­ ©¤¥­.",0
not386 db "Žè¨¡ª  - ’ॡã¥âáï ¯à®æ¥áá®à 386+.",0
fatalsel db "Žè¨¡ª  - ‚ë¡à ­­ë© ¢¨¤¥®à¥¦¨¬ ­¥ ¯®¤¤¥à¦¨¢ ¥âáï.",0
pres_key db "<EFBFBD> ¦¨¬¨â¥ «î¡ãî ª« ¢¨èã, ¤«ï ¯¥à¥å®¤  ¢ ¢ë¡®à ०¨¬®¢.",0
badsect db 13,10,186," Žè¨¡ª  - „¨áª¥â  ¯®¢à¥¦¤¥­ . <20>®¯à®¡ã©â¥ ¤àã£ãî.",0
memmovefailed db 13,10,186," Žè¨¡ª  - Int 0x15 move failed.",0
okt db " ... OK"
linef db 13,10,0
diskload db "‡ £à㧪  ¤¨áª¥âë: 00 %",8,8,8,8,0
pros db "00"
backspace2 db 8,8,0
boot_dev db 0
start_msg db "<EFBFBD> ¦¬¨â¥ [abc] ¤«ï ¨§¬¥­¥­¨ï ­ áâ஥ª, [Enter] ¤«ï ¯à®¤®«¦¥­¨ï § £à㧪¨",13,10,0
time_msg db " ¨«¨ ¯®¤®¦¤¨â¥ "
time_str db " 5 ᥪ㭤 "
db " ¤®  ¢â®¬ â¨ç¥áª®£® ¯à®¤®«¦¥­¨ï",13,10,0
current_cfg_msg db "’¥ªã騥 ­ áâனª¨:",13,10,0
curvideo_msg db " [a] ‚¨¤¥®à¥¦¨¬: ",0
mode0 db "320x200, EGA/CGA 256 梥⮢",13,10,0
mode9 db "640x480, VGA 16 梥⮢",13,10,0
usebd_msg db " [b] „®¡ ¢¨âì ¤¨áª¨, ¢¨¤¨¬ë¥ ç¥à¥§ BIOS:",0
on_msg db " ¢ª«",13,10,0
off_msg db " ¢ëª«",13,10,0
readonly_msg db " ⮫쪮 ç⥭¨¥",13,10,0
vrrm_msg db " [c] ˆá¯®«ì§®¢ ­¨¥ VRR:",0
;preboot_device_msg db " [d] Ž¡à § ¤¨áª¥âë: ",0
;preboot_device_msgs dw 0,pdm1,pdm2,pdm3,pdm4
;pdm1 db "­ áâ®ïé ï ¤¨áª¥â ",13,10,0
;pdm2 db "C:\kolibri.img (FAT32)",13,10,0
;pdm3 db "¨á¯®«ì§®¢ âì 㦥 § £à㦥­­ë© ®¡à §",13,10,0
;pdm4 db "ᮧ¤ âì ç¨áâë© ®¡à §",13,10,0
loading_msg db "ˆ¤ñâ § £à㧪  KolibriOS...",0
save_quest db "‡ ¯®¬­¨âì ⥪ã騥 ­ áâனª¨? [y/n]: ",0
loader_block_error db "Žè¨¡ª  ¢ ¤ ­­ëå ­ ç «ì­®£® § £àã§ç¨ª , ¯à®¤®«¦¥­¨¥ ­¥¢®§¬®¦­®.",0
_st db 186,' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄ¿ ',13,10,0
_r1 db 186,' ³ 320x200 EGA/CGA 256 梥⮢ ³ ³ ',13,10,0
_r2 db 186,' ³ 640x480 VGA 16 梥⮢ ³ ³ ',13,10,0
_rs db 186,' ³ ????x????@?? SVGA VESA ³ ³ ',13,10,0
_bt db 186,' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÙ ',13,10,0
remark1 db "‡­ ç¥­¨ï ¯® 㬮«ç ­¨î ¢ë¡à ­ë ¤«ï 㤮¡á⢠ ¡®«ì設á⢠, ­® ­¥ ¢á¥å.",0
remark2 db "…᫨ ã ‚ á LCD-¬®­¨â®à, ®âª«îç¨â¥ VRR ¢ ¯ã­ªâ¥ [c] - ®­ ‚ ¬ ­¥ ­ã¦¥­.",0
remark3 db "…᫨ ã ‚ á ­¥ £à㧨âáï á¨á⥬ , ¯®¯à®¡ã©â¥ ®âª«îç¨âì ¯ã­ªâ [b].",0
remarks dw remark1, remark2, remark3
num_remarks = 3

View File

@ -1,56 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; boot data: common strings (for all languages)
macro line_full_top {
db 201
times 78 db 205
db 187
}
macro line_full_bottom {
db 200
times 78 db 205
db 188
}
macro line_half {
db 186,' '
times 76 db 0xc4
db ' ',186
}
macro line_space {
db 186
times 78 db 32
db 186
}
d80x25_top:
line_full_top
cur_line_pos = 75
; store byte ' ' at d80x25_top+cur_line_pos+1
; store byte ' ' at d80x25_top+cur_line_pos
; store dword ' SVN' at d80x25_top+cur_line_pos-4
space_msg:
line_space
;verstr:
; line_space
; version string
; db 186,32
; repeat 78
; load a byte from version+%-1
; if a = 13
; break
; end if
; db a
; end repeat
; repeat 78 - ($-verstr)
; db ' '
; end repeat
; db 32,186
; line_half

View File

@ -1,759 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
struc VBE_VGAInfo {
.VESASignature dd ? ; char
.VESAVersion dw ? ; short
.OemStringPtr dd ? ; char *
.Capabilities dd ? ; ulong
.VideoModePtr dd ? ; ulong
.TotalMemory dw ? ; short
; VBE 2.0+
.OemSoftwareRev db ? ; short
.OemVendorNamePtr dw ? ; char *
.OemProductNamePtr dw ? ; char *
.OemProductRevPtr dw ? ; char *
.reserved rb 222 ; char
.OemData rb 256 ; char
}
struc VBE_ModeInfo {
.ModeAttributes dw ? ; short
.WinAAttributes db ? ; char
.WinBAttributes db ? ; char
.WinGranularity dw ? ; short
.WinSize dw ? ; short
.WinASegment dw ? ; ushort
.WinBSegment dw ? ; ushort
.WinFuncPtr dd ? ; void *
.BytesPerScanLine dw ? ; short
.XRes dw ? ; short
.YRes dw ? ; short
.XCharSize db ? ; char
.YCharSize db ? ; char
.NumberOfPlanes db ? ; char
.BitsPerPixel db ? ; char
.NumberOfBanks db ? ; char
.MemoryModel db ? ; char
.BankSize db ? ; char
.NumberOfImagePages db ? ; char
.res1 db ? ; char
.RedMaskSize db ? ; char
.RedFieldPosition db ? ; char
.GreenMaskSize db ? ; char
.GreenFieldPosition db ? ; char
.BlueMaskSize db ? ; char
.BlueFieldPosition db ? ; char
.RsvedMaskSize db ? ; char
.RsvedFieldPosition db ? ; char
.DirectColorModeInfo db ? ; char ; MISSED IN THIS TUTORIAL!! SEE ABOVE
; VBE 2.0+
.PhysBasePtr dd ? ; ulong
.OffScreenMemOffset dd ? ; ulong
.OffScreenMemSize dw ? ; short
; VBE 3.0+
.LinbytesPerScanLine dw ? ; short
.BankNumberOfImagePages db ? ; char
.LinNumberOfImagePages db ? ; char
.LinRedMaskSize db ? ; char
.LinRedFieldPosition db ? ; char
.LingreenMaskSize db ? ; char
.LinGreenFieldPosition db ? ; char
.LinBlueMaskSize db ? ; char
.LinBlueFieldPosition db ? ; char
.LinRsvdMaskSize db ? ; char
.LinRsvdFieldPosition db ? ; char
.MaxPixelClock dd ? ; ulong
.res2 rb 190 ; char
}
virtual at $A000
vi VBE_VGAInfo
mi VBE_ModeInfo
modes_table:
end virtual
cursor_pos dw 0 ;âðåìåííîå õðàíåíèå êóðñîðà.
home_cursor dw 0 ;current shows rows a table
end_cursor dw 0 ;end of position current shows rows a table
scroll_start dw 0 ;start position of scroll bar
scroll_end dw 0 ;end position of scroll bar
long_v_table equ 9 ;long of visible video table
size_of_step equ 10
scroll_area_size equ (long_v_table-2)
int2str:
dec bl
jz @f
xor edx, edx
div ecx
push edx
call int2str
pop eax
@@:
or al, 0x30
mov [ds:di], al
inc di
ret
int2strnz:
cmp eax, ecx
jb @f
xor edx, edx
div ecx
push edx
call int2strnz
pop eax
@@:
or al, 0x30
mov [es:di], al
inc di
ret
;-------------------------------------------------------
;Write message about incorrect v_mode and write message about jmp on swith v_mode
v_mode_error:
_setcursor 19,2
mov si, fatalsel
call printplain
_setcursor 20,2
mov si, pres_key
call printplain
xor eax, eax
int 16h
jmp cfgmanager.d
;-------------------------------------------------------
;
;-------------------------------------------------------
print_vesa_info:
_setcursor 5,2
mov [es:vi.VESASignature], 'VBE2'
mov ax, 0x4F00
mov di, vi ;0xa000
int 0x10
or ah, ah
jz @f
mov [es:vi.VESASignature], 'VESA'
mov ax, $4F00
mov di, vi
int 0x10
or ah, ah
jnz .exit
@@:
cmp [es:vi.VESASignature], 'VESA'
jne .exit
cmp [es:vi.VESAVersion], 0x0100
jb .exit
jmp .vesaok2
.exit:
mov si, novesa
call printplain
ret
.vesaok2:
mov ax, [es:vi.VESAVersion]
add ax, '00'
mov [s_vesa.ver], ah
mov [s_vesa.ver+2], al
mov si, s_vesa
call printplain
_setcursor 4,2
mov si, word[es:vi.OemStringPtr]
mov di, si
push ds
mov ds, word[es:vi.OemStringPtr+2]
call printplain
pop ds
ret
;-----------------------------------------------------------------------------
calc_vmodes_table:
pushad
; push 0
; pop es
lfs si, [es:vi.VideoModePtr]
mov bx, modes_table
;save no vesa mode of work 320x200, EGA/CGA 256 梥⮢ and 640x480, VGA 16 梥⮢
mov word [es:bx], 640
mov word [es:bx+2], 480
mov word [es:bx+6], 0x13
mov word [es:bx+10], 640
mov word [es:bx+12], 480
mov word [es:bx+16], 0x12
add bx, 20
.next_mode:
mov cx, word [fs:si]; mode number
cmp cx, -1
je .modes_ok.2
mov ax, 0x4F01
mov di, mi
int 0x10
or ah, ah
jnz .modes_ok.2;vesa_info.exit
test [es:mi.ModeAttributes], 00000001b ;videomode support ?
jz @f
test [es:mi.ModeAttributes], 00010000b ;picture ?
jz @f
test [es:mi.ModeAttributes], 10000000b ;LFB ?
jz @f
cmp [es:mi.BitsPerPixel], 24 ;It show only videomodes to have support 24 and 32 bpp
jb @f
; cmp [es:mi.BitsPerPixel],16
; jne .l0
; cmp [es:mi.GreenMaskSize],5
; jne .l0
; mov [es:mi.BitsPerPixel],15
.l0:
cmp [es:mi.XRes], 640
jb @f
cmp [es:mi.YRes], 480
jb @f
; cmp [es:mi.BitsPerPixel],8
; jb @f
mov ax, [es:mi.XRes]
mov [es:bx+0], ax ; +0[2] : resolution X
mov ax, [es:mi.YRes]
mov [es:bx+2], ax ; +2[2] : resolution Y
mov ax, [es:mi.ModeAttributes]
mov [es:bx+4], ax ; +4[2] : attributes
cmp [s_vesa.ver], '2'
jb .lp1
or cx, 0x4000 ; use LFB
.lp1:
mov [es:bx+6], cx ; +6 : mode number
movzx ax, byte [es:mi.BitsPerPixel]
mov word [es:bx+8], ax ; +8 : bits per pixel
add bx, size_of_step ; size of record
@@:
add si, 2
jmp .next_mode
.modes_ok.2:
mov word[es:bx], -1 ;end video table
mov word[end_cursor], bx ;save end cursor position
;;;;;;;;;;;;;;;;;;
;Sort array
; mov si,modes_table
;.new_mode:
; mov ax,word [es:si]
; cmp ax,-1
; je .exxit
; add ax,word [es:si+2]
; add ax,word [es:si+8]
; mov bp,si
;.again:
; add bp,12
; mov bx,word [es:bp]
; cmp bx,-1
; je .exit
; add bx,word [es:bp+2]
; add bx,word [es:bp+8]
;
; cmp ax,bx
; ja .loops
; jmp .again
;.loops:
; push dword [es:si]
; push dword [es:si+4]
; push dword [es:si+8]
; push dword [es:bp]
; push dword [es:bp+4]
; push dword [es:bp+8]
;
; pop dword [es:si+8]
; pop dword [es:si+4]
; pop dword [es:si]
; pop dword [es:bp+8]
; pop dword [es:bp+4]
; pop dword [es:bp]
; jmp .new_mode
;
;.exit: add si,12
; jmp .new_mode
;.exxit:
popad
ret
;-----------------------------------------------------------------------------
draw_current_vmode:
push 0
pop es
mov si, word [cursor_pos]
cmp word [es:si+6], 0x12
je .no_vesa_0x12
cmp word [es:si+6], 0x13
je .no_vesa_0x13
mov di, loader_block_error
movzx eax, word[es:si+0]
mov ecx, 10
call int2strnz
mov byte[es:di], 'x'
inc di
movzx eax, word[es:si+2]
call int2strnz
mov byte[es:di], 'x'
inc di
movzx eax, word[es:si+8]
call int2strnz
mov dword[es:di], 0x00000d0a
mov si, loader_block_error
push ds
push es
pop ds
call printplain
pop ds
ret
.no_vesa_0x13:
mov si, mode0
jmp .print
.no_vesa_0x12:
mov si, mode9
.print:
call printplain
ret
;-----------------------------------------------------------------------------
check_first_parm:
mov si, word [preboot_graph]
test si, si
jnz .no_zero ;if no zero
.zerro:
; mov ax,modes_table
; mov word [cursor_pos],ax
; mov word [home_cursor],ax
; mov word [preboot_graph],ax
;SET default video of mode first probe will fined a move of work 1024x768@32
mov ax, 1024
mov bx, 768
mov si, modes_table
call .loops
test ax, ax
jz .ok_found_mode
mov ax, 800
mov bx, 600
mov si, modes_table
call .loops
test ax, ax
jz .ok_found_mode
mov ax, 640
mov bx, 480
mov si, modes_table
call .loops
test ax, ax
jz .ok_found_mode
mov si, modes_table
jmp .ok_found_mode
.no_zero:
mov bp, word [number_vm]
cmp bp, word [es:si+6]
jz .ok_found_mode
mov ax, word [x_save]
mov bx, word [y_save]
mov si, modes_table
call .loops
test ax, ax
jz .ok_found_mode
mov si, modes_table
; cmp ax,modes_table
; jb .zerro ;check on correct if bellow
; cmp ax,word [end_cursor]
; ja .zerro ;check on correct if anymore
.ok_found_mode:
mov word [home_cursor], si
; mov word [cursor_pos],si
mov word [preboot_graph], si
mov ax, si
mov ecx, long_v_table
.loop:
add ax, size_of_step
cmp ax, word [end_cursor]
jae .next_step
loop .loop
.next_step:
sub ax, size_of_step*long_v_table
cmp ax, modes_table
jae @f
mov ax, modes_table
@@:
mov word [home_cursor], ax
mov si, [preboot_graph]
mov word [cursor_pos], si
push word [es:si]
pop word [x_save]
push word [es:si+2]
pop word [y_save]
push word [es:si+6]
pop word [number_vm]
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;
.loops:
cmp ax, word [es:si]
jne .next
cmp bx, word [es:si+2]
jne .next
cmp word [es:si+8], 32
je .ok
cmp word [es:si+8], 24
je .ok
.next:
add si, size_of_step
cmp word [es:si], -1
je .exit
jmp .loops
.ok:
xor ax, ax
ret
.exit:
or ax, -1
ret
;-----------------------------------------------------------------------------
;default_vmode:
;-----------------------------------------------------------------------------
draw_vmodes_table:
_setcursor 9, 2
mov si, gr_mode
call printplain
mov si, _st
call printplain
push word [cursor_pos]
pop ax
push word [home_cursor]
pop si
mov cx, si
cmp ax, si
je .ok
jb .low
add cx, size_of_step*long_v_table
cmp ax, cx
jb .ok
sub cx, size_of_step*long_v_table
add cx, size_of_step
cmp cx, word[end_cursor]
jae .ok
add si, size_of_step
push si
pop word [home_cursor]
jmp .ok
.low:
sub cx, size_of_step
cmp cx, modes_table
jb .ok
push cx
push cx
pop word [home_cursor]
pop si
.ok:
; calculate scroll position
push si
mov ax, [end_cursor]
sub ax, modes_table
mov bx, size_of_step
cwd
div bx
mov si, ax ; si = size of list
mov ax, [home_cursor]
sub ax, modes_table
cwd
div bx
mov di, ax
mov ax, scroll_area_size*long_v_table
cwd
div si
test ax, ax
jnz @f
inc ax
@@:
cmp al, scroll_area_size
jb @f
mov al, scroll_area_size
@@:
mov cx, ax
; cx = scroll height
; calculate scroll pos
xor bx, bx ; initialize scroll pos
sub al, scroll_area_size+1
neg al
sub si, long_v_table-1
jbe @f
mul di
div si
mov bx, ax
@@:
inc bx
imul ax, bx, size_of_step
add ax, [home_cursor]
mov [scroll_start], ax
imul cx, size_of_step
add ax, cx
mov [scroll_end], ax
pop si
mov bp, long_v_table ;show rows
.@@_next_bit:
;clear cursor
mov ax, ' '
mov word[ds:_r1+21], ax
mov word[ds:_r1+50], ax
mov word[ds:_r2+21], ax
mov word[ds:_r2+45], ax
mov word[ds:_rs+21], ax
mov word[ds:_rs+46], ax
; draw string
cmp word [es:si+6], 0x12
je .show_0x12
cmp word [es:si+6], 0x13
je .show_0x13
movzx eax, word[es:si]
cmp ax, -1
je .@@_end
mov di, _rs+23
mov ecx, 10
mov bl, 4
call int2str
movzx eax, word[es:si+2]
inc di
mov bl, 4
call int2str
movzx eax, word[es:si+8]
inc di
mov bl, 2
call int2str
cmp si, word [cursor_pos]
jne .next
;draw cursor
mov word[ds:_rs+21], '>>'
mov word[ds:_rs+46], '<<'
.next:
push si
mov si, _rs
.@@_sh:
; add to the string pseudographics for scrollbar
pop bx
push bx
mov byte [si+53], ' '
cmp bx, [scroll_start]
jb @f
cmp bx, [scroll_end]
jae @f
mov byte [si+53], 0xDB ; filled bar
@@:
push bx
add bx, size_of_step
cmp bx, [end_cursor]
jnz @f
mov byte [si+53], 31 ; 'down arrow' symbol
@@:
sub bx, [home_cursor]
cmp bx, size_of_step*long_v_table
jnz @f
mov byte [si+53], 31 ; 'down arrow' symbol
@@:
pop bx
cmp bx, [home_cursor]
jnz @f
mov byte [si+53], 30 ; 'up arrow' symbol
@@:
call printplain
pop si
add si, size_of_step
dec bp
jnz .@@_next_bit
.@@_end:
mov si, _bt
call printplain
ret
.show_0x13:
push si
cmp si, word [cursor_pos]
jne @f
mov word[ds:_r1+21], '>>'
mov word[ds:_r1+50], '<<'
@@:
mov si, _r1
jmp .@@_sh
.show_0x12:
push si
cmp si, word [cursor_pos]
jne @f
mov word[ds:_r2+21], '>>'
mov word[ds:_r2+45], '<<'
@@:
mov si, _r2
jmp .@@_sh
;-----------------------------------------------------------------------------
;Clear arrea of current video page (0xb800)
clear_vmodes_table:
pusha
; draw frames
push es
push 0xb800
pop es
mov di, 1444
xor ax, ax
mov ah, 1*16+15
mov cx, 70
mov bp, 12
.loop_start:
rep stosw
mov cx, 70
add di, 20
dec bp
jns .loop_start
pop es
popa
ret
;-----------------------------------------------------------------------------
set_vmode:
push 0 ;0;x1000
pop es
mov si, word [preboot_graph] ;[preboot_graph]
mov cx, word [es:si+6] ; number of mode
mov ax, word [es:si+0] ; resolution X
mov bx, word [es:si+2] ; resolution Y
mov word [es:BOOT_X_RES], ax ; resolution X
mov word [es:BOOT_Y_RES], bx ; resolution Y
mov word [es:BOOT_VESA_MODE], cx ; number of mode
cmp cx, 0x12
je .mode0x12_0x13
cmp cx, 0x13
je .mode0x12_0x13
cmp byte [s_vesa.ver], '2'
jb .vesa12
; VESA 2 and Vesa 3
mov ax, 0x4f01
and cx, 0xfff
mov di, mi;0xa000
int 0x10
; LFB
mov eax, [es:mi.PhysBasePtr];di+0x28]
mov [es:BOOT_LFB], eax
; ---- vbe voodoo
BytesPerLine equ 0x10
mov ax, [es:di+BytesPerLine]
mov [es:BOOT_PITCH], ax
; BPP
cmp [es:mi.BitsPerPixel], 16
jne .l0
cmp [es:mi.GreenMaskSize], 5
jne .l0
mov [es:mi.BitsPerPixel], 15
.l0:
mov al, byte [es:di+0x19]
mov [es:BOOT_BPP], al
jmp .exit
.mode0x12_0x13:
mov byte [es:BOOT_BPP], 32
or dword [es:BOOT_LFB], 0xFFFFFFFF; 0x800000
; VESA 1.2 PM BANK SWITCH ADDRESS
.vesa12:
mov ax, 0x4f0A
xor bx, bx
int 0x10
xor eax, eax
xor ebx, ebx
mov ax, es
shl eax, 4
mov bx, di
add eax, ebx
movzx ebx, word[es:di]
add eax, ebx
push 0x0000
pop es
mov [es:0x9014], eax
.exit:
ret
;=============================================================================
;=============================================================================
;=============================================================================

View File

@ -1,89 +0,0 @@
@echo off
set languages=en ru ge et
call :Check_Lang %1
for %%a in (ru) do if %%a==%target%
call :Target_%target%
if ERRORLEVEL 0 goto Exit_OK
echo There was an error executing script.
echo For any help, please send a report.
pause
goto :eof
:Check_Lang
set res=%1
:Check_Lang_loop
for %%a in (%languages%) do if %%a==%res% set lang=%res%
if defined lang call :make_all goto :eof
echo Language '%res%' is incorrect
echo Enter valid language [ %languages% ]:
set /P res=">
goto Check_Lang_loop
goto :eof
:make_all
echo *** building module Kolibri.ldm for Secondary Loader with language '%lang%' ...
if not exist bin mkdir bin
echo lang fix %lang% > lang.inc
fasm -m 65536 kolibri_ldm.asm bin\kolibri.ldm
if not %errorlevel%==0 goto :Error_FasmFailed
erase lang.inc
goto Exit_OK
:Target_all
call :Target_kernel
call :Target_drivers
call :Target_skins
goto :eof
:Target_drivers
echo *** building drivers ...
if not exist bin\drivers mkdir bin\drivers
cd drivers
for %%a in (%drivers%) do (
fasm -m 65536 %%a.asm ..\bin\drivers\%%a.obj
if not %errorlevel%==0 goto :Error_FasmFailed
)
cd ..
move bin\drivers\vmode.obj bin\drivers\vmode.mdr
goto :eof
:Target_skins
echo *** building skins ...
if not exist bin\skins mkdir bin\skins
cd skin
fasm -m 65536 default.asm ..\bin\skins\default.skn
if not %errorlevel%==0 goto :Error_FasmFailed
cd ..
goto :eof
:Target_clean
echo *** cleaning ...
rmdir /S /Q bin
goto :Exit_OK
:Error_FasmFailed
echo error: fasm execution failed
erase lang.inc
pause
exit 1
:Exit_OK
echo all operations has been done
pause
exit 0

View File

@ -1,14 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Full ASCII code font
; only õ and ä added
; Kaitz
ET_FNT:
fontfile file "ETFONT.FNT"

View File

@ -1,814 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Last modify Alexey Teplov <Lrz> 2008. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; kolibri_ldm.asm the module for Secondary Loader ;;
;; ;;
;; KolibriOS 16-bit loader module, ;;
;; based on bootcode for KolibriOS ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include "lang.inc"
macro _setcursor row,column
{
mov dx, row*256 + column
call setcursor
}
long_v_table equ 9 ;long of visible video table
size_of_step equ 10
d80x25_bottom_num equ 3
d80x25_top_num equ 4
;It's a module for Secondary Loader to load kolibri OS
;
start_of_code:
cld
; \begin{diamond}[02.12.2005]
; if bootloader sets ax = 'KL', then ds:si points to loader block
; cmp ax, 'KL'
; jnz @f
; mov word [cs:cfgmanager.loader_block], si
; mov word [cs:cfgmanager.loader_block+2], ds
;@@:
; \end{diamond}[02.12.2005]
; if bootloader sets cx = 'HA' and dx = 'RD', then bx contains identifier of source hard disk
; (see comment to bx_from_load)
; cmp cx, 'HA'
; jnz no_hd_load
; cmp dx,'RD'
; jnz no_hd_load
; mov word [cs:bx_from_load], bx ; {SPraid}[13.03.2007]
;no_hd_load:
; set up stack
push cs
pop ss
xor ax, ax
mov sp, ax
; mov ax, 3000h
; mov ss, ax
; mov sp, 0EC00h
; set up segment registers
push cs
pop ds
push cs
pop es
; set videomode
mov ax, 3
int 0x10
;if lang eq ru
; Load & set russian VGA font (RU.INC)
mov bp, RU_FNT1 ; RU_FNT1 - First part
mov bx, 1000h ; 768 bytes
mov cx, 30h ; 48 symbols
mov dx, 80h ; 128 - position of first symbol
mov ax, 1100h
int 10h
mov bp, RU_FNT2 ; RU_FNT2 -Second part
mov bx, 1000h ; 512 bytes
mov cx, 20h ; 32 symbols
mov dx, 0E0h ; 224 - position of first symbol
mov ax, 1100h
int 10h
; End set VGA russian font
;else if lang eq et
; mov bp, ET_FNT ; ET_FNT1
; mov bx, 1000h ;
; mov cx, 255 ; 256 symbols
; xor dx, dx ; 0 - position of first symbol
; mov ax, 1100h
; int 10h
;end if
; draw frames
push 0xb800
pop es
xor di, di
mov ah, 1*16+15
; draw top
mov si, d80x25_top
mov cx, d80x25_top_num * 80
@@:
lodsb
stosw
loop @b
; draw spaces
mov si, space_msg
mov dx, 25 - d80x25_top_num - d80x25_bottom_num
dfl1:
push si
mov cx, 80
@@:
lodsb
stosw
loop @b
pop si
dec dx
jnz dfl1
; draw bottom
mov si, d80x25_bottom
mov cx, d80x25_bottom_num * 80
@@:
lodsb
stosw
loop @b
mov byte [space_msg+80], 0 ; now space_msg is null terminated
_setcursor d80x25_top_num,0
; TEST FOR 386+
mov bx, 0x4000
pushf
pop ax
mov dx, ax
xor ax, bx
push ax
popf
pushf
pop ax
and ax, bx
and dx, bx
cmp ax, dx
jnz cpugood
mov si, not386
sayerr:
call print
jmp $
cpugood:
push 0
popf
sti
; set up esp
movzx esp, sp
push 0
pop es
and word [es:BOOT_IDE_BASE_ADDR], 0
; \begin{Mario79}
; find HDD IDE DMA PCI device
; check for PCI BIOS
mov ax, 0xB101
int 0x1A
jc .nopci
cmp edx, 'PCI '
jnz .nopci
; find PCI class code
; class 1 = mass storage
; subclass 1 = IDE controller
; a) class 1, subclass 1, programming interface 0x80
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x80
xor si, si ; device index = 0
int 0x1A
jnc .found
; b) class 1, subclass 1, programming interface 0x8A
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x8A
xor si, si ; device index = 0
int 0x1A
jnc .found
; c) class 1, subclass 1, programming interface 0x85
mov ax, 0xB103
mov ecx, 1*10000h + 1*100h + 0x85
xor si, si
int 0x1A
jc .nopci
.found:
; get memory base
mov ax, 0xB10A
mov di, 0x20 ; memory base is config register at 0x20
int 0x1A
jc .nopci
and cx, 0xFFF0 ; clear address decode type
mov [es:BOOT_IDE_BASE_ADDR], cx
.nopci:
; \end{Mario79}
mov al, 0xf6 ; Ñáðîñ êëàâèàòóðû, ðàçðåøèòü ñêàíèðîâàíèå
out 0x60, al
xor cx, cx
wait_loop: ; variant 2
; reading state of port of 8042 controller
in al, 64h
and al, 00000010b ; ready flag
; wait until 8042 controller is ready
loopnz wait_loop
;;;/diamond today 5.02.2008
; set keyboard typematic rate & delay
mov al, 0xf3
out 0x60, al
xor cx, cx
@@:
in al, 64h
test al, 2
loopnz @b
mov al, 0
out 0x60, al
xor cx, cx
@@:
in al, 64h
test al, 2
loopnz @b
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; --------------- APM ---------------------
and word [es:BOOT_APM_VERSION], 0 ; ver = 0.0 (APM not found)
mov ax, 0x5300
xor bx, bx
int 0x15
jc apm_end ; APM not found
test cx, 2
jz apm_end ; APM 32-bit protected-mode interface not supported
mov [es:BOOT_APM_VERSION], ax ; Save APM Version
mov [es:BOOT_APM_FLAGS], cx ; Save APM flags
; Write APM ver ----
and ax, 0xf0f
add ax, '00'
mov si, msg_apm
mov [si + 5], ah
mov [si + 7], al
_setcursor 0, 3
call printplain
; ------------------
mov ax, 0x5304 ; Disconnect interface
xor bx, bx
int 0x15
mov ax, 0x5303 ; Connect 32 bit mode interface
xor bx, bx
int 0x15
mov [es:BOOT_APM_ENTRY], ebx
mov [es:BOOT_APM_CODE_32], ax
mov [es:BOOT_APM_CODE_16], cx
mov [es:BOOT_APM_DATA_16], dx
apm_end:
_setcursor d80x25_top_num, 0
;CHECK current of code
cmp [cfgmanager.loader_block], -1
jz noloaderblock
les bx, [cfgmanager.loader_block]
cmp byte [es:bx], 1
mov si, loader_block_error
jnz sayerr
push 0
pop es
noloaderblock:
; DISPLAY VESA INFORMATION
call print_vesa_info
call calc_vmodes_table
call check_first_parm ;check and enable cursor_pos
; \begin{diamond}[30.11.2005]
cfgmanager:
; settings:
; a) preboot_graph = graphical mode
; preboot_gprobe = probe this mode?
; b) preboot_dma = use DMA access?
; c) preboot_vrrm = use VRR?
; determine default settings
mov [.bSettingsChanged], 0
;.preboot_gr_end:
mov di, preboot_device
; if image in memory is present and [preboot_device] is uninitialized,
; set it to use this preloaded image
cmp byte [di], 0
jnz .preboot_device_inited
cmp [.loader_block], -1
jz @f
les bx, [.loader_block]
test byte [es:bx+1], 1
jz @f
mov byte [di], 3
jmp .preboot_device_inited
@@:
; otherwise, set [preboot_device] to 1 (default value - boot from floppy)
mov byte [di], 1
.preboot_device_inited:
; following 6 lines set variables to 1 if its current value is 0
cmp byte [di+preboot_dma-preboot_device], 1
adc byte [di+preboot_dma-preboot_device], 0
cmp byte [di+preboot_biosdisk-preboot_device], 1
adc byte [di+preboot_biosdisk-preboot_device], 0
cmp byte [di+preboot_vrrm-preboot_device], 1
adc byte [di+preboot_vrrm-preboot_device], 0
; notify user
_setcursor 5,2
mov si, linef
call printplain
mov si, start_msg
call print
mov si, time_msg
call print
; get start time
call .gettime
mov [.starttime], eax
mov word [.timer], .newtimer
mov word [.timer+2], cs
.printcfg:
_setcursor 9,0
mov si, current_cfg_msg
call print
mov si, curvideo_msg
call print
call draw_current_vmode
mov si, usebd_msg
cmp [preboot_biosdisk], 1
call .say_on_off
mov si, vrrm_msg
cmp [preboot_vrrm], 1
call .say_on_off
; mov si, preboot_device_msg
; call print
; mov al, [preboot_device]
; and eax, 7
; mov si, [preboot_device_msgs+eax*2]
; call printplain
.show_remarks:
; show remarks in gray color
mov di, ((21-num_remarks)*80 + 2)*2
push 0xB800
pop es
mov cx, num_remarks
mov si, remarks
.write_remarks:
lodsw
push si
xchg ax, si
mov ah, 1*16+7 ; background: blue (1), foreground: gray (7)
push di
.write_remark:
lodsb
test al, al
jz @f
stosw
jmp .write_remark
@@:
pop di
pop si
add di, 80*2
loop .write_remarks
.wait:
_setcursor 25,0 ; out of screen
; set timer interrupt handler
cli
push 0
pop es
push dword [es:8*4]
pop dword [.oldtimer]
push dword [.timer]
pop dword [es:8*4]
; mov eax, [es:8*4]
; mov [.oldtimer], eax
; mov eax, [.timer]
; mov [es:8*4], eax
sti
; wait for keypressed
xor ax, ax
int 16h
push ax
; restore timer interrupt
; push 0
; pop es
mov eax, [.oldtimer]
mov [es:8*4], eax
mov [.timer], eax
_setcursor 7,0
mov si, space_msg
call printplain
; clear remarks and restore normal attributes
push es
mov di, ((21-num_remarks)*80 + 2)*2
push 0xB800
pop es
mov cx, num_remarks
mov ax, ' ' + (1*16 + 15)*100h
@@:
push cx
mov cx, 76
rep stosw
pop cx
add di, 4*2
loop @b
pop es
pop ax
; switch on key
cmp al, 13
jz .continue
or al, 20h
cmp al, 'a'
jz .change_a
cmp al, 'b'
jz .change_b
cmp al, 'c'
jnz .show_remarks
_setcursor 15,0
mov si, vrrmprint
call print
mov bx, '12'
call getkey
mov [preboot_vrrm], al
_setcursor 12,0
.d:
mov [.bSettingsChanged], 1
call clear_vmodes_table ;clear vmodes_table
jmp .printcfg
.change_a:
.loops:
call draw_vmodes_table
_setcursor 25,0 ; out of screen
xor ax, ax
int 0x16
; call clear_table_cursor ;clear current position of cursor
mov si, word [cursor_pos]
cmp ah, 0x48;x,0x48E0 ; up
jne .down
cmp si, modes_table
jbe .loops
sub word [cursor_pos], size_of_step
jmp .loops
.down:
cmp ah, 0x50;x,0x50E0 ; down
jne .pgup
cmp word[es:si+10], -1
je .loops
add word [cursor_pos], size_of_step
jmp .loops
.pgup:
cmp ah, 0x49 ; page up
jne .pgdn
sub si, size_of_step*long_v_table
cmp si, modes_table
jae @f
mov si, modes_table
@@:
mov word [cursor_pos], si
mov si, word [home_cursor]
sub si, size_of_step*long_v_table
cmp si, modes_table
jae @f
mov si, modes_table
@@:
mov word [home_cursor], si
jmp .loops
.pgdn:
cmp ah, 0x51 ; page down
jne .enter
mov ax, [end_cursor]
add si, size_of_step*long_v_table
cmp si, ax
jb @f
mov si, ax
sub si, size_of_step
@@:
mov word [cursor_pos], si
mov si, word [home_cursor]
sub ax, size_of_step*long_v_table
add si, size_of_step*long_v_table
cmp si, ax
jb @f
mov si, ax
@@:
mov word [home_cursor], si
jmp .loops
.enter:
cmp al, 0x0D;x,0x1C0D ; enter
jne .loops
push word [cursor_pos]
pop bp
push word [es:bp]
pop word [x_save]
push word [es:bp+2]
pop word [y_save]
push word [es:bp+6]
pop word [number_vm]
mov word [preboot_graph], bp ;save choose
jmp .d
.change_b:
_setcursor 15,0
; mov si, ask_dma
; call print
; mov bx, '13'
; call getkey
; mov [preboot_dma], al
mov si, ask_bd
call print
mov bx, '12'
call getkey
mov [preboot_biosdisk], al
_setcursor 11,0
jmp .d
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.say_on_off:
pushf
call print
mov si, on_msg
popf
jz @f
mov si, off_msg
@@:
jmp printplain
; novesa and vervesa strings are not used at the moment of executing this code
virtual at novesa
.oldtimer dd ?
.starttime dd ?
.bSettingsChanged db ?
.timer dd ?
end virtual
.loader_block dd -1
.gettime:
mov ah, 0
int 1Ah
xchg ax, cx
shl eax, 10h
xchg ax, dx
ret
.newtimer:
push ds
push cs
pop ds
pushf
call [.oldtimer]
pushad
call .gettime
sub eax, [.starttime]
sub ax, 18*5
jae .timergo
neg ax
add ax, 18-1
mov bx, 18
xor dx, dx
div bx
if lang eq ru
; ¯®¤®¦¤¨â¥ 5 ᥪ㭤, 4/3/2 ᥪ㭤ë, 1 ᥪ㭤ã
cmp al, 5
mov cl, ' '
jae @f
cmp al, 1
mov cl, 'ã'
jz @f
mov cl, 'ë'
@@:
mov [time_str+9], cl
else if lang eq et
cmp al, 1
ja @f
mov [time_str+9], ' '
mov [time_str+10], ' '
@@:
else
; wait 5/4/3/2 seconds, 1 second
cmp al, 1
mov cl, 's'
ja @f
mov cl, ' '
@@:
mov [time_str+9], cl
end if
add al, '0'
mov [time_str+1], al
mov si, time_msg
_setcursor 7,0
call print
_setcursor 25,0
popad
pop ds
iret
.timergo:
push 0
pop es
mov eax, [.oldtimer]
mov [es:8*4], eax
mov sp, 0EC00h
.continue:
sti
_setcursor 6,0
mov si, space_msg
call printplain
call printplain
_setcursor 6,0
mov si, loading_msg
call print
_setcursor 15,0
cmp [.bSettingsChanged], 0
jz .load
cmp [.loader_block], -1
jz .load
les bx, [.loader_block]
mov eax, [es:bx+3]
push ds
pop es
test eax, eax
jz .load
push eax
mov si, save_quest
call print
.waityn:
mov ah, 0
int 16h
or al, 20h
cmp al, 'n'
jz .loadc
cmp al, 'y'
jnz .waityn
call putchar
mov byte [space_msg+80], 186
pop eax
push cs
push .cont
push eax
retf
.loadc:
pop eax
.cont:
push cs
pop ds
mov si, space_msg
mov byte [si+80], 0
_setcursor 15,0
call printplain
_setcursor 15,0
.load:
; \end{diamond}[02.12.2005]
; ASK GRAPHICS MODE
call set_vmode
; GRAPHICS ACCELERATION
; force yes
mov [es:BOOT_MTRR], byte 1
; DMA ACCESS TO HD
mov al, [preboot_dma]
mov [es:BOOT_DMA], al
; VRR_M USE
; mov al, [preboot_vrrm]
; mov [es:0x9030], al
; BOOT DEVICE
mov al, [preboot_device]
dec al
mov [boot_dev], al
;;;;;;;;;;; set videomode
xor ax, ax
mov es, ax
mov ax, [es:BOOT_VESA_MODE] ; vga & 320x200
mov bx, ax
cmp ax, 0x13
je setgr
cmp ax, 0x12
je setgr
mov ax, 0x4f02 ; Vesa
setgr:
int 0x10
test ah, ah
mov si, fatalsel
jnz v_mode_error
; set mode 0x12 graphics registers:
cmp bx, 0x12
jne gmok2
mov al, 0x05
mov dx, 0x03ce
push dx
out dx, al ; select GDC mode register
mov al, 0x02
inc dx
out dx, al ; set write mode 2
mov al, 0x02
mov dx, 0x03c4
out dx, al ; select VGA sequencer map mask register
mov al, 0x0f
inc dx
out dx, al ; set mask for all planes 0-3
mov al, 0x08
pop dx
out dx, al ; select GDC bit mask register
; for writes to 0x03cf
gmok2:
push ds
pop es
jmp $
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include "lang.inc"
include "bootstr.inc" ; language-independent boot messages
;if lang eq en
;include "booteng.inc" ; english system boot messages
;else if lang eq ru
include "bootru.inc" ; russian system boot messages
include "ru.inc" ; Russian font
;else if lang eq et
;include "bootet.inc" ; estonian system boot messages
;include "et.inc" ; Estonian font
;else
;include "bootge.inc" ; german system boot messages
;end if
include 'macros.inc'
include 'bootvesa.inc'
include "preboot.inc"
setcursor:
; in: dl=column, dh=row
mov ah, 2
mov bh, 0
int 10h
ret
putchar:
; in: al=character
mov ah, 0Eh
mov bh, 0
int 10h
ret
print:
; in: si->string
mov al, 186
call putchar
mov al, ' '
call putchar
printplain:
; in: si->string
pusha
lodsb
@@:
call putchar
lodsb
cmp al, 0
jnz @b
popa
ret
getkey:
; get number in range [bl,bh] (bl,bh in ['0'..'9'])
; in: bx=range
; out: ax=digit (1..9, 10 for 0)
mov ah, 0
int 16h
cmp al, bl
jb getkey
cmp al, bh
ja getkey
push ax
call putchar
pop ax
and ax, 0Fh
jnz @f
mov al, 10
@@:
ret

View File

@ -1,86 +0,0 @@
; structure definition helper
macro struct name, [arg]
{
common
name@struct equ name
struc name arg {
}
macro struct_helper name
{
match xname,name
\{
virtual at 0
xname xname
sizeof.#xname = $ - xname
name equ sizeof.#xname
end virtual
\}
}
ends fix } struct_helper name@struct
;// mike.dld, 2006-29-01 [
; macros definition
macro diff16 title,l1,l2
{
local s,d
s = l2-l1
display title,': 0x'
repeat 16
d = 48 + s shr ((16-%) shl 2) and $0F
if d > 57
d = d + 65-57-1
end if
display d
end repeat
display 13,10
}
macro diff10 title,l1,l2
{
local s,d,z,m
s = l2-l1
z = 0
m = 1000000000
display title,': '
repeat 10
d = '0' + s / m
s = s - (s/m)*m
m = m / 10
if d <> '0'
z = 1
end if
if z <> 0
display d
end if
end repeat
display 13,10
}
; \begin{diamond}[29.09.2006]
; may be useful for kernel debugging
; example 1:
; dbgstr 'Hello, World!'
; example 2:
; dbgstr 'Hello, World!', save_flags
macro dbgstr string*, f
{
local a
iglobal_nested
a db 'K : ',string,13,10,0
endg_nested
if ~ f eq
pushfd
end if
push esi
mov esi, a
call sys_msg_board_str
pop esi
if ~ f eq
popfd
end if
}
; \end{diamond}[29.09.2006]

View File

@ -1,36 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
display_modechg db 0 ; display mode change for text, yes/no (0 or 2)
;
; !! Important note !!
;
; Must be set to 2, to avoid two screenmode
; changes within a very short period of time.
display_atboot db 0 ; show boot screen messages ( 2-no )
preboot_graph dw 0 ; graph mode
x_save dw 0 ; x
y_save dw 0 ; y
number_vm dw 0 ;
;pixel_save dw 0 ; per to pixel
preboot_gprobe db 0 ; probe vesa3 videomodes (1-no, 2-yes)
preboot_vrrm db 0 ; use VRR_M (1-yes, 2- no)
preboot_dma db 0 ; use DMA for access to HDD (1-always, 2-only for read, 3-never)
preboot_device db 0 ; boot device
; (1-floppy 2-harddisk 3-kernel restart 4-format ram disk)
;!!!! 0 - autodetect !!!!
preboot_blogesc = 0 ; start immediately after bootlog
preboot_biosdisk db 0 ; use V86 to access disks through BIOS (1-yes, 2-no)
; if $>0x200
;ERROR: prebooting parameters must fit in first sector!!!
; end if
;hdsysimage db 'KOLIBRI IMG' ; load from
;image_save db 'KOLIBRI IMG' ; save to

View File

@ -1,123 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; READ RAMDISK IMAGE FROM HD
cmp [boot_dev+OS_BASE+0x10000], 1
jne no_sys_on_hd
test [DRIVE_DATA+1], byte 0x40
jz position_2
mov [hdbase], 0x1f0
mov [hdid], 0x0
mov [hdpos], 1
mov [fat32part], 0
position_1_1:
inc [fat32part]
call search_and_read_image
cmp [image_retrieved], 1
je yes_sys_on_hd
movzx eax, byte [DRIVE_DATA+2]
cmp [fat32part], eax
jle position_1_1
position_2:
test [DRIVE_DATA+1], byte 0x10
jz position_3
mov [hdbase], 0x1f0
mov [hdid], 0x10
mov [hdpos], 2
mov [fat32part], 0
position_2_1:
inc [fat32part]
call search_and_read_image
cmp [image_retrieved], 1
je yes_sys_on_hd
movzx eax, byte [DRIVE_DATA+3]
cmp eax, [fat32part]
jle position_2_1
position_3:
test [DRIVE_DATA+1], byte 0x4
jz position_4
mov [hdbase], 0x170
mov [hdid], 0x0
mov [hdpos], 3
mov [fat32part], 0
position_3_1:
inc [fat32part]
call search_and_read_image
cmp [image_retrieved], 1
je yes_sys_on_hd
movzx eax, byte [DRIVE_DATA+4]
cmp eax, [fat32part]
jle position_3_1
position_4:
test [DRIVE_DATA+1], byte 0x1
jz no_sys_on_hd
mov [hdbase], 0x170
mov [hdid], 0x10
mov [hdpos], 4
mov [fat32part], 0
position_4_1:
inc [fat32part]
call search_and_read_image
cmp [image_retrieved], 1
je yes_sys_on_hd
movzx eax, byte [DRIVE_DATA+5]
cmp eax, [fat32part]
jle position_4_1
jmp yes_sys_on_hd
search_and_read_image:
call set_FAT32_variables
mov edx, bootpath
call read_image
test eax, eax
jz image_present
mov edx, bootpath2
call read_image
test eax, eax
jz image_present
ret
image_present:
mov [image_retrieved], 1
ret
read_image:
mov eax, hdsysimage+OS_BASE+0x10000
mov ebx, 1474560/512
mov ecx, RAMDISK
mov esi, 0
mov edi, 12
call file_read
ret
image_retrieved db 0
counter_of_partitions db 0
no_sys_on_hd:
; test_to_format_ram_disk (need if not using ram disk)
cmp [boot_dev+OS_BASE+0x10000], 3
jne not_format_ram_disk
; format_ram_disk
mov edi, RAMDISK
mov ecx, 0x1080
xor eax, eax
@@:
stosd
loop @b
mov ecx, 0x58F7F
mov eax, 0xF6F6F6F6
@@:
stosd
loop @b
mov [RAMDISK+0x200], dword 0xFFFFF0 ; fat table
mov [RAMDISK+0x4200], dword 0xFFFFF0
not_format_ram_disk:
yes_sys_on_hd:

View File

@ -1,100 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Generated by RUFNT.EXE
; By BadBugsKiller (C)
; Modifyed by BadBugsKiller 12.01.2004 17:45
; Øðèôò óìåíüøåí â ðàçìåðå è òåïåðü ñîñòîèò èç 2-óõ ÷àñòåé,
; ñîäåðæàùèõ òîëüêî ñèìâîëû ðóññêîãî àëôàâèòà.
; ñèìâîëû â êîäèðîâêå ASCII (ÄÎÑ'îâñêàÿ), êîäîâàÿ ñòðàíèöà 866.
RU_FNT1:
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFE, 0x62, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0x81, 0x00, 0x00
db 0x00, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xDB, 0xDB, 0x5A, 0x5A, 0x7E, 0x7E, 0x5A, 0xDB, 0xDB, 0xDB, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xE6, 0x66, 0x6C, 0x6C, 0x78, 0x78, 0x6C, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x1F, 0x36, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xCF, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xFF, 0xDB, 0x99, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x7C, 0x38, 0x38, 0x7C, 0x6C, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
db 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFF, 0x03, 0x03, 0x00, 0x00
db 0x00, 0x00, 0xF8, 0xF0, 0xB0, 0x30, 0x3E, 0x33, 0x33, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xC3, 0xC3, 0xC3, 0xC3, 0xF3, 0xDB, 0xDB, 0xDB, 0xDB, 0xF3, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x7C, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x26, 0x3E, 0x26, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x3F, 0x66, 0x66, 0x66, 0x3E, 0x3E, 0x66, 0x66, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x02, 0x06, 0x7C, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x62, 0x62, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xFF, 0xC3, 0xC3, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0x54, 0x7C, 0x54, 0xD6, 0xD6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xCE, 0xD6, 0xE6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xE6, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x36, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xD6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00
RU_FNT2:
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
db 0x00, 0x00, 0x00, 0x3C, 0x18, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x18, 0x18, 0x3C, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x38, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFF, 0x03, 0x03, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xFE, 0x03, 0x03, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xB0, 0xB0, 0x3E, 0x33, 0x33, 0x7E, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xF6, 0xDE, 0xDE, 0xF6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0x06, 0x3E, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0xCE, 0xDB, 0xDB, 0xFB, 0xDB, 0xDB, 0xCE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xC6, 0xC6, 0x7E, 0x36, 0x66, 0xE7, 0x00, 0x00, 0x00, 0x00
db 0x6C, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x7C, 0xC6, 0xC6, 0xFC, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC8, 0xF8, 0xC8, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xF8, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x66, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x6C, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00
db 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x6C, 0x38, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0xC6, 0x7C, 0x00
db 0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0xCF, 0xCD, 0xEF, 0xEC, 0xFF, 0xDC, 0xDC, 0xCC, 0xCC, 0xCC, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

View File

@ -1,207 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Shutdown for Menuet ;;
;; ;;
;; Distributed under General Public License ;;
;; See file COPYING for details. ;;
;; Copyright 2003 Ville Turjanmaa ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 4
pr_mode_exit:
; setup stack
mov ax, 0x3000
mov ss, ax
mov esp, 0x0EC00
; setup ds
push cs
pop ds
lidt [old_ints_h]
;remap IRQs
mov al, 0x11
out 0x20, al
call rdelay
out 0xA0, al
call rdelay
mov al, 0x08
out 0x21, al
call rdelay
mov al, 0x70
out 0xA1, al
call rdelay
mov al, 0x04
out 0x21, al
call rdelay
mov al, 0x02
out 0xA1, al
call rdelay
mov al, 0x01
out 0x21, al
call rdelay
out 0xA1, al
call rdelay
mov al, 0xB8
out 0x21, al
call rdelay
mov al, 0xBD
out 0xA1, al
sti
temp_3456:
xor ax, ax
mov es, ax
mov al, byte [es:0x9030]
cmp al, 1
jl nbw
cmp al, 4
jle nbw32
nbw:
in al, 0x60
cmp al, 6
jae nbw
mov bl, al
nbw2:
in al, 0x60
cmp al, bl
je nbw2
cmp al, 240;ax,240
jne nbw31
mov al, bl
dec ax
jmp nbw32
nbw31:
add bl, 128
cmp al, bl
jne nbw
sub al, 129
nbw32:
dec ax
dec ax ; 2 = power off
jnz no_apm_off
call APM_PowerOff
jmp $
no_apm_off:
dec ax ; 3 = reboot
jnz restart_kernel ; 4 = restart kernel
push 0x40
pop ds
mov word[0x0072], 0x1234
jmp 0xF000:0xFFF0
rdelay:
ret
APM_PowerOff:
mov ax, 5304h
xor bx, bx
int 15h
;!!!!!!!!!!!!!!!!!!!!!!!!
mov ax, 0x5300
xor bx, bx
int 0x15
push ax
mov ax, 0x5301
xor bx, bx
int 0x15
mov ax, 0x5308
mov bx, 1
mov cx, bx
int 0x15
mov ax, 0x530E
xor bx, bx
pop cx
int 0x15
mov ax, 0x530D
mov bx, 1
mov cx, bx
int 0x15
mov ax, 0x530F
mov bx, 1
mov cx, bx
int 0x15
mov ax, 0x5307
mov bx, 1
mov cx, 3
int 0x15
;!!!!!!!!!!!!!!!!!!!!!!!!
ret
restart_kernel:
mov ax, 0x0003 ; set text mode for screen
int 0x10
jmp 0x4000:0000
restart_kernel_4000:
cli
push ds
pop es
mov cx, 0x8000
push cx
push 0x7000
pop ds
xor si, si
xor di, di
rep movsw
pop cx
mov ds, cx
push 0x2000
pop es
rep movsw
push 0x9000
pop ds
push 0x3000
pop es
mov cx, 0xE000/2
rep movsw
wbinvd ; write and invalidate cache
mov al, 00110100b
out 43h, al
jcxz $+2
mov al, 0xFF
out 40h, al
jcxz $+2
out 40h, al
jcxz $+2
sti
; (hint by Black_mirror)
; We must read data from keyboard port,
; because there may be situation when previous keyboard interrupt is lost
; (due to return to real mode and IRQ reprogramming)
; and next interrupt will not be generated (as keyboard waits for handling)
in al, 0x60
; bootloader interface
push 0x1000
pop ds
mov si, kernel_restart_bootblock
mov ax, 'KL'
jmp 0x1000:0000

View File

@ -5,7 +5,7 @@
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 5164 $
$Revision: 5363 $
struct BLITTER_BLOCK
@ -37,7 +37,7 @@ block_clip:
;esi= clip RECT ptr
;edi= RECT ptr
;return code:
;eax= 0 - draw, 1 - don't draw
;CF= 0 - draw, 1 - don't draw
push ebx
@ -53,18 +53,15 @@ block_clip:
jl .fail
cmp eax, ecx ;left >= clip.left
jae @F
jge @F
mov eax, ecx
mov [edi+RECT.left], ecx
@@:
mov [edi+RECT.left], eax
cmp ebx, edx ;right <= clip.right
jle @f
mov ebx, edx
@@:
mov [edi+RECT.right], ebx
mov [edi+RECT.right], edx
@@:
mov eax, [edi+RECT.top]
mov ebx, [edi+RECT.bottom]
mov ecx, [esi+RECT.top] ;clip.top
@ -77,29 +74,30 @@ block_clip:
jl .fail
cmp eax, ecx ;top >= clip.top
jae @F
jge @F
mov eax, ecx
mov [edi+RECT.top], ecx
@@:
mov [edi+RECT.top], eax
cmp ebx, edx ;bottom <= clip.bottom
jle @f
mov ebx, edx
mov [edi+RECT.bottom], edx
@@:
mov [edi+RECT.bottom], ebx
pop ebx
xor eax, eax
clc
ret
.fail:
pop ebx
mov eax, 1
stc
ret
align 4
blit_clip:
;return code:
;CF= 0 - draw, 1 - don't draw
.sx0 equ 8
.sy0 equ 12
.sx1 equ 16
@ -130,9 +128,7 @@ blit_clip:
lea esi, [ebx+BLITTER.sc]
call block_clip
test eax, eax
mov esi, 1
jnz .done
jc .done
mov edi, [esp+.sx0]
mov edx, [ebx+BLITTER.dst_x]
@ -157,9 +153,7 @@ blit_clip:
lea edi, [esp+.dx0]
lea esi, [ebx+BLITTER.dc]
call block_clip
test eax, eax
mov esi, 1
jnz .done
jc .done
mov edx, [esp+.dx0]
mov eax, [esp+.dx1]
@ -182,9 +176,8 @@ blit_clip:
mov [ebx+BLITTER.src_y], ecx
mov [ebx+BLITTER.dst_x], edx
mov [ebx+BLITTER.dst_y], eax
xor esi, esi
clc
.done:
mov eax, esi
add esp, 40
pop ebx
pop esi
@ -205,16 +198,17 @@ purge .dy1
align 4
blit_32:
.x_y equ 72
.tmp_x_y equ 76
push ebp
push edi
push esi
push ebx
sub esp, 80
virtual at sizeof.BLITTER
.position dd ? ; (x shl 16) + y
; ???
.extra_var1 dd ?
.local_vars_size = $
end virtual
sub esp, .local_vars_size
mov eax, [TASK_BASE]
mov ebx, [eax-twdw + WDATA.box.width]
@ -254,14 +248,13 @@ blit_32:
mov eax, [ecx+32]
mov [esp+56], eax
mov [esp+BLITTER.bitmap], eax
mov eax, [ecx+36]
mov [esp+60], eax
mov [esp+BLITTER.stride], eax
mov ecx, esp
call blit_clip
test eax, eax
jne .done
jc .L57
mov eax, [TASK_BASE]
@ -271,13 +264,21 @@ blit_32:
add ebp, [eax-twdw + WDATA.box.top]
mov ecx, ebx
add ecx, [esp+BLITTER.w]
shl ecx, 16
mov cx, bp
mov [esp+.x_y], ecx
add ecx, [esp+BLITTER.h]
mov eax, ebx
shl eax, 16
mov ax, bp
mov [esp+.position], eax
mov edi, ebp
; imul edi, [_display.pitch]
mov edi, [BPSLine_calc_area+edi*4]
; imul ebp, [_display.width]
mov ebp, [d_width_calc_area+ebp*4]
add ebp, ebx
@ -289,155 +290,236 @@ blit_32:
lea esi, [eax+esi*4]
add esi, [esp+BLITTER.bitmap]
mov eax, ecx
mov ecx, [esp+BLITTER.h]
mov edx, [esp+BLITTER.w]
test ecx, ecx ;FIXME check clipping
jz .done
jz .L57
test edx, edx
jz .done
jz .L57
cmp [_display.bits_per_pixel], 32
jne .core_24
lea edi, [edi+ebx*4]
; xchg bx, bx
mov ebx, [CURRENT_TASK]
mov ecx, [esp+80]
shr ecx, 4
and ecx, 3
jmp dword [.tbl_32+ecx*4]
; check for hardware cursor
cmp [_display.select_cursor], select_cursor
je .core_32.software_cursor
cmp [_display.select_cursor], 0
jne .core_32.hardware_cursor
;--------------------------------------
.core_32.software_cursor:
align 4
.outer32:
align 4
.tbl_32 dd blit_copy_32
dd blit_copy_32_bgr
dd blit_trans_32
dd blit_trans_32_bgr
.inner32:
cmp [ebp], bl
jne .skip
;--------------------------------------
mov eax, [esi]
mov ecx, [esp+.position]
; check mouse area for putpixel
call [_display.check_mouse]
;--------------------------------------
; store to real LFB
mov [LFB_BASE+edi], eax
;--------------------------------------
align 4
.skip:
add esi, 4
add edi, 4
inc ebp
add [esp+.position], 1 shl 16
dec edx
jnz .inner32
add esi, [esp+BLITTER.stride]
add edi, [_display.lfb_pitch]
add ebp, [_display.width]
mov edx, [esp+BLITTER.w]
mov eax, edx
inc [esp+.position]
sub ebp, edx
shl eax, 2
sub esi, eax
sub edi, eax
shl eax, 16-2
sub [esp+.position], eax
dec [esp+BLITTER.h]
jnz .outer32
jmp .done
.core_32.hardware_cursor:
align 4
.hw.outer32:
xor ecx, ecx
align 4
.hw.inner32:
cmp [ebp+ecx], bl
jne .hw.skip
mov eax, [esi+ecx*4]
mov [LFB_BASE+edi+ecx*4], eax
align 4
.hw.skip:
inc ecx
dec edx
jnz .hw.inner32
add esi, [esp+BLITTER.stride]
add edi, [_display.lfb_pitch]
add ebp, [_display.width]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .hw.outer32
.done:
add esp, 80
; call [draw_pointer]
; call __sys_draw_pointer
.L57:
add esp, .local_vars_size
pop ebx
pop esi
pop edi
pop ebp
ret
align 4
blit_copy_32_bgr:
mov ebx, 1
.core_24:
cmp [_display.bits_per_pixel], 24
jne .core_16
lea ebx, [ebx+ebx*2]
lea edi, [LFB_BASE+edi+ebx]
mov ebx, [CURRENT_TASK]
align 4
blit_copy_32:
.outer32:
mov eax, [esp+.x_y]
mov [esp+.tmp_x_y], eax
.outer24:
mov [esp+.extra_var1], edi
xor ecx, ecx
align 4
.inner32:
cmp [ebp+ecx], bl
jne .skip
.inner24:
cmp [ebp+ecx], bl ; Does the process own this pixel?
jne .skip_1
;--------------------------------------
push eax
mov eax, [esi+ecx*4]
lea edi, [edi+ecx*2]
; check for hardware cursor
cmp [_display.select_cursor], select_cursor
je @f
cmp [_display.select_cursor], 0
jne .no_mouseunder
;--------------------------------------
align 4
@@:
push ecx
mov ecx, [esp+4+.tmp_x_y]
; check mouse area for putpixel
call [_display.check_mouse]
pop ecx
;--------------------------------------
align 4
.no_mouseunder:
; store to real LFB
mov [LFB_BASE+edi+ecx*4], eax
;--------------------------------------
align 4
.skip:
add [esp+.tmp_x_y], dword 0x10000
inc ecx
dec edx
jnz .inner32
add esi, [esp+BLITTER.stride]
add edi, [_display.lfb_pitch]
add ebp, [_display.width]
inc dword [esp+.x_y]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .outer32
jmp blit_32.done
align 4
blit_trans_32_bgr:
mov ebx, 1
align 4
blit_trans_32:
.outer32:
mov eax, [esp+.x_y]
mov [esp+.tmp_x_y], eax
xor ecx, ecx
align 4
.inner32:
cmp [ebp+ecx], bl
jne .skip
;--------------------------------------
mov eax, [esi+ecx*4]
test eax, 0xFF000000
jz .skip
; check for hardware cursor
cmp [_display.select_cursor], select_cursor
je @f
cmp [_display.select_cursor], 0
jne .no_mouseunder
jne .no_mouseunder_1
;--------------------------------------
align 4
@@:
push ecx
mov ecx, [esp+4+.tmp_x_y]
mov ecx, [esp+4]
ror ecx, 16
sub ecx, edx
rol ecx, 16
sub ecx, [esp+BLITTER.h + 8]
; check mouse area for putpixel
call [_display.check_mouse]
pop ecx
;--------------------------------------
align 4
.no_mouseunder:
; store to real LFB
mov [LFB_BASE+edi+ecx*4], eax
.no_mouseunder_1:
mov [edi+ecx], ax
shr eax, 16
mov [edi+ecx+2], al
pop eax
;--------------------------------------
align 4
.skip:
add [esp+.tmp_x_y], dword 0x10000
.skip_1:
inc ecx
dec edx
jnz .inner32
jnz .inner24
add esi, [esp+BLITTER.stride]
mov edi, [esp+.extra_var1]
add edi, [_display.lfb_pitch]
add ebp, [_display.width]
inc dword [esp+.x_y]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .outer32
jnz .outer24
jmp .done
.core_16:
lea edi, [LFB_BASE+edi+ebx*2]
mov ebx, [CURRENT_TASK]
.outer16:
mov [esp+.extra_var1], edi
xor ecx, ecx
.inner16:
cmp [ebp+ecx], bl ; Does the process own this pixel?
jne .skip_2
;--------------------------------------
push eax
mov eax, [esi+ecx*4]
; check for hardware cursor
cmp [_display.select_cursor], select_cursor
je @f
cmp [_display.select_cursor], 0
jne .no_mouseunder_2
;--------------------------------------
@@:
push ecx
mov ecx, [esp+4]
ror ecx, 16
sub ecx, edx
rol ecx, 16
sub ecx, [esp+BLITTER.h + 8]
; check mouse area for putpixel
call [_display.check_mouse]
pop ecx
;--------------------------------------
.no_mouseunder_2:
; convert to 16 bpp and store to LFB
and eax, 00000000111110001111110011111000b
shr ah, 2
shr ax, 3
ror eax, 8
add al, ah
rol eax, 8
mov [edi+ecx*2], ax
pop eax
;--------------------------------------
.skip_2:
inc ecx
dec edx
jnz .inner16
add esi, [esp+BLITTER.stride]
mov edi, [esp+.extra_var1]
add edi, [_display.lfb_pitch]
add ebp, [_display.width]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .outer16
jmp .done
jmp blit_32.done

View File

@ -84,7 +84,7 @@ Vesa20_getpixel24:
@@:
; check mouse area for putpixel
test ecx, 0x04000000 ; don't load to mouseunder area
test ecx, 0x04000000 ; don't load to mouseunder area
jnz .no_mouseunder
call [_display.check_m_pixel]
test ecx, ecx ; 0xff000000
@ -94,7 +94,7 @@ Vesa20_getpixel24:
; imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
mov ebx, [BPSLine_calc_area+ebx*4]
lea edi, [eax+eax*2] ; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier)
add edi, ebx ; edi = x*3+(y*y multiplier)
mov ecx, [LFB_BASE+edi]
@@:
@ -116,7 +116,7 @@ Vesa20_getpixel32:
@@:
; check mouse area for putpixel
test ecx, 0x04000000 ; don't load to mouseunder area
test ecx, 0x04000000 ; don't load to mouseunder area
jnz .no_mouseunder
call [_display.check_m_pixel]
test ecx, ecx ; 0xff000000
@ -879,7 +879,7 @@ __sys_putpixel:
jge .exit
cmp ebx, [_display.height]
jge .exit
test edi, 1 ; force ?
test edi, 1 ; force ?
jnz .forced
; not forced
@ -1175,46 +1175,46 @@ dl_dy equ esp+0
pusha
xor edx, edx ; clear edx
xor esi, esi ; unpack arguments
xor edx, edx ; clear edx
xor esi, esi ; unpack arguments
xor ebp, ebp
mov si, ax ; esi = x2
mov bp, bx ; ebp = y2
shr eax, 16 ; eax = x1
shr ebx, 16 ; ebx = y1
push eax ; save x1
push ebx ; save y1
push esi ; save x2
push ebp ; save y2
mov si, ax ; esi = x2
mov bp, bx ; ebp = y2
shr eax, 16 ; eax = x1
shr ebx, 16 ; ebx = y1
push eax ; save x1
push ebx ; save y1
push esi ; save x2
push ebp ; save y2
; checking x-axis...
sub esi, eax ; esi = x2-x1
push esi ; save y2-y1
jl .x2lx1 ; is x2 less than x1 ?
jg .no_vline ; x1 > x2 ?
mov edx, ebp ; else (if x1=x2)
sub esi, eax ; esi = x2-x1
push esi ; save y2-y1
jl .x2lx1 ; is x2 less than x1 ?
jg .no_vline ; x1 > x2 ?
mov edx, ebp ; else (if x1=x2)
call vline
push edx ; necessary to rightly restore stack frame at .exit
push edx ; necessary to rightly restore stack frame at .exit
jmp .exit
.x2lx1:
neg esi ; get esi absolute value
neg esi ; get esi absolute value
.no_vline:
; checking y-axis...
sub ebp, ebx ; ebp = y2-y1
push ebp ; save y2-y1
jl .y2ly1 ; is y2 less than y1 ?
jg .no_hline ; y1 > y2 ?
sub ebp, ebx ; ebp = y2-y1
push ebp ; save y2-y1
jl .y2ly1 ; is y2 less than y1 ?
jg .no_hline ; y1 > y2 ?
mov edx, [dl_x2] ; else (if y1=y2)
call hline
jmp .exit
.y2ly1:
neg ebp ; get ebp absolute value
neg ebp ; get ebp absolute value
.no_hline:
cmp ebp, esi
jle .x_rules ; |y2-y1| < |x2-x1| ?
jle .x_rules ; |y2-y1| < |x2-x1| ?
cmp [dl_y2], ebx ; make sure y1 is at the begining
jge .no_reverse1
neg dword [dl_dx]
@ -1227,9 +1227,9 @@ dl_dy equ esp+0
.no_reverse1:
mov eax, [dl_dx]
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1)
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1)
; correction for the remainder of the division
shl edx, 1
@ -1237,12 +1237,12 @@ dl_dy equ esp+0
jb @f
inc eax
@@:
mov edx, ebp ; edx = counter (number of pixels to draw)
mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 shl 16 ; ebp = dy = 1.0
mov esi, eax ; esi = dx
mov esi, eax ; esi = dx
jmp .y_rules
.x_rules:
cmp [dl_x2], eax ; make sure x1 is at the begining
cmp [dl_x2], eax ; make sure x1 is at the begining
jge .no_reverse2
neg dword [dl_dy]
mov edx, [dl_x2]
@ -1254,18 +1254,18 @@ dl_dy equ esp+0
.no_reverse2:
xor edx, edx
mov eax, [dl_dy]
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv esi ; eax = ((y2-y1)*65536)/(x2-x1)
cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths
idiv esi ; eax = ((y2-y1)*65536)/(x2-x1)
; correction for the remainder of the division
shl edx, 1
cmp esi, edx
jb @f
inc eax
@@:
mov edx, esi ; edx = counter (number of pixels to draw)
mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 shl 16 ; esi = dx = 1.0
mov ebp, eax ; ebp = dy
mov ebp, eax ; ebp = dy
.y_rules:
mov eax, [dl_x1]
@ -2015,7 +2015,7 @@ vesa20_drawbackground_tiled:
dp2:
mov ebp, [draw_data+32+RECT.left] ; x start
; 1) Calculate pointers in WinMapAddress (does pixel belong to OS thread?) [ebp]
; and LFB data (output for our function) [edi]
; and LFB data (output for our function) [edi]
; mov eax, [BytesPerScanLine]
; mul ebx
mov eax, [BPSLine_calc_area+ebx*4]