Subversion Repositories Kolibri OS

Rev

Rev 5054 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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