<commit_before>/*
 * Copyright (c) 2010 Broadcom Corporation
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _linux_osl_h_
#define _linux_osl_h_

#ifdef BRCM_FULLMAC
#include <typedefs.h>
#endif

/* Linux Kernel: File Operations: start */
extern void *osl_os_open_image(char *filename);
extern int osl_os_get_image_block(char *buf, int len, void *image);
extern void osl_os_close_image(void *image);
/* Linux Kernel: File Operations: end */

extern osl_t *osl_attach(void *pdev, uint bustype, bool pkttag);
extern void osl_detach(osl_t *osh);

extern u32 g_assert_type;

#if defined(BCMDBG_ASSERT)
#define ASSERT(exp) \
	  do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
extern void osl_assert(char *exp, char *file, int line);
#else
#ifdef __GNUC__
#define GCC_VERSION \
			(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 30100
#define ASSERT(exp)	do {} while (0)
#else
			/* ASSERT could cause segmentation fault on GCC3.1, use empty instead */
#define ASSERT(exp)
#endif				/* GCC_VERSION > 30100 */
#endif				/* __GNUC__ */
#endif				/* defined(BCMDBG_ASSERT) */

/* PCI configuration space access macros */
#define	OSL_PCI_READ_CONFIG(osh, offset, size) \
	osl_pci_read_config((osh), (offset), (size))
#define	OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
	osl_pci_write_config((osh), (offset), (size), (val))
extern u32 osl_pci_read_config(osl_t *osh, uint offset, uint size);
extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);

/* PCI device bus # and slot # */
#define OSL_PCI_BUS(osh)	osl_pci_bus(osh)
#define OSL_PCI_SLOT(osh)	osl_pci_slot(osh)
extern uint osl_pci_bus(osl_t *osh);
extern uint osl_pci_slot(osl_t *osh);

/* Pkttag flag should be part of public information */
typedef struct {
	bool pkttag;
	uint pktalloced;	/* Number of allocated packet buffers */
	bool mmbus;		/* Bus supports memory-mapped register accesses */
	pktfree_cb_fn_t tx_fn;	/* Callback function for PKTFREE */
	void *tx_ctx;		/* Context to the callback function */
#if defined(BCMSDIO) && !defined(BRCM_FULLMAC)
	osl_rreg_fn_t rreg_fn;	/* Read Register function */
	osl_wreg_fn_t wreg_fn;	/* Write Register function */
	void *reg_ctx;		/* Context to the reg callback functions */
#endif
} osl_pubinfo_t;

#define PKTFREESETCB(osh, _tx_fn, _tx_ctx)			\
	do {							\
		((osl_pubinfo_t *)osh)->tx_fn = _tx_fn;		\
		((osl_pubinfo_t *)osh)->tx_ctx = _tx_ctx;	\
	} while (0)

#if defined(BCMSDIO) && !defined(BRCM_FULLMAC)
#define REGOPSSET(osh, rreg, wreg, ctx)			\
	do {						\
		((osl_pubinfo_t *)osh)->rreg_fn = rreg;	\
		((osl_pubinfo_t *)osh)->wreg_fn = wreg;	\
		((osl_pubinfo_t *)osh)->reg_ctx = ctx;	\
	} while (0)
#endif

#define BUS_SWAP32(v)		(v)

#define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
extern void osl_mfree(osl_t *osh, void *addr, uint size);

#define NATIVE_MALLOC(osh, size)	kmalloc(size, GFP_ATOMIC)
#define NATIVE_MFREE(osh, addr, size)	kfree(addr)

#define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
extern uint osl_dma_consistent_align(void);
extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,<commit_msg>staging: brcm80211: remove unused NATIVE_{MALLOC,MFREE}<commit_after>/*
 * Copyright (c) 2010 Broadcom Corporation
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef _linux_osl_h_
#define _linux_osl_h_

#ifdef BRCM_FULLMAC
#include <typedefs.h>
#endif

/* Linux Kernel: File Operations: start */
extern void *osl_os_open_image(char *filename);
extern int osl_os_get_image_block(char *buf, int len, void *image);
extern void osl_os_close_image(void *image);
/* Linux Kernel: File Operations: end */

