<commit_before>/*
 * Copyright (C) 2009-2010 <NAME>
 * Copyright (C) 2009-2010 Nokia Corporation
 * Copyright (C) 2007 Texas Instruments, Incorporated
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This file may be used under the terms of the GNU Lesser General Public
 * License version 2.1, a copy of which is found in LICENSE included in the
 * packaging of this file.
 */

#include "dsp_bridge.h"

/* for open */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <unistd.h> /* for close */
#include <sys/ioctl.h> /* for ioctl */
#include <stdlib.h> /* for free */

#include <malloc.h> /* for memalign */

#define ALLOCATE_SM

#ifdef ALLOCATE_SM
#include <malloc.h> /* for memalign */
#include <sys/mman.h> /* for mmap */
#endif

#if DSP_API < 2
#include <errno.h>
#endif

/*
 * Dspbridge ioctl numbering scheme
 *
 *    7                           0
 *  ---------------------------------
 *  |  Module   |   ioctl Number    |
 *  ---------------------------------
 *  | x | x | x | 0 | 0 | 0 | 0 | 0 |
 *  ---------------------------------
 */

/* ioctl driver identifier */
#define DB 0xDB

/*
 * Following are used to distinguish between module ioctls, this is needed
 * in case new ioctls are introduced.
 */
#define DB_MODULE_MASK 0xE0
#define DB_IOC_MASK    0x1F

#if DSP_API >= 1

#include <linux/ioctl.h>

/* ioctl module masks */
#define DB_MGR  0x0
#define DB_PROC 0x20
#define DB_NODE 0x40
#define DB_STRM 0x60
#define DB_CMM  0x80

/* Used to calculate the ioctl per dspbridge module */
#define DB_IOC(module, num) \
	(((module) & DB_MODULE_MASK) | ((num) & DB_IOC_MASK))

#else

#define DB_MGR  1
#define DB_PROC 7
#define DB_NODE 24
#define DB_STRM 39
#define DB_CMM  50

#define DB_IOC(module, num)	((module) + (num))

#undef _IOR
#undef _IOW
#undef _IOWR

#define _IOR(type, nr, size)	(nr)
#define _IOW(type, nr, size)	(nr)
#define _IOWR(type, nr, size)	(nr)

#endif /* DSP_API */

/* MGR Module */
#define MGR_WAIT		_IOWR(DB, DB_IOC(DB_MGR, 4), unsigned long)
#define MGR_ENUMNODE_INFO	_IOWR(DB, DB_IOC(DB_MGR, 0), unsigned long)
#define MGR_REGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 2), unsigned long)
#define MGR_UNREGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 3), unsigned long)

/* PROC Module */
#define PROC_ATTACH		_IOWR(DB, DB_IOC(DB_PROC, 0), unsigned long)
/* PROC_DETACH Deprecated */
#define PROC_DETACH		_IOR(DB, DB_IOC(DB_PROC, 2), unsigned long)
#define PROC_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_PROC, 8), unsigned long)
#define PROC_RSVMEM		_IOWR(DB, DB_IOC(DB_PROC, 10), unsigned long)
#define PROC_UNRSVMEM		_IOW(DB, DB_IOC(DB_PROC, 11), unsigned long)
#define PROC_MAPMEM		_IOWR(DB, DB_IOC(DB_PROC, 12), unsigned long)
#define PROC_UNMAPMEM		_IOR(DB, DB_IOC(DB_PROC, 13), unsigned long)
#define PROC_FLUSHMEMORY	_IOW(DB, DB_IOC(DB_PROC, 14), unsigned long)
#define PROC_INVALIDATEMEMORY	_IOW(DB, DB_IOC(DB_PROC, 16), unsigned long)
#define PROC_GET_STATE		_IOWR(DB, DB_IOC(DB_PROC, 5), unsigned long)
#define PROC_ENUMRESOURCES	_IOWR(DB, DB_IOC(DB_PROC, 4), unsigned long)
#define PROC_ENUMNODE		_IOWR(DB, DB_IOC(DB_PROC, 3), unsigned long)
#define PROC_STOP               _IOWR(DB, DB_IOC(DB_PROC, 15), unsigned long)
#define PROC_LOAD               _IOW(DB, DB_IOC(DB_PROC, 7), unsigned long)
#define PROC_START              _IOW(DB, DB_IOC(DB_PROC, 9), unsigned long)

