main.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Created by longjin on 2022/1/20.
  3. //
  4. #include "common/glib.h"
  5. #include "common/printk.h"
  6. int *FR_address = (int *)0xffff800000a00000; //帧缓存区的地址
  7. void show_welcome()
  8. {
  9. /**
  10. * @brief 打印欢迎页面
  11. *
  12. */
  13. printk("\n\n");
  14. for (int i = 0; i < 74; ++i)
  15. printk(" ");
  16. printk_color(0x00e0ebeb, 0x00e0ebeb, " \n");
  17. for (int i = 0; i < 74; ++i)
  18. printk(" ");
  19. printk_color(BLACK, 0x00e0ebeb, " Welcome to DragonOS ! \n");
  20. for (int i = 0; i < 74; ++i)
  21. printk(" ");
  22. printk_color(0x00e0ebeb, 0x00e0ebeb, " \n");
  23. }
  24. void test_printk()
  25. {
  26. //测试直接输出
  27. printk("\nTesting printk...\n");
  28. //测试输出单个字符
  29. printk("%c\n", 't');
  30. //测试输出字符串%s
  31. printk("%s\n", "xxx");
  32. //测试输出数字
  33. printk("%d %ld %lld\n", 1, 2, 3);
  34. //测试输出两个百分号
  35. printk("%%\n");
  36. //测试输出\t
  37. printk("\nTesting tab...\n");
  38. printk("date\t\tname\tscore\n");
  39. printk("2022-01-01\tDavid\t99\n");
  40. printk("2022-01-01\tJohn\t95\n");
  41. //测试输出八进制
  42. printk("\nTest base 8 : %d --> %o\n", 255, 255);
  43. //测试输出十六进制
  44. printk("\nTest base 16 : %d --> %x\n", 255, 255);
  45. printk("\nTest base 16 : %d --> %X\n", 255, 255);
  46. }
  47. //操作系统内核从这里开始执行
  48. void Start_Kernel(void)
  49. {
  50. // 初始化printk
  51. init_printk(1440, 900, FR_address, 1440 * 900 * 4, 8, 16);
  52. show_welcome();
  53. //test_printk();
  54. int t = 1 / 0; // 测试异常处理模块ignore_int能否正常工作
  55. while (1)
  56. ;
  57. }
  58. void ignore_int()
  59. {
  60. printk("[");
  61. printk_color(YELLOW, BLACK, "WARN");
  62. printk("] Unknown interrupt or fault at RIP.\n");
  63. while (1)
  64. ;
  65. }