2007-08-31 01:59:49 +04:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2007, Haiku Inc. All rights reserved.
|
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* JiSheng Zhang
|
|
|
|
|
*/
|
|
|
|
|
#ifndef _FW_GLUE_H
|
|
|
|
|
#define _FW_GLUE_H
|
|
|
|
|
|
2014-08-08 01:12:54 +04:00
|
|
|
|
|
2007-08-31 01:59:49 +04:00
|
|
|
|
#include <dpc.h>
|
2014-08-08 01:12:54 +04:00
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <strings.h>
|
|
|
|
|
|
2007-08-31 01:59:49 +04:00
|
|
|
|
|
|
|
|
|
#define device_printf(dev, a...) dprintf("firewire:" a)
|
|
|
|
|
#define printf(a...) dprintf(a)
|
|
|
|
|
#define KASSERT(cond,msg) do { \
|
|
|
|
|
if (!cond) \
|
|
|
|
|
panic msg; \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#ifndef howmany
|
|
|
|
|
#define howmany(x, y) (((x)+((y)-1))/(y)) // x/y的上界
|
|
|
|
|
#endif
|
|
|
|
|
#define rounddown(x, y) (((x)/(y))*(y)) // 比x小,y的最大的倍数
|
|
|
|
|
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ // 比x大,y的最小倍数
|
|
|
|
|
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
|
|
|
|
|
#define powerof2(x) ((((x)-1)&(x))==0) // 是否是2的次方
|
|
|
|
|
|
|
|
|
|
typedef uint32_t bus_addr_t;
|
|
|
|
|
typedef uint32_t bus_size_t;
|
|
|
|
|
|
2013-11-06 01:32:59 +04:00
|
|
|
|
#define atomic_readandclear_int(ptr) atomic_get_and_set((int32*)(ptr), 0)
|
2008-04-26 19:02:43 +04:00
|
|
|
|
#define atomic_set_int(ptr, value) atomic_or((int32 *)(ptr), value)
|
2007-08-31 01:59:49 +04:00
|
|
|
|
|
2008-05-31 23:50:53 +04:00
|
|
|
|
#define mtx_lock mutex_lock
|
|
|
|
|
#define mtx_unlock mutex_unlock
|
|
|
|
|
#define mtx_destroy mutex_destroy
|
|
|
|
|
#define mtx_init(lockaddr, name, type, opts) mutex_init(lockaddr, name)
|
2007-08-31 01:59:49 +04:00
|
|
|
|
|
2009-05-25 03:15:04 +04:00
|
|
|
|
#define wakeup(i) release_sem_etc(i->Sem, 0, B_RELEASE_IF_WAITING_ONLY | B_RELEASE_ALL)
|
|
|
|
|
|
2007-08-31 01:59:49 +04:00
|
|
|
|
#define splfw() 0
|
2012-02-12 18:13:04 +04:00
|
|
|
|
#define splx(s) (void)s
|
2007-08-31 01:59:49 +04:00
|
|
|
|
|
|
|
|
|
#define hz 1000000LL
|
|
|
|
|
|
|
|
|
|
#define DELAY(n) snooze(n)
|
|
|
|
|
|
|
|
|
|
#define OWRITE(sc, offset, value) (*(volatile uint32 *)((char *)(sc->regAddr) + (offset)) = value)
|
|
|
|
|
#define OREAD(sc, offset) (*(volatile uint32 *)((char *)(sc->regAddr) + (offset)))
|
|
|
|
|
|
|
|
|
|
#define MAX_CARDS 4
|
|
|
|
|
extern dpc_module_info *gDpc;
|
|
|
|
|
|
|
|
|
|
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
|
|
|
|
|
|
|
|
|
|
#endif /*_FW_GLUE_H*/
|