linux/drivers/firewire/core.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _FIREWIRE_CORE_H
#define _FIREWIRE_CORE_H

#include <linux/compiler.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/idr.h>
#include <linux/mm_types.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
#include <linux/types.h>

#include <linux/refcount.h>

struct device;
struct fw_card;
struct fw_device;
struct fw_iso_buffer;
struct fw_iso_context;
struct fw_iso_packet;
struct fw_node;
struct fw_packet;


/* -card */

extern __printf(2, 3)
void fw_err(const struct fw_card *card, const char *fmt, ...);
extern __printf(2, 3)
void fw_notice(const struct fw_card *card, const char *fmt, ...);

/* bitfields within the PHY registers */
#define PHY_LINK_ACTIVE
#define PHY_CONTENDER
#define PHY_BUS_RESET
#define PHY_EXTENDED_REGISTERS
#define PHY_BUS_SHORT_RESET
#define PHY_INT_STATUS_BITS
#define PHY_ENABLE_ACCEL
#define PHY_ENABLE_MULTI
#define PHY_PAGE_SELECT

#define BANDWIDTH_AVAILABLE_INITIAL
#define BROADCAST_CHANNEL_INITIAL
#define BROADCAST_CHANNEL_VALID

#define CSR_STATE_BIT_CMSTR
#define CSR_STATE_BIT_ABDICATE

struct fw_card_driver {};

void fw_card_initialize(struct fw_card *card,
		const struct fw_card_driver *driver, struct device *device);
int fw_card_add(struct fw_card *card,
		u32 max_receive, u32 link_speed, u64 guid);
void fw_core_remove_card(struct fw_card *card);
int fw_compute_block_crc(__be32 *block);
void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);

/* -cdev */

extern const struct file_operations fw_device_ops;

void fw_device_cdev_update(struct fw_device *device);
void fw_device_cdev_remove(struct fw_device *device);
void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p);


/* -device */

extern struct rw_semaphore fw_device_rwsem;
extern struct idr fw_device_idr;
extern int fw_cdev_major;

static inline struct fw_device *fw_device_get(struct fw_device *device)
{}

static inline void fw_device_put(struct fw_device *device)
{}

struct fw_device *fw_device_get_by_devt(dev_t devt);
int fw_device_set_broadcast_channel(struct device *dev, void *gen);
void fw_node_event(struct fw_card *card, struct fw_node *node, int event);


/* -iso */

int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count);
int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card,
			  enum dma_data_direction direction);


/* -topology */

enum {};

struct fw_node {};

static inline struct fw_node *fw_node_get(struct fw_node *node)
{}

static inline void fw_node_put(struct fw_node *node)
{}

void fw_core_handle_bus_reset(struct fw_card *card, int node_id,
	int generation, int self_id_count, u32 *self_ids, bool bm_abdicate);
void fw_destroy_nodes(struct fw_card *card);

/*
 * Check whether new_generation is the immediate successor of old_generation.
 * Take counter roll-over at 255 (as per OHCI) into account.
 */
static inline bool is_next_generation(int new_generation, int old_generation)
{}


/* -transaction */

#define TCODE_LINK_INTERNAL

static inline bool tcode_is_read_request(unsigned int tcode)
{}

static inline bool tcode_is_block_packet(unsigned int tcode)
{}

static inline bool tcode_is_link_internal(unsigned int tcode)
{}

#define LOCAL_BUS

/* OHCI-1394's default upper bound for physical DMA: 4 GB */
#define FW_MAX_PHYSICAL_RANGE

void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
int fw_get_response_length(struct fw_request *request);
void fw_fill_response(struct fw_packet *response, u32 *request_header,
		      int rcode, void *payload, size_t length);

void fw_request_get(struct fw_request *request);
void fw_request_put(struct fw_request *request);

// Convert the value of IEEE 1394 CYCLE_TIME register to the format of timeStamp field in
// descriptors of 1394 OHCI.
static inline u32 cycle_time_to_ohci_tstamp(u32 tstamp)
{}

#define FW_PHY_CONFIG_NO_NODE_ID
#define FW_PHY_CONFIG_CURRENT_GAP_COUNT
void fw_send_phy_config(struct fw_card *card,
			int node_id, int generation, int gap_count);

static inline bool is_ping_packet(u32 *data)
{}

static inline bool is_in_fcp_region(u64 offset, size_t length)
{}

#endif /* _FIREWIRE_CORE_H */