* remove "\r" nonsense
[mascara-docs.git] / amd64 / bareMetalOS-0.5.2 / baremetal0.5.2 / os / drivers / net / bcm57xx.asm
blob7bdf91ef518c9dab6feb3bdc2f4291dcc4b23c68
1 ; =============================================================================
2 ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
5 ; Broadcom 57XX NIC.
6 ; =============================================================================
8 align 16
9 db 'DEBUG: BCM57xx '
10 align 16
13 ; -----------------------------------------------------------------------------
14 ; os_net_bcm57xx_init - Initialize a Broadcom 57XX NIC
15 ; IN: AL = Bus number of the Realtek device
16 ; BL = Device/Slot number of the Realtek device
17 os_net_bcm57xx_init:
18 push rsi
19 push rdx
20 push rcx
21 push rax
23 ; Grab the Base I/O Address of the device
24 push ax
25 mov cl, 0x04 ; BAR0 - Lower 32 bits of memory address
26 call os_pci_read_reg
27 ; mov dword [os_NetIOAddress], eax
28 pop ax
30 ; Grab the IRQ of the device
31 mov cl, 0x0F ; Get device's IRQ number from PCI Register 15 (IRQ is bits 7-0)
32 call os_pci_read_reg
33 mov [os_NetIRQ], al ; AL holds the IRQ
35 ; Grab the MAC address
36 mov rsi, [os_NetIOBaseMem]
37 mov eax, [rsi+0x410] ; Mac_Address_0 Part 1
38 ror eax, 8
39 mov [os_NetMAC], al
40 rol eax, 8
41 mov [os_NetMAC+1], al
42 mov eax, [rsi+0x414] ; Mac_Address_0 Part 2
43 rol eax, 8
44 mov [os_NetMAC+2], al
45 rol eax, 8
46 mov [os_NetMAC+3], al
47 rol eax, 8
48 mov [os_NetMAC+4], al
49 rol eax, 8
50 mov [os_NetMAC+5], al
52 ; Enable the Network IRQ in the PIC
53 ; IRQ value 0-7 set to zero bit 0-7 in 0x21 and value 8-15 set to zero bit 0-7 in 0xa1
54 in al, 0x21 ; low byte target 0x21
55 mov bl, al
56 mov al, [os_NetIRQ]
57 mov dx, 0x21 ; Use the low byte pic
58 cmp al, 8
59 jl os_net_bcm57xx_init_low
60 sub al, 8 ; IRQ 8-16
61 push ax
62 in al, 0xA1 ; High byte target 0xA1
63 mov bl, al
64 pop ax
65 mov dx, 0xA1 ; Use the high byte pic
66 os_net_bcm57xx_init_low:
67 mov cl, al
68 mov al, 1
69 shl al, cl
70 not al
71 and al, bl
72 out dx, al
74 ; Reset the device
75 call os_net_bcm57xx_reset
77 pop rax
78 pop rcx
79 pop rdx
80 pop rsi
81 ret
82 ; -----------------------------------------------------------------------------
85 ; -----------------------------------------------------------------------------
86 ; os_net_bcm57xx_reset - Reset a Broadcom 57XX NIC
87 ; IN: Nothing
88 ; OUT: Nothing, all registers preserved
89 os_net_bcm57xx_reset:
91 ret
92 ; -----------------------------------------------------------------------------
95 ; -----------------------------------------------------------------------------
96 ; os_net_bcm57xx_transmit - Transmit a packet via a Broadcom 57XX NIC
97 ; IN: RSI = Location of packet
98 ; RCX = Length of packet
99 ; OUT: Nothing
100 ; Uses RAX, RCX, RDX, RSI, RDI
101 ; ToDo: Check for proper timeout instead of calling os_delay
102 os_net_bcm57xx_transmit:
105 ; -----------------------------------------------------------------------------
108 ; -----------------------------------------------------------------------------
109 ; os_net_bcm57xx_poll - Polls the Broadcom 57XX NIC for a received packet
110 ; IN: RDI = Location to store packet
111 ; OUT: RCX = Length of packet
112 ; Uses RAX, RCX, RDX, RSI, RDI
113 os_net_bcm57xx_poll:
115 os_net_bcm57xx_ack_int:
118 ; -----------------------------------------------------------------------------
121 ; =============================================================================
122 ; EOF