1 ; =============================================================================
2 ; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
3 ; Copyright (C) 2008-2011 Return Infinity -- see LICENSE.TXT
6 ; =============================================================================
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
23 ; Grab the Base I/O Address of the device
25 mov cl, 0x04 ; BAR0 - Lower 32 bits of memory address
27 ; mov dword [os_NetIOAddress], eax
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)
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
42 mov eax, [rsi
+0x414] ; Mac_Address_0 Part 2
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
57 mov dx, 0x21 ; Use the low byte pic
59 jl os_net_bcm57xx_init_low
62 in al, 0xA1 ; High byte target 0xA1
65 mov dx, 0xA1 ; Use the high byte pic
66 os_net_bcm57xx_init_low:
75 call os_net_bcm57xx_reset
82 ; -----------------------------------------------------------------------------
85 ; -----------------------------------------------------------------------------
86 ; os_net_bcm57xx_reset - Reset a Broadcom 57XX NIC
88 ; OUT: Nothing, all registers preserved
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
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
115 os_net_bcm57xx_ack_int:
118 ; -----------------------------------------------------------------------------
121 ; =============================================================================