2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 #ifndef __SSI_SRAM_MGR_H__
18 #define __SSI_SRAM_MGR_H__
21 #ifndef SSI_CC_SRAM_SIZE
22 #define SSI_CC_SRAM_SIZE 4096
28 * Address (offset) within CC internal SRAM
31 typedef uint64_t ssi_sram_addr_t;
33 #define NULL_SRAM_ADDR ((ssi_sram_addr_t)-1)
36 * Initializes SRAM pool.
37 * The first X bytes of SRAM are reserved for ROM usage, hence, pool
38 * starts right after X bytes.
42 * \return int Zero for success, negative value otherwise.
44 int ssi_sram_mgr_init(struct ssi_drvdata *drvdata);
51 void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata);
54 * Allocated buffer from SRAM pool.
55 * Note: Caller is responsible to free the LAST allocated buffer.
56 * This function does not taking care of any fragmentation may occur
57 * by the order of calls to alloc/free.
60 * \param size The requested bytes to allocate
62 ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, uint32_t size);
65 * ssi_sram_mgr_const2sram_desc() - Create const descriptors sequence to
66 * set values in given array into SRAM.
67 * Note: each const value can't exceed word size.
69 * @src: A pointer to array of words to set as consts.
70 * @dst: The target SRAM buffer to set into
71 * @nelements: The number of words in "src" array
72 * @seq: A pointer to the given IN/OUT descriptor sequence
73 * @seq_len: A pointer to the given IN/OUT sequence length
75 void ssi_sram_mgr_const2sram_desc(
76 const uint32_t *src, ssi_sram_addr_t dst,
77 unsigned int nelement,
78 HwDesc_s *seq, unsigned int *seq_len);
80 #endif /*__SSI_SRAM_MGR_H__*/