console.c 708 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-11-11 GuEe-GUI the first version
  9. */
  10. #include <rtthread.h>
  11. #include <virtio_console.h>
  12. static int console_init()
  13. {
  14. rt_err_t status = RT_EOK;
  15. rt_device_t device = rt_device_find("virtio-console0");
  16. if (device != RT_NULL && rt_device_open(device, 0) == RT_EOK)
  17. {
  18. /* Create vport0p1 */
  19. status = rt_device_control(device, VIRTIO_DEVICE_CTRL_CONSOLE_PORT_CREATE, RT_NULL);
  20. }
  21. if (device != RT_NULL)
  22. {
  23. rt_device_close(device);
  24. }
  25. return status;
  26. }
  27. INIT_ENV_EXPORT(console_init);