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

Last change on this file since 371 was 314, checked in by max@…, 4 years ago

Add hal_remote_memset.

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