mm.c 840 B

1234567891011121314151617181920212223242526272829
  1. #include "mm.h"
  2. #include "../common/printk.h"
  3. ul Total_Memory = 0;
  4. void mm_init()
  5. {
  6. // 实模式下获取到的信息的起始地址,转换为ARDS指针
  7. struct ARDS *ards_ptr = (struct ARDS *)0xffff800000007e00;
  8. for (int i = 0; i < 32; ++i)
  9. {
  10. printk("Addr = %#10lx,%8lx\tLength = %#10lx,%8lx\tType = %#10lx\n",
  11. ards_ptr->BaseAddrH, ards_ptr->BaseAddrL, ards_ptr->LengthH, ards_ptr->LengthL, ards_ptr->type);
  12. //可用的内存
  13. if (ards_ptr->type == 1)
  14. {
  15. Total_Memory += ards_ptr->LengthL;
  16. Total_Memory += ((ul)(ards_ptr->LengthH)) << 32;
  17. }
  18. ++ards_ptr;
  19. // 脏数据
  20. if (ards_ptr->type > 4)
  21. break;
  22. }
  23. printk_color(ORANGE, BLACK, "Total amount of RAM DragonOS can use: %ld bytes\n", Total_Memory);
  24. }