Subversion Repositories Kolibri OS

Rev

Rev 2455 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2455 Rev 5054
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
;driver sceletone
8
;driver sceletone
-
 
9
 
Line 9... Line 10...
9
 
10
format PE DLL native 0.05
Line 10... Line 11...
10
format MS COFF
11
entry START
Line 11... Line -...
11
 
-
 
12
DEBUG        equ 1
-
 
13
 
-
 
14
API_VERSION     equ 0  ;debug
-
 
15
 
-
 
16
include 'proc32.inc'
-
 
17
include 'imports.inc'
-
 
18
 
-
 
19
struc IOCTL
-
 
20
{  .handle      dd ?
-
 
21
   .io_code     dd ?
-
 
22
   .input       dd ?
-
 
23
   .inp_size    dd ?
-
 
24
   .output      dd ?
-
 
25
   .out_size    dd ?
-
 
26
}
-
 
27
 
-
 
28
virtual at 0
-
 
29
  IOCTL IOCTL
-
 
30
end virtual
-
 
31
 
-
 
32
public START
-
 
33
public service_proc
12
 
Line 34... Line 13...
34
public version
13
DEBUG        equ 1
Line 35... Line 14...
35
 
14
 
-
 
15
API_VERSION     equ 0  ;debug
-
 
16
 
-
 
17
STRIDE       equ 4      ;size of row in devices table
-
 
18
 
Line 36... Line 19...
36
DRV_ENTRY    equ 1
19
SRV_GETVERSION  equ 0
Line 37... Line 20...
37
DRV_EXIT     equ -1
20
 
38
STRIDE       equ 4      ;size of row in devices table
21
section '.flat' code readable writable executable
39
 
22
include 'proc32.inc'
Line -... Line 23...
-
 
23
include 'struct.inc'
40
SRV_GETVERSION  equ 0
24
include 'macros.inc'
41
 
25
include 'peimport.inc'
42
section '.flat' code readable align 16
26
 
43
 
27
proc START c, state:dword, cmdline:dword
-
 
28
 
-
 
29
        cmp     [state], 1
-
 
30
        jne     .exit
-
 
31
.entry:
Line 44... Line 32...
44
proc START stdcall, state:dword
32
 
45
 
33
        push    esi
46
        cmp     [state], 1
34
     if DEBUG
47
        jne     .exit
35
        mov     esi, msgInit
48
.entry:
36
        invoke  SysMsgBoardStr
49
 
37
     end if
50
     if DEBUG
38
        call    detect
Line 51... Line -...
51
        mov     esi, msgInit
-
 
52
        call    SysMsgBoardStr
-
 
53
     end if
-
 
54
 
-
 
55
        stdcall RegService, my_service, service_proc
-
 
56
        ret
-
 
57
.fail:
-
 
58
.exit:
-
 
59
        xor     eax, eax
39
        pop     esi
Line 60... Line 40...
60
        ret
40
        test    eax, eax
61
endp
41
        jz      .fail
62
 
42
 
63
handle     equ  IOCTL.handle
43
        invoke  RegService, my_service, service_proc
Line 64... Line 44...
64
io_code    equ  IOCTL.io_code
44
        ret
65
input      equ  IOCTL.input
45
.fail:
66
inp_size   equ  IOCTL.inp_size
46
.exit:
67
output     equ  IOCTL.output
47
        xor     eax, eax
68
out_size   equ  IOCTL.out_size
48
        ret
69
 
49
endp
70
align 4
50
 
71
proc service_proc stdcall, ioctl:dword
51
proc service_proc stdcall, ioctl:dword
72
 
52
 
73
        mov     ebx, [ioctl]
53
        mov     ebx, [ioctl]
74
        mov     eax, [ebx+io_code]
54
        mov     eax, [ebx+IOCTL.io_code]
Line 75... Line -...
75
        cmp     eax, SRV_GETVERSION
