Rev 387 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 387 | Rev 444 | ||
---|---|---|---|
- | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
- | 2 | ;; ;; |
|
- | 3 | ;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; |
|
- | 4 | ;; Distributed under terms of the GNU General Public License ;; |
|
- | 5 | ;; ;; |
|
- | 6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
1 | ;driver sceletone |
7 | |
2 | 8 | ;driver sceletone |
|
3 | format MS COFF |
9 | |
4 | 10 | format MS COFF |
|
5 | include 'proc32.inc' |
11 | |
6 | include 'imports.inc' |
12 | include 'proc32.inc' |
7 | 13 | include 'imports.inc' |
|
8 | OS_BASE equ 0; |
14 | |
9 | new_app_base equ 0x60400000 |
15 | OS_BASE equ 0; |
10 | PROC_BASE equ OS_BASE+0x0080000 |
16 | new_app_base equ 0x60400000 |
11 | 17 | PROC_BASE equ OS_BASE+0x0080000 |
|
12 | struc IOCTL |
18 | |
13 | { .handle dd ? |
19 | struc IOCTL |
14 | .io_code dd ? |
20 | { .handle dd ? |
15 | .input dd ? |
21 | .io_code dd ? |
16 | .inp_size dd ? |
22 | .input dd ? |
17 | .output dd ? |
23 | .inp_size dd ? |
18 | .out_size dd ? |
24 | .output dd ? |
19 | } |
25 | .out_size dd ? |
20 | 26 | } |
|
21 | virtual at 0 |
27 | |
22 | IOCTL IOCTL |
28 | virtual at 0 |
23 | end virtual |
29 | IOCTL IOCTL |
24 | 30 | end virtual |
|
25 | public START |
31 | |
26 | public service_proc |
32 | public START |
27 | public version |
33 | public service_proc |
28 | 34 | public version |
|
29 | DEBUG equ 1 |
35 | |
30 | 36 | DEBUG equ 1 |
|
31 | DRV_ENTRY equ 1 |
37 | |
32 | DRV_EXIT equ -1 |
38 | DRV_ENTRY equ 1 |
33 | STRIDE equ 4 ;size of row in devices table |
39 | DRV_EXIT equ -1 |
34 | 40 | STRIDE equ 4 ;size of row in devices table |
|
35 | section '.flat' code readable align 16 |
41 | |
36 | 42 | section '.flat' code readable align 16 |
|
37 | proc START stdcall, state:dword |
43 | |
38 | 44 | proc START stdcall, state:dword |
|
39 | cmp [state], 1 |
45 | |
40 | jne .exit |
46 | cmp [state], 1 |
41 | .entry: |
47 | jne .exit |
42 | 48 | .entry: |
|
43 | if DEBUG |
49 | |
44 | mov esi, msgInit |
50 | if DEBUG |
45 | call SysMsgBoardStr |
51 | mov esi, msgInit |
46 | end if |
52 | call SysMsgBoardStr |
47 | 53 | end if |
|
48 | stdcall RegService, my_service, service_proc |
54 | |
49 | ret |
55 | stdcall RegService, my_service, service_proc |
50 | .fail: |
56 | ret |
51 | .exit: |
57 | .fail: |
52 | xor eax, eax |
58 | .exit: |
53 | ret |
59 | xor eax, eax |
54 | endp |
60 | ret |
55 | 61 | endp |
|
56 | handle equ IOCTL.handle |
62 | |
57 | io_code equ IOCTL.io_code |
63 | handle equ IOCTL.handle |
58 | input equ IOCTL.input |
64 | io_code equ IOCTL.io_code |
59 | inp_size equ IOCTL.inp_size |
65 | input equ IOCTL.input |
60 | output equ IOCTL.output |
66 | inp_size equ IOCTL.inp_size |
61 | out_size equ IOCTL.out_size |
67 | output equ IOCTL.output |
62 | 68 | out_size equ IOCTL.out_size |
|
63 | align 4 |
69 | |
64 | proc service_proc stdcall, ioctl:dword |
70 | align 4 |
65 | 71 | proc service_proc stdcall, ioctl:dword |
|
66 | ; mov edi, [ioctl] |
72 | |
67 | ; mov eax, [edi+io_code] |
73 | ; mov edi, [ioctl] |
68 | 74 | ; mov eax, [edi+io_code] |
|
69 | xor eax, eax |
75 | |
70 | ret |
76 | xor eax, eax |
71 | endp |
77 | ret |
72 | 78 | endp |
|
73 | restore handle |
79 | |
74 | restore io_code |
80 | restore handle |
75 | restore input |
81 | restore io_code |
76 | restore inp_size |
82 | restore input |
77 | restore output |
83 | restore inp_size |
78 | restore out_size |
84 | restore output |
79 | 85 | restore out_size |
|
80 | align 4 |
86 | |
81 | proc detect |
87 | align 4 |
82 | locals |
88 | proc detect |
83 | last_bus dd ? |
89 | locals |
84 | endl |
90 | last_bus dd ? |
85 | 91 | endl |
|
86 | xor eax, eax |
92 | |
87 | mov [bus], eax |
93 | xor eax, eax |
88 | inc eax |
94 | mov [bus], eax |
89 | call PciApi |
95 | inc eax |
90 | cmp eax, -1 |
96 | call PciApi |
91 | je .err |
97 | cmp eax, -1 |
92 | 98 | je .err |
|
93 | mov [last_bus], eax |
99 | |
94 | 100 | mov [last_bus], eax |
|
95 | .next_bus: |
101 | |
96 | and [devfn], 0 |
102 | .next_bus: |
97 | .next_dev: |
103 | and [devfn], 0 |
98 | stdcall PciRead32, [bus], [devfn], dword 0 |
104 | .next_dev: |
99 | test eax, eax |
105 | stdcall PciRead32, [bus], [devfn], dword 0 |
100 | jz .next |
106 | test eax, eax |
101 | cmp eax, -1 |
107 | jz .next |
102 | je .next |
108 | cmp eax, -1 |
103 | 109 | je .next |
|
104 | mov edi, devices |
110 | |
105 | @@: |
111 | mov edi, devices |
106 | mov ebx, [edi] |
112 | @@: |
107 | test ebx, ebx |
113 | mov ebx, [edi] |
108 | jz .next |
114 | test ebx, ebx |
109 | 115 | jz .next |
|
110 | cmp eax, ebx |
116 | |
111 | je .found |
117 | cmp eax, ebx |
112 | add edi, STRIDE |
118 | je .found |
113 | jmp @B |
119 | add edi, STRIDE |
114 | 120 | jmp @B |
|
115 | .next: inc [devfn] |
121 | |
116 | cmp [devfn], 256 |
122 | .next: inc [devfn] |
117 | jb .next_dev |
123 | cmp [devfn], 256 |
118 | mov eax, [bus] |
124 | jb .next_dev |
119 | inc eax |
125 | mov eax, [bus] |
120 | mov [bus], eax |
126 | inc eax |
121 | cmp eax, [last_bus] |
127 | mov [bus], eax |
122 | jna .next_bus |
128 | cmp eax, [last_bus] |
123 | xor eax, eax |
129 | jna .next_bus |
124 | ret |
130 | xor eax, eax |
125 | .found: |
131 | ret |
126 | xor eax, eax |
132 | .found: |
127 | inc eax |
133 | xor eax, eax |
128 | ret |
134 | inc eax |
129 | .err: |
135 | ret |
130 | xor eax, eax |
136 | .err: |
131 | ret |
137 | xor eax, eax |
132 | endp |
138 | ret |
133 | 139 | endp |
|
134 | 140 | ||
135 | ;DEVICE_ID equ ; pci device id |
141 | |
136 | ;VENDOR_ID equ ; device vendor id |
142 | ;DEVICE_ID equ ; pci device id |
137 | 143 | ;VENDOR_ID equ ; device vendor id |
|
138 | 144 | ||
139 | ;all initialized data place here |
145 | |
140 | 146 | ;all initialized data place here |
|
141 | align 4 |
147 | |
142 | devices dd (DEVICE_ID shl 16)+VENDOR_ID |
148 | align 4 |
143 | dd 0 ;terminator |
149 | devices dd (DEVICE_ID shl 16)+VENDOR_ID |
144 | 150 | dd 0 ;terminator |
|
145 | version dd 0x00030003 |
151 | |
146 | 152 | version dd 0x00030003 |
|
147 | my_service db 'MY_SERVICE',0 ;max 16 chars include zero |
153 | |
148 | 154 | my_service db 'MY_SERVICE',0 ;max 16 chars include zero |
|
149 | msgInit db 'detect hardware...',13,10,0 |
155 | |
150 | msgPCI db 'PCI accsess not supported',13,10,0 |
156 | msgInit db 'detect hardware...',13,10,0 |
151 | msgFail db 'device not found',13,10,0 |
157 | msgPCI db 'PCI accsess not supported',13,10,0 |
152 | 158 | msgFail db 'device not found',13,10,0 |
|
153 | section '.data' data readable writable align 16 |
159 | |
154 | 160 | section '.data' data readable writable align 16 |
|
155 | ;all uninitialized data place here |
161 | |
- | 162 | ;all uninitialized data place here |