source: trunk/hal/x86_64/core/hal_remote.c @ 123

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

add a few atomic functions

File size: 2.5 KB
Line 
1/*
2 * hal_remote.c - implementation of Generic Remote Access API x86
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_types.h>
23#include <hal_internal.h>
24
25void hal_remote_sb( xptr_t   xp,
26                    uint8_t  data )
27{
28        *(uint8_t *)xp = data;
29}
30
31void hal_remote_sw( xptr_t    xp,
32                    uint32_t  data )
33{
34        *(uint32_t *)xp = data;
35}
36
37void hal_remote_swd( xptr_t    xp,
38                     uint64_t  data )
39{
40        *(uint64_t *)xp = data;
41}
42
43void hal_remote_spt( xptr_t      xp,
44                     void *      pt )
45{
46        hal_remote_swd( xp , (uint64_t)pt );
47}
48
49uint8_t hal_remote_lb( xptr_t  xp )
50{
51        return *(uint8_t *)xp;
52}
53
54uint32_t hal_remote_lw( xptr_t  xp )
55{
56        return *(uint32_t *)xp;
57}
58
59uint64_t hal_remote_lwd( xptr_t  xp )
60{
61        return *(uint64_t *)xp;
62}
63
64void *hal_remote_lpt( xptr_t    xp )
65{
66        return (void *)hal_remote_lwd( xp );
67}
68
69bool_t hal_remote_atomic_cas( xptr_t    xp,
70                              uint32_t  old,
71                              uint32_t  new )
72{
73        return (atomic_cas_32((volatile uint32_t *)xp, old, new) == old);
74}
75
76uint32_t hal_remote_atomic_add( xptr_t   xp, 
77                                uint32_t incr ) // XXX define as signed
78{
79        return atomic_add_32((volatile uint32_t *)xp, incr);
80}
81
82uint32_t hal_remote_atomic_and( xptr_t   xp, 
83                                uint32_t mask )
84{
85        return atomic_and_32((volatile uint32_t *)xp, mask);
86}
87
88uint32_t hal_remote_atomic_or( xptr_t   xp, 
89                               uint32_t mask )
90{
91        return atomic_or_32((volatile uint32_t *)xp, mask);
92}
93
94error_t hal_remote_atomic_try_add( xptr_t     xp,
95                                   uint32_t   incr,
96                                   uint32_t * old )
97{
98        x86_panic((char *)__func__);
99        return 0;
100}
101
102void hal_remote_memcpy( xptr_t   dst,
103                        xptr_t   src,
104                        uint32_t size )
105{
106        x86_panic((char *)__func__);
107}
108
Note: See TracBrowser for help on using the repository browser.