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

Last change on this file since 192 was 169, checked in by max@…, 7 years ago

remove unused var

File size: 2.7 KB
RevLine 
[25]1/*
[46]2 * hal_special.c - implementation of TLS API for x86_64
[71]3 *
[46]4 * Copyright (c) 2017 Maxime Villard
[71]5 *
[46]6 * This file is part of ALMOS-MKH.
[25]7 *
[46]8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
[25]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 *
[46]12 * ALMOS-MKH is distributed in the hope that it will be useful, but
[25]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_types.h>
[82]23#include <hal_apic.h>
[25]24#include <hal_special.h>
[46]25#include <hal_register.h>
26#include <hal_internal.h>
[167]27#include <hal_segmentation.h>
[25]28
[102]29#include <core.h>
30#include <thread.h>
31
[25]32struct thread_s;
33
[167]34tls_t *curcpu()
[46]35{
[167]36        tls_t *cputls;
[46]37
38        __asm volatile("movq %%gs:%1, %0" :
[167]39            "=r" (cputls) :
[46]40            "m"
[167]41            (*(tls_t * const *)offsetof(tls_t, tls_self)));
42        return cputls;
[46]43}
44
[25]45gid_t hal_get_gid()
46{
[167]47        return curcpu()->tls_gid;
[25]48}
49
[125]50cycle_t hal_time_stamp()
51{
52        return rdtsc();
53}
54
[102]55uint64_t hal_get_cycles()
[25]56{
[102]57        uint64_t cycles;
58        core_t *core = CURRENT_THREAD->core;
59
60        /*
61         * Put the value of the TSC everywhere
62         */
63        cycles = rdtsc();
64        core->time_stamp = cycles;
65        core->cycles = cycles;
66
67        return cycles;
[25]68}
69
[102]70struct thread_s *hal_get_current_thread()
[25]71{
[167]72        return curcpu()->tls_thr;
[25]73}
74
75void hal_set_current_thread( struct thread_s * thread )
[71]76{
[167]77        curcpu()->tls_thr = thread;
[25]78}
79
[46]80/* -------------------------------------------------------------------------- */
81
[25]82void hal_fpu_enable()
83{
[46]84        x86_panic((char *)__func__);
[25]85}
86
87void hal_fpu_disable()
88{
[46]89        x86_panic((char *)__func__);
[25]90}
91
92uint32_t hal_get_stack()
93{
[46]94        x86_panic((char *)__func__);
[25]95        return 0;
96}
97
98uint32_t hal_set_stack( void * new_val )
99{
[46]100        x86_panic((char *)__func__);
[25]101        return 0;
102}
103
104uint32_t hal_get_bad_vaddr()
105{
[46]106        x86_panic((char *)__func__);
[25]107        return 0;
108}
109
110uint32_t hal_uncached_read( uint32_t * ptr )
111{
[46]112        x86_panic((char *)__func__);
[25]113        return 0;
114}
115
116void hal_invalid_dcache_line( void * ptr )
117{
[46]118        x86_panic((char *)__func__);
[25]119}
120
[124]121void hal_fence()
[25]122{
[125]123        mfence();
[25]124}
125
126void hal_rdbar()
127{
[46]128        x86_panic((char *)__func__);
[25]129}
130
131void hal_core_sleep()
132{
[46]133        x86_panic((char *)__func__);
[25]134}
135
136void hal_fixed_delay( uint32_t delay )
[71]137{
[46]138        x86_panic((char *)__func__);
[25]139}
140
141void hal_get_mmu_excp( intptr_t * mmu_ins_excp_code,
142                       intptr_t * mmu_ins_bad_vaddr,
143                       intptr_t * mmu_dat_excp_code,
144                       intptr_t * mmu_dat_bad_vaddr )
145{
[46]146        x86_panic((char *)__func__);
[25]147}
Note: See TracBrowser for help on using the repository browser.