Rev 224 | Rev 251 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 224 | Rev 242 | ||
---|---|---|---|
Line 42... | Line 42... | ||
42 | 42 | ||
43 | panic_printf: |
43 | panic_printf: |
44 | movq $halt, (%rsp) |
44 | movq $halt, (%rsp) |
45 | jmp printf |
45 | jmp printf |
46 | 46 | ||
- | 47 | .global has_cpuid |
|
- | 48 | .global rdtsc |
|
- | 49 | ||
- | 50 | ||
- | 51 | ## Determine CPUID support |
|
- | 52 | # |
|
- | 53 | # Return 0 in EAX if CPUID is not support, 1 if supported. |
|
- | 54 | # |
|
- | 55 | has_cpuid: |
|
- | 56 | pushq %rbx |
|
- | 57 | ||
- | 58 | pushfq # store flags |
|
- | 59 | popq %rax # read flags |
|
- | 60 | movq %rax,%rbx # copy flags |
|
- | 61 | btcl $21,%ebx # swap the ID bit |
|
- | 62 | pushq %rbx |
|
- | 63 | popfq # propagate the change into flags |
|
- | 64 | pushfq |
|
- | 65 | popq %rbx # read flags |
|
- | 66 | andl $(1<<21),%eax # interested only in ID bit |
|
- | 67 | andl $(1<<21),%ebx |
|
- | 68 | xorl %ebx,%eax # 0 if not supported, 1 if supported |
|
- | 69 | ||
- | 70 | popq %rbx |
|
- | 71 | ret |
|
- | 72 | ||
- | 73 | ||
- | 74 | rdtsc: |
|
- | 75 | xorq %rax,%rax |
|
- | 76 | rdtsc |
|
- | 77 | ret |
|
- | 78 | ||
- | 79 | ||
47 | # Push all general purpose registers on stack except %rbp, %rsp |
80 | # Push all general purpose registers on stack except %rbp, %rsp |
48 | .macro push_all_gpr |
81 | .macro push_all_gpr |
49 | pushq %rax |
82 | pushq %rax |
50 | pushq %rbx |
83 | pushq %rbx |
51 | pushq %rcx |
84 | pushq %rcx |