1/*
2 * pci_ethernet.h
3 *
4 *  Created on: May 13, 2012
5 *      Author: luki
6 */
7
8#ifndef PCI_ETHERNET_H_
9#define PCI_ETHERNET_H_
10
11#include <dev/pci_hdr0_mem_dev.h>
12#include "pci.h"
13
14// Mask for the MMIO region size
15#define ETH_MMIO_MASK(eth) (~(~eth->bytes + 1)) // I think ~(-eth->bytes) is also correct
16
17// Checks if a address is a mmio access to the ethernet card
18//#define ETH_MMIO_ADDR_CHECK(eth,addr) ( (addr & ~ETH_MMIO_MASK(eth)) == eth->phys_base_addr )
19
20#define ETH_MMIO_ADDR_CHECK(eth,addr) ( eth->phys_base_addr <= addr && addr <= eth->phys_base_addr + eth->bytes  )
21
22
23struct pci_ethernet {
24    pci_hdr0_mem_t      ph;
25    uint32_t            pci_header[0x40];
26    uint64_t            phys_base_addr; //host physical device memory base address
27    void *              virt_base_addr; //vmkitmon virtual adress
28	size_t              bytes;
29	struct pci_device *pci_device;
30};
31
32
33#endif /* PCI_ETHERNET_H_ */
34