diff --git a/include/ap.h b/include/ap.h index df1485cd94a7e04c69a401a97e7bb45f2cde42d1..adaf1bde40d868107a6fa42815b2da1588951eaa 100644 --- a/include/ap.h +++ b/include/ap.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _AP_H_ @@ -17,7 +16,7 @@ * * @return AP Interface */ -struct gb_interface *ap_init(); +struct gb_interface *ap_init(void); /* * Submit message received by AP from transport @@ -26,13 +25,13 @@ struct gb_interface *ap_init(); * * @return 0 if successfull, negative in case of error */ -int ap_rx_submit(struct gb_message *); +int ap_rx_submit(struct gb_message *msg); /* * Get AP Interface * * @return AP Interface */ -struct gb_interface *ap_interface(); +struct gb_interface *ap_interface(void); #endif diff --git a/include/greybus_protocol.h b/include/greybus_protocol.h index 0c6dfe8dad6412fb54e165be3eb48c4f3c618487..7dde8201d3fadace27f18965da8bbc622a2e94d6 100644 --- a/include/greybus_protocol.h +++ b/include/greybus_protocol.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ /* * Copyright(c) 2014 - 2015 Google Inc. All rights reserved. * Copyright(c) 2014 - 2015 Linaro Ltd. All rights reserved. * - * SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) - * * Modifications Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> */ @@ -21,49 +20,49 @@ /* Greybus SVC request types */ #define GB_SVC_TYPE_PROTOCOL_VERSION_REQUEST 0x01 -#define GB_SVC_TYPE_PROTOCOL_VERSION_RESPONSE OP_RESPONSE | GB_SVC_TYPE_PROTOCOL_VERSION_REQUEST +#define GB_SVC_TYPE_PROTOCOL_VERSION_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_PROTOCOL_VERSION_REQUEST) #define GB_SVC_TYPE_HELLO_REQUEST 0x02 -#define GB_SVC_TYPE_HELLO_RESPONSE OP_RESPONSE | GB_SVC_TYPE_HELLO_REQUEST +#define GB_SVC_TYPE_HELLO_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_HELLO_REQUEST) #define GB_SVC_TYPE_INTF_DEVICE_ID_REQUEST 0x03 -#define GB_SVC_TYPE_INTF_DEVICE_ID_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_DEVICE_ID_REQUEST +#define GB_SVC_TYPE_INTF_DEVICE_ID_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_DEVICE_ID_REQUEST) #define GB_SVC_TYPE_CONN_CREATE_REQUEST 0x07 -#define GB_SVC_TYPE_CONN_CREATE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_CONN_CREATE_REQUEST +#define GB_SVC_TYPE_CONN_CREATE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_CONN_CREATE_REQUEST) #define GB_SVC_TYPE_CONN_DESTROY_REQUEST 0x08 -#define GB_SVC_TYPE_CONN_DESTROY_RESPONSE OP_RESPONSE | GB_SVC_TYPE_CONN_DESTROY_REQUEST +#define GB_SVC_TYPE_CONN_DESTROY_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_CONN_DESTROY_REQUEST) #define GB_SVC_TYPE_DME_PEER_GET_REQUEST 0x09 -#define GB_SVC_TYPE_DME_PEER_GET_RESPONSE OP_RESPONSE | GB_SVC_TYPE_DME_PEER_GET_REQUEST +#define GB_SVC_TYPE_DME_PEER_GET_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_DME_PEER_GET_REQUEST) #define GB_SVC_TYPE_DME_PEER_SET_REQUEST 0x0a -#define GB_SVC_TYPE_DME_PEER_SET_RESPONSE OP_RESPONSE | GB_SVC_TYPE_DME_PEER_SET_REQUEST +#define GB_SVC_TYPE_DME_PEER_SET_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_DME_PEER_SET_REQUEST) #define GB_SVC_TYPE_ROUTE_CREATE_REQUEST 0x0b -#define GB_SVC_TYPE_ROUTE_CREATE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_ROUTE_CREATE_REQUEST +#define GB_SVC_TYPE_ROUTE_CREATE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_ROUTE_CREATE_REQUEST) #define GB_SVC_TYPE_ROUTE_DESTROY_REQUEST 0x0c -#define GB_SVC_TYPE_ROUTE_DESTROY_RESPONSE OP_RESPONSE | GB_SVC_TYPE_ROUTE_DESTROY_REQUEST +#define GB_SVC_TYPE_ROUTE_DESTROY_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_ROUTE_DESTROY_REQUEST) #define GB_SVC_TYPE_INTF_SET_PWRM_REQUEST 0x10 -#define GB_SVC_TYPE_INTF_SET_PWRM_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_SET_PWRM_REQUEST +#define GB_SVC_TYPE_INTF_SET_PWRM_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_SET_PWRM_REQUEST) #define GB_SVC_TYPE_PING_REQUEST 0x13 -#define GB_SVC_TYPE_PING_RESPONSE OP_RESPONSE | GB_SVC_TYPE_PING_REQUEST +#define GB_SVC_TYPE_PING_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_PING_REQUEST) #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET_REQUEST 0x14 #define GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET_RESPONSE \ - OP_RESPONSE | GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET_REQUEST + (OP_RESPONSE | GB_SVC_TYPE_PWRMON_RAIL_COUNT_GET_REQUEST) #define GB_SVC_TYPE_MODULE_INSERTED_REQUEST 0x1f -#define GB_SVC_TYPE_MODULE_INSERTED_RESPONSE OP_RESPONSE | GB_SVC_TYPE_MODULE_INSERTED_REQUEST +#define GB_SVC_TYPE_MODULE_INSERTED_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_MODULE_INSERTED_REQUEST) #define GB_SVC_TYPE_INTF_VSYS_ENABLE_REQUEST 0x21 -#define GB_SVC_TYPE_INTF_VSYS_ENABLE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_ENABLE_REQUEST +#define GB_SVC_TYPE_INTF_VSYS_ENABLE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_ENABLE_REQUEST) #define GB_SVC_TYPE_INTF_VSYS_DISABLE_REQUEST 0x22 -#define GB_SVC_TYPE_INTF_VSYS_DISABLE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_DISABLE_REQUEST +#define GB_SVC_TYPE_INTF_VSYS_DISABLE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_DISABLE_REQUEST) #define GB_SVC_TYPE_INTF_REFCLK_ENABLE_REQUEST 0x23 -#define GB_SVC_TYPE_INTF_REFCLK_ENABLE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_REFCLK_ENABLE_REQUEST +#define GB_SVC_TYPE_INTF_REFCLK_ENABLE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_REFCLK_ENABLE_REQUEST) #define GB_SVC_TYPE_INTF_REFCLK_DISABLE_REQUEST 0x24 -#define GB_SVC_TYPE_INTF_REFCLK_DISABLE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_DISABLE_REQUEST +#define GB_SVC_TYPE_INTF_REFCLK_DISABLE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_VSYS_DISABLE_REQUEST) #define GB_SVC_TYPE_INTF_UNIPRO_ENABLE_REQUEST 0x25 -#define GB_SVC_TYPE_INTF_UNIPRO_ENABLE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_UNIPRO_ENABLE_REQUEST +#define GB_SVC_TYPE_INTF_UNIPRO_ENABLE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_UNIPRO_ENABLE_REQUEST) #define GB_SVC_TYPE_INTF_UNIPRO_DISABLE_REQUEST 0x26 #define GB_SVC_TYPE_INTF_UNIPRO_DISABLE_RESPONSE \ - OP_RESPONSE | GB_SVC_TYPE_INTF_UNIPRO_DISABLE_REQUEST + (OP_RESPONSE | GB_SVC_TYPE_INTF_UNIPRO_DISABLE_REQUEST) #define GB_SVC_TYPE_INTF_ACTIVATE_REQUEST 0x27 -#define GB_SVC_TYPE_INTF_ACTIVATE_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_ACTIVATE_REQUEST +#define GB_SVC_TYPE_INTF_ACTIVATE_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_ACTIVATE_REQUEST) #define GB_SVC_TYPE_INTF_RESUME_REQUEST 0x28 -#define GB_SVC_TYPE_INTF_RESUME_RESPONSE OP_RESPONSE | GB_SVC_TYPE_INTF_RESUME_REQUEST +#define GB_SVC_TYPE_INTF_RESUME_RESPONSE (OP_RESPONSE | GB_SVC_TYPE_INTF_RESUME_REQUEST) #define GB_SVC_UNIPRO_HIBERNATE_MODE 0x11 diff --git a/include/hdlc.h b/include/hdlc.h index 033ecb14cec3d8ac8c8493e3effb4d0345dbdb73..81164a24615570b79d3400158fe4ac896d47722f 100644 --- a/include/hdlc.h +++ b/include/hdlc.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _HDLC_H_ @@ -43,7 +42,7 @@ struct hdlc_block { * * @return 0 if successful. Negative in case of error. */ -int hdlc_init(hdlc_process_frame_callback); +int hdlc_init(hdlc_process_frame_callback cb); /* * Submit an HDLC Block syncronously @@ -55,7 +54,8 @@ int hdlc_init(hdlc_process_frame_callback); * * @return block size (> 0) if successful. Negative in case of error */ -int hdlc_block_send_sync(const uint8_t *, size_t, uint8_t, uint8_t); +int hdlc_block_send_sync(const uint8_t *buffer, size_t buffer_len, uint8_t address, + uint8_t control); /* * Get a buffer to write HDLC message recieved for processing. Make HDLC transport agnostic. @@ -64,7 +64,7 @@ int hdlc_block_send_sync(const uint8_t *, size_t, uint8_t, uint8_t); * * @return number of bytes that can be written */ -uint32_t hdlc_rx_start(uint8_t **); +uint32_t hdlc_rx_start(uint8_t **buffer); /* * Finish writing to rx buffer. Also queues rx buffer for processing @@ -73,6 +73,6 @@ uint32_t hdlc_rx_start(uint8_t **); * * @return 0 if successful. Negative in case of error. */ -int hdlc_rx_finish(uint32_t); +int hdlc_rx_finish(uint32_t written); #endif diff --git a/include/mcumgr.h b/include/mcumgr.h index ed792c394caf624973f4a3aca31e66825cd484f5..0dff45ee68af57a6ac7dc7df39c5d2713220f6ca 100644 --- a/include/mcumgr.h +++ b/include/mcumgr.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _MCUMGR_H_ @@ -11,16 +10,16 @@ #include <zephyr/toolchain.h> #ifdef CONFIG_BEAGLEPLAY_GREYBUS_MCUMGR -int mcumgr_init(); +int mcumgr_init(void); #else -static int mcumgr_init() +static int mcumgr_init(void) { return 0; } #endif #ifdef CONFIG_BEAGLEPLAY_GREYBUS_MCUMGR -int mcumgr_process_frame(const void *, size_t); +int mcumgr_process_frame(const void *buffer, size_t buffer_len); #else static int mcumgr_process_frame(const void *buffer, size_t buffer_len) { diff --git a/include/node.h b/include/node.h index b8ee70f95b08198f1261f9316e75482b65999c6c..116a4588b5d228118226ab752b9e737ba0694796 100644 --- a/include/node.h +++ b/include/node.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _NODE_H_ @@ -16,14 +15,14 @@ * * @param address to search for */ -struct gb_interface *node_find_by_addr(struct in6_addr *); +struct gb_interface *node_find_by_addr(struct in6_addr *addr); /* * Destroy a tcp greybus inteface * * @return greybus interface */ -void node_destroy_interface(struct gb_interface *); +void node_destroy_interface(struct gb_interface *intf); /* * Create a new tcp greybus node interface @@ -32,7 +31,7 @@ void node_destroy_interface(struct gb_interface *); * * @return allocated greybus interface */ -struct gb_interface *node_create_interface(struct in6_addr *); +struct gb_interface *node_create_interface(struct in6_addr *addr); /* * Find greybus node by interface ID @@ -41,6 +40,6 @@ struct gb_interface *node_create_interface(struct in6_addr *); * * @return greybus interface */ -struct gb_interface *node_find_by_id(uint8_t); +struct gb_interface *node_find_by_id(uint8_t intf_id); #endif diff --git a/include/operations.h b/include/operations.h index 5bdedbfd33107cf531f1853b012bb0c68458720a..8b1b35cfa4404cb686b00123e8bb5218e1eadffb 100644 --- a/include/operations.h +++ b/include/operations.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _OPERATIONS_H_ @@ -176,7 +175,7 @@ static inline bool gb_message_is_success(const struct gb_message *msg) * * TODO: Move to hdlc */ -int gb_message_hdlc_send(const struct gb_message *); +int gb_message_hdlc_send(const struct gb_message *msg); /* * Create a greybus connection between two interfaces @@ -188,8 +187,8 @@ int gb_message_hdlc_send(const struct gb_message *); * * @return greybus connection allocated on heap. Null in case of errro */ -struct gb_connection *gb_create_connection(struct gb_interface *, struct gb_interface *, uint16_t, - uint16_t); +struct gb_connection *gb_create_connection(struct gb_interface *intf1, struct gb_interface *intf2, + uint16_t intf1_cport_id, uint16_t intf2_cport_id); /* * Destroy greybus connection @@ -201,7 +200,8 @@ struct gb_connection *gb_create_connection(struct gb_interface *, struct gb_inte * * @return 0 on success. Negative in case of error */ -int gb_destroy_connection(struct gb_interface *, struct gb_interface *, uint16_t, uint16_t); +int gb_destroy_connection(struct gb_interface *intf1, struct gb_interface *intf2, + uint16_t intf1_cport_id, uint16_t intf2_cport_id); /* * Allocate a greybus request message @@ -213,26 +213,30 @@ int gb_destroy_connection(struct gb_interface *, struct gb_interface *, uint16_t * * @return greybus message allocated on heap. Null in case of errro */ -struct gb_message *gb_message_request_alloc(const void *, size_t, uint8_t, bool); +struct gb_message *gb_message_request_alloc(const void *payload, size_t payload_len, + uint8_t request_type, bool is_oneshot); /* * Allocate a greybus response message * * @param Payload * @param Payload len - * @param Request Type + * @param Response Type * @param Operation ID + * @param Status * * @return greybus message allocated on heap. Null in case of errro */ -struct gb_message *gb_message_response_alloc(const void *, size_t, uint8_t, uint16_t, uint8_t); +struct gb_message *gb_message_response_alloc(const void *payload, size_t payload_len, + uint8_t response_type, uint16_t operation_id, + uint8_t status); /* * Deallocate a greybus message. * * @param pointer to the message to deallcate */ -void gb_message_dealloc(struct gb_message *); +void gb_message_dealloc(struct gb_message *msg); /* * Allocate a greybus interface @@ -241,20 +245,22 @@ void gb_message_dealloc(struct gb_message *); * @param write callback * @param create connection callback * @param destroy connection callback + * @param controller data * * @return allocated greybus interface. NULL in case of error */ -struct gb_interface *gb_interface_alloc(gb_controller_read_callback_t, - gb_controller_write_callback_t, - gb_controller_create_connection_t, - gb_controller_destroy_connection_t, void *); +struct gb_interface *gb_interface_alloc(gb_controller_read_callback_t read_cb, + gb_controller_write_callback_t write_cb, + gb_controller_create_connection_t create_connection_cb, + gb_controller_destroy_connection_t destroy_connection_cb, + void *ctrl_data); /* * Deallocate a greybus interface * * @param greybus interface */ -void gb_interface_dealloc(struct gb_interface *); +void gb_interface_dealloc(struct gb_interface *intf); /* * Get interface associated with interface id. @@ -263,13 +269,13 @@ void gb_interface_dealloc(struct gb_interface *); * * @param greybus interface */ -struct gb_interface *find_interface_by_id(uint8_t); +struct gb_interface *find_interface_by_id(uint8_t intf_id); /* * Execute a function on all active connections * * @param input function to run on the connection */ -void gb_connections_process_all(gb_connection_callback); +void gb_connections_process_all(gb_connection_callback cb); #endif diff --git a/include/svc.h b/include/svc.h index 004ae603c398af2a22c15f70661f08743f13f0a9..531509d56fab226aa80140fe9ba938e95eb6bbb8 100644 --- a/include/svc.h +++ b/include/svc.h @@ -1,7 +1,6 @@ +/* SPDX-License-Identifier: Apache-2.0 */ /* * Copyright (c) 2023 Ayush Singh <ayushdevel1325@gmail.com> - * - * SPDX-License-Identifier: Apache-2.0 */ #ifndef _SVC_H_ @@ -15,20 +14,20 @@ * Initialize SVC Interface. Should be called before sending any greybus * request. */ -struct gb_interface *svc_init(); +struct gb_interface *svc_init(void); /* * Check if SVC is ready. This mostly means if SVC Hello was successfuly * executed. */ -bool svc_is_ready(); +bool svc_is_ready(void); /* * Create SVC_TYPE_VERSION greybus message and queue it for sending. * * @return 0 if successful, else error. */ -int svc_send_version(); +int svc_send_version(void); /* * Send the SVC module inserted event. @@ -37,13 +36,13 @@ int svc_send_version(); * * @return 0 if successfuly, negative in case of error */ -int svc_send_module_inserted(uint8_t); +int svc_send_module_inserted(uint8_t intf_id); /* * Get the SVC interface * * @return pointer to svc interface */ -struct gb_interface *svc_interface(); +struct gb_interface *svc_interface(void); #endif