[25] | 1 | /* |
---|
| 2 | * hal_remote.c - implementation of Generic Remote Access API for TSAR-MIPS32 |
---|
| 3 | * |
---|
| 4 | * Authors : Mohammed Karaoui (2015) |
---|
| 5 | * Alain Greiner (2016) |
---|
| 6 | * |
---|
| 7 | * Copyright (c) UPMC Sorbonne Universites |
---|
| 8 | * |
---|
| 9 | * This file is part of ALMOS-MKH.. |
---|
| 10 | * |
---|
| 11 | * ALMOS-MKH. is free software; you can redistribute it and/or modify it |
---|
| 12 | * under the terms of the GNU General Public License as published by |
---|
| 13 | * the Free Software Foundation; version 2.0 of the License. |
---|
| 14 | * |
---|
| 15 | * ALMOS-MKH. is distributed in the hope that it will be useful, but |
---|
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 18 | * General Public License for more details. |
---|
| 19 | * |
---|
| 20 | * You should have received a copy of the GNU General Public License |
---|
| 21 | * along with ALMOS-MKH.; if not, write to the Free Software Foundation, |
---|
| 22 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include <hal_types.h> |
---|
[48] | 26 | #include <hal_internal.h> |
---|
[25] | 27 | |
---|
| 28 | void hal_remote_sb( xptr_t xp, |
---|
[69] | 29 | uint8_t data ) |
---|
[25] | 30 | { |
---|
[72] | 31 | *(uint8_t *)xp = data; |
---|
[25] | 32 | } |
---|
| 33 | |
---|
| 34 | void hal_remote_sw( xptr_t xp, |
---|
| 35 | uint32_t data ) |
---|
| 36 | { |
---|
[72] | 37 | *(uint32_t *)xp = data; |
---|
[25] | 38 | } |
---|
| 39 | |
---|
| 40 | void hal_remote_swd( xptr_t xp, |
---|
| 41 | uint64_t data ) |
---|
| 42 | { |
---|
[72] | 43 | *(uint64_t *)xp = data; |
---|
[25] | 44 | } |
---|
| 45 | |
---|
| 46 | void hal_remote_spt( xptr_t xp, |
---|
| 47 | void * pt ) |
---|
| 48 | { |
---|
[92] | 49 | hal_remote_swd( xp , (uint64_t)pt ); |
---|
[25] | 50 | } |
---|
| 51 | |
---|
[72] | 52 | uint8_t hal_remote_lb( xptr_t xp ) |
---|
[25] | 53 | { |
---|
[72] | 54 | return *(uint8_t *)xp; |
---|
[25] | 55 | } |
---|
| 56 | |
---|
| 57 | uint32_t hal_remote_lw( xptr_t xp ) |
---|
| 58 | { |
---|
[72] | 59 | return *(uint32_t *)xp; |
---|
[25] | 60 | } |
---|
| 61 | |
---|
| 62 | uint64_t hal_remote_lwd( xptr_t xp ) |
---|
| 63 | { |
---|
[72] | 64 | return *(uint64_t *)xp; |
---|
[25] | 65 | } |
---|
| 66 | |
---|
[92] | 67 | void *hal_remote_lpt( xptr_t xp ) |
---|
[25] | 68 | { |
---|
[92] | 69 | return (void *)hal_remote_lwd( xp ); |
---|
[25] | 70 | } |
---|
| 71 | |
---|
| 72 | bool_t hal_remote_atomic_cas( xptr_t xp, |
---|
| 73 | uint32_t old, |
---|
| 74 | uint32_t new ) |
---|
| 75 | { |
---|
[96] | 76 | return (atomic_cas_32((volatile uint32_t *)xp, old, new) == old); |
---|
[25] | 77 | } |
---|
| 78 | |
---|
| 79 | uint32_t hal_remote_atomic_add( xptr_t xp, |
---|
[94] | 80 | uint32_t incr ) // XXX define as signed |
---|
[48] | 81 | { |
---|
[96] | 82 | return atomic_add_32((volatile uint32_t *)xp, incr); |
---|
[25] | 83 | } |
---|
| 84 | |
---|
| 85 | uint32_t hal_remote_atomic_and( xptr_t xp, |
---|
| 86 | uint32_t mask ) |
---|
[48] | 87 | { |
---|
[98] | 88 | return atomic_and_32((volatile uint32_t *)xp, mask); |
---|
[25] | 89 | } |
---|
| 90 | |
---|
| 91 | uint32_t hal_remote_atomic_or( xptr_t xp, |
---|
| 92 | uint32_t mask ) |
---|
[48] | 93 | { |
---|
[98] | 94 | return atomic_or_32((volatile uint32_t *)xp, mask); |
---|
[25] | 95 | } |
---|
| 96 | |
---|
| 97 | error_t hal_remote_atomic_try_add( xptr_t xp, |
---|
| 98 | uint32_t incr, |
---|
| 99 | uint32_t * old ) |
---|
| 100 | { |
---|
[48] | 101 | x86_panic((char *)__func__); |
---|
[25] | 102 | return 0; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | void hal_remote_memcpy( xptr_t dst, |
---|
| 106 | xptr_t src, |
---|
| 107 | uint32_t size ) |
---|
| 108 | { |
---|
[48] | 109 | x86_panic((char *)__func__); |
---|
[25] | 110 | } |
---|
| 111 | |
---|