textui.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "textui.h"
  2. #include "screen_manager.h"
  3. #include "driver/uart/uart.h"
  4. #include <common/string.h>
  5. #include <common/printk.h>
  6. struct scm_ui_framework_t textui_framework;
  7. int textui_install_handler(struct scm_buffer_info_t *buf)
  8. {
  9. return printk_init(buf);
  10. }
  11. int textui_uninstall_handler(void *args)
  12. {
  13. }
  14. int textui_enable_handler(void *args)
  15. {
  16. }
  17. int textui_disable_handler(void *args)
  18. {
  19. }
  20. int textui_change_handler(struct scm_buffer_info_t *buf)
  21. {
  22. memcpy((void*)buf->vaddr, (void*)(textui_framework.buf->vaddr), textui_framework.buf->size);
  23. textui_framework.buf = buf;
  24. set_pos_VBE_FB_addr((uint*)buf->vaddr);
  25. return 0;
  26. }
  27. struct scm_ui_framework_operations_t textui_ops =
  28. {
  29. .install = &textui_install_handler,
  30. .uninstall = &textui_uninstall_handler,
  31. .change = &textui_change_handler,
  32. .enable = &textui_enable_handler,
  33. .disable = &textui_disable_handler,
  34. };
  35. /**
  36. * @brief 初始化text ui框架
  37. *
  38. * @return int
  39. */
  40. int textui_init()
  41. {
  42. memset(&textui_framework, 0, sizeof(textui_framework));
  43. io_mfence();
  44. char name[] = "textUI";
  45. strcpy(textui_framework.name, name);
  46. textui_framework.ui_ops = &textui_ops;
  47. textui_framework.type = SCM_FRAMWORK_TYPE_TEXT;
  48. uart_send_str(COM1, "12121");
  49. int retval = scm_register(&textui_framework);
  50. if (retval != 0)
  51. {
  52. uart_send_str(COM1, "text ui init failed");
  53. while (1)
  54. pause();
  55. }
  56. uart_send_str(COM1, "text ui initialized");
  57. return 0;
  58. }