Commit 2367df8d authored by Anas Nashif's avatar Anas Nashif Committed by Anas Nashif
Browse files

drivers: update ipm driver to use unified kernel


Move away from legacy APIs and use unified kenrel instead.

Change-Id: Icae86beec66df1b041405cbe3455913630fc8ad1
Signed-off-by: default avatarAnas Nashif <anas.nashif@intel.com>
parent 55273b0c
Showing with 20 additions and 20 deletions
+20 -20
......@@ -51,12 +51,12 @@ QUARK_SE_IPM_DEFINE(quark_se_ipm4, 4, QUARK_SE_IPM_INBOUND);
#define QUARK_SE_IPM_CONSOLE_LINE_BUF_SIZE 80
static uint32_t ipm_console_ring_buf_data[CONFIG_QUARK_SE_IPM_CONSOLE_RING_BUF_SIZE32];
static char __stack ipm_console_fiber_stack[IPM_CONSOLE_STACK_SIZE];
static char __stack ipm_console_thread_stack[IPM_CONSOLE_STACK_SIZE];
static char ipm_console_line_buf[QUARK_SE_IPM_CONSOLE_LINE_BUF_SIZE];
static struct ipm_console_receiver_config_info quark_se_ipm_receiver_config = {
.bind_to = "quark_se_ipm4",
.fiber_stack = ipm_console_fiber_stack,
.thread_stack = ipm_console_thread_stack,
.ring_buf_data = ipm_console_ring_buf_data,
.rb_size32 = CONFIG_QUARK_SE_IPM_CONSOLE_RING_BUF_SIZE32,
.line_buf = ipm_console_line_buf,
......
......@@ -18,7 +18,7 @@
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <misc/ring_buffer.h>
#include <misc/printk.h>
#include <stdio.h>
......@@ -26,7 +26,7 @@
#include <console/ipm_console.h>
#include <misc/__assert.h>
static void ipm_console_fiber(int arg1, int arg2)
static void ipm_console_thread(void *arg1, void *arg2, void *arg3)
{
uint8_t size32;
uint16_t type;
......@@ -44,7 +44,7 @@ static void ipm_console_fiber(int arg1, int arg2)
pos = 0;
while (1) {
nano_fiber_sem_take(&driver_data->sem, TICKS_UNLIMITED);
k_sem_take(&driver_data->sem, TICKS_UNLIMITED);
ret = sys_ring_buf_get(&driver_data->rb, &type,
(uint8_t *)&config_info->line_buf[pos],
......@@ -108,10 +108,10 @@ static void ipm_console_receive_callback(void *context, uint32_t id,
/* Should always be at least one free buffer slot */
ret = sys_ring_buf_put(&driver_data->rb, 0, id, NULL, 0);
__ASSERT(ret == 0, "Failed to insert data into ring buffer");
nano_isr_sem_give(&driver_data->sem);
k_sem_give(&driver_data->sem);
/* If the buffer is now full, disable future interrupts for this channel
* until the fiber has a chance to consume characters.
* until the thread has a chance to consume characters.
*
* This works without losing data if the sending side tries to send
* more characters because the sending side is making an ipm_send()
......@@ -148,15 +148,15 @@ int ipm_console_receiver_init(struct device *d)
driver_data->ipm_device = ipm;
driver_data->channel_disabled = 0;
nano_sem_init(&driver_data->sem);
k_sem_init(&driver_data->sem, 0, UINT_MAX);
sys_ring_buf_init(&driver_data->rb, config_info->rb_size32,
config_info->ring_buf_data);
ipm_register_callback(ipm, ipm_console_receive_callback, d);
task_fiber_start(config_info->fiber_stack, IPM_CONSOLE_STACK_SIZE,
ipm_console_fiber, (int)d, 0,
IPM_CONSOLE_PRI, 0);
k_thread_spawn(config_info->thread_stack, IPM_CONSOLE_STACK_SIZE,
ipm_console_thread, d, NULL, NULL,
K_PRIO_COOP(IPM_CONSOLE_PRI), 0, 0);
ipm_set_enabled(ipm, 1);
return 0;
......
......@@ -18,7 +18,7 @@
#include <errno.h>
#include <nanokernel.h>
#include <kernel.h>
#include <misc/printk.h>
#include <ipm.h>
#include <console/ipm_console.h>
......
......@@ -19,7 +19,7 @@
#ifndef _IPM_CONSOLE_H_
#define _IPM_CONSOLE_H_
#include <nanokernel.h>
#include <kernel.h>
#include <device.h>
#include <misc/ring_buffer.h>
......@@ -32,7 +32,7 @@ extern "C" {
/*
* Good way to determine these numbers other than trial-and-error?
* using printf() in the fiber seems to require a lot more stack space
* using printf() in the thread seems to require a lot more stack space
*/
#define IPM_CONSOLE_STACK_SIZE 512
#define IPM_CONSOLE_PRI 2
......@@ -42,10 +42,10 @@ struct ipm_console_receiver_config_info {
char *bind_to;
/**
* Stack for the receiver's fiber, which prints out messages as
* Stack for the receiver's thread, which prints out messages as
* they come in. Should be sized IPM_CONSOLE_STACK_SIZE
*/
char *fiber_stack;
char *thread_stack;
/**
* Ring buffer data area for stashing characters from the interrupt
......@@ -77,8 +77,8 @@ struct ipm_console_receiver_runtime_data {
/** Buffer for received bytes from the low-level IPM device */
struct ring_buf rb;
/** Semaphore to wake up the fiber to print out messages */
struct nano_sem sem;
/** Semaphore to wake up the thread to print out messages */
struct k_sem sem;
/** pointer to the bound low-level IPM device */
struct device *ipm_device;
......
......@@ -60,13 +60,13 @@ DEVICE_INIT(ipm_console_send0, "ipm_send0", ipm_console_sender_init,
#define RING_BUF_SIZE32 8
static uint32_t ring_buf_data[RING_BUF_SIZE32];
static char __stack fiber_stack[IPM_CONSOLE_STACK_SIZE];
static char __stack thread_stack[IPM_CONSOLE_STACK_SIZE];
static char line_buf[LINE_BUF_SIZE];
/* Dump incoming messages to printk() */
static struct ipm_console_receiver_config_info receiver_config = {
.bind_to = "ipm_dummy0",
.fiber_stack = fiber_stack,
.thread_stack = thread_stack,
.ring_buf_data = ring_buf_data,
.rb_size32 = RING_BUF_SIZE32,
.line_buf = line_buf,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment