Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 555 → Rev 557

/kernel/trunk/const.inc
334,29 → 334,11
std_application_base_address equ new_app_base
RING0_STACK_SIZE equ (0x2000 - 512) ;512 áàéò äëÿ êîíòåêñòà FPU
 
if 0
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EFL_2 equ (RING0_STACK_SIZE-24)
REG_EAX equ (RING0_STACK_SIZE-28)
REG_ECX equ (RING0_STACK_SIZE-32)
REG_EDX equ (RING0_STACK_SIZE-36)
REG_EBX equ (RING0_STACK_SIZE-40)
REG_ESP equ (RING0_STACK_SIZE-44) ;RING0_STACK_SIZE-20
REG_EBP equ (RING0_STACK_SIZE-48)
REG_ESI equ (RING0_STACK_SIZE-52)
REG_EDI equ (RING0_STACK_SIZE-56)
REG_RET equ (RING0_STACK_SIZE-60) ;irq0.return
end if
 
REG_SS equ (RING0_STACK_SIZE-4)
REG_APP_ESP equ (RING0_STACK_SIZE-8)
REG_EFLAGS equ (RING0_STACK_SIZE-12)
REG_CS equ (RING0_STACK_SIZE-16)
REG_EIP equ (RING0_STACK_SIZE-20)
REG_EAX equ (RING0_STACK_SIZE-24)
REG_ECX equ (RING0_STACK_SIZE-28)
REG_EDX equ (RING0_STACK_SIZE-32)
491,7 → 473,6
end virtual
 
 
 
