FreeBSD kernel E1000 device code
e1000_osdep.h File Reference
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/iflib.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <machine/resource.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/clock.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
Include dependency graph for e1000_osdep.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  e1000_osdep
 

Macros

#define ASSERT(x)   if(!(x)) panic("EM: x")
 
#define us_scale(x)   max(1, (x/(1000000/hz)))
 
#define usec_delay(x)   safe_pause_us(x)
 
#define usec_delay_irq(x)   usec_delay(x)
 
#define msec_delay(x)   safe_pause_ms(x)
 
#define msec_delay_irq(x)   msec_delay(x)
 
#define DBG   0
 
#define DEBUGOUT(...)    do { if (DBG) printf(__VA_ARGS__); } while (0)
 
#define DEBUGOUT1(...)   DEBUGOUT(__VA_ARGS__)
 
#define DEBUGOUT2(...)   DEBUGOUT(__VA_ARGS__)
 
#define DEBUGOUT3(...)   DEBUGOUT(__VA_ARGS__)
 
#define DEBUGOUT7(...)   DEBUGOUT(__VA_ARGS__)
 
#define DEBUGFUNC(F)   DEBUGOUT(F "\n")
 
#define STATIC   static
 
#define CMD_MEM_WRT_INVALIDATE   0x0010 /* BIT_4 */
 
#define PCI_COMMAND_REGISTER   PCIR_COMMAND
 
#define __le16   u16
 
#define __le32   u32
 
#define __le64   u64
 
#define mb()
 
#define rmb()
 
#define wmb()
 
#define ASSERT_CTX_LOCK_HELD(hw)
 
#define prefetch(x)
 
#define E1000_REGISTER(hw, reg)
 
#define E1000_WRITE_FLUSH(a)   E1000_READ_REG(a, E1000_STATUS)
 
#define E1000_READ_OFFSET(hw, offset)
 
#define E1000_WRITE_OFFSET(hw, offset, value)
 
#define E1000_READ_REG(hw, reg)
 
#define E1000_WRITE_REG(hw, reg, value)
 
#define E1000_READ_REG_ARRAY(hw, reg, index)
 
#define E1000_WRITE_REG_ARRAY(hw, reg, index, value)
 
#define E1000_READ_REG_ARRAY_DWORD   E1000_READ_REG_ARRAY
 
#define E1000_WRITE_REG_ARRAY_DWORD   E1000_WRITE_REG_ARRAY
 
#define E1000_READ_REG_ARRAY_BYTE(hw, reg, index)
 
#define E1000_WRITE_REG_ARRAY_BYTE(hw, reg, index, value)
 
#define E1000_WRITE_REG_ARRAY_WORD(hw, reg, index, value)
 
#define E1000_WRITE_REG_IO(hw, reg, value)
 
#define E1000_READ_FLASH_REG(hw, reg)
 
#define E1000_READ_FLASH_REG16(hw, reg)
 
#define E1000_WRITE_FLASH_REG(hw, reg, value)
 
#define E1000_WRITE_FLASH_REG16(hw, reg, value)
 
#define ASSERT_NO_LOCKS()
 

Typedefs

typedef uint64_t u64
 
typedef uint32_t u32
 
typedef uint16_t u16
 
typedef uint8_t u8
 
typedef int64_t s64
 
typedef int32_t s32
 
typedef int16_t s16
 
typedef int8_t s8
 

Functions

static int ms_scale (int x)
 
static void safe_pause_us (int x)
 
static void safe_pause_ms (int x)
 

Macro Definition Documentation

◆ __le16

#define __le16   u16

Definition at line 130 of file e1000_osdep.h.

◆ __le32

#define __le32   u32

Definition at line 131 of file e1000_osdep.h.

◆ __le64

#define __le64   u64

Definition at line 132 of file e1000_osdep.h.

◆ ASSERT

#define ASSERT (   x)    if(!(x)) panic("EM: x")

Definition at line 70 of file e1000_osdep.h.

◆ ASSERT_CTX_LOCK_HELD

#define ASSERT_CTX_LOCK_HELD (   hw)

Definition at line 149 of file e1000_osdep.h.

◆ ASSERT_NO_LOCKS

#define ASSERT_NO_LOCKS ( )

Definition at line 267 of file e1000_osdep.h.

◆ CMD_MEM_WRT_INVALIDATE

#define CMD_MEM_WRT_INVALIDATE   0x0010 /* BIT_4 */

Definition at line 118 of file e1000_osdep.h.

