4
* The SharedRegion module is designed to be used in a
5
* multi-processor environment where there are memory regions
6
* that are shared and accessed across different processors
8
* Copyright (C) 2008-2010 Texas Instruments, Inc.
10
* This package is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License version 2 as
12
* published by the Free Software Foundation.
14
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
20
#ifndef _SHAREDREGION_H_
21
#define _SHAREDREGION_H_
23
#include <linux/types.h>
24
#include <heapmemmp.h>
27
* SHAREDREGION_MODULEID
28
* Module ID for Shared region manager
30
#define SHAREDREGION_MODULEID (0x5D8A)
33
* Name of the reserved nameserver used for application
35
#define SHAREDREGION_NAMESERVER "SHAREDREGION"
38
* Name of the reserved nameserver used for application
40
#define SHAREDREGION_INVALIDREGIONID ((u16)(~0))
43
* @def SharedRegion_DEFAULTOWNERID
44
* @brief Default owner processor id
46
#define SHAREDREGION_DEFAULTOWNERID ((u16)(~0))
49
* Name of the reserved nameserver used for application
51
#define SHAREDREGION_INVALIDSRPTR ((u32 *)(~0))
54
struct sharedregion_entry {
55
/* The base address of the region */
57
/* The length of the region */
59
/* The MultiProc id of the owner of the region */
61
/* Whether the region is valid */
63
/* Whether to perform cache operations for the region */
65
/* The cache line size of the region */
67
/* Whether a heap is created for the region */
69
/* The name of the region */
74
* Module configuration structure
76
struct sharedregion_config {
79
* Worst-case cache line size
81
* This is the default system cache line size for all modules.
82
* When a module puts structures in shared memory, this value is
83
* used to make sure items are aligned on a cache line boundary.
84
* If no cacheLineSize is specified for a region, it will use this
90
* The number of shared region table entries.
92
* This value is used for calculating the number of bits for the offset.
93
* Note: This value must be the same across all processors in the
94
* system. Increasing this parameter will increase the footprint
95
* and the time for translating a pointer to a SRPtr.
100
* This configuration parameter should be set to 'true'
101
* if and only if all shared memory regions are the same
102
* for all processors. If 'true', it results in a fast
103
* getPtr and getSRPtr.
108
* Information stored on a per region basis
110
struct sharedregion_region {
111
struct sharedregion_entry entry;
113
struct heapmemmp_object *heap;
118
* Function to get the configuration
120
int sharedregion_get_config(struct sharedregion_config *config);
123
* Function to setup the SharedRegion module
125
int sharedregion_setup(const struct sharedregion_config *config);
128
* Function to destroy the SharedRegion module
130
int sharedregion_destroy(void);
133
* Creates a heap by owner of region for each SharedRegion.
134
* Function is called by ipc_start(). Requires that SharedRegion 0
135
* be valid before calling start().
137
int sharedregion_start(void);
140
* Function to stop Shared Region 0
142
int sharedregion_stop(void);
145
* Opens a heap, for non-owner processors, for each SharedRegion.
147
int sharedregion_attach(u16 remote_proc_id);
150
* Closes a heap, for non-owner processors, for each SharedRegion.
152
int sharedregion_detach(u16 remote_proc_id);
155
* Reserve shared region memory
157
void *sharedregion_reserve_memory(u16 id, u32 size);
160
* Reserve shared region memory
162
void sharedregion_unreserve_memory(u16 id, u32 size);
165
* Sets the entry at the specified region id(doesn't create heap)
167
int _sharedregion_set_entry(u16 region_id, struct sharedregion_entry *entry);
170
* Function to clear the reserved memory
172
void sharedregion_clear_reserved_memory(void);
175
* Return the region info
177
void sharedregion_get_region_info(u16 i, struct sharedregion_region *region);
180
* Clears the entry at the specified region id
182
int sharedregion_clear_entry(u16 region_id);
185
* Initializes the entry fields
187
void sharedregion_entry_init(struct sharedregion_entry *entry);
190
* Gets the cache line size for the specified region id
192
uint sharedregion_get_cache_line_size(u16 region_id);
195
* Gets the entry information for the specified region id
197
int sharedregion_get_entry(u16 region_id, struct sharedregion_entry *entry);
200
* Gets the heap associated with the specified region id
202
void *sharedregion_get_heap(u16 region_id);
205
* Gets the region id for the specified address
207
u16 sharedregion_get_id(void *addr);
210
* Gets the id of a region, given the name
212
u16 sharedregion_get_id_by_name(char *name);
215
* Gets the number of regions
217
u16 sharedregion_get_num_regions(void);
220
* Returns the address pointer associated with the shared region pointer
222
void *sharedregion_get_ptr(u32 *srptr);
225
* Returns the shared region pointer
227
u32 *sharedregion_get_srptr(void *addr, u16 index);
230
* whether cache enable was specified
232
bool sharedregion_is_cache_enabled(u16 region_id);
235
* Sets the entry at the specified region id
237
int sharedregion_set_entry(u16 region_id, struct sharedregion_entry *entry);
240
* Whether address translation is enabled
242
bool sharedregion_translate_enabled(void);
244
#endif /* _SHAREDREGION_H */