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

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

sync

File size: 2.2 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, uint8_t data)
26{
27        *(uint8_t *)xp = data;
28}
29
30void hal_remote_sw(xptr_t xp, uint32_t data)
31{
32        *(uint32_t *)xp = data;
33}
34
35void hal_remote_swd(xptr_t xp, uint64_t data)
36{
37        *(uint64_t *)xp = data;
38}
39
40void hal_remote_spt(xptr_t xp, void *pt)
41{
42        hal_remote_swd(xp, (uint64_t)pt);
43}
44
45uint8_t hal_remote_lb(xptr_t xp)
46{
47        return *(uint8_t *)xp;
48}
49
50uint32_t hal_remote_lw(xptr_t xp)
51{
52        return *(uint32_t *)xp;
53}
54
55uint64_t hal_remote_lwd(xptr_t xp)
56{
57        return *(uint64_t *)xp;
58}
59
60void *hal_remote_lpt(xptr_t xp)
61{
62        return (void *)hal_remote_lwd(xp);
63}
64
65bool_t hal_remote_atomic_cas(xptr_t xp, uint32_t old, uint32_t new)
66{
67        return (atomic_cas_32((volatile uint32_t *)xp, old, new) == old);
68}
69
70uint32_t hal_remote_atomic_add(xptr_t xp, uint32_t incr)
71{
72        return atomic_add_32((volatile uint32_t *)xp, incr);
73}
74
75uint32_t hal_remote_atomic_and(xptr_t xp, uint32_t mask)
76{
77        return atomic_and_32((volatile uint32_t *)xp, mask);
78}
79
80uint32_t hal_remote_atomic_or(xptr_t xp, uint32_t mask)
81{
82        return atomic_or_32((volatile uint32_t *)xp, mask);
83}
84
85error_t hal_remote_atomic_try_add(xptr_t xp, uint32_t incr, uint32_t *old)
86{
87        x86_panic((char *)__func__);
88        return 0;
89}
90
91void hal_remote_memcpy(xptr_t dst, xptr_t src, uint32_t size)
92{
93        memcpy((void *)dst, (void *)src, size);
94}
95
96void hal_remote_strcpy( xptr_t dst,
97                        xptr_t src )
98{
99        x86_panic((char *)__func__);
100}
101
Note: See TracBrowser for help on using the repository browser.