Subversion Repositories Kolibri OS

Rev

Rev 5054 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2288 clevermous 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
2288 clevermous 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
8
;driver sceletone
9
 
5054 clevermous 10
format PE DLL native 0.05
11
entry START
2288 clevermous 12
 
13
DEBUG        equ 1
14
 
15
API_VERSION     equ 0  ;debug
16
 
17
STRIDE       equ 4      ;size of row in devices table
18
 
19
SRV_GETVERSION  equ 0
20
 
5054 clevermous 21
section '.flat' code readable writable executable
22
include 'proc32.inc'
23
include 'struct.inc'
24
include 'macros.inc'
25
include 'peimport.inc'
2288 clevermous 26
 
5054 clevermous 27
proc START c, state:dword, cmdline:dword
2288 clevermous 28
 
29
        cmp     [state], 1
30
        jne     .exit
31
.entry:
32
 
5054 clevermous 33
        push    esi
2288 clevermous 34
     if DEBUG
35
        mov     esi, msgInit
5054 clevermous 36
        invoke  SysMsgBoardStr
2288 clevermous 37
     end if
5054 clevermous 38
        call    detect
39
        pop     esi
40
        test    eax, eax
41
        jz      .fail
2288 clevermous 42
 
5054 clevermous 43
        invoke  RegService, my_service, service_proc
2288 clevermous 44
        ret
45
.fail:
46
.exit:
47
        xor     eax, eax
48
        ret
49
endp
50
 
51
proc service_proc stdcall, ioctl:dword
52
 
53
        mov     ebx, [ioctl]
5054 clevermous 54
        mov     eax, [ebx+IOCTL.io_code]
2288 clevermous 55
        cmp     eax, SRV_GETVERSION
56
        jne     @F
57
 
5054 clevermous 58
        mov     eax, [ebx+IOCTL.output]
59
        cmp     [ebx+IOCTL.out_size], 4
2288 clevermous 60
        jne     .fail
5054 clevermous 61
        mov     dword [eax], API_VERSION
2288 clevermous 62
        xor     eax, eax
63
        ret
64
@@:
65
.fail:
66
        or      eax, -1
67
        ret
68
endp
69
 
70
proc detect
5054 clevermous 71
        push    ebx
72
        invoke  GetPCIList
73
        mov     ebx, eax
2288 clevermous 74
.next_dev:
5054 clevermous 75
        mov     eax, [eax+PCIDEV.fd]
76
        cmp     eax, ebx
77
        jz      .err
78
        mov     edx, [eax+PCIDEV.vendor_device_id]
2288 clevermous 79
 
5054 clevermous 80
        mov     esi, devices
2288 clevermous 81
@@:
5054 clevermous 82
        cmp     dword [esi], 0
83
        jz      .next_dev
84
        cmp     edx, [esi]
85
        jz      .found
2288 clevermous 86
 
5054 clevermous 87
        add     esi, STRIDE
88
        jmp     @B
2288 clevermous 89
 
90
.found:
91
        xor     eax, eax
92
        inc     eax
5054 clevermous 93
        pop     ebx
2288 clevermous 94
        ret
95
.err:
5054 clevermous 96
        mov     esi, msgFail
97
        invoke  SysMsgBoardStr
2288 clevermous 98
        xor     eax, eax
5054 clevermous 99
        pop     ebx
2288 clevermous 100
        ret
101
endp
102
 
103
DEVICE_ID    equ  1234;  pci device id
104
VENDOR_ID    equ  5678;  device vendor id
105
 
106
 
107
;all initialized data place here
108
 
109
align 4
110
devices      dd (DEVICE_ID shl 16)+VENDOR_ID
111
             dd 0    ;terminator
112
 
113
my_service   db 'MY_SERVICE',0  ;max 16 chars include zero
114
 
115
msgInit      db 'detect hardware...',13,10,0
116
msgFail      db 'device not found',13,10,0
117
 
5054 clevermous 118
align 4
119
data fixups
120
end data