/* NODE Module */
#define NODE_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_NODE, 11), unsigned long)
#define NODE_CREATE		_IOW(DB, DB_IOC(DB_NODE, 4), unsigned long)
#define NODE_RUN		_IOW(DB, DB_IOC(DB_NODE, 12), unsigned long)
#define NODE_TERMINATE		_IOWR(DB, DB_IOC(DB_NODE, 13), unsigned long)
#define NODE_PUTMESSAGE		_IOW(DB, DB_IOC(DB_NODE, 10), unsigned long)
#define NODE_GETMESSAGE		_IOWR(DB, DB_IOC(DB_NODE, 8), unsigned long)
#define NODE_DELETE		_IOW(DB, DB_IOC(DB_NODE, 5), unsigned long)
#define NODE_GETATTR		_IOWR(DB, DB_IOC(DB_NODE, 7), unsigned long)
#define NODE_ALLOCMSGBUF	_IOWR(DB, DB_IOC(DB_NODE, 1), unsigned long)
#define NODE_GETUUIDPROPS	_IOWR(DB, DB_IOC(DB_NODE, 14), unsigned long)
#define NODE_ALLOCATE		_IOWR(DB, DB_IOC(DB_NODE, 0), unsigned long)
#define NODE_CONNECT		_IOW(DB, DB_IOC(DB_NODE, 3), unsigned long)

/* CMM Module */
#define CMM_GETHANDLE		_IOR(DB, DB_IOC(DB_CMM, 2), unsigned long)
#define CMM_GETINFO		_IOR(DB, DB_IOC(DB_CMM, 3), unsigned long)

/* STRM Module */
#define STRM_OPEN		_IOWR(DB, DB_IOC(DB_STRM, 7), unsigned long)
#define STRM_CLOSE		_IOW(DB, DB_IOC(DB_STRM, 1), unsigned long)
#define STRM_GETINFO		_IOWR(DB, DB_IOC(DB_STRM, 4), unsigned long)
#define STRM_ALLOCATEBUFFER	_IOWR(DB, DB_IOC(DB_STRM, 0), unsigned long)
#define STRM_IDLE		_IOW(DB, DB_IOC(DB_STRM, 5), unsigned long)
#define STRM_RECLAIM		_IOWR(DB, DB_IOC(DB_STRM, 8), unsigned long)
#define STRM_FREEBUFFER	_IOWR(DB, DB_IOC(DB_STRM, 2), unsigned long)
#define STRM_ISSUE		_IOW(DB, DB_IOC(DB_STRM, 6), unsigned long)

int dsp_open(void)
{
	return open("/dev/DspBridge", O_RDWR);
}

int dsp_close(int handle)
{
	return close(handle);
}

struct proc_attach {
	unsigned int num;
	const void *info; /* not used */
	void **ret_handle;
};

