source: trunk/hal/x86_64/core/hal_special.c @ 571

Last change on this file since 571 was 482, checked in by viala@…, 6 years ago

[hal/x86_64] Add void type to function prototypes with no parameter

File size: 2.8 KB
Line 
1/*
2 * hal_special.c - implementation of TLS API for x86_64
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#include <hal_kernel_types.h>
23#include <hal_apic.h>
24#include <hal_special.h>
25#include <hal_register.h>
26#include <hal_internal.h>
27#include <hal_segmentation.h>
28
29#include <core.h>
30#include <thread.h>
31
32struct thread_s;
33
34tls_t *curtls( void )
35{
36        tls_t *cputls;
37
38        __asm volatile("movq %%gs:%1, %0" :
39            "=r" (cputls) :
40            "m"
41            (*(tls_t * const *)offsetof(tls_t, tls_self)));
42        return cputls;
43}
44
45gid_t hal_get_gid( void )
46{
47        return curtls()->tls_gid;
48}
49
50cycle_t hal_time_stamp( void )
51{
52        return rdtsc();
53}
54
55inline reg_t hal_get_sr( void )
56{
57        return 0;
58}
59
60uint64_t hal_get_cycles( void )
61{
62        uint64_t cycles;
63        core_t *core = CURRENT_THREAD->core;
64
65        /*
66         * Put the value of the TSC everywhere
67         */
68        cycles = rdtsc();
69        core->time_stamp = cycles;
70        core->cycles = cycles;
71
72        return cycles;
73}
74
75struct thread_s *hal_get_current_thread( void )
76{
77        return curtls()->tls_thr;
78}
79
80void hal_set_current_thread( struct thread_s * thread )
81{
82        curtls()->tls_thr = thread;
83}
84
85/* -------------------------------------------------------------------------- */
86
87void hal_fpu_enable( void )
88{
89        /* FPU not implemented yet */
90        return;
91        clts();
92}
93
94void hal_fpu_disable( void )
95{
96        /* FPU not implemented yet */
97        return;
98        stts();
99}
100
101uint32_t hal_get_stack( void )
102{
103        x86_panic((char *)__func__);
104        return 0;
105}
106
107uint32_t hal_set_stack( void * new_val )
108{
109        x86_panic((char *)__func__);
110        return 0;
111}
112
113uint32_t hal_get_bad_vaddr( void )
114{
115        x86_panic((char *)__func__);
116        return 0;
117}
118
119uint32_t hal_uncached_read( uint32_t * ptr )
120{
121        x86_panic((char *)__func__);
122        return 0;
123}
124
125void hal_invalid_dcache_line( void * ptr )
126{
127        x86_panic((char *)__func__);
128}
129
130void hal_fence( void )
131{
132        mfence();
133}
134
135void hal_rdbar( void )
136{
137        x86_panic((char *)__func__);
138}
139
140void hal_core_sleep( void )
141{
142        x86_panic((char *)__func__);
143}
144
145void hal_fixed_delay( uint32_t delay )
146{
147        x86_panic((char *)__func__);
148}
149
150void hal_get_mmu_excp(intptr_t *mmu_ins_excp_code, intptr_t *mmu_ins_bad_vaddr,
151    intptr_t *mmu_dat_excp_code, intptr_t *mmu_dat_bad_vaddr)
152{
153        x86_panic((char *)__func__);
154}
155
Note: See TracBrowser for help on using the repository browser.