◆ DBG

#define DBG   0

Definition at line 107 of file e1000_osdep.h.

◆ DEBUGFUNC

#define DEBUGFUNC (   F)    DEBUGOUT(F "\n")

Definition at line 115 of file e1000_osdep.h.

◆ DEBUGOUT

#define DEBUGOUT (   ...)     do { if (DBG) printf(__VA_ARGS__); } while (0)

Definition at line 109 of file e1000_osdep.h.

◆ DEBUGOUT1

#define DEBUGOUT1 (   ...)    DEBUGOUT(__VA_ARGS__)

Definition at line 111 of file e1000_osdep.h.

◆ DEBUGOUT2

#define DEBUGOUT2 (   ...)    DEBUGOUT(__VA_ARGS__)

Definition at line 112 of file e1000_osdep.h.

◆ DEBUGOUT3

#define DEBUGOUT3 (   ...)    DEBUGOUT(__VA_ARGS__)

Definition at line 113 of file e1000_osdep.h.

◆ DEBUGOUT7

#define DEBUGOUT7 (   ...)    DEBUGOUT(__VA_ARGS__)

Definition at line 114 of file e1000_osdep.h.

◆ E1000_READ_FLASH_REG

#define E1000_READ_FLASH_REG (   hw,
  reg 
)
Value:
bus_space_read_4(((struct e1000_osdep *)(hw)->back)->flash_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->flash_bus_space_handle, reg)

Definition at line 237 of file e1000_osdep.h.

◆ E1000_READ_FLASH_REG16

#define E1000_READ_FLASH_REG16 (   hw,
  reg 
)
Value:
bus_space_read_2(((struct e1000_osdep *)(hw)->back)->flash_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->flash_bus_space_handle, reg)

Definition at line 241 of file e1000_osdep.h.

◆ E1000_READ_OFFSET

#define E1000_READ_OFFSET (   hw,
  offset 
)
Value:
bus_space_read_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, offset)

Definition at line 180 of file e1000_osdep.h.

◆ E1000_READ_REG

#define E1000_READ_REG (   hw,
  reg 
)
Value:
bus_space_read_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg))
#define E1000_REGISTER(hw, reg)
Definition: e1000_osdep.h:174

Definition at line 191 of file e1000_osdep.h.

◆ E1000_READ_REG_ARRAY

#define E1000_READ_REG_ARRAY (   hw,
  reg,
  index 
)
Value:
bus_space_read_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg) + ((index)<< 2))

Definition at line 201 of file e1000_osdep.h.

◆ E1000_READ_REG_ARRAY_BYTE

#define E1000_READ_REG_ARRAY_BYTE (   hw,
  reg,
  index 
)
Value:
bus_space_read_1(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg) + index)

Definition at line 214 of file e1000_osdep.h.

◆ E1000_READ_REG_ARRAY_DWORD

#define E1000_READ_REG_ARRAY_DWORD   E1000_READ_REG_ARRAY

Definition at line 211 of file e1000_osdep.h.

◆ E1000_REGISTER

#define E1000_REGISTER (   hw,
  reg 
)
Value:
(((hw)->mac.type >= e1000_82543) \
u32 e1000_translate_register_82542(u32 reg)
Definition: e1000_82542.c:449
@ e1000_82543
Definition: e1000_hw.h:241

Definition at line 174 of file e1000_osdep.h.

◆ E1000_WRITE_FLASH_REG

#define E1000_WRITE_FLASH_REG (   hw,
  reg,
  value 
)
Value:
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->flash_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->flash_bus_space_handle, reg, value)

Definition at line 245 of file e1000_osdep.h.

◆ E1000_WRITE_FLASH_REG16

#define E1000_WRITE_FLASH_REG16 (   hw,
  reg,
  value 
)
Value:
bus_space_write_2(((struct e1000_osdep *)(hw)->back)->flash_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->flash_bus_space_handle, reg, value)

Definition at line 249 of file e1000_osdep.h.

◆ E1000_WRITE_FLUSH

#define E1000_WRITE_FLUSH (   a)    E1000_READ_REG(a, E1000_STATUS)

Definition at line 177 of file e1000_osdep.h.

◆ E1000_WRITE_OFFSET

#define E1000_WRITE_OFFSET (   hw,
  offset,
  value 
)
Value:
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, offset, value)

Definition at line 185 of file e1000_osdep.h.

◆ E1000_WRITE_REG

#define E1000_WRITE_REG (   hw,
  reg,
  value 
)
Value:
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg), value)

