2015-11-12 14:00:47 -08:00
|
|
|
/* ipm_console_send.c - Console messages to another processor */
|
2015-09-10 13:26:27 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-09-10 13:26:27 -07:00
|
|
|
*/
|
|
|
|
|
2016-03-09 15:22:04 -03:00
|
|
|
#include <errno.h>
|
|
|
|
|
2016-11-12 08:00:52 -05:00
|
|
|
#include <kernel.h>
|
2019-06-26 10:33:49 -04:00
|
|
|
#include <sys/printk.h>
|
2019-06-25 15:53:55 -04:00
|
|
|
#include <drivers/ipm.h>
|
2020-01-25 05:34:53 -06:00
|
|
|
#include <drivers/console/ipm_console.h>
|
2015-09-10 13:26:27 -07:00
|
|
|
|
2015-11-12 14:00:47 -08:00
|
|
|
static struct device *ipm_console_device;
|
2015-09-10 13:26:27 -07:00
|
|
|
|
|
|
|
static int consoleOut(int character)
|
|
|
|
{
|
2015-09-21 10:29:00 -07:00
|
|
|
if (character == '\r') {
|
|
|
|
return character;
|
|
|
|
}
|
|
|
|
|
2015-10-20 09:42:33 -07:00
|
|
|
/*
|
|
|
|
* We just stash the character into the id field and don't supply
|
|
|
|
* any extra data
|
|
|
|
*/
|
2015-11-12 14:00:47 -08:00
|
|
|
ipm_send(ipm_console_device, 1, character, NULL, 0);
|
2015-09-21 10:29:00 -07:00
|
|
|
|
2015-09-10 13:26:27 -07:00
|
|
|
return character;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void __printk_hook_install(int (*fn)(int));
|
|
|
|
extern void __stdout_hook_install(int (*fn)(int));
|
|
|
|
|
2015-11-12 14:00:47 -08:00
|
|
|
int ipm_console_sender_init(struct device *d)
|
2015-09-10 13:26:27 -07:00
|
|
|
{
|
2016-10-06 16:45:58 +01:00
|
|
|
const struct ipm_console_sender_config_info *config_info;
|
2015-09-10 13:26:27 -07:00
|
|
|
|
2020-03-09 12:49:07 +01:00
|
|
|
config_info = d->config_info;
|
2015-11-12 14:00:47 -08:00
|
|
|
ipm_console_device = device_get_binding(config_info->bind_to);
|
2015-09-10 13:26:27 -07:00
|
|
|
|
2015-11-12 14:00:47 -08:00
|
|
|
if (!ipm_console_device) {
|
|
|
|
printk("unable to bind IPM console sender to '%s'\n",
|
2015-09-10 13:26:27 -07:00
|
|
|
config_info->bind_to);
|
2016-03-09 15:22:04 -03:00
|
|
|
return -EINVAL;
|
2015-09-10 13:26:27 -07:00
|
|
|
}
|
|
|
|
|
2015-11-12 14:00:47 -08:00
|
|
|
if (config_info->flags & IPM_CONSOLE_STDOUT) {
|
2015-09-10 13:26:27 -07:00
|
|
|
__stdout_hook_install(consoleOut);
|
|
|
|
}
|
2015-11-12 14:00:47 -08:00
|
|
|
if (config_info->flags & IPM_CONSOLE_PRINTK) {
|
2015-09-10 13:26:27 -07:00
|
|
|
__printk_hook_install(consoleOut);
|
|
|
|
}
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-09-10 13:26:27 -07:00
|
|
|
}
|