1 /*
2  * context.h
3  *
4  *  Created on: 27 февр. 2020 г.
5  *      Author: Vladimir Sadovnikov <lsp.plugin@gmail.com>
6  *
7  * This file is part of tamgamp.lv2 <https://github.com/sadko4u/tamgamp.lv2>.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
22  */
23 
24 #ifndef DSP_COMMON_CONTEXT_H_
25 #define DSP_COMMON_CONTEXT_H_
26 
27 #ifndef __DSP_DSP_DEFS
28     #error "This header should not be included directly"
29 #endif /* __DSP_DSP_DEFS */
30 
31 //-----------------------------------------------------------------------
32 // DSP context functions
33 namespace dsp
34 {
35     #pragma pack(push, 1)
36     /**
37      * DSP context to store and restore machine state
38      */
39     typedef struct context_t
40     {
41         uint32_t        top;
42         uint32_t        data[15];
43     } context_t;
44     #pragma pack(pop)
45 
46     typedef struct info_t
47     {
48         const char     *arch;       /* Architecture information */
49         const char     *cpu;        /* CPU information */
50         const char     *model;      /* CPU model information */
51         const char     *features;   /* CPU features */
52     } info_t;
53 
54     // Start and finish types
55     typedef void (* start_t)(context_t *ctx);
56     typedef void (* finish_t)(context_t *ctx);
57 
58     /** Initialize DSP
59      *
60      */
61     void init();
62 
63     /** Start DSP processing, save machine context
64      *
65      * @param ctx structure to save context
66      */
67     extern void (* start)(context_t *ctx);
68 
69     /** Finish DSP processing, restore machine context
70      *
71      * @param ctx structure to restore context
72      */
73     extern void (* finish)(context_t *ctx);
74 
75     /**
76      * Get DSP information, returns pointer to dsp::info_t structure
77      * that can be freed by free()
78      * @return pointer to dsp::info_t structure
79      */
80     extern info_t * (*info)();
81 }
82 
83 
84 #endif /* DSP_COMMON_CONTEXT_H_ */
85