aboutsummaryrefslogtreecommitdiffstats
path: root/base/src/common/kernel_internal_types.h
blob: e38c0f6d79cdee3961560fb76a6acf7843247ddd (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
/*
 * Copyright 2008 Sony Corporation of America
 *
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this Library and associated documentation files (the
 * "Library"), to deal in the Library without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Library, and to
 * permit persons to whom the Library is furnished to do so, subject to
 * the following conditions:
 *
 *  The above copyright notice and this permission notice shall be
 *  included in all copies or substantial portions of the Library.
 *
 *  If you modify the Library, you may copy and distribute your modified
 *  version of the Library in object code or as an executable provided
 *  that you also do one of the following:
 *
 *   Accompany the modified version of the Library with the complete
 *   corresponding machine-readable source code for the modified version
 *   of the Library; or,
 *
 *   Accompany the modified version of the Library with a written offer
 *   for a complete machine-readable copy of the corresponding source
 *   code of the modified version of the Library.
 *
 *
 * THE LIBRARY IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
 */

#ifndef MARS_KERNEL_INTERNAL_TYPES_H
#define MARS_KERNEL_INTERNAL_TYPES_H

#include <stdint.h>

#include "mars/mutex_types.h"

#define MARS_KERNEL_ID_NONE			0xffff

#define MARS_KERNEL_STATUS_BUSY			0x0
#define MARS_KERNEL_STATUS_IDLE			0x1
#define MARS_KERNEL_STATUS_EXIT			0x2

#define MARS_KERNEL_TICKS_FLAG_SYNC_BEGIN	0x1
#define MARS_KERNEL_TICKS_FLAG_SYNC_END		0x2

#define MARS_KERNEL_PARAMS_ALIGN		128
#define MARS_KERNEL_PARAMS_SIZE			128

#define MARS_KERNEL_DMA_TAG			31

/* mars kernel syscalls */
struct mars_kernel_syscalls {
	uint32_t                       (*get_ticks)(void);
	uint64_t                       (*get_mars_context_ea)(void);
	uint16_t                       (*get_kernel_id)(void);
	uint16_t                       (*get_workload_id)(void);
	struct mars_workload_context * (*get_workload)(void);
	struct mars_workload_context * (*get_workload_by_id)(uint16_t id);

	void (*workload_exit)(uint8_t state);
	int  (*workload_query)(uint16_t id, int query);
	int  (*workload_wait_set)(uint16_t id);
	int  (*workload_wait_reset)(void);
	int  (*workload_signal_set)(uint16_t id);
	int  (*workload_signal_reset)(void);
	int  (*workload_schedule_begin)(uint16_t id, uint8_t priority,
					struct mars_workload_context **workload);
	int  (*workload_schedule_end)(uint16_t id);
	int  (*workload_schedule_cancel)(uint16_t id);

	int  (*host_signal_send)(uint64_t watch_point_ea);

	int  (*mutex_lock_get)(uint64_t mutex_ea, struct mars_mutex *mutex);
	int  (*mutex_unlock_put)(uint64_t mutex_ea, struct mars_mutex *mutex);

	int  (*dma_get)(void *ls, uint64_t ea, uint32_t size, uint32_t tag);
	int  (*dma_put)(const void *ls, uint64_t ea, uint32_t size,
			uint32_t tag);
	int  (*dma_wait)(uint32_t tag);
};

/* mars kernel ticks */
struct mars_kernel_ticks {
	uint32_t flag;
	uint32_t offset;
};

/* mars kernel parameters */
struct mars_kernel_params {
	uint64_t mars_context_ea;
	uint64_t workload_queue_ea;
	struct mars_kernel_ticks kernel_ticks;
	uint16_t kernel_id;
	uint8_t pad[MARS_KERNEL_PARAMS_SIZE - 26];
} __attribute__((aligned(MARS_KERNEL_PARAMS_ALIGN)));

/* mars kernel mutex */
int mutex_lock_get(uint64_t mutex_ea, struct mars_mutex *mutex);
int mutex_unlock_put(uint64_t mutex_ea, struct mars_mutex *mutex);

/* mars kernel dma */
int dma_get(void *ls, uint64_t ea, uint32_t size, uint32_t tag);
int dma_put(const void *ls, uint64_t ea, uint32_t size, uint32_t tag);
int dma_wait(uint32_t tag);

/* mars module entry */
void mars_module_entry(struct mars_kernel_syscalls *syscalls);

#endif