summaryrefslogtreecommitdiff
path: root/drivers/dsp/syslink/multicore_ipc/gate.c
blob: 066ef53a37b4d9bc24b59b5b69371aee258f19b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 *  gatemp.c
 *
 *  Gate wrapper implementation
 *
 *  Copyright (C) 2008-2009 Texas Instruments, Inc.
 *
 *  This package is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 *
 *  THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 *  WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
 *  PURPOSE.
 */


/* Standard headers */
#include <linux/types.h>
#include <linux/kernel.h>

/* Module level headers */
#include <igateprovider.h>
#include <gate.h>


/* Structure defining internal object for the Gate Peterson.*/
struct gate_object {
	IGATEPROVIDER_SUPEROBJECT; /* For inheritance from IGateProvider */
};

/* Function to enter a Gate */
int *gate_enter_system(void)
{
	unsigned long flags;

	local_irq_save(flags);

	return (int *)flags;
}

/* Function to leave a gate */
void gate_leave_system(int *key)
{
	local_irq_restore((unsigned long) key);
}

/* Match with IGateProvider */
static inline int *_gate_enter_system(struct gate_object *obj)
{
	(void) obj;
	return gate_enter_system();
}

/* Match with IGateProvider */
static inline void _gate_leave_system(struct gate_object *obj, int *key)
{
	(void) obj;
	gate_leave_system(key);
}

static struct gate_object gate_system_object = {
	.enter = (int *(*)(void *))_gate_enter_system,
	.leave = (void (*)(void *, int *))_gate_leave_system,
};

struct igateprovider_object *gate_system_handle = \
			(struct igateprovider_object *)&gate_system_object;