CS350 COS
COS
Loading...
Searching...
No Matches
amd64op.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static INLINE void enable_interrupts ()
 
static INLINE void disable_interrupts ()
 
static INLINE void hlt ()
 
static INLINE void pause ()
 
static INLINE void breakpoint ()
 
static INLINE void icebp ()
 
static INLINE uint64_t rdtsc ()
 
static INLINE uint64_t rdtscp (uint32_t *procno)
 
static INLINE void lidt (PseudoDescriptor *idt)
 
static INLINE void lgdt (PseudoDescriptor *gdt)
 
static INLINE void ltr (uint16_t tss)
 
static INLINE void cpuid (uint32_t info, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
 
static INLINE void wrmsr (uint32_t addr, uint64_t val)
 
static INLINE uint64_t rdmsr (uint32_t addr)
 
static INLINE uint64_t read_cr0 ()
 
static INLINE void write_cr0 (uint64_t val)
 
static INLINE uint64_t read_cr2 ()
 
static INLINE uint64_t read_cr3 ()
 
static INLINE void write_cr3 (uint64_t val)
 
static INLINE uint64_t read_cr4 ()
 
static INLINE void write_cr4 (uint64_t val)
 
static INLINE uint64_t read_dr0 ()
 
static INLINE void write_dr0 (uint64_t val)
 
static INLINE uint64_t read_dr1 ()
 
static INLINE void write_dr1 (uint64_t val)
 
static INLINE uint64_t read_dr2 ()
 
static INLINE void write_dr2 (uint64_t val)
 
static INLINE uint64_t read_dr3 ()
 
static INLINE void write_dr3 (uint64_t val)
 
static INLINE uint64_t read_dr6 ()
 
static INLINE void write_dr6 (uint64_t val)
 
static INLINE uint64_t read_dr7 ()
 
static INLINE void write_dr7 (uint64_t val)
 
static INLINE uint16_t read_ds ()
 
static INLINE void write_ds (uint16_t val)
 
static INLINE uint16_t read_es ()
 
static INLINE void write_es (uint16_t val)
 
static INLINE uint16_t read_fs ()
 
static INLINE void write_fs (uint16_t val)
 
static INLINE uint16_t read_gs ()
 
static INLINE void write_gs (uint16_t val)
 
static INLINE void clts ()
 
static INLINE void fxsave (struct XSAVEArea *xsa)
 
static INLINE void fxrstor (struct XSAVEArea *xsa)
 
static INLINE void xsave (struct XSAVEArea *xsa, uint64_t mask)
 
static INLINE void xsaveopt (struct XSAVEArea *xsa, uint64_t mask)
 
static INLINE void xrstor (struct XSAVEArea *xsa, uint64_t mask)
 
static INLINE void outb (uint16_t port, uint8_t data)
 
static INLINE void outw (uint16_t port, uint16_t data)
 
static INLINE void outl (uint16_t port, uint32_t data)
 
static INLINE uint8_t inb (uint16_t port)
 
static INLINE uint16_t inw (uint16_t port)
 
static INLINE uint32_t inl (uint16_t port)
 

Function Documentation

◆ breakpoint()

static INLINE void breakpoint ( )
static

Definition at line 29 of file amd64op.h.

30{
31 asm volatile("int3");
32}
Here is the caller graph for this function:

◆ clts()

static INLINE void clts ( )
static

Definition at line 372 of file amd64op.h.

373{
374 asm volatile("clts");
375}
Here is the caller graph for this function:

◆ cpuid()

static INLINE void cpuid ( uint32_t  info,
uint32_t eax,
uint32_t ebx,
uint32_t ecx,
uint32_t edx 
)
static

Definition at line 85 of file amd64op.h.

87{
88 uint32_t a, b, c, d;
89
90 asm volatile("cpuid"
91 : "=a" (a), "=b" (b), "=c" (c), "=d" (d)
92 : "a" (info));
93
94 if (eax)
95 *eax = a;
96 if (ebx)
97 *ebx = b;
98 if (ecx)
99 *ecx = c;
100 if (edx)
101 *edx = d;
102}
unsigned int uint32_t
Definition: types.h:12
Here is the caller graph for this function:

◆ disable_interrupts()

static INLINE void disable_interrupts ( )
static

Definition at line 14 of file amd64op.h.

15{
16 asm volatile("cli");
17}
Here is the caller graph for this function:

◆ enable_interrupts()

static INLINE void enable_interrupts ( )
static

Definition at line 9 of file amd64op.h.

10{
11 asm volatile("sti");
12}
Here is the caller graph for this function:

◆ fxrstor()

static INLINE void fxrstor ( struct XSAVEArea xsa)
static

Definition at line 386 of file amd64op.h.

387{
388 asm volatile("fxrstor %0"
389 :
390 : "m" (*xsa)
391 : "memory");
392}
Here is the caller graph for this function:

◆ fxsave()

static INLINE void fxsave ( struct XSAVEArea xsa)
static

Definition at line 377 of file amd64op.h.

378{
379 asm volatile("fxsave %0"
380 : "=m" (*xsa)
381 :
382 : "memory");
383}
Here is the caller graph for this function:

◆ hlt()

static INLINE void hlt ( )
static

Definition at line 19 of file amd64op.h.

20{
21 asm volatile("hlt");
22}
Here is the caller graph for this function:

◆ icebp()

static INLINE void icebp ( )
static

Definition at line 34 of file amd64op.h.

35{
36 asm volatile(".byte 0xf1");
37}

◆ inb()

static INLINE uint8_t inb ( uint16_t  port)
static

Definition at line 452 of file amd64op.h.

453{
454 uint8_t data;
455
456 asm volatile("inb %1, %0"
457 : "=a" (data)
458 :"d" (port));
459
460 return data;
461}
unsigned char uint8_t
Definition: types.h:10
Here is the caller graph for this function:

◆ inl()

static INLINE uint32_t inl ( uint16_t  port)
static

Definition at line 474 of file amd64op.h.

475{
476 uint32_t data;
477
478 asm volatile("inl %1, %0"
479 : "=a" (data)
480 :"d" (port));
481
482 return data;
483}
Here is the caller graph for this function:

◆ inw()

static INLINE uint16_t inw ( uint16_t  port)
static

Definition at line 463 of file amd64op.h.

464{
465 uint16_t data;
466
467 asm volatile("inw %1, %0"
468 : "=a" (data)
469 :"d" (port));
470
471 return data;
472}
unsigned short uint16_t
Definition: types.h:11
Here is the caller graph for this function:

◆ lgdt()

static INLINE void lgdt ( PseudoDescriptor gdt)
static

Definition at line 70 of file amd64op.h.

71{
72 asm volatile("lgdt (%0)"
73 :
74 : "r" (gdt)
75 : "memory");
76}
Here is the caller graph for this function:

◆ lidt()

static INLINE void lidt ( PseudoDescriptor idt)
static

Definition at line 62 of file amd64op.h.

63{
64 asm volatile("lidt (%0)"
65 :
66 : "r" (idt)
67 : "memory");
68}
static InteruptGate64 idt[256]
Definition: trap.c:28
Here is the caller graph for this function:

◆ ltr()

static INLINE void ltr ( uint16_t  tss)
static

Definition at line 78 of file amd64op.h.

79{
80 asm volatile("ltr %0"
81 :
82 : "r" (tss));
83}
Here is the caller graph for this function:

◆ outb()

static INLINE void outb ( uint16_t  port,
uint8_t  data 
)
static

Definition at line 431 of file amd64op.h.

432{
433 asm volatile("outb %0, %1"
434 :
435 : "a" (data), "d" (port));
436}
Here is the caller graph for this function:

◆ outl()

static INLINE void outl ( uint16_t  port,
uint32_t  data 
)
static

Definition at line 445 of file amd64op.h.

446{
447 asm volatile("outl %0, %1"
448 :
449 : "a" (data), "d" (port));
450}
Here is the caller graph for this function:

◆ outw()

static INLINE void outw ( uint16_t  port,
uint16_t  data 
)
static

Definition at line 438 of file amd64op.h.

439{
440 asm volatile("outw %0, %1"
441 :
442 : "a" (data), "d" (port));
443}
Here is the caller graph for this function:

◆ pause()

static INLINE void pause ( )
static

Definition at line 24 of file amd64op.h.

25{
26 asm volatile("pause");
27}
Here is the caller graph for this function:

◆ rdmsr()

static INLINE uint64_t rdmsr ( uint32_t  addr)
static

Definition at line 114 of file amd64op.h.

115{
116 uint64_t eax, edx;
117
118 asm volatile("rdmsr"
119 : "=a" (eax), "=d" (edx)
120 : "c" (addr));
121
122 return edx << 32 | eax;
123}
uint64_t addr
Definition: multiboot.h:1
unsigned long uint64_t
Definition: types.h:13
Here is the caller graph for this function:

◆ rdtsc()

static INLINE uint64_t rdtsc ( )
static

Definition at line 39 of file amd64op.h.

40{
41 uint32_t lo, hi;
42
43 asm volatile("rdtsc"
44 : "=a" (lo), "=d" (hi));
45
46 return ((uint64_t)hi << 32) | (uint64_t)lo;
47}
Here is the caller graph for this function:

◆ rdtscp()

static INLINE uint64_t rdtscp ( uint32_t procno)
static

Definition at line 49 of file amd64op.h.

50{
51 uint32_t lo, hi, proc;
52
53 asm volatile("rdtsc"
54 : "=a" (lo), "=d" (hi), "=c" (proc));
55
56 if (procno)
57 *procno = proc;
58
59 return ((uint64_t)hi << 32) | (uint64_t)lo;
60}

◆ read_cr0()

static INLINE uint64_t read_cr0 ( )
static

Definition at line 129 of file amd64op.h.

130{
131 uint64_t val;
132
133 asm volatile("movq %%cr0, %0"
134 : "=r" (val));
135
136 return val;
137}
Here is the caller graph for this function:

◆ read_cr2()

static INLINE uint64_t read_cr2 ( )
static

Definition at line 146 of file amd64op.h.

147{
148 uint64_t val;
149
150 asm volatile("movq %%cr2, %0"
151 : "=r" (val));
152
153 return val;
154}
Here is the caller graph for this function:

◆ read_cr3()

static INLINE uint64_t read_cr3 ( )
static

Definition at line 156 of file amd64op.h.

157{
158 uint64_t val;
159
160 asm volatile("movq %%cr3, %0"
161 : "=r" (val));
162
163 return val;
164}
Here is the caller graph for this function:

◆ read_cr4()

static INLINE uint64_t read_cr4 ( )
static

Definition at line 173 of file amd64op.h.

174{
175 uint64_t val;
176
177 asm volatile("movq %%cr4, %0"
178 : "=r" (val));
179
180 return val;
181}
Here is the caller graph for this function:

◆ read_dr0()

static INLINE uint64_t read_dr0 ( )
static

Definition at line 194 of file amd64op.h.

195{
196 uint64_t val;
197
198 asm volatile("movq %%dr0, %0"
199 : "=r" (val));
200
201 return val;
202}
Here is the caller graph for this function:

◆ read_dr1()

static INLINE uint64_t read_dr1 ( )
static

Definition at line 211 of file amd64op.h.

212{
213 uint64_t val;
214
215 asm volatile("movq %%dr1, %0"
216 : "=r" (val));
217
218 return val;
219}
Here is the caller graph for this function:

◆ read_dr2()

static INLINE uint64_t read_dr2 ( )
static

Definition at line 228 of file amd64op.h.

229{
230 uint64_t val;
231
232 asm volatile("movq %%dr2, %0"
233 : "=r" (val));
234
235 return val;
236}
Here is the caller graph for this function:

◆ read_dr3()

static INLINE uint64_t read_dr3 ( )
static

Definition at line 245 of file amd64op.h.

246{
247 uint64_t val;
248
249 asm volatile("movq %%dr3, %0"
250 : "=r" (val));
251
252 return val;
253}
Here is the caller graph for this function:

◆ read_dr6()

static INLINE uint64_t read_dr6 ( )
static

Definition at line 262 of file amd64op.h.

263{
264 uint64_t val;
265
266 asm volatile("movq %%dr6, %0"
267 : "=r" (val));
268
269 return val;
270}
Here is the caller graph for this function:

◆ read_dr7()

static INLINE uint64_t read_dr7 ( )
static

Definition at line 279 of file amd64op.h.

280{
281 uint64_t val;
282
283 asm volatile("movq %%dr7, %0"
284 : "=r" (val));
285
286 return val;
287}
Here is the caller graph for this function:

◆ read_ds()

static INLINE uint16_t read_ds ( )
static

Definition at line 300 of file amd64op.h.

301{
302 uint16_t val;
303
304 asm volatile("movw %%ds, %0"
305 : "=r" (val));
306
307 return val;
308}
Here is the caller graph for this function:

◆ read_es()

static INLINE uint16_t read_es ( )
static

Definition at line 317 of file amd64op.h.

318{
319 uint16_t val;
320
321 asm volatile("movw %%es, %0"
322 : "=r" (val));
323
324 return val;
325}
Here is the caller graph for this function:

◆ read_fs()

static INLINE uint16_t read_fs ( )
static

Definition at line 334 of file amd64op.h.

335{
336 uint16_t val;
337
338 asm volatile("movw %%fs, %0"
339 : "=r" (val));
340
341 return val;
342}
Here is the caller graph for this function:

◆ read_gs()

static INLINE uint16_t read_gs ( )
static

Definition at line 351 of file amd64op.h.

352{
353 uint16_t val;
354
355 asm volatile("movw %%gs, %0"
356 : "=r" (val));
357
358 return val;
359}
Here is the caller graph for this function:

◆ write_cr0()

static INLINE void write_cr0 ( uint64_t  val)
static

Definition at line 139 of file amd64op.h.

140{
141 asm volatile("movq %0, %%cr0"
142 :
143 : "r" (val));
144}

◆ write_cr3()

static INLINE void write_cr3 ( uint64_t  val)
static

Definition at line 166 of file amd64op.h.

167{
168 asm volatile("movq %0, %%cr3"
169 :
170 : "r" (val));
171}
Here is the caller graph for this function:

◆ write_cr4()

static INLINE void write_cr4 ( uint64_t  val)
static

Definition at line 183 of file amd64op.h.

184{
185 asm volatile("movq %0, %%cr4"
186 :
187 : "r" (val));
188}

◆ write_dr0()

static INLINE void write_dr0 ( uint64_t  val)
static

Definition at line 204 of file amd64op.h.

205{
206 asm volatile("movq %0, %%dr0"
207 :
208 : "r" (val));
209}
Here is the caller graph for this function:

◆ write_dr1()

static INLINE void write_dr1 ( uint64_t  val)
static

Definition at line 221 of file amd64op.h.

222{
223 asm volatile("movq %0, %%dr1"
224 :
225 : "r" (val));
226}
Here is the caller graph for this function:

◆ write_dr2()

static INLINE void write_dr2 ( uint64_t  val)
static

Definition at line 238 of file amd64op.h.

239{
240 asm volatile("movq %0, %%dr2"
241 :
242 : "r" (val));
243}
Here is the caller graph for this function:

◆ write_dr3()

static INLINE void write_dr3 ( uint64_t  val)
static

Definition at line 255 of file amd64op.h.

256{
257 asm volatile("movq %0, %%dr3"
258 :
259 : "r" (val));
260}
Here is the caller graph for this function:

◆ write_dr6()

static INLINE void write_dr6 ( uint64_t  val)
static

Definition at line 272 of file amd64op.h.

273{
274 asm volatile("movq %0, %%dr6"
275 :
276 : "r" (val));
277}

◆ write_dr7()

static INLINE void write_dr7 ( uint64_t  val)
static

Definition at line 289 of file amd64op.h.

290{
291 asm volatile("movq %0, %%dr7"
292 :
293 : "r" (val));
294}
Here is the caller graph for this function:

◆ write_ds()

static INLINE void write_ds ( uint16_t  val)
static

Definition at line 310 of file amd64op.h.

311{
312 asm volatile("movw %0, %%ds"
313 :
314 : "r" (val));
315}

◆ write_es()

static INLINE void write_es ( uint16_t  val)
static

Definition at line 327 of file amd64op.h.

328{
329 asm volatile("movw %0, %%es"
330 :
331 : "r" (val));
332}

◆ write_fs()

static INLINE void write_fs ( uint16_t  val)
static

Definition at line 344 of file amd64op.h.

345{
346 asm volatile("movw %0, %%fs"
347 :
348 : "r" (val));
349}

◆ write_gs()

static INLINE void write_gs ( uint16_t  val)
static

Definition at line 361 of file amd64op.h.

362{
363 asm volatile("movw %0, %%gs"
364 :
365 : "r" (val));
366}

◆ wrmsr()

static INLINE void wrmsr ( uint32_t  addr,
uint64_t  val 
)
static

Definition at line 104 of file amd64op.h.

105{
106 uint32_t eax = val & 0xFFFFFFFF;
107 uint32_t edx = val >> 32;
108
109 asm volatile("wrmsr"
110 :
111 : "a" (eax), "c" (addr), "d" (edx));
112}
Here is the caller graph for this function:

◆ xrstor()

static INLINE void xrstor ( struct XSAVEArea xsa,
uint64_t  mask 
)
static

Definition at line 416 of file amd64op.h.

417{
418 uint32_t lo = (uint32_t)mask;
419 uint32_t hi = (uint32_t)(mask >> 32);
420
421 asm volatile("xrstor %0"
422 :
423 : "m" (*xsa), "a" (lo), "d" (hi)
424 : "memory");
425}

◆ xsave()

static INLINE void xsave ( struct XSAVEArea xsa,
uint64_t  mask 
)
static

Definition at line 394 of file amd64op.h.

395{
396 uint32_t lo = (uint32_t)mask;
397 uint32_t hi = (uint32_t)(mask >> 32);
398
399 asm volatile("xsave %0"
400 : "=m" (*xsa)
401 : "a" (lo), "d" (hi)
402 : "memory");
403}

◆ xsaveopt()

static INLINE void xsaveopt ( struct XSAVEArea xsa,
uint64_t  mask 
)
static

Definition at line 405 of file amd64op.h.

406{
407 uint32_t lo = (uint32_t)mask;
408 uint32_t hi = (uint32_t)(mask >> 32);
409
410 asm volatile("xsaveopt %0"
411 : "=m" (*xsa)
412 : "a" (lo), "d" (hi)
413 : "memory");
414}