-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconst.js
365 lines (300 loc) · 7.53 KB
/
const.js
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
"use strict";
var
/** @const */ LOG_ALL = -1,
/** @const */ LOG_NONE = 0,
/** @const */ LOG_OTHER = 0x000001,
/** @const */ LOG_CPU = 0x000002,
/** @const */ LOG_FPU = 0x000004,
/** @const */ LOG_MEM = 0x000008,
/** @const */ LOG_DMA = 0x000010,
/** @const */ LOG_IO = 0x000020,
/** @const */ LOG_PS2 = 0x000040,
/** @const */ LOG_PIC = 0x000080,
/** @const */ LOG_VGA = 0x000100,
/** @const */ LOG_PIT = 0x000200,
/** @const */ LOG_MOUSE = 0x000400,
/** @const */ LOG_PCI = 0x000800,
/** @const */ LOG_BIOS = 0x001000,
/** @const */ LOG_FLOPPY = 0x002000,
/** @const */ LOG_SERIAL = 0x004000,
/** @const */ LOG_DISK = 0x008000,
/** @const */ LOG_RTC = 0x010000,
/** @const */ LOG_HPET = 0x020000,
/** @const */ LOG_ACPI = 0x040000,
/** @const */ LOG_APIC = 0x080000,
/** @const */ LOG_NET = 0x100000,
/** @const */ LOG_VIRTIO = 0x200000,
/** @const */ LOG_9P = 0x400000,
/** @const */ LOG_SB16 = 0x800000;
/**
* @const
* @type {Array<Array<string|number>>}
*/
var LOG_NAMES = [
[1, ""],
[LOG_CPU, "CPU"],
[LOG_DISK, "DISK"],
[LOG_FPU, "FPU"],
[LOG_MEM, "MEM"],
[LOG_DMA, "DMA"],
[LOG_IO, "IO"],
[LOG_PS2, "PS2"],
[LOG_PIC, "PIC"],
[LOG_VGA, "VGA"],
[LOG_PIT, "PIT"],
[LOG_MOUSE, "MOUS"],
[LOG_PCI, "PCI"],
[LOG_BIOS, "BIOS"],
[LOG_FLOPPY, "FLOP"],
[LOG_SERIAL, "SERI"],
[LOG_RTC, "RTC"],
[LOG_HPET, "HPET"],
[LOG_ACPI, "ACPI"],
[LOG_APIC, "APIC"],
[LOG_NET, "NET"],
[LOG_VIRTIO, "VIO"],
[LOG_9P, "9P"],
[LOG_SB16, "SB16"]
];
var
/** @const */ TLB_SYSTEM_READ = 1,
/** @const */ TLB_SYSTEM_WRITE = 2,
/** @const */ TLB_USER_READ = 4,
/** @const */ TLB_USER_WRITE = 8;
var
// flags register bitflags
/** @const */ flag_carry = 1,
/** @const */ flag_parity = 4,
/** @const */ flag_adjust = 16,
/** @const */ flag_zero = 64,
/** @const */ flag_sign = 128,
/** @const */ flag_trap = 256,
/** @const */ flag_interrupt = 512,
/** @const */ flag_direction = 1024,
/** @const */ flag_overflow = 2048,
/** @const */ flag_iopl = 1 << 12 | 1 << 13,
/** @const */ flag_nt = 1 << 14,
/** @const */ flag_rf = 1 << 16,
/** @const */ flag_vm = 1 << 17,
/** @const */ flag_ac = 1 << 18,
/** @const */ flag_vif = 1 << 19,
/** @const */ flag_vip = 1 << 20,
/** @const */ flag_id = 1 << 21,
/**
* default values of reserved flags bits
* @const
*/
flags_default = 1 << 1,
/**
* bitmask to select non-reserved flags bits
* @const
*/
flags_mask =
flag_carry | flag_parity | flag_adjust | flag_zero | flag_sign | flag_trap | flag_interrupt |
flag_direction | flag_overflow | flag_iopl | flag_nt | flag_rf | flag_vm | flag_ac |
flag_vif | flag_vip | flag_id,
/**
* all arithmetic flags
* @const
*/
flags_all = flag_carry | flag_parity | flag_adjust | flag_zero | flag_sign | flag_overflow,
/**
* opsizes used by get flag functions
*
* @const
*/
OPSIZE_8 = 7,
/** @const */
OPSIZE_16 = 15,
/** @const */
OPSIZE_32 = 31,
/** @const */
PSE_ENABLED = 128,
/** @const */ reg_eax = 0,
/** @const */ reg_ecx = 1,
/** @const */ reg_edx = 2,
/** @const */ reg_ebx = 3,
/** @const */ reg_esp = 4,
/** @const */ reg_ebp = 5,
/** @const */ reg_esi = 6,
/** @const */ reg_edi = 7,
/** @const */ reg_ax = 0,
/** @const */ reg_cx = 2,
/** @const */ reg_dx = 4,
/** @const */ reg_bx = 6,
/** @const */ reg_sp = 8,
/** @const */ reg_bp = 10,
/** @const */ reg_si = 12,
/** @const */ reg_di = 14,
/** @const */ reg_al = 0,
/** @const */ reg_cl = 4,
/** @const */ reg_dl = 8,
/** @const */ reg_bl = 12,
/** @const */ reg_ah = 1,
/** @const */ reg_ch = 5,
/** @const */ reg_dh = 9,
/** @const */ reg_bh = 13,
/** @const */ reg_es = 0,
/** @const */ reg_cs = 1,
/** @const */ reg_ss = 2,
/** @const */ reg_ds = 3,
/** @const */ reg_fs = 4,
/** @const */ reg_gs = 5,
/** @const */ reg_tr = 6, // task register
/** @const */ reg_ldtr = 7; // local descriptor table register
var
/**
* The minimum number of bytes that can be memory-mapped
* by one device.
*
* @const
*/
MMAP_BLOCK_BITS = 17,
/** @const */
MMAP_BLOCK_SIZE = 1 << MMAP_BLOCK_BITS;
/** @const */
var MEM_PAGE_WRITTEN = 1;
/** @const */
var MAGIC_CPU_EXCEPTION = 0xDEADBEE;
var
/** @const */
REPEAT_STRING_PREFIX_NONE = 0,
/** @const */
REPEAT_STRING_PREFIX_NZ = 1,
/** @const */
REPEAT_STRING_PREFIX_Z = 2;
var
/** @const */
CR0_PE = 1,
/** @const */
CR0_MP = 1 << 1,
/** @const */
CR0_EM = 1 << 2,
/** @const */
CR0_TS = 1 << 3,
/** @const */
CR0_ET = 1 << 4,
/** @const */
CR0_WP = 1 << 16,
/** @const */
CR0_NW = 1 << 29,
/** @const */
CR0_CD = 1 << 30,
/** @const */
CR0_PG = 1 << 31;
var
/** @const */
CR4_VME = 1,
/** @const */
CR4_PVI = 1 << 1,
/** @const */
CR4_TSD = 1 << 2,
/** @const */
CR4_PSE = 1 << 4,
/** @const */
CR4_DE = 1 << 3,
/** @const */
CR4_PAE = 1 << 5,
/** @const */
CR4_PGE = 1 << 7,
/** @const */
CR4_OSFXSR = 1 << 9,
/** @const */
CR4_OSXMMEXCPT = 1 << 10;
// Segment prefixes must not collide with reg_*s variables
// _ZERO is a special zero offset segment
var
/** @const */
SEG_PREFIX_NONE = -1,
/** @const */
SEG_PREFIX_ZERO = 7;
var
/** @const */
IA32_SYSENTER_CS = 0x174,
// Note: These are wrong in Intel's manuals. Fuck Intel
/** @const */
IA32_SYSENTER_ESP = 0x175,
/** @const */
IA32_SYSENTER_EIP = 0x176;
/** @const */
var IA32_TIME_STAMP_COUNTER = 0x10;
/** @const */
var IA32_PLATFORM_ID = 0x17;
/** @const */
var MSR_EBC_FREQUENCY_ID = 0x2C;
/** @const */
var IA32_APIC_BASE_MSR = 0x1B;
/** @const */
var IA32_BIOS_SIGN_ID = 0x8B;
/** @const */
var IA32_MISC_ENABLE = 0x1A0;
/** @const */
var IA32_RTIT_CTL = 0x570;
/** @const */
var MSR_SMI_COUNT = 0x34;
/** @const */
var IA32_MCG_CAP = 0x179;
/** @const */
var IA32_KERNEL_GS_BASE = 0xC0000101 | 0;
/** @const */
var MSR_PKG_C2_RESIDENCY = 0x60D;
/** @const */
var IA32_APIC_BASE_BSP = 1 << 8;
/** @const */
var IA32_APIC_BASE_EXTD = 1 << 10;
/** @const */
var IA32_APIC_BASE_EN = 1 << 11;
/** @const */ var TSR_BACKLINK = 0x00;
/** @const */ var TSR_CR3 = 0x1C;
/** @const */ var TSR_EIP = 0x20;
/** @const */ var TSR_EFLAGS = 0x24;
/** @const */ var TSR_EAX = 0x28;
/** @const */ var TSR_ECX = 0x2c;
/** @const */ var TSR_EDX = 0x30;
/** @const */ var TSR_EBX = 0x34;
/** @const */ var TSR_ESP = 0x38;
/** @const */ var TSR_EBP = 0x3c;
/** @const */ var TSR_ESI = 0x40;
/** @const */ var TSR_EDI = 0x44;
/** @const */ var TSR_ES = 0x48;
/** @const */ var TSR_CS = 0x4c;
/** @const */ var TSR_SS = 0x50;
/** @const */ var TSR_DS = 0x54;
/** @const */ var TSR_FS = 0x58;
/** @const */ var TSR_GS = 0x5c;
/** @const */ var TSR_LDT = 0x60;
/** @const */ var FW_CFG_SIGNATURE = 0x00;
/** @const */ var FW_CFG_RAM_SIZE = 0x03;
/** @const */ var FW_CFG_NB_CPUS = 0x05;
/** @const */
var PREFIX_MASK_REP = 0b11000;
/** @const */
var PREFIX_REPZ = 0b01000;
/** @const */
var PREFIX_REPNZ = 0b10000;
/** @const */
var PREFIX_MASK_SEGMENT = 0b111;
/** @const */
var PREFIX_MASK_OPSIZE = 0b100000;
/** @const */
var PREFIX_MASK_ADDRSIZE = 0b1000000;
/** @const */
var PREFIX_F2 = PREFIX_REPNZ; // alias
/** @const */
var PREFIX_F3 = PREFIX_REPZ; // alias
/** @const */
var PREFIX_66 = PREFIX_MASK_OPSIZE; // alias
/** @const */
var MXCSR_MASK = (0xFFFF & ~(1 << 6));
/** @const */
var MIXER_CHANNEL_LEFT = 0;
/** @const */
var MIXER_CHANNEL_RIGHT = 1;
/** @const */
var MIXER_CHANNEL_BOTH = 2;
/** @const */
var MIXER_SRC_MASTER = 0;
/** @const */
var MIXER_SRC_PCSPEAKER = 1;
/** @const */
var MIXER_SRC_DAC = 2;