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

Last change on this file since 457 was 457, checked in by alain, 6 years ago

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

File size: 2.3 KB
RevLine 
[25]1/*
[105]2 * hal_remote.c - implementation of Generic Remote Access API x86
[25]3 *
[105]4 * Copyright (c) 2017 Maxime Villard
[25]5 *
[105]6 * This file is part of ALMOS-MKH.
7 *
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 *
[105]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
[234]18 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
[25]19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
[457]22#include <hal_kernel_types.h>
[48]23#include <hal_internal.h>
[25]24
[209]25#include <string.h>
26
[145]27void hal_remote_sb(xptr_t xp, uint8_t data)
[25]28{
[72]29        *(uint8_t *)xp = data;
[25]30}
31
[145]32void hal_remote_sw(xptr_t xp, uint32_t data)
[25]33{
[72]34        *(uint32_t *)xp = data;
[25]35}
36
[145]37void hal_remote_swd(xptr_t xp, uint64_t data)
[25]38{
[72]39        *(uint64_t *)xp = data;
[25]40}
41
[145]42void hal_remote_spt(xptr_t xp, void *pt)
[25]43{
[145]44        hal_remote_swd(xp, (uint64_t)pt);
[25]45}
46
[145]47uint8_t hal_remote_lb(xptr_t xp)
[25]48{
[72]49        return *(uint8_t *)xp;
[25]50}
51
[145]52uint32_t hal_remote_lw(xptr_t xp)
[25]53{
[72]54        return *(uint32_t *)xp;
[25]55}
56
[145]57uint64_t hal_remote_lwd(xptr_t xp)
[25]58{
[72]59        return *(uint64_t *)xp;
[25]60}
61
[145]62void *hal_remote_lpt(xptr_t xp)
[25]63{
[145]64        return (void *)hal_remote_lwd(xp);
[25]65}
66
[145]67bool_t hal_remote_atomic_cas(xptr_t xp, uint32_t old, uint32_t new)
[25]68{
[96]69        return (atomic_cas_32((volatile uint32_t *)xp, old, new) == old);
[25]70}
71
[145]72uint32_t hal_remote_atomic_add(xptr_t xp, uint32_t incr)
[48]73{
[96]74        return atomic_add_32((volatile uint32_t *)xp, incr);
[25]75}
76
[145]77uint32_t hal_remote_atomic_and(xptr_t xp, uint32_t mask)
[48]78{
[98]79        return atomic_and_32((volatile uint32_t *)xp, mask);
[25]80}
81
[145]82uint32_t hal_remote_atomic_or(xptr_t xp, uint32_t mask)
[48]83{
[98]84        return atomic_or_32((volatile uint32_t *)xp, mask);
[25]85}
86
[145]87error_t hal_remote_atomic_try_add(xptr_t xp, uint32_t incr, uint32_t *old)
[25]88{
[48]89        x86_panic((char *)__func__);
[25]90        return 0;
91}
92
[145]93void hal_remote_memcpy(xptr_t dst, xptr_t src, uint32_t size)
[25]94{
[124]95        memcpy((void *)dst, (void *)src, size);
[25]96}
97
[314]98void hal_remote_strcpy(xptr_t dst, xptr_t src)
[189]99{
[209]100        strcpy((void *)dst, (void *)src);
[189]101}
102
[314]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.