summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/syslink/gatepeterson.h
blob: 31e7e7c0ed425fe4095076eb97dd0d6ad03b7980 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 *  gatepeterson.h
 *
 *  The Gate Peterson Algorithm for mutual exclusion of shared memory.
 *  Current implementation works for 2 processors.
 *
 *  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.
 */

#ifndef _GATEPETERSON_H_
#define _GATEPETERSON_H_

#include <linux/types.h>

#include <igatempsupport.h>

/*
 *  GATEPETERSON_MODULEID
 *  Unique module ID
 */
#define GATEPETERSON_MODULEID       (0xF415)

/*
 *  A set of context protection levels that each correspond to
 *  single processor gates used for local protection
 */
enum gatepeterson_protect {
	GATEPETERSON_PROTECT_DEFAULT	= 0,
	GATEPETERSON_PROTECT_NONE	= 1,
	GATEPETERSON_PROTECT_INTERRUPT	= 2,
	GATEPETERSON_PROTECT_TASKLET	= 3,
	GATEPETERSON_PROTECT_THREAD	= 4,
	GATEPETERSON_PROTECT_PROCESS	= 5,
	GATEPETERSON_PROTECT_END_VALUE	= 6
};

/*
 *  Structure defining config parameters for the Gate Peterson
 *  module
 */
struct gatepeterson_config {
	enum gatepeterson_protect default_protection;
	/*!< Default module-wide local context protection level. The level of
	* protection specified here determines which local gate is created per
	* GatePeterson instance for local protection during create. The instance
	* configuration parameter may be usedto override this module setting per
	* instance.  The configuration used here should reflect both the context
	* in which enter and leave are to be called,as well as the maximum level
	* of protection needed locally.
	*/
	u32 num_instances;
	/*!< Maximum number of instances supported by the GatePeterson module */

};

/*
 *  Structure defining config parameters for the Gate Peterson
 *  instances
 */
struct gatepeterson_params {
	IGATEMPSUPPORT_SUPERPARAMS;
};

/*
 *  Function to initialize the parameter structure
 */
void gatepeterson_get_config(struct gatepeterson_config *config);

/*
 *  Function to initialize GP module
 */
int gatepeterson_setup(const struct gatepeterson_config *config);

/*
 *  Function to destroy the GP module
 */
int gatepeterson_destroy(void);

/*
 *  Function to initialize the parameter structure
 */
void gatepeterson_params_init(struct gatepeterson_params *params);

/*
 *  Function to create an instance of GatePeterson
 */
void *gatepeterson_create(enum igatempsupport_local_protect local_protect,
				const struct gatepeterson_params *params);

/*
 *  Function to delete an instance of GatePeterson
 */
int gatepeterson_delete(void **gphandle);

/*
 *  Function to open a previously created instance by address
 */
int gatepeterson_open_by_addr(enum igatempsupport_local_protect local_protect,
				void *shared_addr, void **gphandle);

/*
 *  Function to close a previously opened instance
 */
int gatepeterson_close(void **gphandle);

/*
 * Function to enter the gate peterson
 */
int *gatepeterson_enter(void *gphandle);

/*
 *Function to leave the gate peterson
 */
void gatepeterson_leave(void *gphandle, int *key);

/*
 * Function to return the shared memory requirement
 */
u32 gatepeterson_shared_mem_req(const struct gatepeterson_params *params);

/*
 * Function to return the number of instances configured in the module.
 */
u32 gatepeterson_get_num_instances(void);

/*
 * Function to return the number of instances not controlled by GateMP.
 */
u32 gatepeterson_get_num_reserved(void);

/*
 * Function to initialize the locks module.
 */
void gatepeterson_locks_init(void);

#endif /* _GATEPETERSON_H_ */