]>
Commit | Line | Data |
---|---|---|
1 | .text | |
2 | /* | |
3 | * Taken from Libc | |
4 | */ | |
5 | .globl _cpu_number | |
6 | _cpu_number: | |
7 | #if defined(__x86_64__) | |
8 | push %rbp | |
9 | mov %rsp,%rbp | |
10 | sub $16,%rsp // space to read IDTR | |
11 | ||
12 | sidt (%rsp) // store limit:base on stack | |
13 | movw (%rsp), %rax // get limit | |
14 | and $0xfff, %rax // mask off lower 12 bits to return | |
15 | ||
16 | mov %rbp,%rsp | |
17 | pop %rbp | |
18 | ret | |
19 | #elif defined(__i386__) | |
20 | push %ebp | |
21 | mov %esp,%ebp | |
22 | sub $8, %esp // space to read IDTR | |
23 | ||
24 | sidt (%esp) // store limit:base on stack | |
25 | movw (%esp), %ax // get limit | |
26 | and $0xfff, %eax // mask off lower 12 bits to return | |
27 | ||
28 | mov %ebp,%esp | |
29 | pop %ebp | |
30 | ret | |
31 | #else | |
32 | #error Unsupported architecture | |
33 | #endif |