1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Inc. nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
41 #ifndef __CVMX_SHMEM_H__
42 #define __CVMX_SHMEM_H__
47 * cvmx-shmem provides APIs for setting up shared memory between Linux
48 * and simple executive applications.
50 * <hr>$Revision: 41586 $<hr>
58 #include "cvmx-spinlock.h"
60 #define CVMX_SHMEM_NUM_DSCPTR 8
61 #define CVMX_SHMEM_DSCPTR_NAME "SMDR"
63 #define CVMX_SHMEM_O_RDONLY 0x00
64 #define CVMX_SHMEM_O_WRONLY 0x01
65 #define CVMX_SHMEM_O_RDWR 0x02
66 #define CVMX_SHMEM_O_CREAT 0x04
68 #define CVMX_SHMEM_MAP_PROT_READ 0x01
69 #define CVMX_SHMEM_MAP_PROT_WRITE 0x02
70 #define CVMX_SHMEM_MAP_EXEC 0x04
72 #define CVMX_SHMEM_OWNER_NONE 0xff
74 #define CVMX_SHMEM_VADDR64_START 0x500000000ULL
75 #define CVMX_SHMEM_VADDR64_END 0x600000000ULL
77 #define CVMX_SHMEM_VADDR32_START 0x10000000
78 #define CVMX_SHMEM_VADDR32_END 0x18000000
80 struct cvmx_shmem_dscptr {
83 uint64_t is_named_block: 1;
86 int32_t use_count; /* must use atomic operation to maintain count */
94 struct cvmx_shmem_smdr {
96 struct cvmx_shmem_dscptr shmd[CVMX_SHMEM_NUM_DSCPTR];
97 void *break64; /* Keep track of unused 64 bit virtual address space */
101 struct cvmx_shmem_smdr *cvmx_shmem_init(void);
104 * Create a piece memory out of named block
106 * @param name Named block name
107 * @param flag create flag
109 struct cvmx_shmem_dscptr *cvmx_shmem_named_block_open(char *name, uint32_t size, int oflag);
112 * Update TLB mapping based on the descriptor
114 void* cvmx_shmem_map(struct cvmx_shmem_dscptr *desc, int pflag);
117 * Remove the TLB mapping created for the descriptor
119 void cvmx_shmem_unmap(struct cvmx_shmem_dscptr *desc);
123 * Close the share memory,
125 * @Param remove Remove the named block if it is created by the application
127 int cvmx_shmem_close(struct cvmx_shmem_dscptr *desc, int remove);
130 * Debug function, dump all SMDR descriptors
132 void cvmx_shmem_show(void);