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