Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
cvmx.h File Reference
#include <linux/kernel.h>
#include <linux/string.h>
#include <asm/octeon/cvmx-asm.h>
#include <asm/octeon/cvmx-packet.h>
#include <asm/octeon/cvmx-sysinfo.h>
#include <asm/octeon/cvmx-ciu-defs.h>
#include <asm/octeon/cvmx-gpio-defs.h>
#include <asm/octeon/cvmx-iob-defs.h>
#include <asm/octeon/cvmx-ipd-defs.h>
#include <asm/octeon/cvmx-l2c-defs.h>
#include <asm/octeon/cvmx-l2d-defs.h>
#include <asm/octeon/cvmx-l2t-defs.h>
#include <asm/octeon/cvmx-led-defs.h>
#include <asm/octeon/cvmx-mio-defs.h>
#include <asm/octeon/cvmx-pow-defs.h>
#include <asm/octeon/cvmx-bootinfo.h>
#include <asm/octeon/cvmx-bootmem.h>
#include <asm/octeon/cvmx-l2c.h>

Go to the source code of this file.

Macros

#define CVMX_MIPS32_SPACE_KSEG0   1l
 
#define CVMX_ADD_SEG32(segment, add)   (((int32_t)segment << 31) | (int32_t)(add))
 
#define CVMX_IO_SEG   CVMX_MIPS_SPACE_XKPHYS
 
#define CVMX_ADD_SEG(segment, add)   ((((uint64_t)segment) << 62) | (add))
 
#define CVMX_ADD_IO_SEG(add)   CVMX_ADD_SEG(CVMX_IO_SEG, (add))
 
#define CVMX_ENABLE_DEBUG_PRINTS   1
 
#define cvmx_dprintf   printk
 
#define CVMX_MAX_CORES   (16)
 
#define CVMX_CACHE_LINE_SIZE   (128) /* In bytes */
 
#define CVMX_CACHE_LINE_MASK   (CVMX_CACHE_LINE_SIZE - 1) /* In bytes */
 
#define CVMX_CACHE_LINE_ALIGNED   __attribute__ ((aligned(CVMX_CACHE_LINE_SIZE)))
 
#define CAST64(v)   ((long long)(long)(v))
 
#define CASTPTR(type, v)   ((type *)(long)(v))
 
#define CVMX_TMP_STR(x)   CVMX_TMP_STR2(x)
 
#define CVMX_TMP_STR2(x)   #x
 
#define CVMX_BUILD_WRITE64(TYPE, ST)
 
#define CVMX_BUILD_READ64(TYPE, LT)
 
#define cvmx_write64   cvmx_write64_uint64
 
#define cvmx_read64   cvmx_read64_uint64
 
#define CVMX_WAIT_FOR_FIELD64(address, type, field, op, value, timeout_usec)
 

Enumerations

enum  cvmx_mips_space { CVMX_MIPS_SPACE_XKSEG = 3LL, CVMX_MIPS_SPACE_XKPHYS = 2LL, CVMX_MIPS_SPACE_XSSEG = 1LL, CVMX_MIPS_SPACE_XUSEG = 0LL }
 

Functions

 CVMX_BUILD_WRITE64 (int64,"sd")
 
 CVMX_BUILD_WRITE64 (int32,"sw")
 
 CVMX_BUILD_WRITE64 (int16,"sh")
 
 CVMX_BUILD_WRITE64 (int8,"sb")
 
 CVMX_BUILD_WRITE64 (uint64,"sd")
 
 CVMX_BUILD_WRITE64 (uint32,"sw")
 
 CVMX_BUILD_WRITE64 (uint8,"sb")
 
 CVMX_BUILD_READ64 (int64,"ld")
 
 CVMX_BUILD_READ64 (int32,"lw")
 
 CVMX_BUILD_READ64 (int16,"lh")
 
 CVMX_BUILD_READ64 (int8,"lb")
 
 CVMX_BUILD_READ64 (uint64,"ld")
 
 CVMX_BUILD_READ64 (uint32,"lw")
 
 CVMX_BUILD_READ64 (uint16,"lhu")
 
 CVMX_BUILD_READ64 (uint8,"lbu")
 

Macro Definition Documentation

#define CAST64 (   v)    ((long long)(long)(v))

Definition at line 88 of file cvmx.h.

#define CASTPTR (   type,
  v 
)    ((type *)(long)(v))

Definition at line 89 of file cvmx.h.

#define CVMX_ADD_IO_SEG (   add)    CVMX_ADD_SEG(CVMX_IO_SEG, (add))

Definition at line 52 of file cvmx.h.

#define CVMX_ADD_SEG (   segment,
  add 
)    ((((uint64_t)segment) << 62) | (add))

