]> git.proxmox.com Git - mirror_qemu.git/blob - include/hw/misc/mips_itu.h
Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-january-17-2019-v2...
[mirror_qemu.git] / include / hw / misc / mips_itu.h
1 /*
2 * Inter-Thread Communication Unit emulation.
3 *
4 * Copyright (c) 2016 Imagination Technologies
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef MIPS_ITU_H
21 #define MIPS_ITU_H
22
23 #include "hw/sysbus.h"
24
25 #define TYPE_MIPS_ITU "mips-itu"
26 #define MIPS_ITU(obj) OBJECT_CHECK(MIPSITUState, (obj), TYPE_MIPS_ITU)
27
28 #define ITC_CELL_DEPTH_SHIFT 2
29 #define ITC_CELL_DEPTH (1u << ITC_CELL_DEPTH_SHIFT)
30
31 typedef struct ITCStorageCell {
32 struct {
33 uint8_t FIFODepth; /* Log2 of the cell depth */
34 uint8_t FIFOPtr; /* Number of elements in a FIFO cell */
35 uint8_t FIFO; /* 1 - FIFO cell, 0 - Semaphore cell */
36 uint8_t T; /* Trap Bit */
37 uint8_t F; /* Full Bit */
38 uint8_t E; /* Empty Bit */
39 } tag;
40
41 /* Index of the oldest element in the queue */
42 uint8_t fifo_out;
43
44 /* Circular buffer for FIFO. Semaphore cells use index 0 only */
45 uint64_t data[ITC_CELL_DEPTH];
46
47 /* Bitmap tracking blocked threads on the cell.
48 TODO: support >64 threads ? */
49 uint64_t blocked_threads;
50 } ITCStorageCell;
51
52 #define ITC_ADDRESSMAP_NUM 2
53
54 typedef struct MIPSITUState {
55 /*< private >*/
56 SysBusDevice parent_obj;
57 /*< public >*/
58
59 int32_t num_fifo;
60 int32_t num_semaphores;
61
62 /* ITC Storage */
63 ITCStorageCell *cell;
64 MemoryRegion storage_io;
65
66 /* ITC Configuration Tags */
67 uint64_t ITCAddressMap[ITC_ADDRESSMAP_NUM];
68 MemoryRegion tag_io;
69
70 /* ITU Control Register */
71 uint64_t icr0;
72
73 /* SAAR */
74 bool saar_present;
75 void *saar;
76
77 } MIPSITUState;
78
79 /* Get ITC Configuration Tag memory region. */
80 MemoryRegion *mips_itu_get_tag_region(MIPSITUState *itu);
81
82 #endif /* MIPS_ITU_H */