extern osl_t *osl_attach(void *pdev, uint bustype, bool pkttag);
extern void osl_detach(osl_t *osh);

extern u32 g_assert_type;

#if defined(BCMDBG_ASSERT)
#define ASSERT(exp) \
	  do { if (!(exp)) osl_assert(#exp, __FILE__, __LINE__); } while (0)
extern void osl_assert(char *exp, char *file, int line);
#else
#ifdef __GNUC__
#define GCC_VERSION \
			(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 30100
#define ASSERT(exp)	do {} while (0)
#else
			/* ASSERT could cause segmentation fault on GCC3.1, use empty instead */
#define ASSERT(exp)
#endif				/* GCC_VERSION > 30100 */
#endif				/* __GNUC__ */
#endif				/* defined(BCMDBG_ASSERT) */

/* PCI configuration space access macros */
#define	OSL_PCI_READ_CONFIG(osh, offset, size) \
	osl_pci_read_config((osh), (offset), (size))
#define	OSL_PCI_WRITE_CONFIG(osh, offset, size, val) \
	osl_pci_write_config((osh), (offset), (size), (val))
extern u32 osl_pci_read_config(osl_t *osh, uint offset, uint size);
extern void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val);

/* PCI device bus # and slot # */
#define OSL_PCI_BUS(osh)	osl_pci_bus(osh)
#define OSL_PCI_SLOT(osh)	osl_pci_slot(osh)
extern uint osl_pci_bus(osl_t *osh);
extern uint osl_pci_slot(osl_t *osh);

/* Pkttag flag should be part of public information */
typedef struct {
	bool pkttag;
	uint pktalloced;	/* Number of allocated packet buffers */
	bool mmbus;		/* Bus supports memory-mapped register accesses */
	pktfree_cb_fn_t tx_fn;	/* Callback function for PKTFREE */
	void *tx_ctx;		/* Context to the callback function */
#if defined(BCMSDIO) && !defined(BRCM_FULLMAC)
	osl_rreg_fn_t rreg_fn;	/* Read Register function */
	osl_wreg_fn_t wreg_fn;	/* Write Register function */
	void *reg_ctx;		/* Context to the reg callback functions */
#endif
} osl_pubinfo_t;

#define PKTFREESETCB(osh, _tx_fn, _tx_ctx)			\
	do {							\
		((osl_pubinfo_t *)osh)->tx_fn = _tx_fn;		\
		((osl_pubinfo_t *)osh)->tx_ctx = _tx_ctx;	\
	} while (0)

#if defined(BCMSDIO) && !defined(BRCM_FULLMAC)
#define REGOPSSET(osh, rreg, wreg, ctx)			\
	do {						\
		((osl_pubinfo_t *)osh)->rreg_fn = rreg;	\
		((osl_pubinfo_t *)osh)->wreg_fn = wreg;	\
		((osl_pubinfo_t *)osh)->reg_ctx = ctx;	\
	} while (0)
#endif

#define BUS_SWAP32(v)		(v)

#define MFREE(osh, addr, size)	osl_mfree((osh), (addr), (size))
extern void osl_mfree(osl_t *osh, void *addr, uint size);

#define	DMA_CONSISTENT_ALIGN	osl_dma_consistent_align()
extern uint osl_dma_consistent_align(void);
extern void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align,
{'fraction_non_alphanumeric': 0.11173844537815127, 'fraction_numerical': 0.01011029411764706, 'mean_word_length': 4.859230769230769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2145', 'n_tokens_mistral': 2970, 'n_tokens_neox': 2761, 'n_words': 835}