Switchtec Userspace  PROJECT_NUMBER = PROJECT_NUMBER=PROJECT_NUMBER = 2.2
gas.h
Go to the documentation of this file.
1 /*
2  * Microsemi Switchtec(tm) PCIe Management Library
3  * Copyright (c) 2017, Microsemi Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  */
24 
25 #ifndef LIBSWITCHTEC_GAS_H
26 #define LIBSWITCHTEC_GAS_H
27 
54 #include <switchtec/switchtec.h>
55 
56 #ifdef SWITCHTEC_LIB_CORE
57 #error "You should not be using GAS access functions in the core library."
58 #endif
59 
60 #ifdef SWITCHTEC_LIB_LINUX
61 #error "GAS Access functions should not be used on the Linux platform " \
62  "as they require full root access."
63 #endif
64 
65 #include <stdint.h>
66 
67 void memcpy_to_gas(struct switchtec_dev *dev, void __gas *dest,
68  const void *src, size_t n);
69 
70 void memcpy_from_gas(struct switchtec_dev *dev, void *dest,
71  const void __gas *src, size_t n);
72 
73 ssize_t write_from_gas(struct switchtec_dev *dev, int fd,
74  const void __gas *src, size_t n);
75 
76 uint8_t gas_read8(struct switchtec_dev *dev, uint8_t __gas *addr);
77 uint16_t gas_read16(struct switchtec_dev *dev, uint16_t __gas *addr);
78 uint32_t gas_read32(struct switchtec_dev *dev, uint32_t __gas *addr);
79 uint64_t gas_read64(struct switchtec_dev *dev, uint64_t __gas *addr);
80 
81 void gas_write8(struct switchtec_dev *dev, uint8_t val, uint8_t __gas *addr);
82 void gas_write16(struct switchtec_dev *dev, uint16_t val,
83  uint16_t __gas *addr);
84 void gas_write32(struct switchtec_dev *dev, uint32_t val,
85  uint32_t __gas *addr);
86 void gas_write64(struct switchtec_dev *dev, uint64_t val,
87  uint64_t __gas *addr);
88 
91 #endif
uint32_t gas_read32(struct switchtec_dev *dev, uint32_t __gas *addr)
Read a uint32_t from the GAS.
Definition: platform.c:341
void gas_write32(struct switchtec_dev *dev, uint32_t val, uint32_t __gas *addr)
Write a uint32_t to the GAS.
Definition: platform.c:397
void gas_write8(struct switchtec_dev *dev, uint8_t val, uint8_t __gas *addr)
Write a uint8_t to the GAS.
Definition: platform.c:369
uint16_t gas_read16(struct switchtec_dev *dev, uint16_t __gas *addr)
Read a uint16_t from the GAS.
Definition: platform.c:327
uint64_t gas_read64(struct switchtec_dev *dev, uint64_t __gas *addr)
Read a uint64_t from the GAS.
Definition: platform.c:355
void memcpy_to_gas(struct switchtec_dev *dev, void __gas *dest, const void *src, size_t n)
Copy data to the GAS.
Definition: platform.c:426
Main Switchtec header.
uint8_t gas_read8(struct switchtec_dev *dev, uint8_t __gas *addr)
Read a uint8_t from the GAS.
Definition: platform.c:313
void gas_write16(struct switchtec_dev *dev, uint16_t val, uint16_t __gas *addr)
Write a uint16_t to the GAS.
Definition: platform.c:383
void gas_write64(struct switchtec_dev *dev, uint64_t val, uint64_t __gas *addr)
Write a uint64_t to the GAS.
Definition: platform.c:411
ssize_t write_from_gas(struct switchtec_dev *dev, int fd, const void __gas *src, size_t n)
Call write() with data from the GAS.
Definition: platform.c:458
void memcpy_from_gas(struct switchtec_dev *dev, void *dest, const void __gas *src, size_t n)
Copy data from the GAS.
Definition: platform.c:442