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
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-09-11 04:26:27 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-09-11 04:26:27 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
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>
|
2015-09-11 04:26:27 +08:00
|
|
|
#include <misc/printk.h>
|
2015-11-13 06:00:47 +08:00
|
|
|
#include <ipm.h>
|
|
|
|
#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
|
|
|
}
|