Skip to content

Commit 7405797

Browse files
Dan-Lightsourcecalvinatintel
authored andcommitted
Updates and fixes to Component Framework code for Arduino on ARC
- Sync'd CFW code with Thunderdome code base from 01-July-2015 - Fixed issue with mailbox interrupts halting CPU, caused by bug in scss_registers.h - Added CFW test service client to facilitate CFW sanity check (requires LMT build running Test service) Signed-off-by: Dan O'Donovan <[email protected]>
1 parent cdc73f8 commit 7405797

39 files changed

+1332
-397
lines changed

cores/arduino/wiring_constants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ extern "C"{
3030
#define OUTPUT 0x1
3131
#define INPUT_PULLUP 0x2
3232

33+
#ifndef true
3334
#define true 0x1
35+
#endif
36+
#ifndef false
3437
#define false 0x0
38+
#endif
3539

3640
#define PI 3.1415926535897932384626433832795
3741
#define HALF_PI 1.5707963267948966192313216916398

system/libarc32_edu/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ HWFLAGS=-mARCv2EM -mav2em -mlittle-endian
2424

2525
CFGFLAGS=-DCONFIG_SOC_GPIO_32 -DINFRA_MULTI_CPU_SUPPORT -DCFW_MULTI_CPU_SUPPORT -DHAS_SHARED_MEM
2626
OPTFLAGS=-g -Os -Wall -Werror
27+
#CFGFLAGS+=-DCONFIG_CFW_SERVICES_TEST
2728
INCLUDES=-Icommon -Ibootcode -Iframework/include
2829
EXTRA_CFLAGS=-D__CPU_ARC__ -DCLOCK_SPEED=32 -fno-reorder-functions -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-defer-pop -Wno-unused-but-set-variable -Wno-main -ffreestanding -fno-stack-protector -mno-sdata -ffunction-sections -fdata-sections
2930
CFLAGS=$(HWFLAGS) $(OPTFLAGS) $(EXTRA_CFLAGS) $(CFGFLAGS) $(INCLUDES)

system/libarc32_edu/bootcode/init.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919
#include "aux_regs.h"
2020

21+
.globl _do_fault
22+
.type _do_fault,%function
23+
2124
.globl _do_isr
2225
.type _do_isr,%function
2326

system/libarc32_edu/common/scss_registers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
#define SCSS_INT_MAILBOX_START_CHANNEL 0x00
367367
#elif defined(__CPU_ARC__)
368368
/* Second byte is for ARC */
369-
#define SCSS_INT_MAILBOX_START_CHANNEL 0x10
369+
#define SCSS_INT_MAILBOX_START_CHANNEL 0x8
370370
#endif
371371

372372
#define SOC_MBX_INT_UNMASK(channel) SCSS_REG_VAL(SCSS_INT_MAILBOX_MASK) &= \

system/libarc32_edu/framework/include/cfw/cfw.h

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
#ifndef _CFW_H_
2+
#define _CFW_H_
3+
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
7+
#include "os/os.h"
8+
#include "util/list.h"
9+
#include "infra/port.h"
10+
#include "infra/message.h"
11+
112
/**
2-
* \defgroup cfw CFW: Component Framework
3-
* \brief The component framework is the main building block for a custom application.
13+
* @defgroup cfw CFW: Component Framework
14+
* The Component Framework is the main building block for custom applications.
415
*
516
* It consists of:
617
* - Service APIs
@@ -12,20 +23,10 @@
1223
* order to be interfaced with it.
1324
* It could have other threads for its specific need and would have to manage
1425
* communication with the framework thread for interface with the rest of the platform.
26+
*
1527
* @{
1628
*/
1729

18-
#ifndef _CFW_H_
19-
#define _CFW_H_
20-
21-
#include <stdio.h>
22-
#include <stdlib.h>
23-
24-
#include "os/os.h"
25-
#include "util/list.h"
26-
#include "infra/port.h"
27-
#include "infra/message.h"
28-
2930
struct cfw_message {
3031
struct message m;
3132

@@ -74,6 +75,8 @@ typedef void * cfw_handle_t;
7475
typedef struct svc_client_handle_ {
7576
/** Port to attain the service. */
7677
uint16_t port;
78+
/** Service id */
79+
int service_id;
7780
/** Framework handle. */
7881
cfw_handle_t cfw_handle;
7982
/** Pointer to store the server-side connection handle.
@@ -82,28 +85,6 @@ typedef struct svc_client_handle_ {
8285
void * server_handle;
8386
} svc_client_handle_t;
8487

85-
/**
86-
* Services id definitions
87-
*
88-
* Keep them numbered manually to avoid shifting on
89-
* removal/addition of services
90-
*/
91-
enum {
92-
FRAMEWORK_SERVICE_ID = 1,
93-
TEST2_SERVICE_ID = 2,
94-
TEST_SERVICE_ID = 3,
95-
BLE_SERVICE_ID = 4,
96-
BLE_CORE_SERVICE_ID = 5,
97-
};
98-
99-
/**
100-
* Logging macro.
101-
*/
102-
/*
103-
* Function Prototypes
104-
*
105-
*/
106-
void cfw_log(char * fmt, ...);
10788

10889
/**
10990
* \brief Allocate a memory buffer
@@ -176,27 +157,6 @@ int _find_service(int);
176157
*/
177158
int _cfw_get_service_port(int);
178159

179-
180-
/*
181-
* Multi cpu APIs.
182-
*/
183-
184-
/**
185-
* \brief set the callback to be used to send a message to the given cpu.
186-
*
187-
* \param cpu_id the cpu id for which we want to set the handler.
188-
* \param handler the callback used to send a message to this cpu.
189-
*/
190-
void set_cpu_message_sender(int cpu_id, int (*handler)(struct cfw_message * msg));
191-
192-
/**
193-
* \brief set the callback to be used to request free a message to a cpu.
194-
*
195-
* \param cpu_id the cpu id for which we want to set the handler.
196-
* \param handler the callback used to request message free on.
197-
*/
198-
void set_cpu_free_handler(int cpu_id, void (*free_handler)(void *));
160+
/** @} */
199161

200162
#endif /* #ifndef _CFW_H_ */
201-
202-
/**@}*/

system/libarc32_edu/framework/include/cfw/cfw_client.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
/**
2-
* \addtogroup cfw
3-
* @{
4-
* \defgroup cfw_client CFW Client API
5-
* @{
6-
* \brief Definition of the structure and functions needed by CFW clients, i.e.
7-
* for users of services.
8-
*/
9-
101
#ifndef __CFW_CLIENT_H__
112
#define __CFW_CLIENT_H__
3+
124
#include "cfw/cfw.h"
135

6+
/**
7+
* @defgroup cfw_client CFW Client API
8+
* CFW Client API, i.e for users of services.
9+
* @ingroup cfw
10+
* @{
11+
*/
12+
1413
/**
1514
* Create a handle to the component framework.
1615
* This handle is to be used for all other requests
@@ -84,9 +83,8 @@ int cfw_register_events(svc_client_handle_t * handle, int * msg_ids, int size, v
8483
* \param handle the framework handle.
8584
* \param param the private param sent back with the response message.
8685
*/
87-
int cfw_register_svc_available(cfw_handle_t handle, void *param);
86+
int cfw_register_svc_available(cfw_handle_t handle, int service_id, void *param);
8887

89-
#endif
90-
91-
/**@} @}*/
88+
/** @} */
9289

90+
#endif

system/libarc32_edu/framework/include/cfw/cfw_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct {
2424
*
2525
* \return the value to be passed as response to the requestor
2626
*/
27-
int handle_ipc_sync_request(int cpu_id, int request, int param1,
27+
int handle_ipc_sync_request(uint8_t cpu_id, int request, int param1,
2828
int param2, void * ptr);
2929

3030
#endif /* __CFW_INTERNAL_H__ */

system/libarc32_edu/framework/include/cfw/cfw_messages.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ typedef struct {
2828
int service_id;
2929
/** client side service handle */
3030
void *client_handle;
31+
/** client side cpu id, required for remote node services */
32+
uint8_t client_cpu_id;
3133
} cfw_open_conn_req_msg_t;
3234

3335
/**
@@ -40,7 +42,7 @@ typedef struct {
4042
/** port to attain this service */
4143
uint16_t port;
4244
/** cpu_id of service */
43-
int cpu_id;
45+
uint8_t cpu_id;
4446
/** service handle for accessing the service */
4547
void * svc_server_handle;
4648
/** client side service handle as passed in
@@ -55,6 +57,8 @@ typedef struct {
5557
typedef struct {
5658
/** common message header */
5759
struct cfw_message header;
60+
/** service id to close */
61+
int service_id;
5862
/** service to open connection to */
5963
void * inst;
6064
} cfw_close_conn_req_msg_t;
@@ -84,6 +88,11 @@ typedef struct {
8488
} cfw_register_evt_rsp_msg_t;
8589

8690

91+
typedef struct {
92+
struct cfw_message header;
93+
int service_id;
94+
} cfw_register_svc_avail_req_msg_t;
95+
8796
typedef struct {
8897
/** common response message header */
8998
struct cfw_rsp_message rsp_header;
@@ -99,4 +108,6 @@ typedef struct {
99108
/** Service id of the newly available service. */
100109
int service_id;
101110
} cfw_svc_available_evt_msg_t;
111+
112+
102113
#endif /* __CFW_MESSAGE_H__ */

system/libarc32_edu/framework/include/cfw/cfw_service.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
/**
2-
* \addtogroup cfw
3-
* @{
4-
* \defgroup cfw_service CFW Service API
5-
* @{
6-
* \brief Definition of the structure and functions used by CFW services implementation.
7-
*/
8-
91
#ifndef __CFW_SERVICE_H_
102
#define __CFW_SERVICE_H_
3+
114
#include "os/os.h"
125
#include "cfw/cfw.h"
136
#include "cfw/cfw_internal.h"
@@ -17,6 +10,13 @@
1710
struct service;
1811
struct _port;
1912

13+
/**
14+
* @defgroup cfw_service CFW Service API
15+
* @brief CFW Service API.
16+
* @ingroup cfw
17+
* @{
18+
*/
19+
2020
/**
2121
* \struct conn_handle_t
2222
*
@@ -56,14 +56,17 @@ typedef struct service {
5656
void (*registered_events_changed)(conn_handle_t *);
5757
} service_t;
5858

59-
int _cfw_register_service(service_t * svc);
60-
int _cfw_deregister_service(cfw_handle_t handle, service_t * svc);
6159
#ifdef CFW_MULTI_CPU_SUPPORT
6260
void _cfw_init_proxy(T_QUEUE queue, void * p, service_t**s, uint16_t svc_mgr_port);
6361
#endif
6462
service_t * cfw_get_service(int service_id);
6563

66-
64+
/**
65+
* Gets the service manager port id.
66+
*
67+
* \return service manager port id
68+
*/
69+
uint16_t cfw_get_service_mgr_port_id(void);
6770

6871
/**
6972
* Allocate and build a response message for a specific request.
@@ -135,6 +138,6 @@ int cfw_unregister_service(service_t * service);
135138
*/
136139
void cfw_send_event(struct cfw_message * msg);
137140

138-
#endif /* __CFW_SERVICE_H_ */
141+
/** @} */
139142

140-
/**@} @}*/
143+
#endif /* __CFW_SERVICE_H_ */

system/libarc32_edu/framework/include/infra/ipc.h

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** INTEL CONFIDENTIAL Copyright 2014 Intel Corporation All Rights Reserved.
1+
/* INTEL CONFIDENTIAL Copyright 2014 Intel Corporation All Rights Reserved.
22
*
33
* The source code contained or described herein and all documents related to
44
* the source code ("Material") are owned by Intel Corporation or its suppliers
@@ -25,6 +25,7 @@
2525
#define __IPC_H__
2626

2727
#include "infra/ipc_requests.h"
28+
#include "infra/message.h"
2829

2930
/**
3031
* \brief initialize ipc component.
@@ -36,7 +37,7 @@
3637
* \param remote_cpu_id the remote cpu id of this IPC
3738
*/
3839
void ipc_init(int tx_channel, int rx_channel, int tx_ack_channel,
39-
int rx_ack_channel, int remote_cpu_id);
40+
int rx_ack_channel, uint8_t remote_cpu_id);
4041

4142
/**
4243
* \brief request a synchronous ipc call.
@@ -73,7 +74,34 @@ void ipc_handle_message();
7374
*
7475
* \return 0 if success, -1 otherwise
7576
*/
76-
int ipc_sync_callback(int cpu_id, int request, int param1, int param2,
77+
int ipc_sync_callback(uint8_t cpu_id, int request, int param1, int param2,
7778
void *ptr);
7879

80+
/**
81+
* \brief Called by port implementation when a message has to be sent to a
82+
* CPU connected through the mailbox ipc mechanism.
83+
*
84+
* \param message the message to send to the other end
85+
*/
86+
int ipc_async_send_message(struct message *message);
87+
/**
88+
* \brief Called by port implementation when a message that comes from a
89+
* different CPU than ours has to be freed.
90+
*
91+
* \param message the message to be freed.
92+
*/
93+
void ipc_async_free_message(struct message *message);
94+
95+
/**
96+
* \brief initialize the async message sender / freeing mechanism for remote
97+
* message sending and freeing.
98+
*
99+
* Async message sender / freeing is needed as message can be sent / freed in
100+
* the context of interrupts. And in interrupt context, the ipc requests sync
101+
* cannot be called.
102+
*
103+
* \param queue the queue on which context the ipc requests have to be called.
104+
*/
105+
void ipc_async_init(T_QUEUE queue);
106+
79107
#endif

system/libarc32_edu/framework/include/infra/ipc_requests.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@
99
#define IPC_REQUEST_REGISTER_SERVICE 0x11
1010
#define IPC_REQUEST_DEREGISTER_SERVICE 0x12
1111
#define IPC_REQUEST_REG_TCMD_ENGINE 0x13
12+
#define IPC_REQUEST_REGISTER_PROXY 0x14
13+
#define IPC_PANIC_NOTIFICATION 0x15
14+
#define IPC_REQUEST_POWER_MANAGEMENT 0x16
15+
#define IPC_REQUEST_LOGGER 0x17
1216

1317
#endif

0 commit comments

Comments
 (0)