Switchtec Userspace
PROJECT_NUMBER = PROJECT_NUMBER=PROJECT_NUMBER = 2.2
|
Functions to access the Global Address Space (GAS) More...
Functions | |
gasptr_t | switchtec_gas_map (struct switchtec_dev *dev, int writeable, size_t *map_size) |
Map the GAS and return a pointer to access the gas. More... | |
void | switchtec_gas_unmap (struct switchtec_dev *dev, gasptr_t map) |
Unmap the GAS region mapped with. More... | |
void | memcpy_to_gas (struct switchtec_dev *dev, void __gas *dest, const void *src, size_t n) |
Copy data to the GAS. More... | |
void | memcpy_from_gas (struct switchtec_dev *dev, void *dest, const void __gas *src, size_t n) |
Copy data from the GAS. More... | |
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. More... | |
uint8_t | gas_read8 (struct switchtec_dev *dev, uint8_t __gas *addr) |
Read a uint8_t from the GAS. More... | |
uint16_t | gas_read16 (struct switchtec_dev *dev, uint16_t __gas *addr) |
Read a uint16_t from the GAS. More... | |
uint32_t | gas_read32 (struct switchtec_dev *dev, uint32_t __gas *addr) |
Read a uint32_t from the GAS. More... | |
uint64_t | gas_read64 (struct switchtec_dev *dev, uint64_t __gas *addr) |
Read a uint64_t from the GAS. More... | |
void | gas_write8 (struct switchtec_dev *dev, uint8_t val, uint8_t __gas *addr) |
Write a uint8_t to the GAS. More... | |
void | gas_write16 (struct switchtec_dev *dev, uint16_t val, uint16_t __gas *addr) |
Write a uint16_t to the GAS. More... | |
void | gas_write32 (struct switchtec_dev *dev, uint32_t val, uint32_t __gas *addr) |
Write a uint32_t to the GAS. More... | |
void | gas_write64 (struct switchtec_dev *dev, uint64_t val, uint64_t __gas *addr) |
Write a uint64_t to the GAS. More... | |
Functions to access the Global Address Space (GAS)
switchtec_gas_map() and switchtec_gas_unmap() map and unmap the GAS into the processes address space. Once mapped, the various gas_read and gas_write functions may be used to access the addresspace.
Although on Linux and Windows, switchtec_gas_map() returns an addressable pointer, the data should not be accessed directly. Instead the accessor functions should be used. This will allow for support on systems that do not have direct access to the address space (ie. I2C or Ethernet).
Note: these functions should only be used in client code between calls of switchtec_gas_map() and switchtec_gas_unmap(). This implies the code will require full root priviliges in Linux. The functions may also be used in platform specific code on platforms that have full access to the GAS.
uint16_t gas_read16 | ( | struct switchtec_dev * | dev, |
uint16_t __gas * | addr | ||
) |
Read a uint16_t from the GAS.
[in] | dev | Switchtec device handle |
[in] | addr | Address to read the value |
Definition at line 327 of file platform.c.
uint32_t gas_read32 | ( | struct switchtec_dev * | dev, |
uint32_t __gas * | addr | ||
) |
Read a uint32_t from the GAS.
[in] | dev | Switchtec device handle |
[in] | addr | Address to read the value |
Definition at line 341 of file platform.c.
uint64_t gas_read64 | ( | struct switchtec_dev * | dev, |
uint64_t __gas * | addr | ||
) |
Read a uint64_t from the GAS.
[in] | dev | Switchtec device handle |
[in] | addr | Address to read the value |
Definition at line 355 of file platform.c.
uint8_t gas_read8 | ( | struct switchtec_dev * | dev, |
uint8_t __gas * | addr | ||
) |
Read a uint8_t from the GAS.
[in] | dev | Switchtec device handle |
[in] | addr | Address to read the value |
Definition at line 313 of file platform.c.
void gas_write16 | ( | struct switchtec_dev * | dev, |
uint16_t | val, | ||
uint16_t __gas * | addr | ||
) |
Write a uint16_t to the GAS.
[in] | dev | Switchtec device handle |
[in] | val | Value to write |
[out] | addr | Address to write the value |
Definition at line 383 of file platform.c.
void gas_write32 | ( | struct switchtec_dev * | dev, |
uint32_t | val, | ||
uint32_t __gas * | addr | ||
) |
Write a uint32_t to the GAS.
[in] | dev | Switchtec device handle |
[in] | val | Value to write |
[out] | addr | Address to write the value |
Definition at line 397 of file platform.c.
void gas_write64 | ( | struct switchtec_dev * | dev, |
uint64_t | val, | ||
uint64_t __gas * | addr | ||
) |
Write a uint64_t to the GAS.
[in] | dev | Switchtec device handle |
[in] | val | Value to write |
[out] | addr | Address to write the value |
Definition at line 411 of file platform.c.
void gas_write8 | ( | struct switchtec_dev * | dev, |
uint8_t | val, | ||
uint8_t __gas * | addr | ||
) |
Write a uint8_t to the GAS.
[in] | dev | Switchtec device handle |
[in] | val | Value to write |
[out] | addr | Address to write the value |
Definition at line 369 of file platform.c.
void memcpy_from_gas | ( | struct switchtec_dev * | dev, |
void * | dest, | ||
const void __gas * | src, | ||
size_t | n | ||
) |
Copy data from the GAS.
[in] | dev | Switchtec device handle |
[out] | dest | Destination buffer |
[in] | src | Source gas address |
[in] | n | Number of bytes to transfer |
Definition at line 442 of file platform.c.
void memcpy_to_gas | ( | struct switchtec_dev * | dev, |
void __gas * | dest, | ||
const void * | src, | ||
size_t | n | ||
) |
Copy data to the GAS.
[in] | dev | Switchtec device handle |
[out] | dest | Destination gas address |
[in] | src | Source data buffer |
[in] | n | Number of bytes to transfer |
Definition at line 426 of file platform.c.
gasptr_t switchtec_gas_map | ( | struct switchtec_dev * | dev, |
int | writeable, | ||
size_t * | map_size | ||
) |
Map the GAS and return a pointer to access the gas.
[in] | dev | Switchtec device handle |
[in] | writeable | Set to non-null to make the region writable |
[out] | map_size | Size of the mapped region |
This maps the hardware registers into user memory space. Needless to say, this can be very dangerous and should only be done if you know what you are doing. Any register accesses that use this will remain unsupported by Microsemi unless it's done within the switchtec user project or otherwise specified.
writeable
is only supported on the Linux platform. Other platforms will always be writeable.
The gasptr_t must only be accessed with the functions in gas.h.
The region should always be unmapped with switchtec_gas_unmap().
Definition at line 223 of file platform.c.
void switchtec_gas_unmap | ( | struct switchtec_dev * | dev, |
gasptr_t | map | ||
) |
Unmap the GAS region mapped with.
[in] | dev | Switchtec device handle |
[in] | map | The mapped region |
Definition at line 235 of file platform.c.
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.
[in] | dev | Switchtec device handle |
[in] | fd | Destination buffer |
[in] | src | Source gas address |
[in] | n | Number of bytes to transfer |
Definition at line 458 of file platform.c.