Rev 4974 | Rev 5363 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4974 | Rev 5005 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
15 | ;; Version 2, June 1991 ;; |
15 | ;; Version 2, June 1991 ;; |
16 | ;; ;; |
16 | ;; ;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 18... | Line 18... | ||
18 | 18 | ||
- | 19 | format PE DLL native |
|
Line 19... | Line 20... | ||
19 | format MS COFF |
20 | entry START |
20 | 21 | ||
- | 22 | CURRENT_API = 0x0200 |
|
Line 21... | Line 23... | ||
21 | API_VERSION = 0x01000100 |
23 | COMPATIBLE_API = 0x0100 |
Line 22... | Line 24... | ||
22 | DRIVER_VERSION = 5 |
24 | API_VERSION = (COMPATIBLE_API shl 16) + CURRENT_API |
23 | 25 | ||
24 | MAX_DEVICES = 16 |
26 | MAX_DEVICES = 16 |
Line -... | Line 27... | ||
- | 27 | ||
- | 28 | DEBUG = 1 |
|
25 | 29 | __DEBUG__ = 1 |
|
26 | DEBUG = 1 |
30 | __DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only |
27 | __DEBUG__ = 1 |
31 | |
28 | __DEBUG_LEVEL__ = 2 ; 1 = verbose, 2 = errors only |
- | |
29 | 32 | section '.flat' readable writable executable |
|
30 | include '../struct.inc' |
33 | |
31 | include '../macros.inc' |
- | |
32 | include '../proc32.inc' |
- | |
33 | include '../imports.inc' |
- | |
34 | include '../fdo.inc' |
- | |
35 | include '../netdrv.inc' |
- | |
36 | - | ||
Line 37... | Line -... | ||
37 | virtual at ebx |
- | |
38 | - | ||
39 | device: |
- | |
40 | 34 | include '../struct.inc' |
|
Line 41... | Line 35... | ||
41 | ETH_DEVICE |
35 | include '../macros.inc' |
- | 36 | include '../proc32.inc' |
|
- | 37 | include '../fdo.inc' |
|
42 | 38 | include '../netdrv_pe.inc' |
|
Line 43... | Line -... | ||
43 | .io_addr dd ? |
- | |
44 | .irq_line db ? |
- | |
45 | .pci_bus dd ? |
- | |
46 | .pci_dev dd ? |
39 | |
47 | 40 | struct device ETH_DEVICE |
|
Line 48... | Line 41... | ||
48 | .flags db ? |
41 | |
- | 42 | io_addr dd ? |
|
- | 43 | irq_line db ? |
|
- | 44 | pci_bus dd ? |
|
- | 45 | pci_dev dd ? |
|
Line 49... | Line 46... | ||
49 | .vendor db ? |
46 | |
50 | - | ||
51 | .memsize db ? |
- | |
52 | .rx_start db ? |
- | |
53 | .tx_start db ? |
- | |
54 | .bmem dd ? |
- | |
Line 55... | Line 47... | ||
55 | .rmem dd ? |
47 | flags db ? |
56 | 48 | vendor db ? |
|
57 | .size = $ - device |
49 | |
58 | 50 | memsize db ? |
|
Line 155... | Line 147... | ||
155 | 147 | ||
Line -... | Line 148... | ||
- | 148 | ISA_MAX_ADDR = 0x400 |
|
- | 149 | ||
- | 150 | ||
- | 151 | ||
156 | ISA_MAX_ADDR = 0x400 |
152 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | 153 | ;; ;; |
|
Line 157... | Line -... | ||
157 | - | ||
158 | - | ||
159 | - | ||
160 | section '.flat' code readable align 16 |
- | |
161 | 154 | ;; proc START ;; |
|
Line 162... | Line 155... | ||
162 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
155 | ;; ;; |
163 | ;; |
156 | ;; (standard driver proc) ;; |
Line 164... | Line -... | ||
164 | ;; proc START |
- | |
165 | ;; |
- | |
166 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
- | |
167 | 157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|
168 | align 4 |
158 | |
169 | proc START stdcall, state:dword |
159 | proc START c, reason:dword, cmdline:dword |
- | 160 | ||
170 | 161 | cmp [reason], DRV_ENTRY |
|
171 | cmp [state], 1 |
- | |
172 | jne .exit |
162 | jne .fail |
173 | .entry: |
163 | |
Line 174... | Line 164... | ||
174 | DEBUGF 1, "Loading driver\n" |
164 | DEBUGF 2,"Loading driver\n" |
Line 175... | Line 165... | ||
175 | stdcall RegService, my_service, service_proc |
165 | invoke RegService, my_service, service_proc |
176 | ret |
166 | ret |
177 | .fail: |
167 | |
- | 168 | .fail: |
|
178 | .exit: |
169 | xor eax, eax |
179 | xor eax, eax |
170 | ret |
Line 180... | Line 171... | ||
180 | ret |
171 | |
181 | 172 | endp |
|
Line 182... | Line 173... | ||
182 | endp |
173 | |
Line 238... | Line 229... | ||
238 | jz .firstdevice_pci |
229 | jz .firstdevice_pci |
Line 239... | Line 230... | ||
239 | 230 | ||
240 | mov ax, [eax+1] ; get the pci bus and device numbers |
231 | mov ax, [eax+1] ; get the pci bus and device numbers |
241 | .nextdevice: |
232 | .nextdevice: |
242 | mov ebx, [esi] |
233 | mov ebx, [esi] |
243 | cmp al, byte[device.pci_bus] |
234 | cmp al, byte[ebx + device.pci_bus] |
244 | jne @f |
235 | jne @f |
245 | cmp ah, byte[device.pci_dev] |
236 | cmp ah, byte[ebx + device.pci_dev] |
246 | je .find_devicenum ; Device is already loaded, let's find it's device number |
237 | je .find_devicenum ; Device is already loaded, let's find it's device number |
247 | @@: |
238 | @@: |
248 | add esi, 4 |
239 | add esi, 4 |
Line 249... | Line 240... | ||
249 | loop .nextdevice |
240 | loop .nextdevice |
250 | 241 | ||
Line 251... | Line 242... | ||
251 | .firstdevice_pci: |
242 | .firstdevice_pci: |
252 | call create_new_struct |
243 | call create_new_struct |
253 | 244 | ||
254 | mov eax, [edx + IOCTL.input] |
245 | mov eax, [edx + IOCTL.input] |
255 | movzx ecx, byte[eax+1] |
246 | movzx ecx, byte[eax+1] |
Line 256... | Line 247... | ||
256 | mov [device.pci_bus], ecx |
247 | mov [ebx + device.pci_bus], ecx |
Line -... | Line 248... | ||
- | 248 | movzx ecx, byte[eax+2] |
|
257 | movzx ecx, byte[eax+2] |
249 | mov [ebx + device.pci_dev], ecx |
Line 258... | Line 250... | ||
258 | mov [device.pci_dev], ecx |
250 | |
Line -... | Line 251... | ||
- | 251 | ; Now, it's time to find the base io addres of the PCI device |
|
259 | 252 | ||
260 | ; Now, it's time to find the base io addres of the PCI device |
- | |
261 | 253 | stdcall PCI_find_io, [ebx + device.pci_bus], [ebx + device.pci_dev] |
|
Line 262... | Line 254... | ||
262 | PCI_find_io |
254 | mov [ebx + device.io_addr], eax |
263 | 255 | ||
264 | ; We've found the io address, find IRQ now |
256 | ; We've found the io address, find IRQ now |
Line 274... | Line 266... | ||
274 | jz .firstdevice_isa |
266 | jz .firstdevice_isa |
275 | movzx edi, word [eax+1] |
267 | movzx edi, word [eax+1] |
276 | mov al, [eax+3] |
268 | mov al, [eax+3] |
277 | .nextdevice_isa: |
269 | .nextdevice_isa: |
278 | mov ebx, [esi] |
270 | mov ebx, [esi] |
279 | cmp edi, [device.io_addr] |
271 | cmp edi, [ebx + device.io_addr] |
280 | jne .maybenext |
272 | jne .maybenext |
281 | cmp al, [device.irq_line] |
273 | cmp al, [ebx + device.irq_line] |
282 | je find_device_num |
274 | je find_device_num |
283 | .maybenext: |
275 | .maybenext: |
284 | add esi, 4 |
276 | add esi, 4 |
285 | loop .nextdevice_isa |
277 | loop .nextdevice_isa |
Line 289... | Line 281... | ||
289 | .firstdevice_isa: |
281 | .firstdevice_isa: |
290 | call create_new_struct |
282 | call create_new_struct |
Line 291... | Line 283... | ||
291 | 283 | ||
292 | mov eax, [edx + IOCTL.input] |
284 | mov eax, [edx + IOCTL.input] |
293 | movzx ecx, word[eax+1] |
285 | movzx ecx, word[eax+1] |
294 | mov [device.io_addr], ecx |
286 | mov [ebx + device.io_addr], ecx |
295 | mov cl, [eax+3] |
287 | mov cl, [eax+3] |
Line 296... | Line 288... | ||
296 | mov [device.irq_line], cl |
288 | mov [ebx + device.irq_line], cl |
297 | - | ||
298 | .hook: |
289 | |
299 | 290 | .hook: |
|
Line 300... | Line 291... | ||
300 | DEBUGF 1, "Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
291 | DEBUGF 1,"Hooking into device, dev:%x, bus:%x, irq:%x, addr:%x\n",\ |
301 | [device.pci_dev]:1,[device.pci_bus]:1,[device.irq_line]:1,[device.io_addr]:4 |
292 | [ebx + device.pci_dev]:1,[ebx + device.pci_bus]:1,[ebx + device.irq_line]:1,[ebx + device.io_addr]:8 |
302 | 293 | ||
Line -... | Line 294... | ||
- | 294 | call probe ; this function will output in eax |
|
- | 295 | test eax, eax |
|
303 | call probe ; this function will output in eax |
296 | jnz .err ; If an error occured, exit |
304 | test eax, eax |
297 | |
305 | jnz .err ; If an error occured, exit |
298 | DEBUGF 2,"Initialised OK\n" |
Line 306... | Line 299... | ||
306 | 299 | ||
307 | mov eax, [devices] |
300 | mov eax, [devices] |
Line 308... | Line 301... | ||
308 | mov [device_list+4*eax], ebx |
301 | mov [device_list+4*eax], ebx |
309 | inc [devices] |
302 | inc [devices] |
310 | 303 | ||
Line 311... | Line 304... | ||
311 | mov [device.type], NET_TYPE_ETH |
304 | mov [ebx + device.type], NET_TYPE_ETH |
Line 312... | Line 305... | ||
312 | call NetRegDev |
305 | invoke NetRegDev |
313 | 306 | ||
314 | cmp eax, -1 |
307 | cmp eax, -1 |
315 | jz .err |
308 | jz .err |
316 | ret |
309 | ret |
317 | 310 | ||
318 | 311 | ||
Line 319... | Line 312... | ||
319 | ; If the device was already loaded, find the device number and return it in eax |
312 | ; If the device was already loaded, find the device number and return it in eax |
320 | 313 | ||
321 | .find_devicenum: |
314 | .find_devicenum: |
Line 322... | Line 315... | ||
322 | DEBUGF 1, "Trying to find device number of already registered device\n" |
315 | DEBUGF 1, "Trying to find device number of already registered device\n" |
Line 323... | Line 316... | ||
323 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
316 | invoke NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
324 | ; into a device number in edi |
317 | ; into a device number in edi |
Line 345... | Line 338... | ||
345 | create_new_struct: |
338 | create_new_struct: |
Line 346... | Line 339... | ||
346 | 339 | ||
347 | cmp [devices], MAX_DEVICES |
340 | cmp [devices], MAX_DEVICES |
Line 348... | Line 341... | ||
348 | jae .fail |
341 | jae .fail |
Line 349... | Line 342... | ||
349 | 342 | ||
350 | allocate_and_clear ebx, device.size, .fail ; Allocate the buffer for device structure |
343 | allocate_and_clear ebx, sizeof.device, .fail ; Allocate the buffer for device structure |
351 | 344 | ||
352 | mov [device.reset], reset |
345 | mov [ebx + device.reset], reset |
Line 353... | Line 346... | ||
353 | mov [device.transmit], transmit |
346 | mov [ebx + device.transmit], transmit |
Line 354... | Line 347... | ||
354 | mov [device.unload], unload |
347 | mov [ebx + device.unload], unload |
355 | mov [device.name], my_service |
348 | mov [ebx + device.name], my_service |
Line 363... | Line 356... | ||
363 | 356 | ||
Line 364... | Line 357... | ||
364 | find_device_num: |
357 | find_device_num: |
365 | 358 | ||
366 | DEBUGF 1, "Trying to find device number of already registered device\n" |
359 | DEBUGF 1, "Trying to find device number of already registered device\n" |
367 | mov ebx, eax |
360 | mov ebx, eax |
368 | call NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
361 | invoke NetPtrToNum ; This kernel procedure converts a pointer to device struct in ebx |
369 | ; into a device number in edi |
362 | ; into a device number in edi |
370 | mov eax, edi ; Application wants it in eax instead |
363 | mov eax, edi ; Application wants it in eax instead |
Line 390... | Line 383... | ||
390 | ;; probe: enables the device and clears the rx buffer |
383 | ;; probe: enables the device and clears the rx buffer |
391 | ;; |
384 | ;; |
392 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
385 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 393... | Line 386... | ||
393 | 386 | ||
394 | probe: |
387 | probe: |
395 | mov [device.vendor], VENDOR_NONE |
388 | mov [ebx + device.vendor], VENDOR_NONE |
Line 396... | Line 389... | ||
396 | mov [device.bmem], 0 |
389 | mov [ebx + device.bmem], 0 |
Line 397... | Line 390... | ||
397 | 390 | ||
398 | DEBUGF 1, "Trying 16-bit mode\n" |
391 | DEBUGF 1, "Trying 16-bit mode\n" |
399 | 392 | ||
400 | mov [device.flags], FLAG_16BIT + FLAG_PIO |
393 | mov [ebx + device.flags], FLAG_16BIT + FLAG_PIO |
Line 401... | Line 394... | ||
401 | mov [device.memsize], MEM_32k |
394 | mov [ebx + device.memsize], MEM_32k |
402 | mov [device.tx_start], 64 |
395 | mov [ebx + device.tx_start], 64 |
403 | mov [device.rx_start], TXBUF_SIZE + 64 |
396 | mov [ebx + device.rx_start], TXBUF_SIZE + 64 |
404 | 397 | ||
Line 405... | Line 398... | ||
405 | set_io 0 |
398 | set_io [ebx + device.io_addr], 0 |
406 | set_io P0_DCR |
399 | set_io [ebx + device.io_addr], P0_DCR |
407 | mov al, DCR_WTS + DCR_FT1 + DCR_LS ; word transfer select + |
400 | mov al, DCR_WTS + DCR_FT1 + DCR_LS ; word transfer select + |
Line 408... | Line 401... | ||
408 | out dx, al |
401 | out dx, al |
409 | 402 | ||
410 | set_io P0_PSTART |
403 | set_io [ebx + device.io_addr], P0_PSTART |
Line 411... | Line 404... | ||
411 | mov al, MEM_16k |
404 | mov al, MEM_16k |
412 | out dx, al |
405 | out dx, al |
Line 434... | Line 427... | ||
434 | je ep_set_vendor |
427 | je ep_set_vendor |
Line 435... | Line 428... | ||
435 | 428 | ||
436 | DEBUGF 1, "16-bit mode failed\n" |
429 | DEBUGF 1, "16-bit mode failed\n" |
Line 437... | Line 430... | ||
437 | DEBUGF 1, "Trying 8-bit mode\n" |
430 | DEBUGF 1, "Trying 8-bit mode\n" |
438 | 431 | ||
439 | mov [device.flags], FLAG_PIO |
432 | mov [ebx + device.flags], FLAG_PIO |
440 | mov [device.memsize], MEM_16k |
433 | mov [ebx + device.memsize], MEM_16k |
Line 441... | Line 434... | ||
441 | mov [device.tx_start], 32 |
434 | mov [ebx + device.tx_start], 32 |
442 | mov [device.rx_start], TXBUF_SIZE + 32 |
435 | mov [ebx + device.rx_start], TXBUF_SIZE + 32 |
443 | 436 | ||
Line 444... | Line 437... | ||
444 | set_io NE_ASIC + NE_RESET |
437 | set_io [ebx + device.io_addr], NE_ASIC + NE_RESET |
Line 445... | Line 438... | ||
445 | in al, dx |
438 | in al, dx |
446 | out dx, al |
439 | out dx, al |
447 | 440 | ||
Line 448... | Line 441... | ||
448 | in al, 0x84 |
441 | in al, 0x84 |
449 | 442 | ||
450 | set_io P0_COMMAND |
443 | set_io [ebx + device.io_addr], P0_COMMAND |
Line 451... | Line 444... | ||
451 | mov al, CMD_RD2 + CMD_STP |
444 | mov al, CMD_RD2 + CMD_STP |
452 | out dx, al |
445 | out dx, al |
453 | 446 | ||
Line 454... | Line 447... | ||
454 | set_io P0_RCR |
447 | set_io [ebx + device.io_addr], P0_RCR |
455 | mov al, RCR_MON |
448 | mov al, RCR_MON |
456 | out dx, al |
449 | out dx, al |
Line 457... | Line 450... | ||
457 | 450 | ||
458 | set_io P0_DCR |
451 | set_io [ebx + device.io_addr], P0_DCR |
459 | mov al, DCR_FT1 + DCR_LS |
452 | mov al, DCR_FT1 + DCR_LS |
Line 460... | Line 453... | ||
460 | out dx, al |
453 | out dx, al |
461 | 454 | ||
Line 492... | Line 485... | ||
492 | 485 | ||
Line 493... | Line 486... | ||
493 | ep_set_vendor: |
486 | ep_set_vendor: |
Line 494... | Line 487... | ||
494 | 487 | ||
495 | DEBUGF 1, "Mode ok\n" |
488 | DEBUGF 1, "Mode ok\n" |
Line 496... | Line 489... | ||
496 | 489 | ||
Line 497... | Line 490... | ||
497 | cmp [device.io_addr], ISA_MAX_ADDR |
490 | cmp [ebx + device.io_addr], ISA_MAX_ADDR |
498 | jbe .isa |
491 | jbe .isa |
Line 499... | Line 492... | ||
499 | 492 | ||
500 | DEBUGF 1, "Card is using PCI bus\n" |
493 | DEBUGF 1, "Card is using PCI bus\n" |
Line 501... | Line 494... | ||
501 | 494 | ||
Line 502... | Line 495... | ||
502 | mov [device.vendor], VENDOR_NOVELL ;;; FIXME |
495 | mov [ebx + device.vendor], VENDOR_NOVELL ;;; FIXME |
Line 503... | Line 496... | ||
503 | jmp ep_check_have_vendor |
496 | jmp ep_check_have_vendor |
504 | 497 | ||
505 | .isa: |
498 | .isa: |
Line 506... | Line 499... | ||
506 | DEBUGF 1, "Card is using ISA bus\n" |
499 | DEBUGF 1, "Card is using ISA bus\n" |
507 | 500 | ||
Line 508... | Line 501... | ||
508 | mov [device.vendor], VENDOR_NOVELL |
501 | mov [ebx + device.vendor], VENDOR_NOVELL |
509 | 502 | ||
Line 510... | Line 503... | ||
510 | ep_check_have_vendor: |
503 | ep_check_have_vendor: |
511 | 504 | ||
512 | 505 | ||
513 | mov al, [device.vendor] |
506 | mov al, [ebx + device.vendor] |
Line 528... | Line 521... | ||
528 | 521 | ||
529 | reset: |
522 | reset: |
Line 530... | Line 523... | ||
530 | DEBUGF 1, "Resetting device\n" |
523 | DEBUGF 1, "Resetting device\n" |
531 | 524 | ||
532 | ; attach int handler |
525 | ; attach int handler |
533 | movzx eax, [device.irq_line] |
526 | movzx eax, [ebx + device.irq_line] |
534 | DEBUGF 1, "Attaching int handler to irq %x\n", eax:1 |
527 | DEBUGF 1, "Attaching int handler to irq %x\n", eax:1 |
535 | stdcall AttachIntHandler, eax, int_handler, dword 0 |
528 | invoke AttachIntHandler, eax, int_handler, ebx |
536 | test eax, eax |
529 | test eax, eax |
537 | jnz @f |
530 | jnz @f |
538 | DEBUGF 2, "Could not attach int handler!\n" |
531 | DEBUGF 2, "Could not attach int handler!\n" |
539 | ; or eax, -1 |
532 | or eax, -1 |
Line 540... | Line 533... | ||
540 | ; ret |
533 | ret |
541 | @@: |
534 | @@: |
542 | 535 | ||
543 | ; Stop card + DMA |
536 | ; Stop card + DMA |
544 | set_io 0 |
537 | set_io [ebx + device.io_addr], 0 |
Line 545... | Line 538... | ||
545 | ; set_io P0_COMMAND |
538 | ; set_io [ebx + device.io_addr], P0_COMMAND |
546 | mov al, CMD_PS0 + CMD_RDMA_ABORT + CMD_STP |
539 | mov al, CMD_PS0 + CMD_RDMA_ABORT + CMD_STP |
547 | out dx, al |
540 | out dx, al |
548 | 541 | ||
549 | ; initialize DCR |
542 | ; initialize DCR |
550 | set_io P0_DCR |
543 | set_io [ebx + device.io_addr], P0_DCR |
551 | mov al, DCR_FT1 + DCR_LS |
544 | mov al, DCR_FT1 + DCR_LS |
552 | test [device.flags], FLAG_16BIT |
545 | test [ebx + device.flags], FLAG_16BIT |
Line 553... | Line 546... | ||
553 | jz @f |
546 | jz @f |
554 | or al, DCR_WTS ; word transfer select |
547 | or al, DCR_WTS ; word transfer select |
555 | @@: |
548 | @@: |
556 | out dx, al |
549 | out dx, al |
Line 557... | Line 550... | ||
557 | 550 | ||
558 | ; clear remote bytes count |
551 | ; clear remote bytes count |
Line 559... | Line 552... | ||
559 | set_io P0_RBCR0 |
552 | set_io [ebx + device.io_addr], P0_RBCR0 |
560 | xor al, al |
553 | xor al, al |
561 | out dx, al |
554 | out dx, al |
562 | 555 | ||
Line 563... | Line 556... | ||
563 | set_io P0_RBCR1 |
556 | set_io [ebx + device.io_addr], P0_RBCR1 |
564 | out dx, al |
557 | out dx, al |
565 | 558 | ||
566 | ; initialize Receive configuration register (until all init is done) |
559 | ; initialize Receive configuration register (until all init is done) |
Line 567... | Line 560... | ||
567 | set_io P0_RCR |
560 | set_io [ebx + device.io_addr], P0_RCR |
568 | mov al, 0x20 ; monitor mode |
561 | mov al, 0x20 ; monitor mode |
569 | out dx, al |
562 | out dx, al |
570 | 563 | ||
Line 571... | Line 564... | ||
571 | ; transmit configuration register to monitor mode (until all ini is done) |
564 | ; transmit configuration register to monitor mode (until all ini is done) |
572 | set_io P0_TCR |
565 | set_io [ebx + device.io_addr], P0_TCR |
573 | mov al, 2 ; internal loopback |
566 | mov al, 2 ; internal loopback |
574 | out dx, al |
567 | out dx, al |
Line 575... | Line 568... | ||
575 | 568 | ||
576 | ; clear interupt status |
569 | ; clear interupt status |
577 | set_io P0_ISR |
570 | set_io [ebx + device.io_addr], P0_ISR |
578 | mov al, 0xff |
571 | mov al, 0xff |
Line 579... | Line 572... | ||
579 | out dx, al |
572 | out dx, al |
580 | 573 | ||
581 | ; clear IRQ mask ;;;;; CHECKME ;;;;; |
574 | ; clear IRQ mask ;;;;; CHECKME ;;;;; |
582 | set_io P0_IMR |
575 | set_io [ebx + device.io_addr], P0_IMR |
Line 583... | Line 576... | ||
583 | xor al, al |
576 | xor al, al |
584 | out dx, al |
577 | out dx, al |
585 | 578 | ||
586 | ; set transmit pointer |
579 | ; set transmit pointer |
Line 587... | Line 580... | ||
587 | set_io P0_TPSR |
580 | set_io [ebx + device.io_addr], P0_TPSR |
588 | mov al, [device.tx_start] |
581 | mov al, [ebx + device.tx_start] |
589 | out dx, al |
582 | out dx, al |
590 | 583 | ||
591 | ; set pagestart pointer |
584 | ; set pagestart pointer |
Line 592... | Line 585... | ||
592 | set_io P0_PSTART |
585 | set_io [ebx + device.io_addr], P0_PSTART |
593 | mov al, [device.rx_start] |
586 | mov al, [ebx + device.rx_start] |
594 | out dx, al |
587 | out dx, al |
595 | 588 | ||
Line 596... | Line 589... | ||
596 | ; set pagestop pointer |
589 | ; set pagestop pointer |
597 | set_io P0_PSTOP |
590 | set_io [ebx + device.io_addr], P0_PSTOP |
598 | mov al, [device.memsize] |
591 | mov al, [ebx + device.memsize] |
Line 599... | Line 592... | ||
599 | out dx, al |
592 | out dx, al |
600 | 593 | ||
601 | ; set boundary pointer |
594 | ; set boundary pointer |
Line 602... | Line 595... | ||
602 | set_io P0_BOUND |
595 | set_io [ebx + device.io_addr], P0_BOUND |
603 | mov al, [device.memsize] |
596 | mov al, [ebx + device.memsize] |
604 | dec al |
597 | dec al |
605 | out dx, al |
598 | out dx, al |
606 | 599 | ||
607 | ; set curr pointer |
600 | ; set curr pointer |
608 | set_io P0_COMMAND |
601 | set_io [ebx + device.io_addr], P0_COMMAND |
609 | mov al, CMD_PS1 ;+ CMD_RD2 + CMD_STP ; page 1, stop mode |
602 | mov al, CMD_PS1 ;+ CMD_RD2 + CMD_STP ; page 1, stop mode |
610 | out dx, al |
603 | out dx, al |
611 | 604 | ||
Line 612... | Line 605... | ||
612 | set_io P1_CURR |
605 | set_io [ebx + device.io_addr], P1_CURR |
613 | mov al, [device.rx_start] |
606 | mov al, [ebx + device.rx_start] |
614 | out dx, al |
607 | out dx, al |
615 | 608 | ||
616 | set_io P0_COMMAND |
609 | set_io [ebx + device.io_addr], P0_COMMAND |
Line 617... | Line 610... | ||
617 | mov al, CMD_PS0 ;+ CMD_RD2 + CMD_STA ; go to page 0, start mode |
610 | mov al, CMD_PS0 ;+ CMD_RD2 + CMD_STA ; go to page 0, start mode |
618 | out dx, al |
611 | out dx, al |
619 | 612 | ||
620 | ; Read MAC address and set it to registers |
613 | ; Read MAC address and set it to registers |
Line 621... | Line 614... | ||
621 | call read_mac |
614 | call read_mac |
622 | push .macret |
615 | push .macret |
623 | sub esp, 6 |
616 | sub esp, 6 |
624 | lea esi, [device.mac] |
617 | lea esi, [ebx + device.mac] |
Line 625... | Line 618... | ||
625 | mov edi, esp |
618 | mov edi, esp |
626 | movsd |
619 | movsd |
627 | movsw |
620 | movsw |
628 | jmp write_mac |
621 | jmp write_mac |
Line 629... | Line 622... | ||
629 | .macret: |
622 | .macret: |
630 | 623 | ||
631 | ; set IRQ mask |
624 | ; set IRQ mask |
632 | set_io 0 |
625 | set_io [ebx + device.io_addr], 0 |
633 | set_io P0_IMR |
626 | set_io [ebx + device.io_addr], P0_IMR |
Line 634... | Line 627... | ||
634 | mov al, IRQ_MASK |
627 | mov al, IRQ_MASK |
635 | out dx, al |
628 | out dx, al |
Line 636... | Line 629... | ||
636 | 629 | ||
637 | ; start mode |
630 | ; start mode |
Line 638... | Line 631... | ||
638 | set_io P0_COMMAND |
631 | set_io [ebx + device.io_addr], P0_COMMAND |
639 | mov al, CMD_STA |
632 | mov al, CMD_STA |
640 | out dx, al |
633 | out dx, al |
Line 673... | Line 666... | ||
673 | ; Function |
666 | ; Function |
674 | ; transmit |
667 | ; transmit |
675 | ; buffer in [esp+4], size in [esp+8], pointer to device struct in ebx |
668 | ; buffer in [esp+4], size in [esp+8], pointer to device struct in ebx |
676 | ;*************************************************************************** |
669 | ;*************************************************************************** |
Line -... | Line 670... | ||
- | 670 | ||
- | 671 | proc transmit stdcall buffer_ptr, buffer_size |
|
677 | 672 | ||
678 | align 4 |
673 | pushf |
Line 679... | Line 674... | ||
679 | transmit: |
674 | cli |
680 | 675 | ||
681 | mov esi, [esp + 4] |
676 | mov esi, [buffer_ptr] |
682 | mov ecx, [esp + 8] |
677 | mov ecx, [buffer_size] |
683 | DEBUGF 1, "Transmitting packet, buffer:%x, size:%u\n",esi, ecx |
678 | DEBUGF 1, "Transmitting packet, buffer:%x, size:%u\n", esi, ecx |
Line 684... | Line 679... | ||
684 | DEBUGF 1, "To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
679 | DEBUGF 1, "To: %x-%x-%x-%x-%x-%x From: %x-%x-%x-%x-%x-%x Type:%x%x\n",\ |
685 | [esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2,[esi+6]:2,[esi+7]:2,[esi+8]:2,[esi+9]:2,[esi+10]:2,[esi+11]:2,[esi+13]:2,[esi+12]:2 |
680 | [esi+0]:2,[esi+1]:2,[esi+2]:2,[esi+3]:2,[esi+4]:2,[esi+5]:2,[esi+6]:2,[esi+7]:2,[esi+8]:2,[esi+9]:2,[esi+10]:2,[esi+11]:2,[esi+13]:2,[esi+12]:2 |
686 | 681 | ||
687 | cmp ecx, ETH_FRAME_LEN |
682 | cmp ecx, ETH_FRAME_LEN |
Line 688... | Line 683... | ||
688 | ja .err ; packet is too long |
683 | ja .err ; packet is too long |
689 | cmp ecx, ETH_ZLEN |
684 | cmp ecx, ETH_ZLEN |
690 | jb .err ; packet is too short |
685 | jb .err ; packet is too short |
691 | 686 | ||
692 | movzx edi, [device.tx_start] |
687 | movzx edi, [ebx + device.tx_start] |
Line 693... | Line 688... | ||
693 | shl edi, 8 |
688 | shl edi, 8 |
694 | push cx |
689 | push cx |
695 | call PIO_write |
690 | call PIO_write |
696 | pop cx |
691 | pop cx |
Line 697... | Line 692... | ||
697 | 692 | ||
698 | set_io 0 |
693 | set_io [ebx + device.io_addr], 0 |
699 | ; set_io P0_COMMAND |
694 | ; set_io [ebx + device.io_addr], P0_COMMAND |
Line 700... | Line 695... | ||
700 | mov al, CMD_PS0 + CMD_RD2 + CMD_STA |
695 | mov al, CMD_PS0 + CMD_RD2 + CMD_STA |
701 | out dx, al |
696 | out dx, al |
702 | 697 | ||
Line 703... | Line 698... | ||
703 | set_io P0_TPSR |
698 | set_io [ebx + device.io_addr], P0_TPSR |
704 | mov al, [device.tx_start] |
699 | mov al, [ebx + device.tx_start] |
705 | out dx, al |
700 | out dx, al |
Line 706... | Line 701... | ||
706 | 701 | ||
707 | set_io P0_TBCR0 |
702 | set_io [ebx + device.io_addr], P0_TBCR0 |
708 | mov al, cl |
703 | mov al, cl |
Line 709... | Line 704... | ||
709 | out dx, al |
704 | out dx, al |
Line 710... | Line 705... | ||
710 | 705 | ||
711 | set_io P0_TBCR1 |
706 | set_io [ebx + device.io_addr], P0_TBCR1 |
712 | mov al, ch |
- | |
713 | out dx, al |
707 | mov al, ch |
714 | 708 | out dx, al |
|
Line 715... | Line 709... | ||
715 | set_io P0_COMMAND |
709 | |
- | 710 | set_io [ebx + device.io_addr], P0_COMMAND |
|
716 | mov al, CMD_PS0 + CMD_TXP + CMD_RD2 + CMD_STA |
711 | mov al, CMD_PS0 + CMD_TXP + CMD_RD2 + CMD_STA |
717 | out dx, al |
712 | out dx, al |
Line 718... | Line 713... | ||
718 | 713 | ||
719 | DEBUGF 1, "Packet Sent!\n" |
714 | DEBUGF 1, "Packet Sent!\n" |
720 | 715 | ||
- | 716 | inc [ebx + device.packets_tx] |
|
721 | inc [device.packets_tx] |
717 | mov eax, [buffer_size] |
722 | mov eax, [esp + 8] ; Get packet size in eax |
718 | add dword[ebx + device.bytes_tx], eax |
- | 719 | adc dword[ebx + device.bytes_tx + 4], 0 |
|
- | 720 | ||
Line 723... | Line 721... | ||
723 | 721 | invoke KernelFree, [buffer_ptr] |
|
724 | add dword [device.bytes_tx], eax |
722 | popf |
Line 744... | Line 742... | ||
744 | 742 | ||
745 | align 4 |
743 | align 4 |
Line 746... | Line 744... | ||
746 | int_handler: |
744 | int_handler: |
747 | - | ||
748 | push ebx esi edi |
745 | |
Line 749... | Line 746... | ||
749 | 746 | push ebx esi edi |
|
Line 750... | Line 747... | ||
750 | DEBUGF 1, "INT\n" |
747 | DEBUGF 1, "INT\n" |
Line 756... | Line 753... | ||
756 | jz .nothing |
753 | jz .nothing |
757 | mov esi, device_list |
754 | mov esi, device_list |
758 | .nextdevice: |
755 | .nextdevice: |
759 | mov ebx, [esi] |
756 | mov ebx, [esi] |
Line 760... | Line 757... | ||
760 | 757 | ||
761 | set_io 0 |
758 | set_io [ebx + device.io_addr], 0 |
762 | ; set_io P0_COMMAND |
759 | ; set_io [ebx + device.io_addr], P0_COMMAND |
763 | mov al, CMD_PS0 |
760 | mov al, CMD_PS0 |
Line 764... | Line 761... | ||
764 | out dx, al |
761 | out dx, al |
765 | 762 | ||
766 | set_io P0_ISR |
763 | set_io [ebx + device.io_addr], P0_ISR |
767 | in al, dx |
764 | in al, dx |
768 | test al, al |
765 | test al, al |
769 | jnz .got_it |
766 | jnz .got_it |
Line 776... | Line 773... | ||
776 | xor eax, eax |
773 | xor eax, eax |
Line 777... | Line 774... | ||
777 | 774 | ||
Line 778... | Line 775... | ||
778 | ret |
775 | ret |
779 | - | ||
780 | .got_it: |
776 | |
Line 781... | Line 777... | ||
781 | 777 | .got_it: |
|
782 | DEBUGF 1, "Device=%x status=%x\n", ebx, eax:2 |
778 | DEBUGF 1, "Device=%x status=%x\n", ebx, eax:2 |
783 | 779 | ||
784 | push ebx |
780 | push ebx |
785 | - | ||
786 | test al, ISR_PRX ; packet received ok ? |
781 | .rx_loop: |
787 | jz .no_rx |
782 | test al, ISR_PRX ; packet received ok ? |
Line 788... | Line -... | ||
788 | - | ||
789 | test [device.flags], FLAG_PIO |
- | |
790 | jz .no_rx ; FIXME: Only PIO mode supported for now |
- | |
791 | - | ||
792 | ; |
783 | jz .no_rx |
793 | - | ||
794 | pushd .no_rx |
784 | test [ebx + device.flags], FLAG_PIO |
795 | 785 | jz .no_rx ; FIXME: Only PIO mode supported for now |
|
796 | ; allocate a buffer |
786 | |
- | 787 | ; allocate a buffer |
|
- | 788 | invoke KernelAlloc, ETH_FRAME_LEN |
|
797 | 789 | test eax, eax |
|
- | 790 | jz .rx_fail_2 |
|
798 | stdcall KernelAlloc, ETH_FRAME_LEN |
791 | |
Line 799... | Line 792... | ||
799 | test eax, eax |
792 | ; Push return address and packet ptr to stack |
800 | jz .fail_2 |
- | |
801 | pushd 0 |
793 | pushd .no_rx |
802 | push eax |
794 | pushd 0 ; Reserve some space for the packet size |
803 | 795 | push eax |
|
804 | ; read offset for current packet from device |
796 | |
805 | - | ||
806 | set_io 0 |
797 | ; read offset for current packet from device |
807 | set_io P0_BOUND ; boundary ptr is offset to next packet we need to read. |
798 | set_io [ebx + device.io_addr], 0 |
808 | in al, dx |
799 | set_io [ebx + device.io_addr], P0_BOUND ; boundary ptr is offset to next packet we need to read. |
809 | inc al |
800 | in al, dx |
810 | 801 | inc al |
|
Line 811... | Line 802... | ||
811 | cmp al, [device.memsize] |
802 | cmp al, [ebx + device.memsize] |
812 | jb @f |
803 | jb @f |
813 | mov al, [device.rx_start] |
804 | mov al, [ebx + device.rx_start] |
814 | @@: |
- | |
815 | mov ch, al |
805 | @@: |
816 | 806 | mov ch, al |
|
817 | set_io P0_COMMAND |
807 | |
Line 818... | Line 808... | ||
818 | mov al, CMD_PS1 |
808 | set_io [ebx + device.io_addr], P0_COMMAND |
819 | out dx, al |
809 | mov al, CMD_PS1 |
820 | 810 | out dx, al |
|
Line 821... | Line 811... | ||
821 | set_io P1_CURR |
811 | set_io [ebx + device.io_addr], P1_CURR |
822 | in al, dx ; get current page in cl |
812 | in al, dx ; get current page in cl |
823 | mov cl, al |
813 | mov cl, al |
824 | 814 | ||
Line 825... | Line 815... | ||
825 | set_io P1_COMMAND |
815 | set_io [ebx + device.io_addr], P1_COMMAND |
826 | mov al, CMD_PS0 |
816 | mov al, CMD_PS0 |
827 | out dx, al |
- | |
828 | 817 | out dx, al |
|
829 | cmp cl, [device.memsize] |
818 | |
Line 830... | Line 819... | ||
830 | jb @f |
819 | cmp cl, [ebx + device.memsize] |
831 | mov cl, [device.rx_start] |
- | |
832 | @@: |
820 | jb @f |
833 | 821 | mov cl, [ebx + device.rx_start] |
|
834 | cmp cl, ch |
822 | @@: |
835 | je .fail |
823 | |
836 | - | ||
837 | movzx esi, ch ; we are using 256 byte pages |
824 | cmp cl, ch |
Line 838... | Line 825... | ||
838 | shl esi, 8 ; esi now holds the offset for current packet |
825 | je .rx_fail |
839 | - | ||
840 | ; Get packet header in eax |
826 | movzx esi, ch ; we are using 256 byte pages |
841 | 827 | shl esi, 8 ; esi now holds the offset for current packet |
|
Line 842... | Line 828... | ||
842 | sub esp, 4 ; reserve 4 bytes on stack to put packet header in |
828 | |
843 | mov edi, esp |
- | |
844 | mov cx, 4 |
829 | ; Get packet header in ecx |
845 | call PIO_read |
830 | push ecx ; reserve 4 bytes on stack to put packet header in |
846 | 831 | mov edi, esp |
|
Line 847... | Line 832... | ||
847 | mov ecx, [esp] ; ecx now contains packet header |
832 | mov cx, 4 |
848 | - | ||
849 | ; check if packet is ok |
833 | call PIO_read |
850 | 834 | mov ecx, [esp] |
|
851 | test ecx, RSTAT_PRX |
835 | |
852 | jz .fail_3 |
836 | ; check if packet is ok |
Line 853... | Line 837... | ||
853 | 837 | test ecx, RSTAT_PRX |
|
854 | ; calculate packet length in ecx |
- | |
855 | 838 | jz .rx_fail_3 |
|
856 | shr ecx, 16 |
- | |
857 | sub ecx, 4 ; CRC doesnt count as data byte |
839 | |
858 | mov [esp + 4 + 4], ecx |
840 | ; calculate packet length in ecx |
859 | 841 | shr ecx, 16 |
|
Line 860... | Line 842... | ||
860 | ; check if packet size is ok |
842 | sub ecx, 4 ; CRC doesnt count as data byte |
861 | - | ||
862 | cmp ecx, ETH_ZLEN |
843 | mov [esp + 8], ecx |
863 | jb .fail_3 |
844 | |
Line 864... | Line 845... | ||
864 | cmp ecx, ETH_FRAME_LEN |
845 | ; check if packet size is ok |
865 | ja .fail_3 |
- | |
866 | 846 | cmp ecx, ETH_ZLEN |
|
867 | ; update stats |
847 | jb .rx_fail_3 |
868 | 848 | cmp ecx, ETH_FRAME_LEN |
|
869 | DEBUGF 1, "Received %u bytes\n", ecx |
849 | ja .rx_fail_3 |
870 | 850 | ||
Line 871... | Line 851... | ||
871 | add dword[device.bytes_rx], ecx |
851 | ; update stats |
872 | adc dword[device.bytes_rx + 4], 0 |
- | |
873 | inc [device.packets_rx] |
852 | DEBUGF 1, "Received %u bytes\n", ecx |
874 | 853 | add dword[ebx + device.bytes_rx], ecx |
|
875 | ; update read and write pointers |
854 | adc dword[ebx + device.bytes_rx + 4], 0 |
876 | - | ||
877 | add esi, 4 |
855 | inc [ebx + device.packets_rx] |
Line 878... | Line 856... | ||
878 | mov edi, [esp + 4] |
856 | |
879 | - | ||
880 | ; now check if we can read all data at once (if we cross the end boundary, we need to wrap back to the beginning) |
857 | ; update read and write pointers |
881 | 858 | add esi, 4 |
|
882 | xor eax, eax |
- | |
883 | mov ah, [device.memsize] |
859 | mov edi, [esp + 4] |
884 | sub eax, esi |
860 | |
Line 885... | Line 861... | ||
885 | cmp ecx, eax ; eax = number of bytes till end of buffer, ecx = bytes we need to read |
861 | ; now check if we can read all data at once (if we cross the end boundary, we need to wrap back to the beginning) |
886 | jbe .no_wrap |
- | |
887 | 862 | xor eax, eax |
|
888 | ; Read first part |
863 | mov ah, [ebx + device.memsize] |
Line 889... | Line 864... | ||
889 | 864 | sub eax, esi |
|
890 | sub ecx, eax |
- | |
891 | push ecx |
865 | cmp ecx, eax ; eax = number of bytes till end of buffer, ecx = bytes we need to read |
892 | mov ecx, eax |
866 | jbe .no_wrap |
893 | 867 | ||
894 | call PIO_read ; Read the data |
868 | ; Read first part |
895 | 869 | sub ecx, eax |
|
896 | ; update pointers |
870 | push ecx |
897 | - | ||
898 | add edi, ecx |
871 | mov ecx, eax |
899 | pop ecx |
872 | call PIO_read ; Read the data |
900 | 873 | ||
901 | movzx esi, [device.rx_start] |
874 | ; update pointers for second read |
Line 902... | Line 875... | ||
902 | shl esi, 8 |
875 | add edi, ecx |
- | 876 | pop ecx |
|
Line 903... | Line -... | ||
903 | - | ||
904 | ; now read second part (or only part) |
- | |
905 | 877 | movzx esi, [ebx + device.rx_start] |
|
906 | .no_wrap: |
878 | shl esi, 8 |
907 | call PIO_read ; Read the data |
879 | |
908 | 880 | ; now read second part (or only part) |
|
909 | ; update boundary pointer |
881 | .no_wrap: |
910 | - | ||
911 | pop eax |
- | |
- | 882 | call PIO_read ; Read the data |
|
912 | mov al, ah |
883 | |
913 | cmp al, [device.rx_start] |
884 | ; update boundary pointer |
914 | jne @f |
885 | pop eax |
Line 915... | Line 886... | ||
915 | mov al, [device.memsize] |
886 | mov al, ah |
916 | @@: |
887 | cmp al, [ebx + device.rx_start] |
917 | 888 | jne @f |
|
918 | set_io 0 |
889 | mov al, [ebx + device.memsize] |
Line 919... | Line 890... | ||
919 | set_io P0_BOUND |
890 | @@: |
Line 920... | Line 891... | ||
920 | dec al |
891 | set_io [ebx + device.io_addr], 0 |
Line 921... | Line -... | ||
921 | out dx, al |
- | |
922 | - | ||
923 | ; now send the data to the kernel |
- | |
924 | 892 | set_io [ebx + device.io_addr], P0_BOUND |
|
925 | jmp Eth_input |
893 | dec al |
926 | 894 | out dx, al |
|
927 | .fail_3: |
895 | |
928 | add esp, 4 |
896 | ; now send the data to the kernel |
Line 957... | Line 925... | ||
957 | align 4 |
925 | align 4 |
958 | write_mac: ; in: mac on stack (6 bytes) |
926 | write_mac: ; in: mac on stack (6 bytes) |
Line 959... | Line 927... | ||
959 | 927 | ||
Line 960... | Line 928... | ||
960 | DEBUGF 1, "Writing MAC\n" |
928 | DEBUGF 1, "Writing MAC\n" |
961 | 929 | ||
962 | set_io 0 |
930 | set_io [ebx + device.io_addr], 0 |
Line 963... | Line 931... | ||
963 | mov al, CMD_PS1; + CMD_RD2 + CMD_STP |
931 | mov al, CMD_PS1; + CMD_RD2 + CMD_STP |
964 | out dx, al |
932 | out dx, al |
965 | 933 | ||
966 | set_io P1_PAR0 |
934 | set_io [ebx + device.io_addr], P1_PAR0 |
967 | mov esi, esp |
935 | mov esi, esp |
968 | mov cx, 6 |
936 | mov cx, 6 |
Line 992... | Line 960... | ||
992 | mov edi, esp |
960 | mov edi, esp |
993 | call PIO_read |
961 | call PIO_read |
Line 994... | Line 962... | ||
994 | 962 | ||
995 | mov esi, esp |
963 | mov esi, esp |
996 | add esp, 16 |
964 | add esp, 16 |
997 | lea edi, [device.mac] |
965 | lea edi, [ebx + device.mac] |
998 | mov ecx, 6 |
966 | mov ecx, 6 |
999 | .loop: |
967 | .loop: |
1000 | movsb |
968 | movsb |
1001 | test [device.flags], FLAG_16BIT |
969 | test [ebx + device.flags], FLAG_16BIT |
1002 | jz .8bit |
970 | jz .8bit |
1003 | inc esi |
971 | inc esi |
1004 | .8bit: |
972 | .8bit: |
1005 | loop .loop |
- | |
1006 | 973 | loop .loop |
|
1007 | DEBUGF 1, "MAC=%x-%x-%x-%x-%x-%x\n",\ |
974 | DEBUGF 1, "MAC=%x-%x-%x-%x-%x-%x\n",\ |
Line 1008... | Line 975... | ||
1008 | [device.mac]:2,[device.mac+1]:2,[device.mac+2]:2,[device.mac+3]:2,[device.mac+4]:2,[device.mac+5]:2 |
975 | [ebx + device.mac]:2,[ebx + device.mac+1]:2,[ebx + device.mac+2]:2,[ebx + device.mac+3]:2,[ebx + device.mac+4]:2,[ebx + device.mac+5]:2 |
Line 1009... | Line 976... | ||
1009 | 976 | ||
Line 1022... | Line 989... | ||
1022 | ;*************************************************************************** |
989 | ;*************************************************************************** |
1023 | PIO_read: |
990 | PIO_read: |
Line 1024... | Line 991... | ||
1024 | 991 | ||
Line 1025... | Line 992... | ||
1025 | DEBUGF 1, "PIO Read from %x to %x, %u bytes ", si, edi, cx |
992 | DEBUGF 1, "PIO Read from %x to %x, %u bytes ", si, edi, cx |
1026 | 993 | ||
1027 | ; start DMA |
994 | ; stop DMA + start |
1028 | set_io 0 |
995 | set_io [ebx + device.io_addr], 0 |
1029 | ; set_io P0_COMMAND |
996 | ; set_io [ebx + device.io_addr], P0_COMMAND |
Line -... | Line 997... | ||
- | 997 | mov al, CMD_RD2 + CMD_STA |
|
- | 998 | out dx, al |
|
- | 999 | ||
- | 1000 | ; Request confirmation of end of DMA transfer |
|
- | 1001 | set_io [ebx + device.io_addr], P0_ISR |
|
1030 | mov al, CMD_RD2 + CMD_STA |
1002 | mov al, ISR_RDC |
1031 | out dx, al |
1003 | out dx, al |
1032 | 1004 | ||
1033 | ; set length of data we're interested in |
1005 | ; set length of data we're interested in |
1034 | set_io P0_RBCR0 |
- | |
1035 | mov al, cl |
1006 | set_io [ebx + device.io_addr], P0_RBCR0 |
1036 | out dx, al |
1007 | mov al, cl |
1037 | 1008 | out dx, al |
|
Line 1038... | Line 1009... | ||
1038 | set_io P0_RBCR1 |
1009 | set_io [ebx + device.io_addr], P0_RBCR1 |
1039 | mov al, ch |
1010 | mov al, ch |
1040 | out dx, al |
1011 | out dx, al |
1041 | 1012 | ||
1042 | ; set offset of what we want to read |
- | |
1043 | set_io P0_RSAR0 |
1013 | ; set offset of what we want to read |
1044 | mov ax, si |
1014 | set_io [ebx + device.io_addr], P0_RSAR0 |
1045 | out dx, al |
1015 | mov ax, si |
Line 1046... | Line 1016... | ||
1046 | 1016 | out dx, al |
|
1047 | set_io P0_RSAR1 |
1017 | set_io [ebx + device.io_addr], P0_RSAR1 |
1048 | shr ax, 8 |
1018 | shr ax, 8 |
1049 | out dx, al |
1019 | out dx, al |
Line 1050... | Line 1020... | ||
1050 | 1020 | ||
1051 | ; start DMA read |
- | |
1052 | set_io P0_COMMAND |
1021 | ; start DMA read |
1053 | mov al, CMD_RD0 + CMD_STA |
1022 | set_io [ebx + device.io_addr], P0_COMMAND |
1054 | out dx, al |
- | |
1055 | 1023 | mov al, CMD_RD0 + CMD_STA |
|
1056 | set_io NE_ASIC |
- | |
1057 | 1024 | out dx, al |
|
1058 | test [device.flags], FLAG_16BIT |
1025 | |
1059 | jz .8bits |
- | |
1060 | 1026 | set_io [ebx + device.io_addr], NE_ASIC |
|
1061 | DEBUGF 1, "(16-bit mode)\n" |
1027 | test [ebx + device.flags], FLAG_16BIT |
1062 | 1028 | jz .8bits |
|
1063 | shr cx, 1 ; note that if the number was odd, carry flag will be set |
1029 | DEBUGF 1, "(16-bit mode)\n" |
1064 | pushf |
- | |
1065 | - | ||
1066 | .16bits: |
1030 | shr cx, 1 ; note that if the number was odd, carry flag will be set |
1067 | in ax, dx |
1031 | pushf |
- | 1032 | .16bits: |
|
- | 1033 | in ax, dx |
|
1068 | stosw |
1034 | stosw |
Line 1069... | Line 1035... | ||
1069 | loopw .16bits |
1035 | loopw .16bits |
1070 | 1036 | popf |
|
1071 | inc cx |
- | |
1072 | popf |
1037 | jnc wait_dma_done |
1073 | jnc .done |
1038 | in al, dx |
1074 | jmp .8bits_ |
1039 | stosb |
1075 | 1040 | jmp wait_dma_done |
|
1076 | .8bits: |
- | |
1077 | DEBUGF 1, "(8-bit mode)\n" |
- | |
1078 | - | ||
1079 | .8bits_: |
- | |
1080 | in al, dx |
- | |
1081 | stosb |
- | |
1082 | loopw .8bits_ |
- | |
1083 | - | ||
1084 | - | ||
1085 | .done: |
1041 | |
1086 | ; set_io 0 |
- | |
1087 | ; set_io P0_ISR |
- | |
1088 | ; |
- | |
1089 | ; .dmawait: ; Wait for Remote DMA Complete |
- | |
Line 1090... | Line 1042... | ||
1090 | ; in al, dx |
1042 | .8bits: |
Line 1110... | Line 1062... | ||
1110 | ;*************************************************************************** |
1062 | ;*************************************************************************** |
1111 | PIO_write: |
1063 | PIO_write: |
Line 1112... | Line 1064... | ||
1112 | 1064 | ||
Line -... | Line 1065... | ||
- | 1065 | DEBUGF 1, "Eth PIO Write from %x to %x, %u bytes ", esi, di, cx |
|
1113 | DEBUGF 1, "Eth PIO Write from %x to %x, %u bytes ", esi, di, cx |
1066 | |
1114 | 1067 | ; Stop DMA + start |
|
1115 | set_io 0 |
1068 | set_io [ebx + device.io_addr], 0 |
1116 | ; set_io P0_COMMAND |
1069 | ; set_io [ebx + device.io_addr], P0_COMMAND |
Line -... | Line 1070... | ||
- | 1070 | mov al, CMD_RD2 + CMD_STA |
|
1117 | mov al, CMD_RD2 + CMD_STA |
1071 | out dx, al |
1118 | out dx, al |
1072 | |
1119 | 1073 | ; Request confirmation of end of DMA transfer |
|
Line -... | Line 1074... | ||
- | 1074 | set_io [ebx + device.io_addr], P0_ISR |
|
1120 | set_io P0_ISR |
1075 | mov al, ISR_RDC |
1121 | mov al, ISR_RDC |
1076 | out dx, al |
1122 | out dx, al |
1077 | |
1123 | - | ||
1124 | set_io P0_RBCR0 |
1078 | ; Program number of bytes we want to write |
1125 | mov al, cl |
1079 | set_io [ebx + device.io_addr], P0_RBCR0 |
1126 | out dx, al |
1080 | mov al, cl |
Line -... | Line 1081... | ||
- | 1081 | out dx, al |
|
1127 | 1082 | set_io [ebx + device.io_addr], P0_RBCR1 |
|
1128 | set_io P0_RBCR1 |
1083 | mov al, ch |
1129 | mov al, ch |
1084 | out dx, al |
1130 | out dx, al |
1085 | |
1131 | 1086 | ; Program where we want to write |
|
1132 | mov ax, di |
1087 | mov ax, di |
Line -... | Line 1088... | ||
- | 1088 | set_io [ebx + device.io_addr], P0_RSAR0 |
|
1133 | set_io P0_RSAR0 |
1089 | out dx, al |
1134 | out dx, al |
1090 | shr ax, 8 |
1135 | shr ax, 8 |
1091 | set_io [ebx + device.io_addr], P0_RSAR1 |
Line 1136... | Line 1092... | ||
1136 | set_io P0_RSAR1 |
1092 | out dx, al |
1137 | out dx, al |
1093 | |
1138 | 1094 | ; Set the DMA to write |
|
1139 | set_io P0_COMMAND |
- | |
1140 | mov al, CMD_RD1 + CMD_STA |
1095 | set_io [ebx + device.io_addr], P0_COMMAND |
1141 | out dx, al |
- | |
1142 | 1096 | mov al, CMD_RD1 + CMD_STA |
|
1143 | set_io NE_ASIC |
1097 | out dx, al |
1144 | test [device.flags], FLAG_16BIT |
- | |
1145 | jz .8_bit |
1098 | |
1146 | 1099 | set_io [ebx + device.io_addr], NE_ASIC |
|
1147 | DEBUGF 1, "(16-bit mode)\n" |
1100 | test [ebx + device.flags], FLAG_16BIT |
1148 | 1101 | jz .8_bit |
|
1149 | shr cx, 1 ; note that if the number was odd, carry flag will be set |
- | |
1150 | pushf ; save the flags for later |
1102 | DEBUGF 1, "(16-bit mode)\n" |
1151 | 1103 | shr cx, 1 ; note that if the number was odd, carry flag will be set |
|
- | 1104 | pushf ; save the flags for later |
|
1152 | .16bit: |
1105 | .16bit: |
1153 | lodsw |
1106 | lodsw |
Line 1154... | Line 1107... | ||
1154 | out dx, ax |
1107 | out dx, ax |
1155 | loopw .16bit |
- | |
1156 | 1108 | loopw .16bit |
|
1157 | popf |
- | |
1158 | jnc .done |
1109 | popf |
1159 | inc cx |
1110 | jnc wait_dma_done |
1160 | jmp .8_bit_ |
1111 | lodsb |
1161 | 1112 | out dx, al |
|
- | 1113 | jmp wait_dma_done |
|
- | 1114 | ||
- | 1115 | .8_bit: |
|
- | 1116 | DEBUGF 1, "(8-bit mode)\n" |
|
- | 1117 | .8_bit_: |
|
Line 1162... | Line -... | ||
1162 | .8_bit: |
- | |
1163 | 1118 | lodsb |
|
1164 | DEBUGF 1, "(8-bit mode)\n" |
1119 | out dx, al |
1165 | 1120 | loopw .8_bit_ |
|
1166 | .8_bit_: |
1121 | jmp wait_dma_done |
1167 | lodsb |
1122 | |
1168 | out dx, al |
1123 | |
1169 | loopw .8_bit_ |
1124 | |
1170 | 1125 | wait_dma_done: |
|
Line 1171... | Line 1126... | ||
1171 | .done: |
1126 | |
Line 1172... | Line -... | ||
1172 | ; set_io 0 |
- | |
1173 | ; set_io P0_ISR |
1127 | set_io [ebx + device.io_addr], 0 |
Line 1174... | Line -... | ||
1174 | ; .dmawait: ; Wait for Remote DMA Complete |
- | |
1175 | ; in al, dx |
- | |
1176 | ; test al, ISR_RDC |
- | |
Line 1177... | Line 1128... | ||
1177 | ; jz .dmawait |
1128 | set_io [ebx + device.io_addr], P0_ISR |
1178 | ; and al, not ISR_RDC |
1129 | .dmawait: |
1179 | ; out dx, al ; clear the bit |
- | |
- | 1130 | in al, dx |
|
1180 | 1131 | test al, ISR_RDC ; Remote DMA Complete |
|
- | 1132 | jz .dmawait |
|
1181 | ret |
1133 | ; and al, not ISR_RDC |
Line -... | Line 1134... | ||
- | 1134 | ; out dx, al ; clear the bit |
|
- | 1135 | ||
- | 1136 | ret |
|
1182 | 1137 | ||
- | 1138 | ||
Line 1183... | Line 1139... | ||
1183 | 1139 | ||
1184 | - | ||
Line -... | Line 1140... | ||
- | 1140 | ; End of code |
|
1185 | ; place all initialized data here |
1141 | |
- | 1142 |