Switchtec Userspace PROJECT_NUMBER = 3.1
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
67void memcpy_to_gas(struct switchtec_dev *dev, void __gas *dest,
68 const void *src, size_t n);
69__attribute__((warn_unused_result))
70int memcpy_from_gas(struct switchtec_dev *dev, void *dest,
71 const void __gas *src, size_t n);
72
73ssize_t write_from_gas(struct switchtec_dev *dev, int fd,
74 const void __gas *src, size_t n);
75
76__attribute__((warn_unused_result))
77int gas_read8(struct switchtec_dev *dev, uint8_t __gas *addr, uint8_t *val);
78__attribute__((warn_unused_result))
79int gas_read16(struct switchtec_dev *dev, uint16_t __gas *addr, uint16_t *val);
80__attribute__((warn_unused_result))
81int gas_read32(struct switchtec_dev *dev, uint32_t __gas *addr, uint32_t *val);
82__attribute__((warn_unused_result))
83int gas_read64(struct switchtec_dev *dev, uint64_t __gas *addr, uint64_t *val);
84
85void gas_write8(struct switchtec_dev *dev, uint8_t val, uint8_t __gas *addr);
86void gas_write16(struct switchtec_dev *dev, uint16_t val,
87 uint16_t __gas *addr);
88void gas_write32(struct switchtec_dev *dev, uint32_t val,
89 uint32_t __gas *addr);
90void gas_write64(struct switchtec_dev *dev, uint64_t val,
91 uint64_t __gas *addr);
92
95#endif
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:470
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:505
void gas_write16(struct switchtec_dev *dev, uint16_t val, uint16_t __gas *addr)
Write a uint16_t to the GAS.
Definition: platform.c:427
void gas_write64(struct switchtec_dev *dev, uint64_t val, uint64_t __gas *addr)
Write a uint64_t to the GAS.
Definition: platform.c:455
void gas_write32(struct switchtec_dev *dev, uint32_t val, uint32_t __gas *addr)
Write a uint32_t to the GAS.
Definition: platform.c:441
void gas_write8(struct switchtec_dev *dev, uint8_t val, uint8_t __gas *addr)
Write a uint8_t to the GAS.
Definition: platform.c:413
int gas_read32(struct switchtec_dev *dev, uint32_t __gas *addr, uint32_t *val)
Read a uint32_t from the GAS.
Definition: platform.c:380
int gas_read16(struct switchtec_dev *dev, uint16_t __gas *addr, uint16_t *val)
Read a uint16_t from the GAS.
Definition: platform.c:363
int memcpy_from_gas(struct switchtec_dev *dev, void *dest, const void __gas *src, size_t n)
Copy data from the GAS.
Definition: platform.c:487
int gas_read8(struct switchtec_dev *dev, uint8_t __gas *addr, uint8_t *val)
Read a uint8_t from the GAS.
Definition: platform.c:346
int gas_read64(struct switchtec_dev *dev, uint64_t __gas *addr, uint64_t *val)
Read a uint64_t from the GAS.
Definition: platform.c:397
Main Switchtec header.