Definition at line 49 of file cvmx.h.

#define CVMX_ADD_SEG32 (   segment,
  add 
)    (((int32_t)segment << 31) | (int32_t)(add))

Definition at line 43 of file cvmx.h.

#define CVMX_BUILD_READ64 (   TYPE,
  LT 
)
Value:
static inline TYPE##_t cvmx_read64_##TYPE(uint64_t addr) \
{ \
return *CASTPTR(volatile TYPE##_t, addr); \
}

Definition at line 224 of file cvmx.h.

#define CVMX_BUILD_WRITE64 (   TYPE,
  ST 
)
Value:
static inline void cvmx_write64_##TYPE(uint64_t addr, TYPE##_t val) \
{ \
*CASTPTR(volatile TYPE##_t, addr) = val; \
}

Definition at line 210 of file cvmx.h.

Definition at line 87 of file cvmx.h.

#define CVMX_CACHE_LINE_MASK   (CVMX_CACHE_LINE_SIZE - 1) /* In bytes */

Definition at line 86 of file cvmx.h.

#define CVMX_CACHE_LINE_SIZE   (128) /* In bytes */

Definition at line 85 of file cvmx.h.

#define cvmx_dprintf   printk

Definition at line 79 of file cvmx.h.

#define CVMX_ENABLE_DEBUG_PRINTS   1

Definition at line 75 of file cvmx.h.

#define CVMX_IO_SEG   CVMX_MIPS_SPACE_XKPHYS

Definition at line 46 of file cvmx.h.

#define CVMX_MAX_CORES   (16)

Definition at line 84 of file cvmx.h.

#define CVMX_MIPS32_SPACE_KSEG0   1l

Definition at line 42 of file cvmx.h.

#define cvmx_read64   cvmx_read64_uint64

Definition at line 261 of file cvmx.h.

#define CVMX_TMP_STR (   x)    CVMX_TMP_STR2(x)

Definition at line 104 of file cvmx.h.

#define CVMX_TMP_STR2 (   x)    #x

Definition at line 105 of file cvmx.h.

#define CVMX_WAIT_FOR_FIELD64 (   address,
  type,
  field,
  op,
  value,
  timeout_usec 
)
Value:
( \
{ \
int result; \
do { \
uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
cvmx_sysinfo_get()->cpu_clock_hz / 1000000; \
type c; \
while (1) { \
c.u64 = cvmx_read_csr(address); \
if ((c.s.field) op(value)) { \
result = 0; \
break; \
} else if (cvmx_get_cycle() > done) { \
result = -1; \
break; \
} else \
cvmx_wait(100); \
} \
} while (0); \
result; \
})

This macro spins on a field waiting for it to reach a value. It is common in code to need to wait for a specific field in a CSR to match a specific value. Conceptually this macro expands to:

1) read csr at "address" with a csr typedef of "type" 2) Check if ("type".s."field" "op" "value") 3) If #2 isn't true loop to #1 unless too much time has passed.

Definition at line 414 of file cvmx.h.

#define cvmx_write64   cvmx_write64_uint64

Definition at line 245 of file cvmx.h.

Enumeration Type Documentation

Enumerator:
CVMX_MIPS_SPACE_XKSEG 
CVMX_MIPS_SPACE_XKPHYS 
CVMX_MIPS_SPACE_XSSEG 
CVMX_MIPS_SPACE_XUSEG 

Definition at line 34 of file cvmx.h.

Function Documentation

CVMX_BUILD_READ64 ( int64  ,
"ld"   
)
CVMX_BUILD_READ64 ( int32  ,
"lw"   
)
CVMX_BUILD_READ64 ( int16  ,
"lh"   
)
CVMX_BUILD_READ64 ( int8  ,
"lb"   
)
CVMX_BUILD_READ64 ( uint64  ,
"ld"   
)
CVMX_BUILD_READ64 ( uint32  ,
"lw"   
)
CVMX_BUILD_READ64 ( uint16  ,
"lhu"   
)
CVMX_BUILD_READ64 ( uint8  ,
"lbu"   
)
CVMX_BUILD_WRITE64 ( int64  ,
"sd"   
)
CVMX_BUILD_WRITE64 ( int32  ,
"sw"   
)
CVMX_BUILD_WRITE64 ( int16  ,
"sh"   
)
CVMX_BUILD_WRITE64 ( int8  ,
"sb"   
)
CVMX_BUILD_WRITE64 ( uint64  ,
"sd"   
)
CVMX_BUILD_WRITE64 ( uint32  ,
"sw"   
)
CVMX_BUILD_WRITE64 ( uint8  ,
"sb"   
)