Definition at line 196 of file e1000_osdep.h.

◆ E1000_WRITE_REG_ARRAY

#define E1000_WRITE_REG_ARRAY (   hw,
  reg,
  index,
  value 
)
Value:
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg) + ((index)<< 2), value)

Definition at line 206 of file e1000_osdep.h.

◆ E1000_WRITE_REG_ARRAY_BYTE

#define E1000_WRITE_REG_ARRAY_BYTE (   hw,
  reg,
  index,
  value 
)
Value:
bus_space_write_1(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg) + index, value)

Definition at line 219 of file e1000_osdep.h.

◆ E1000_WRITE_REG_ARRAY_DWORD

#define E1000_WRITE_REG_ARRAY_DWORD   E1000_WRITE_REG_ARRAY

Definition at line 212 of file e1000_osdep.h.

◆ E1000_WRITE_REG_ARRAY_WORD

#define E1000_WRITE_REG_ARRAY_WORD (   hw,
  reg,
  index,
  value 
)
Value:
bus_space_write_2(((struct e1000_osdep *)(hw)->back)->mem_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->mem_bus_space_handle, \
E1000_REGISTER(hw, reg) + (index << 1), value)

Definition at line 224 of file e1000_osdep.h.

◆ E1000_WRITE_REG_IO

#define E1000_WRITE_REG_IO (   hw,
  reg,
  value 
)
Value:
do {\
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->io_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->io_bus_space_handle, \
(hw)->io_base, reg); \
bus_space_write_4(((struct e1000_osdep *)(hw)->back)->io_bus_space_tag, \
((struct e1000_osdep *)(hw)->back)->io_bus_space_handle, \
(hw)->io_base + 4, value); } while (0)

Definition at line 229 of file e1000_osdep.h.

◆ mb

#define mb ( )

Definition at line 140 of file e1000_osdep.h.

◆ msec_delay

#define msec_delay (   x)    safe_pause_ms(x)

Definition at line 103 of file e1000_osdep.h.

◆ msec_delay_irq

#define msec_delay_irq (   x)    msec_delay(x)

Definition at line 104 of file e1000_osdep.h.

◆ PCI_COMMAND_REGISTER

#define PCI_COMMAND_REGISTER   PCIR_COMMAND

Definition at line 119 of file e1000_osdep.h.

◆ prefetch

#define prefetch (   x)

Definition at line 159 of file e1000_osdep.h.

◆ rmb

#define rmb ( )

Definition at line 141 of file e1000_osdep.h.

◆ STATIC

#define STATIC   static

Definition at line 117 of file e1000_osdep.h.

◆ us_scale

#define us_scale (   x)    max(1, (x/(1000000/hz)))

Definition at line 71 of file e1000_osdep.h.

◆ usec_delay

#define usec_delay (   x)    safe_pause_us(x)

Definition at line 101 of file e1000_osdep.h.

◆ usec_delay_irq

#define usec_delay_irq (   x)    usec_delay(x)

Definition at line 102 of file e1000_osdep.h.

◆ wmb

#define wmb ( )

Definition at line 142 of file e1000_osdep.h.

Typedef Documentation

◆ s16

typedef int16_t s16

Definition at line 127 of file e1000_osdep.h.

◆ s32

typedef int32_t s32

Definition at line 126 of file e1000_osdep.h.

◆ s64

typedef int64_t s64

Definition at line 125 of file e1000_osdep.h.

◆ s8

typedef int8_t s8

Definition at line 128 of file e1000_osdep.h.

◆ u16

typedef uint16_t u16

Definition at line 123 of file e1000_osdep.h.

◆ u32

typedef uint32_t u32

Definition at line 122 of file e1000_osdep.h.

◆ u64

typedef uint64_t u64

Definition at line 121 of file e1000_osdep.h.

◆ u8

typedef uint8_t u8

Definition at line 124 of file e1000_osdep.h.

Function Documentation

◆ ms_scale()

static int ms_scale ( int  x)
inlinestatic

Definition at line 73 of file e1000_osdep.h.

Referenced by safe_pause_ms().

Here is the caller graph for this function:

◆ safe_pause_ms()

static void safe_pause_ms ( int  x)
inlinestatic

Definition at line 93 of file e1000_osdep.h.

References ms_scale().

Here is the call graph for this function:

◆ safe_pause_us()

static void safe_pause_us ( int  x)
inlinestatic

Definition at line 84 of file e1000_osdep.h.