summaryrefslogtreecommitdiff
path: root/bsp/qemu-virt64-aarch64/applications/console.c
blob: 3f8be481891bdc082f4927e468e8f1295af6a2b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-11-11     GuEe-GUI     the first version
 */

#include <rtthread.h>

#include <virtio_console.h>

static int console_init()
{
    rt_err_t status = RT_EOK;
    rt_device_t device = rt_device_find("virtio-console0");

    if (device != RT_NULL && rt_device_open(device, 0) == RT_EOK)
    {
        /* Create vport0p1 */
        status = rt_device_control(device, VIRTIO_DEVICE_CTRL_CONSOLE_PORT_CREATE, RT_NULL);
    }

    if (device != RT_NULL)
    {
        rt_device_close(device);
    }

    return status;
}
INIT_ENV_EXPORT(console_init);