2018-12-21 18:58:41 +08:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* @brief Public APIs to get device Information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Alexander Wachter
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_INCLUDE_HWINFO_H_
|
|
|
|
#define ZEPHYR_INCLUDE_HWINFO_H_
|
|
|
|
|
|
|
|
#include <zephyr/types.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <errno.h>
|
drivers: hwinfo: fix build with NEWLIB_LIBC=y
When NEWLIB_LIBC=y, building the hwinfo drivers fails with:
In file included from ZEPHYR_ROOT/drivers/hwinfo/hwinfo_weak_impl.c:7:0:
ZEPHYR_ROOT/include/hwinfo.h:43:1: error: unknown type name '__syscall';
did you mean '__fastcall'?
__syscall ssize_t hwinfo_get_device_id(u8_t *buffer, size_t length);
^~~~~~~~~
__fastcall
ZEPHYR_ROOT/include/hwinfo.h:43:19: error: expected '=', ',', ';', 'asm'
or '__attribute__' before 'hwinfo_get_device_id'
__syscall ssize_t hwinfo_get_device_id(u8_t *buffer, size_t length);
^~~~~~~~~~~~~~~~~~~~
ZEPHYR_ROOT/drivers/hwinfo/hwinfo_weak_impl.c:9:16: error: expected '=',
',', ';', 'asm' or '__attribute__' before '_impl_hwinfo_get_device_id'
ssize_t __weak _impl_hwinfo_get_device_id(u8_t *buffer, size_t length)
^~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
The <hwinfo.h> file uses __syscall and this symbols is defined by
<kernel.h>. This doesn't happen with the real drivers as they include
<device.h> and thus <kernel.h>.
Fix that by including <kernel.h> from <hwinfo.h>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-02-10 21:20:58 +08:00
|
|
|
#include <kernel.h>
|
2018-12-21 18:58:41 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device ID
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Copy the device id to a buffer
|
|
|
|
*
|
|
|
|
* This routine copies "length" number of bytes of the device ID to the buffer.
|
|
|
|
* If the device ID is smaller then length, the rest of the buffer is left unchanged.
|
|
|
|
* The ID depends on the hardware and is not guaranteed unique.
|
|
|
|
*
|
|
|
|
* @param buffer Buffer to write the ID to.
|
|
|
|
* @param length Max length of the buffer.
|
|
|
|
*
|
|
|
|
* @retval size of the device ID copied or negative on error.
|
|
|
|
*/
|
|
|
|
__syscall ssize_t hwinfo_get_device_id(u8_t *buffer, size_t length);
|
|
|
|
|
|
|
|
ssize_t _impl_hwinfo_get_device_id(u8_t *buffer, size_t length);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <syscalls/hwinfo.h>
|
|
|
|
|
|
|
|
#endif /* ZEPHYR_INCLUDE_HWINFO_H_ */
|