mirror of
https://github.com/OpenAMP/libmetal.git
synced 2026-02-06 03:33:05 +08:00
lib: fix minor coding style
Fix coding style reported by do_checkpatch.sh Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
This commit is contained in:
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup Memory Allocation Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief allocate requested memory size
|
||||
@@ -31,7 +32,7 @@ static inline void *metal_allocate_memory(unsigned int size);
|
||||
/**
|
||||
* @brief free the memory previously allocated
|
||||
*
|
||||
* @param[in] ptr pointer to memory
|
||||
* @param[in] ptr pointer to memory
|
||||
*/
|
||||
static inline void metal_free_memory(void *ptr);
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** \defgroup cache CACHE Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief flush specified data cache
|
||||
|
||||
@@ -20,7 +20,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup condition Condition Variable Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Opaque libmetal condition variable data structure. */
|
||||
struct metal_condition;
|
||||
|
||||
@@ -45,8 +45,8 @@ int metal_bus_find(const char *name, struct metal_bus **result)
|
||||
bus = metal_container_of(node, struct metal_bus, node);
|
||||
if (strcmp(bus->name, name) == 0 && result) {
|
||||
*result = bus;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ int metal_generic_dev_open(struct metal_bus *bus, const char *dev_name,
|
||||
metal_list_for_each(&_metal.common.generic_device_list, node) {
|
||||
dev = metal_container_of(node, struct metal_device, node);
|
||||
if (strcmp(dev->name, dev_name) == 0) {
|
||||
*device = dev;
|
||||
*device = dev;
|
||||
return metal_generic_dev_sys_open(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
|
||||
23
lib/device.h
23
lib/device.h
@@ -23,7 +23,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup device Bus Abstraction
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef METAL_MAX_DEVICE_REGIONS
|
||||
#define METAL_MAX_DEVICE_REGIONS 32
|
||||
@@ -41,8 +42,8 @@ struct metal_bus_ops {
|
||||
void (*dev_close)(struct metal_bus *bus,
|
||||
struct metal_device *device);
|
||||
void (*dev_irq_ack)(struct metal_bus *bus,
|
||||
struct metal_device *device,
|
||||
int irq);
|
||||
struct metal_device *device,
|
||||
int irq);
|
||||
int (*dev_dma_map)(struct metal_bus *bus,
|
||||
struct metal_device *device,
|
||||
uint32_t dir,
|
||||
@@ -50,10 +51,10 @@ struct metal_bus_ops {
|
||||
int nents_in,
|
||||
struct metal_sg *sg_out);
|
||||
void (*dev_dma_unmap)(struct metal_bus *bus,
|
||||
struct metal_device *device,
|
||||
uint32_t dir,
|
||||
struct metal_sg *sg,
|
||||
int nents);
|
||||
struct metal_device *device,
|
||||
uint32_t dir,
|
||||
struct metal_sg *sg,
|
||||
int nents);
|
||||
};
|
||||
|
||||
/** Libmetal bus structure. */
|
||||
@@ -71,10 +72,10 @@ extern struct metal_bus metal_generic_bus;
|
||||
struct metal_device {
|
||||
const char *name; /**< Device name */
|
||||
struct metal_bus *bus; /**< Bus that contains device */
|
||||
unsigned num_regions; /**< Number of I/O regions in
|
||||
device */
|
||||
unsigned int num_regions; /**< Number of I/O regions in
|
||||
device */
|
||||
struct metal_io_region regions[METAL_MAX_DEVICE_REGIONS]; /**< Array of
|
||||
I/O regions in device*/
|
||||
I/O regions in device*/
|
||||
struct metal_list node; /**< Node on bus' list of devices */
|
||||
int irq_num; /**< Number of IRQs per device */
|
||||
void *irq_info; /**< IRQ ID */
|
||||
@@ -143,7 +144,7 @@ extern void metal_device_close(struct metal_device *device);
|
||||
* @return I/O accessor handle, or NULL on failure.
|
||||
*/
|
||||
static inline struct metal_io_region *
|
||||
metal_device_io_region(struct metal_device *device, unsigned index)
|
||||
metal_device_io_region(struct metal_device *device, unsigned int index)
|
||||
{
|
||||
return (index < device->num_regions
|
||||
? &device->regions[index]
|
||||
|
||||
@@ -29,8 +29,7 @@ int metal_dma_map(struct metal_device *dev,
|
||||
/* If it is device read, apply memory write fence. */
|
||||
atomic_thread_fence(memory_order_release);
|
||||
else
|
||||
/* If it is device write or device r/w,
|
||||
apply memory r/w fence. */
|
||||
/* If it is device write or r/w, apply memory r/w fence. */
|
||||
atomic_thread_fence(memory_order_acq_rel);
|
||||
nents_out = dev->bus->ops.dev_dma_map(dev->bus,
|
||||
dev, dir, sg_in, nents_in, sg_out);
|
||||
@@ -47,8 +46,7 @@ void metal_dma_unmap(struct metal_device *dev,
|
||||
/* If it is device read, apply memory write fence. */
|
||||
atomic_thread_fence(memory_order_release);
|
||||
else
|
||||
/* If it is device write or device r/w,
|
||||
apply memory r/w fence. */
|
||||
/*If it is device write or r/w, apply memory r/w fence */
|
||||
atomic_thread_fence(memory_order_acq_rel);
|
||||
|
||||
if (!dev || !dev->bus->ops.dev_dma_unmap || !sg)
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup dma DMA Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <metal/sys.h>
|
||||
@@ -66,9 +67,9 @@ int metal_dma_map(struct metal_device *dev,
|
||||
* @param[in] nents number of sg list entries of DMA memory
|
||||
*/
|
||||
void metal_dma_unmap(struct metal_device *dev,
|
||||
uint32_t dir,
|
||||
struct metal_sg *sg,
|
||||
int nents);
|
||||
uint32_t dir,
|
||||
struct metal_sg *sg,
|
||||
int nents);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
2
lib/io.c
2
lib/io.c
@@ -11,7 +11,7 @@
|
||||
|
||||
void metal_io_init(struct metal_io_region *io, void *virt,
|
||||
const metal_phys_addr_t *physmap, size_t size,
|
||||
unsigned page_shift, unsigned int mem_flags,
|
||||
unsigned int page_shift, unsigned int mem_flags,
|
||||
const struct metal_io_ops *ops)
|
||||
{
|
||||
const struct metal_io_ops nops = {
|
||||
|
||||
50
lib/io.h
50
lib/io.h
@@ -27,7 +27,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup io IO Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __MICROBLAZE__
|
||||
#define NO_ATOMIC_64_SUPPORT
|
||||
@@ -47,24 +48,23 @@ struct metal_io_ops {
|
||||
memory_order order,
|
||||
int width);
|
||||
int (*block_read)(struct metal_io_region *io,
|
||||
unsigned long offset,
|
||||
void *restrict dst,
|
||||
memory_order order,
|
||||
int len);
|
||||
unsigned long offset,
|
||||
void *restrict dst,
|
||||
memory_order order,
|
||||
int len);
|
||||
int (*block_write)(struct metal_io_region *io,
|
||||
unsigned long offset,
|
||||
const void *restrict src,
|
||||
memory_order order,
|
||||
int len);
|
||||
unsigned long offset,
|
||||
const void *restrict src,
|
||||
memory_order order,
|
||||
int len);
|
||||
void (*block_set)(struct metal_io_region *io,
|
||||
unsigned long offset,
|
||||
unsigned char value,
|
||||
memory_order order,
|
||||
int len);
|
||||
unsigned long offset,
|
||||
unsigned char value,
|
||||
memory_order order,
|
||||
int len);
|
||||
void (*close)(struct metal_io_region *io);
|
||||
metal_phys_addr_t
|
||||
(*offset_to_phys)(struct metal_io_region *io,
|
||||
unsigned long offset);
|
||||
metal_phys_addr_t (*offset_to_phys)(struct metal_io_region *io,
|
||||
unsigned long offset);
|
||||
unsigned long (*phys_to_offset)(struct metal_io_region *io,
|
||||
metal_phys_addr_t phys);
|
||||
};
|
||||
@@ -73,8 +73,8 @@ struct metal_io_ops {
|
||||
struct metal_io_region {
|
||||
void *virt; /**< base virtual address */
|
||||
const metal_phys_addr_t *physmap; /**< table of base physical address
|
||||
of each of the pages in the I/O
|
||||
region */
|
||||
of each of the pages in the I/O
|
||||
region */
|
||||
size_t size; /**< size of the I/O region */
|
||||
unsigned long page_shift; /**< page shift of I/O region */
|
||||
metal_phys_addr_t page_mask; /**< page mask of I/O region */
|
||||
@@ -97,7 +97,7 @@ struct metal_io_region {
|
||||
void
|
||||
metal_io_init(struct metal_io_region *io, void *virt,
|
||||
const metal_phys_addr_t *physmap, size_t size,
|
||||
unsigned page_shift, unsigned int mem_flags,
|
||||
unsigned int page_shift, unsigned int mem_flags,
|
||||
const struct metal_io_ops *ops);
|
||||
|
||||
/**
|
||||
@@ -146,6 +146,7 @@ static inline unsigned long
|
||||
metal_io_virt_to_offset(struct metal_io_region *io, void *virt)
|
||||
{
|
||||
size_t offset = (uint8_t *)virt - (uint8_t *)io->virt;
|
||||
|
||||
return (offset < io->size ? offset : METAL_BAD_OFFSET);
|
||||
}
|
||||
|
||||
@@ -163,7 +164,7 @@ metal_io_phys(struct metal_io_region *io, unsigned long offset)
|
||||
unsigned long page = (io->page_shift >=
|
||||
sizeof(offset) * CHAR_BIT ?
|
||||
0 : offset >> io->page_shift);
|
||||
return (io->physmap != NULL && offset < io->size
|
||||
return (io->physmap && offset < io->size
|
||||
? io->physmap[page] + (offset & io->page_mask)
|
||||
: METAL_BAD_PHYS);
|
||||
}
|
||||
@@ -269,6 +270,7 @@ metal_io_write(struct metal_io_region *io, unsigned long offset,
|
||||
uint64_t value, memory_order order, int width)
|
||||
{
|
||||
void *ptr = metal_io_virt(io, offset);
|
||||
|
||||
if (io->ops.write)
|
||||
(*io->ops.write)(io, offset, value, order, width);
|
||||
else if (ptr && sizeof(atomic_uchar) == width)
|
||||
@@ -284,7 +286,7 @@ metal_io_write(struct metal_io_region *io, unsigned long offset,
|
||||
atomic_store_explicit((atomic_ullong *)ptr, value, order);
|
||||
#endif
|
||||
else
|
||||
metal_assert (0);
|
||||
metal_assert(0);
|
||||
}
|
||||
|
||||
#define metal_io_read8_explicit(_io, _ofs, _order) \
|
||||
@@ -332,7 +334,7 @@ metal_io_write(struct metal_io_region *io, unsigned long offset,
|
||||
* @return On success, number of bytes read. On failure, negative value
|
||||
*/
|
||||
int metal_io_block_read(struct metal_io_region *io, unsigned long offset,
|
||||
void *restrict dst, int len);
|
||||
void *restrict dst, int len);
|
||||
|
||||
/**
|
||||
* @brief Write a block into an I/O region.
|
||||
@@ -343,7 +345,7 @@ int metal_io_block_read(struct metal_io_region *io, unsigned long offset,
|
||||
* @return On success, number of bytes written. On failure, negative value
|
||||
*/
|
||||
int metal_io_block_write(struct metal_io_region *io, unsigned long offset,
|
||||
const void *restrict src, int len);
|
||||
const void *restrict src, int len);
|
||||
|
||||
/**
|
||||
* @brief fill a block of an I/O region.
|
||||
@@ -354,7 +356,7 @@ int metal_io_block_write(struct metal_io_region *io, unsigned long offset,
|
||||
* @return On success, number of bytes filled. On failure, negative value
|
||||
*/
|
||||
int metal_io_block_set(struct metal_io_region *io, unsigned long offset,
|
||||
unsigned char value, int len);
|
||||
unsigned char value, int len);
|
||||
|
||||
#include <metal/system/@PROJECT_SYSTEM@/io.h>
|
||||
|
||||
|
||||
12
lib/irq.c
12
lib/irq.c
@@ -61,9 +61,11 @@ int metal_irq_register_controller(struct metal_irq_controller *cntr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate IRQ numbers which are not yet used by any IRQ
|
||||
* controllers.*/
|
||||
irq_base = metal_irq_allocate(cntr->irq_base , cntr->irq_num);
|
||||
/*
|
||||
* Allocate IRQ numbers which are not yet used by any IRQ
|
||||
* controllers.
|
||||
*/
|
||||
irq_base = metal_irq_allocate(cntr->irq_base, cntr->irq_num);
|
||||
if (irq_base == METAL_IRQ_ANY) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -83,11 +85,11 @@ static struct metal_irq_controller *metal_irq_get_controller(int irq)
|
||||
|
||||
cntr = (struct metal_irq_controller *)
|
||||
metal_container_of(node, struct metal_irq_controller,
|
||||
node);
|
||||
node);
|
||||
irq_base = cntr->irq_base;
|
||||
irq_end = irq_base + cntr->irq_num;
|
||||
if (irq >= irq_base && irq < irq_end) {
|
||||
return cntr;
|
||||
return cntr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup irq Interrupt Handling Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <metal/list.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup irq Interrupt Handling Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <metal/irq.h>
|
||||
#include <metal/list.h>
|
||||
@@ -64,12 +65,14 @@ struct metal_irq {
|
||||
/** Libmetal interrupt controller structure */
|
||||
struct metal_irq_controller {
|
||||
int irq_base; /**< Start of IRQ number of the range managed by
|
||||
the IRQ controller */
|
||||
* the IRQ controller
|
||||
*/
|
||||
int irq_num; /**< Number of IRQs managed by the IRQ controller */
|
||||
void *arg; /**< Argument to pass to interrupt controller function */
|
||||
metal_irq_set_enable irq_set_enable; /**< function to set IRQ eanble */
|
||||
metal_cntr_irq_register irq_register; /**< function to register IRQ
|
||||
handler */
|
||||
* handler
|
||||
*/
|
||||
struct metal_list node; /**< list node */
|
||||
struct metal_irq *irqs; /**< Array of IRQs managed by the controller */
|
||||
};
|
||||
@@ -87,7 +90,7 @@ struct metal_irq_controller {
|
||||
.irq_set_enable = _irq_set_enable, \
|
||||
.irq_register = _irq_register, \
|
||||
.irqs = _irqs,\
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief metal_irq_register_controller
|
||||
@@ -115,7 +118,7 @@ int metal_irq_register_controller(struct metal_irq_controller *cntr);
|
||||
static inline
|
||||
int metal_irq_handle(struct metal_irq *irq_data, int irq)
|
||||
{
|
||||
if (irq_data != NULL && irq_data->hd != NULL) {
|
||||
if (irq_data && irq_data->hd) {
|
||||
return irq_data->hd(irq, irq_data->arg);
|
||||
} else {
|
||||
return METAL_IRQ_NOT_HANDLED;
|
||||
|
||||
@@ -19,7 +19,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup list List Primitives
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct metal_list {
|
||||
struct metal_list *next, *prev;
|
||||
@@ -39,7 +40,8 @@ struct metal_list {
|
||||
|
||||
static inline void metal_list_init(struct metal_list *list)
|
||||
{
|
||||
list->next = list->prev = list;
|
||||
list->prev = list;
|
||||
list->next = list;
|
||||
}
|
||||
|
||||
static inline void metal_list_add_before(struct metal_list *node,
|
||||
@@ -81,7 +83,8 @@ static inline void metal_list_del(struct metal_list *node)
|
||||
{
|
||||
node->next->prev = node->prev;
|
||||
node->prev->next = node->next;
|
||||
node->next = node->prev = node;
|
||||
node->prev = node;
|
||||
node->next = node;
|
||||
}
|
||||
|
||||
static inline struct metal_list *metal_list_first(struct metal_list *list)
|
||||
|
||||
@@ -16,7 +16,7 @@ void metal_default_log_handler(enum metal_log_level level,
|
||||
#ifdef DEFAULT_LOGGER_ON
|
||||
char msg[1024];
|
||||
va_list args;
|
||||
static const char *level_strs[] = {
|
||||
static const char * const level_strs[] = {
|
||||
"metal: emergency: ",
|
||||
"metal: alert: ",
|
||||
"metal: critical: ",
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup logging Library Logging Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Log message priority levels for libmetal. */
|
||||
enum metal_log_level {
|
||||
@@ -70,7 +71,6 @@ extern enum metal_log_level metal_get_log_level(void);
|
||||
extern void metal_default_log_handler(enum metal_log_level level,
|
||||
const char *format, ...);
|
||||
|
||||
|
||||
/**
|
||||
* Emit a log message if the log level permits.
|
||||
*
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup mutex Mutex Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <metal/system/@PROJECT_SYSTEM@/mutex.h>
|
||||
|
||||
@@ -40,7 +41,7 @@ static inline void metal_mutex_deinit(metal_mutex_t *mutex)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Try to acquire a mutex
|
||||
* @brief Try to acquire a mutex
|
||||
* @param[in] mutex Mutex to mutex.
|
||||
* @return 0 on failure to acquire, non-zero on success.
|
||||
*/
|
||||
@@ -50,7 +51,7 @@ static inline int metal_mutex_try_acquire(metal_mutex_t *mutex)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Acquire a mutex
|
||||
* @brief Acquire a mutex
|
||||
* @param[in] mutex Mutex to mutex.
|
||||
*/
|
||||
static inline void metal_mutex_acquire(metal_mutex_t *mutex)
|
||||
|
||||
@@ -19,7 +19,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup shmem Shared Memory Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Generic shared memory data structure. */
|
||||
struct metal_generic_shmem {
|
||||
|
||||
@@ -19,7 +19,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup sleep Sleep Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief delay in microseconds
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
static const int metal_softirq_num = num; \
|
||||
static struct metal_irq metal_softirqs[num]; \
|
||||
static atomic_char metal_softirq_pending[num]; \
|
||||
static atomic_char metal_softirq_enabled[num]; \
|
||||
static atomic_char metal_softirq_enabled[num];
|
||||
|
||||
static int metal_softirq_avail = 0;
|
||||
static int metal_softirq_avail;
|
||||
METAL_SOFTIRQ_ARRAY_DECLARE(METAL_SOFTIRQ_NUM)
|
||||
|
||||
static void metal_softirq_set_enable(struct metal_irq_controller *cntr,
|
||||
@@ -45,7 +45,7 @@ static METAL_IRQ_CONTROLLER_DECLARE(metal_softirq_cntr,
|
||||
METAL_IRQ_ANY, METAL_SOFTIRQ_NUM,
|
||||
NULL,
|
||||
metal_softirq_set_enable, NULL,
|
||||
metal_softirqs)
|
||||
metal_softirqs);
|
||||
|
||||
void metal_softirq_set(int irq)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ void metal_softirq_set(int irq)
|
||||
atomic_store(&metal_softirq_pending[irq], 1);
|
||||
}
|
||||
|
||||
int metal_softirq_init()
|
||||
int metal_softirq_init(void)
|
||||
{
|
||||
return metal_irq_register_controller(&metal_softirq_cntr);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ int metal_softirq_allocate(int num)
|
||||
return irq_base;
|
||||
}
|
||||
|
||||
void metal_softirq_dispatch()
|
||||
void metal_softirq_dispatch(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup soft irq Interrupt Handling Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <metal/irq.h>
|
||||
|
||||
@@ -28,14 +29,14 @@ extern "C" {
|
||||
*
|
||||
* @return 0 on success, or negative value for failure
|
||||
*/
|
||||
int metal_softirq_init();
|
||||
int metal_softirq_init(void);
|
||||
|
||||
/**
|
||||
* @brief metal_softirq_dispatch
|
||||
*
|
||||
* Dispatch the pending soft IRQs
|
||||
*/
|
||||
void metal_softirq_dispatch();
|
||||
void metal_softirq_dispatch(void);
|
||||
|
||||
/**
|
||||
* @brief metal_softirq_allocate
|
||||
|
||||
@@ -20,7 +20,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup spinlock Spinlock Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct metal_spinlock {
|
||||
atomic_flag v;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup system Top Level Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Physical address type. */
|
||||
typedef unsigned long metal_phys_addr_t;
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup time TIME Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <metal/sys.h>
|
||||
|
||||
@@ -21,7 +21,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup utilities Simple Utilities
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** Marker for unused function arguments/variables. */
|
||||
#define metal_unused(x) do { (x) = (x); } while (0)
|
||||
@@ -64,7 +65,7 @@ extern "C" {
|
||||
|
||||
/** Compute offset of a field within a structure. */
|
||||
#define metal_offset_of(structure, member) \
|
||||
((uintptr_t) &(((structure *) 0)->member))
|
||||
((uintptr_t)&(((structure *)0)->member))
|
||||
|
||||
/** Compute pointer to a structure given a pointer to one of its fields. */
|
||||
#define metal_container_of(ptr, structure, member) \
|
||||
@@ -104,9 +105,10 @@ metal_bitmap_next_set_bit(unsigned long *bitmap, unsigned int start,
|
||||
unsigned int max)
|
||||
{
|
||||
unsigned int bit;
|
||||
|
||||
for (bit = start;
|
||||
bit < max && !metal_bitmap_is_bit_set(bitmap, bit);
|
||||
bit ++)
|
||||
bit++)
|
||||
;
|
||||
return bit;
|
||||
}
|
||||
@@ -121,9 +123,10 @@ metal_bitmap_next_clear_bit(unsigned long *bitmap, unsigned int start,
|
||||
unsigned int max)
|
||||
{
|
||||
unsigned int bit;
|
||||
|
||||
for (bit = start;
|
||||
bit < max && !metal_bitmap_is_bit_clear(bitmap, bit);
|
||||
bit ++)
|
||||
bit++)
|
||||
;
|
||||
return bit;
|
||||
}
|
||||
@@ -139,7 +142,7 @@ static inline unsigned long metal_log2(unsigned long in)
|
||||
|
||||
metal_assert((in & (in - 1)) == 0);
|
||||
|
||||
for (result = 0; (1UL << result) < in; result ++)
|
||||
for (result = 0; (1UL << result) < in; result++)
|
||||
;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@ int metal_ver_major(void)
|
||||
|
||||
int metal_ver_minor(void)
|
||||
{
|
||||
return METAL_VER_MINOR;
|
||||
return METAL_VER_MINOR;
|
||||
}
|
||||
|
||||
int metal_ver_patch(void)
|
||||
{
|
||||
return METAL_VER_PATCH;
|
||||
return METAL_VER_PATCH;
|
||||
}
|
||||
|
||||
const char *metal_ver(void)
|
||||
{
|
||||
return METAL_VER;
|
||||
return METAL_VER;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/** \defgroup versions Library Version Interfaces
|
||||
* @{ */
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Library major version number.
|
||||
|
||||
Reference in New Issue
Block a user