struc HEAP_DATA
{
.mutex rd 1
/kernel/trunk/core/dll.inc
187,6 → 187,18
endp
 
align 4
proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
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
ret
endp
 
align 4
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
xor eax, eax
xor ebx, ebx
211,6 → 223,19
ret
endp
 
align 4
proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
xor eax, eax
xor ebx, ebx
mov ah, byte [bus]
mov al, 9
mov bh, byte [devfn]
mov bl, byte [reg]
mov ecx, [val]
call pci_write_reg
ret
endp
 
handle equ IOCTL.handle
io_code equ IOCTL.io_code
input equ IOCTL.input
/kernel/trunk/core/exports.inc
19,8 → 19,10
 
szPciApi db 'PciApi', 0
szPciRead32 db 'PciRead32', 0
szPciRead16 db 'PciRead16', 0
szPciRead8 db 'PciRead8', 0
szPciWrite8 db 'PciWrite8',0
szPciWrite16 db 'PciWrite16',0
 
szAllocPage db 'AllocPage',0
szAllocPages db 'AllocPages',0
83,8 → 85,10
 
dd szPciApi , pci_api
dd szPciRead32 , pci_read32
dd szPciRead16 , pci_read16
dd szPciRead8 , pci_read8
dd szPciWrite8 , pci_write8
dd szPciWrite16 , pci_write16
 
dd szAllocPage , alloc_page
dd szAllocPages , alloc_pages
134,7 → 138,6
dd szStrchr , strchr
dd szStrrchr , strrchr
 
 
exp_lfb:
dd szLFBAddress , 0
dd 0 ;terminator, must be zero
/kernel/trunk/core/sched.inc
219,12 → 219,15
mov dword [page_tabs+((tss._io_map_1 and -4096) shr 10)], edx
 
mov eax, [ebx+APPDATA.dir_table]
cmp eax, [esi+APPDATA.dir_table]
je @F
mov cr3, eax
@@:
mov ebx, [ebx+APPDATA.pl0_stack]
add ebx, RING0_STACK_SIZE
mov [tss._esp0], ebx
push graph_data
pop gs
mov ax, graph_data
mov gs, ax
mov ecx, cr0
or ecx, CR0_TS ;set task switch flag
mov cr0, ecx
/kernel/trunk/drivers/imports.inc
32,6 → 32,9
if used PciRead32
extrn PciRead32
end if
if used PciRead16
extrn PciRead16
end if
if used PciRead8
extrn PciRead8
end if
38,6 → 41,9
if used PciWrite8
extrn PciWrite8
end if
if used PciWrite16
extrn PciWrite16
end if
 
if used AllocPage
extrn AllocPage
/kernel/trunk/drivers/usb/usb.asm
0,0 → 1,290
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;driver sceletone
 
format MS COFF
 
API_VERSION equ 0 ;debug
 
include '../proc32.inc'
include '../imports.inc'
 
OS_BASE equ 0x80000000
SLOT_BASE equ OS_BASE+0x0080000
 
struc UHCI
{
.bus dd ?
.devfn dd ?
.io_base dd ?
.mm_base dd ?
.irq dd ?
.flags dd ?
.reset dd ?
.start dd ?
.stop dd ?
.sizeof:
}
 
virtual at 0
UHCI UHCI
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
 
public START
public service_proc
public version
 
DEBUG equ 1
 
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
 
call init
 
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 ?
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, 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:
mov eax, UHCI.sizeof
call Kmalloc
test eax, eax
jz .mem_fail
 
mov ebx, [bus]
mov [eax+UHCI.bus], ebx
 
mov ecx, [devfn]
mov [eax+UHCI.devfn], ecx
ret
.mem_fail:
if DEBUG
mov esi, msgMemFail
call SysMsgBoardStr
end if
.err:
xor eax, eax
ret
endp
 
PCI_BASE equ 0x20
USB_LEGKEY equ 0xC0
 
align 4
proc init
locals
uhci dd ?
endl
 
call detect
test eax, eax
jz .fail
 
mov [uhci], eax
 
stdcall PciRead32, [eax+UHCI.bus], [eax+UHCI.devfn], PCI_BASE
and eax, 0xFFC0
mov esi, [uhci]
mov [esi+UHCI.io_base], eax
 
stdcall uhci_reset, esi
 
 
.fail:
if DEBUG
mov esi, msgDevNotFound
call SysMsgBoardStr
end if
ret
endp
 
UHCI_USBINTR equ 4 ; interrupt register
 
UHCI_USBLEGSUP_RWC equ 0x8f00 ; the R/WC bits
UHCI_USBLEGSUP_RO equ 0x5040 ; R/O and reserved bits
 
UHCI_USBCMD_RUN equ 0x0001 ; RUN/STOP bit
UHCI_USBCMD_HCRESET equ 0x0002 ; Host Controller reset
UHCI_USBCMD_EGSM equ 0x0008 ; Global Suspend Mode
UHCI_USBCMD_CONFIGURE equ 0x0040 ; Config Flag
UHCI_USBINTR_RESUME equ 0x0002 ; Resume interrupt enable
 
 
align 4
proc uhci_reset stdcall, uhci:dword
 
mov esi, [uhci]
stdcall PciRead16, [esi+UHCI.bus], [esi+UHCI.devfn], USB_LEGKEY
test eax, not (UHCI_USBLEGSUP_RO or UHCI_USBLEGSUP_RWC)
jnz .reset
 
mov edx, [esi+UHCI.io_base]
in ax, dx
test ax, UHCI_USBCMD_RUN
jnz .reset
 
test ax, UHCI_USBCMD_CONFIGURE
jz .reset
 
test ax, UHCI_USBCMD_EGSM
jz .reset
ret
.reset:
stdcall PciWrite16, [esi+UHCI.bus], [esi+UHCI.devfn], USB_LEGKEY, UHCI_USBLEGSUP_RWC
 
mov edx, [esi+UHCI.io_base]
mov ax, UHCI_USBCMD_HCRESET
out dx, ax
 
xor eax, eax
out dx, ax
add edx, UHCI_USBINTR
out dx, ax
ret
endp
 
 
DEVICE_ID equ 0x8086; pci device id
VENDOR_ID equ 0x24D4; 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 'UHCI',0 ;max 16 chars include zero
 
msgInit db 'detect hardware...',13,10,0
msgPCI db 'PCI accsess not supported',13,10,0
msgDevNotFound db 'device not found',13,10,0
msgMemFail db 'Kmalloc failed', 10,10,0
;msgFail db 'device not found',13,10,0
 
section '.data' data readable writable align 16
 
;all uninitialized data place here