-
 
76
        jne     @F
-
 
77
 
-
 
78
        mov     eax, [ebx+output]
-
 
79
        cmp     [ebx+out_size], 4
-
 
80
        jne     .fail
-
 
81
        mov     [eax], dword API_VERSION
-
 
82
        xor     eax, eax
-
 
83
        ret
55
        cmp     eax, SRV_GETVERSION
84
@@:
-
 
85
.fail:
-
 
86
        or      eax, -1
-
 
87
        ret
-
 
88
endp
-
 
89
 
-
 
90
restore   handle
56
        jne     @F
91
restore   io_code
57
 
92
restore   input
58
        mov     eax, [ebx+IOCTL.output]
93
restore   inp_size
-
 
94
restore   output
-
 
95
restore   out_size
-
 
96
 
-
 
97
align 4
-
 
98
proc detect
-
 
99
           locals
59
        cmp     [ebx+IOCTL.out_size], 4
100
            last_bus dd ?
60
        jne     .fail
101
           endl
61
        mov     dword [eax], API_VERSION
102
 
62
        xor     eax, eax
103
        xor     eax, eax
63
        ret
104
        mov     [bus], eax
-
 
Line 105... Line 64...
105
        inc     eax
64
@@:
106
        call    PciApi
65
.fail:
107
        cmp     eax, -1
66
        or      eax, -1
-
 
67
        ret
108
        je      .err
68
endp
109
 
69
 
Line 110... Line -...
110
        mov     [last_bus], eax
-
 
111
 
-
 
112
.next_bus:
-
 
113
        and     [devfn], 0
70
proc detect
114
.next_dev:
71
        push    ebx
115
        stdcall PciRead32, [bus], [devfn], dword 0
72
        invoke  GetPCIList
116
        test    eax, eax
-
 
117
        jz      .next
-
 
118
        cmp     eax, -1
-
 
119
        je      .next
-
 
120
 
-
 
121
        mov     edi, devices
-
 
122
@@:
-
 
123
        mov     ebx, [edi]
-
 
124
        test    ebx, ebx
-
 
125
        jz      .next
-
 
126
 
73
        mov     ebx, eax
127
        cmp     eax, ebx
74
.next_dev:
128
        je      .found
75
        mov     eax, [eax+PCIDEV.fd]
-
 
76
        cmp     eax, ebx
129
 
77
        jz      .err
130
        add     edi, STRIDE
78
        mov     edx, [eax+PCIDEV.vendor_device_id]
-
 
79
 
-
 
80
        mov     esi, devices
131
        jmp     @B
81
@@:
-
 
82
        cmp     dword [esi], 0
132
.next:
83
        jz      .next_dev
133
        inc     [devfn]
84
        cmp     edx, [esi]
Line 134... Line 85...
134
        cmp     [devfn], 256
85
        jz      .found
135
        jb      .next_dev
86
 
Line 157... Line 108...
157
 
108
 
158
align 4
109
align 4
159
devices      dd (DEVICE_ID shl 16)+VENDOR_ID
110
devices      dd (DEVICE_ID shl 16)+VENDOR_ID
Line 160... Line -...
160
             dd 0    ;terminator
-
 
161
 
-
 
162
version      dd (5 shl 16) or (API_VERSION and 0xFFFF)
111
             dd 0    ;terminator
Line 163... Line 112...
163
 
112
 
164
my_service   db 'MY_SERVICE',0  ;max 16 chars include zero
-
 
165
 
113
my_service   db 'MY_SERVICE',0  ;max 16 chars include zero
Line 166... Line -...
166
msgInit      db 'detect hardware...',13,10,0
-
 
167
msgPCI       db 'PCI accsess not supported',13,10,0
114
 
168
msgFail      db 'device not found',13,10,0
115
msgInit      db 'detect hardware...',13,10,0
169
 
116
msgFail      db 'device not found',13,10,0