bool dsp_attach(int handle,
		unsigned int num,<commit_msg>bridge: trivial cleanup<commit_after>/*
 * Copyright (C) 2009-2010 <NAME>
 * Copyright (C) 2009-2010 Nokia Corporation
 * Copyright (C) 2007 Texas Instruments, Incorporated
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This file may be used under the terms of the GNU Lesser General Public
 * License version 2.1, a copy of which is found in LICENSE included in the
 * packaging of this file.
 */

#include "dsp_bridge.h"

/* for open */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <unistd.h> /* for close */
#include <sys/ioctl.h> /* for ioctl */
#include <stdlib.h> /* for free */

#include <malloc.h> /* for memalign */

#define ALLOCATE_SM

#ifdef ALLOCATE_SM
#include <malloc.h> /* for memalign */
#include <sys/mman.h> /* for mmap */
#endif

#if DSP_API < 2
#include <errno.h>
#endif

/*
 * Dspbridge ioctl numbering scheme
 *
 *    7                           0
 *  ---------------------------------
 *  |  Module   |   ioctl Number    |
 *  ---------------------------------
 *  | x | x | x | 0 | 0 | 0 | 0 | 0 |
 *  ---------------------------------
 */

/* ioctl driver identifier */
#define DB 0xDB

/*
 * Following are used to distinguish between module ioctls, this is needed
 * in case new ioctls are introduced.
 */
#define DB_MODULE_MASK 0xE0
#define DB_IOC_MASK    0x1F

#if DSP_API >= 1

#include <linux/ioctl.h>

/* ioctl module masks */
#define DB_MGR  0x0
#define DB_PROC 0x20
#define DB_NODE 0x40
#define DB_STRM 0x60
#define DB_CMM  0x80

/* Used to calculate the ioctl per dspbridge module */
#define DB_IOC(module, num) \
	(((module) & DB_MODULE_MASK) | ((num) & DB_IOC_MASK))

#else

#define DB_MGR  1
#define DB_PROC 7
#define DB_NODE 24
#define DB_STRM 39
#define DB_CMM  50

#define DB_IOC(module, num)	((module) + (num))

#undef _IOR
#undef _IOW
#undef _IOWR

#define _IOR(type, nr, size)	(nr)
#define _IOW(type, nr, size)	(nr)
#define _IOWR(type, nr, size)	(nr)

#endif /* DSP_API */

/* MGR Module */
#define MGR_WAIT		_IOWR(DB, DB_IOC(DB_MGR, 4), unsigned long)
#define MGR_ENUMNODE_INFO	_IOWR(DB, DB_IOC(DB_MGR, 0), unsigned long)
#define MGR_REGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 2), unsigned long)
#define MGR_UNREGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 3), unsigned long)

/* PROC Module */
#define PROC_ATTACH		_IOWR(DB, DB_IOC(DB_PROC, 0), unsigned long)
/* PROC_DETACH Deprecated */
#define PROC_DETACH		_IOR(DB, DB_IOC(DB_PROC, 2), unsigned long)
#define PROC_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_PROC, 8), unsigned long)
#define PROC_RSVMEM		_IOWR(DB, DB_IOC(DB_PROC, 10), unsigned long)
#define PROC_UNRSVMEM		_IOW(DB, DB_IOC(DB_PROC, 11), unsigned long)
#define PROC_MAPMEM		_IOWR(DB, DB_IOC(DB_PROC, 12), unsigned long)
#define PROC_UNMAPMEM		_IOR(DB, DB_IOC(DB_PROC, 13), unsigned long)
#define PROC_FLUSHMEMORY	_IOW(DB, DB_IOC(DB_PROC, 14), unsigned long)
#define PROC_INVALIDATEMEMORY	_IOW(DB, DB_IOC(DB_PROC, 16), unsigned long)
#define PROC_GET_STATE		_IOWR(DB, DB_IOC(DB_PROC, 5), unsigned long)
#define PROC_ENUMRESOURCES	_IOWR(DB, DB_IOC(DB_PROC, 4), unsigned long)
#define PROC_ENUMNODE		_IOWR(DB, DB_IOC(DB_PROC, 3), unsigned long)
#define PROC_STOP               _IOWR(DB, DB_IOC(DB_PROC, 15), unsigned long)
#define PROC_LOAD               _IOW(DB, DB_IOC(DB_PROC, 7), unsigned long)
#define PROC_START              _IOW(DB, DB_IOC(DB_PROC, 9), unsigned long)

/* NODE Module */
#define NODE_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_NODE, 11), unsigned long)
#define NODE_CREATE		_IOW(DB, DB_IOC(DB_NODE, 4), unsigned long)
#define NODE_RUN		_IOW(DB, DB_IOC(DB_NODE, 12), unsigned long)
#define NODE_TERMINATE		_IOWR(DB, DB_IOC(DB_NODE, 13), unsigned long)
#define NODE_PUTMESSAGE		_IOW(DB, DB_IOC(DB_NODE, 10), unsigned long)
#define NODE_GETMESSAGE		_IOWR(DB, DB_IOC(DB_NODE, 8), unsigned long)
#define NODE_DELETE		_IOW(DB, DB_IOC(DB_NODE, 5), unsigned long)
#define NODE_GETATTR		_IOWR(DB, DB_IOC(DB_NODE, 7), unsigned long)
#define NODE_ALLOCMSGBUF	_IOWR(DB, DB_IOC(DB_NODE, 1), unsigned long)
#define NODE_GETUUIDPROPS	_IOWR(DB, DB_IOC(DB_NODE, 14), unsigned long)
#define NODE_ALLOCATE		_IOWR(DB, DB_IOC(DB_NODE, 0), unsigned long)
#define NODE_CONNECT		_IOW(DB, DB_IOC(DB_NODE, 3), unsigned long)

/* CMM Module */
#define CMM_GETHANDLE		_IOR(DB, DB_IOC(DB_CMM, 2), unsigned long)
#define CMM_GETINFO		_IOR(DB, DB_IOC(DB_CMM, 3), unsigned long)

/* STRM Module */
#define STRM_OPEN		_IOWR(DB, DB_IOC(DB_STRM, 7), unsigned long)
#define STRM_CLOSE		_IOW(DB, DB_IOC(DB_STRM, 1), unsigned long)
#define STRM_GETINFO		_IOWR(DB, DB_IOC(DB_STRM, 4), unsigned long)
#define STRM_ALLOCATEBUFFER	_IOWR(DB, DB_IOC(DB_STRM, 0), unsigned long)
#define STRM_IDLE		_IOW(DB, DB_IOC(DB_STRM, 5), unsigned long)
#define STRM_RECLAIM		_IOWR(DB, DB_IOC(DB_STRM, 8), unsigned long)
#define STRM_FREEBUFFER		_IOWR(DB, DB_IOC(DB_STRM, 2), unsigned long)
#define STRM_ISSUE		_IOW(DB, DB_IOC(DB_STRM, 6), unsigned long)

int dsp_open(void)
{
	return open("/dev/DspBridge", O_RDWR);
}

int dsp_close(int handle)
{
	return close(handle);
}

struct proc_attach {
	unsigned int num;
	const void *info; /* not used */
	void **ret_handle;
};

bool dsp_attach(int handle,
		unsigned int num,
{'fraction_non_alphanumeric': 0.14213346322454945, 'fraction_numerical': 0.02162688748173405, 'mean_word_length': 4.232415902140673, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6289298', 'n_tokens_mistral': 4407, 'n_tokens_neox': 4210, 'n_words': 1103}