forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 85
/
buffer.rs
172 lines (150 loc) · 4.57 KB
/
buffer.rs
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// SPDX-License-Identifier: GPL-2.0-only OR MIT
#![allow(missing_docs)]
#![allow(dead_code)]
//! GPU tiler buffer control structures
use super::types::*;
use super::workqueue;
use crate::{no_debug, trivial_gpustruct};
use kernel::sync::{smutex::Mutex, Ref};
pub(crate) mod raw {
use super::*;
#[derive(Debug, Default)]
#[repr(C)]
pub(crate) struct BlockControl {
pub(crate) total: AtomicU32,
pub(crate) wptr: AtomicU32,
pub(crate) unk: AtomicU32,
pub(crate) pad: Pad<0x34>,
}
#[derive(Debug, Default)]
#[repr(C)]
pub(crate) struct Counter {
pub(crate) count: AtomicU32,
__pad: Pad<0x3c>,
}
#[derive(Debug, Default)]
#[repr(C)]
pub(crate) struct Stats {
pub(crate) gpu_0: AtomicU32,
pub(crate) gpu_4: AtomicU32,
pub(crate) gpu_8: AtomicU32,
pub(crate) gpu_c: AtomicU32,
pub(crate) __pad0: Pad<0x10>,
pub(crate) cpu_flag: AtomicU32,
pub(crate) __pad1: Pad<0x1c>,
}
#[versions(AGX)]
#[derive(Debug)]
#[repr(C)]
pub(crate) struct Info<'a> {
pub(crate) gpu_counter: u32,
pub(crate) unk_4: u32,
pub(crate) last_id: i32,
pub(crate) cur_id: i32,
pub(crate) unk_10: u32,
pub(crate) gpu_counter2: u32,
pub(crate) unk_18: u32,
#[ver(V < V13_0B4)]
pub(crate) unk_1c: u32,
pub(crate) page_list: GpuPointer<'a, &'a [u32]>,
pub(crate) page_list_size: u32,
pub(crate) page_count: AtomicU32,
pub(crate) unk_30: u32,
pub(crate) block_count: AtomicU32,
pub(crate) unk_38: u32,
pub(crate) block_list: GpuPointer<'a, &'a [u32]>,
pub(crate) block_ctl: GpuPointer<'a, super::BlockControl>,
pub(crate) last_page: AtomicU32,
pub(crate) gpu_page_ptr1: u32,
pub(crate) gpu_page_ptr2: u32,
pub(crate) unk_58: u32,
pub(crate) block_size: u32,
pub(crate) unk_60: U64,
pub(crate) counter: GpuPointer<'a, super::Counter>,
pub(crate) unk_70: u32,
pub(crate) unk_74: u32,
pub(crate) unk_78: u32,
pub(crate) unk_7c: u32,
pub(crate) unk_80: u32,
pub(crate) unk_84: u32,
pub(crate) unk_88: u32,
pub(crate) unk_8c: u32,
pub(crate) unk_90: Array<0x30, u8>,
}
#[derive(Debug, Default)]
#[repr(C)]
pub(crate) struct PreemptBuffer {
pub(crate) part_3: Array<0x20, u8>,
pub(crate) part_2: Array<0x280, u8>,
pub(crate) part_1: Array<0x540, u8>,
}
#[derive(Debug)]
#[repr(C)]
pub(crate) struct Scene<'a> {
pub(crate) unk_0: U64,
pub(crate) unk_8: U64,
pub(crate) unk_10: U64,
pub(crate) user_buffer: GpuPointer<'a, &'a [u8]>,
pub(crate) unk_20: u32,
pub(crate) stats: GpuPointer<'a, super::Stats>,
pub(crate) unk_2c: u32,
pub(crate) unk_30: U64,
pub(crate) unk_38: U64,
}
#[versions(AGX)]
#[derive(Debug)]
#[repr(C)]
pub(crate) struct InitBuffer {
pub(crate) tag: workqueue::CommandType,
pub(crate) context_id: u32,
pub(crate) buffer_mgr_slot: u32,
pub(crate) unk_c: u32,
pub(crate) unk_10: u32,
pub(crate) buffer_mgr: GpuWeakPointer<super::Info::ver>,
pub(crate) stamp_value: u32,
}
}
trivial_gpustruct!(BlockControl);
trivial_gpustruct!(Counter);
trivial_gpustruct!(Stats);
trivial_gpustruct!(PreemptBuffer);
#[versions(AGX)]
#[derive(Debug)]
pub(crate) struct Info {
pub(crate) block_ctl: GpuObject<BlockControl>,
pub(crate) counter: GpuObject<Counter>,
pub(crate) page_list: GpuArray<u32>,
pub(crate) block_list: GpuArray<u32>,
}
#[versions(AGX)]
impl GpuStruct for Info::ver {
type Raw<'a> = raw::Info::ver<'a>;
}
#[versions(AGX)]
pub(crate) struct Scene {
pub(crate) user_buffer: GpuArray<u8>,
pub(crate) stats: GpuObject<Stats>,
pub(crate) buffer: Ref<Mutex<crate::buffer::BufferInner::ver>>,
pub(crate) tvb_heapmeta: GpuArray<u8>,
pub(crate) tvb_tilemap: GpuArray<u8>,
pub(crate) preempt_buf: GpuObject<PreemptBuffer>,
pub(crate) seq_buf: GpuArray<u64>,
}
#[versions(AGX)]
no_debug!(Scene::ver);
#[versions(AGX)]
impl GpuStruct for Scene::ver {
type Raw<'a> = raw::Scene<'a>;
}
#[versions(AGX)]
pub(crate) struct InitBuffer {
pub(crate) buffer: Ref<Mutex<crate::buffer::BufferInner::ver>>,
}
#[versions(AGX)]
no_debug!(InitBuffer::ver);
#[versions(AGX)]
impl workqueue::Command for InitBuffer::ver {}
#[versions(AGX)]
impl GpuStruct for InitBuffer::ver {
type Raw<'a> = raw::InitBuffer::ver;
}