source: trunk/hal/x86_64/core/hal_cpu.S @ 91

Last change on this file since 91 was 91, checked in by max@…, 5 years ago

retrieve the pressed key, and display it

File size: 1.6 KB
Line 
1/*
2 * hal_cpu.S - Miscellaneous CPU functions
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#define x86_ASM
23#include <hal_boot.h>
24#include <hal_segmentation.h>
25
26ASM_ENTRY(lgdt)
27        lgdt    (%rdi)
28        /* Reload the prefetch queue */
29    jmp 1f
30    nop
311:      /* Reload stale selectors */
32        movl    $GDT_FIXED_SEL(GDT_KDATA_SEL, SEL_KPL),%eax
33        movl    %eax,%ds
34        movl    %eax,%es
35        movl    %eax,%ss
36        ret
37
38ASM_ENTRY(lidt)
39        lidt    (%rdi)
40        ret
41
42ASM_ENTRY(ltr)
43        ltr     %di
44        ret
45
46ASM_ENTRY(invlpg)
47        invlpg  (%rdi)
48        ret
49
50ASM_ENTRY(sti)
51        sti
52        ret
53
54ASM_ENTRY(cli)
55        cli
56        ret
57
58ASM_ENTRY(in8)
59        movq    %rdi,%rdx
60        xorq    %rax,%rax
61        inb     %dx,%al
62        ret
63
64ASM_ENTRY(out8)
65        movq    %rdi,%rdx
66        movq    %rsi,%rax
67        outb    %al,%dx
68        ret
69
70ASM_ENTRY(rdmsr)
71        movq    %rdi,%rcx
72        xorq    %rax,%rax
73        rdmsr
74        shlq    $32,%rdx
75        orq     %rdx,%rax
76        ret
77
78ASM_ENTRY(wrmsr)
79        movq    %rdi,%rcx
80        movq    %rsi,%rax
81        movq    %rsi,%rdx
82        shrq    $32,%rdx
83        wrmsr
84        ret
85
86ASM_ENTRY(x86_stop) /* debug only */
87        int     $0x0b
88        ret
89
Note: See TracBrowser for help on using the repository browser.