shared_page.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. /**
  6. * The shared page stores various runtime configuration settings. This memory page is
  7. * read-only for user processes (there is a bit in the header that grants the process
  8. * write access, according to 3dbrew; this is not emulated)
  9. */
  10. #include "common/bit_field.h"
  11. #include "common/common_funcs.h"
  12. #include "common/common_types.h"
  13. #include "common/swap.h"
  14. #include "core/memory.h"
  15. ////////////////////////////////////////////////////////////////////////////////////////////////////
  16. namespace SharedPage {
  17. // See http://3dbrew.org/wiki/Configuration_Memory#Shared_Memory_Page_For_ARM11_Processes
  18. struct DateTime {
  19. u64_le date_time; // 0
  20. u64_le update_tick; // 8
  21. u64_le tick_to_second_coefficient; // 10
  22. u64_le tick_offset; // 18
  23. };
  24. static_assert(sizeof(DateTime) == 0x20, "Datetime size is wrong");
  25. union BatteryState {
  26. u8 raw;
  27. BitField<0, 1, u8> is_adapter_connected;
  28. BitField<1, 1, u8> is_charging;
  29. BitField<2, 3, u8> charge_level;
  30. };
  31. struct SharedPageDef {
  32. // Most of these names are taken from the 3dbrew page linked above.
  33. u32_le date_time_counter; // 0
  34. u8 running_hw; // 4
  35. /// "Microcontroller hardware info"
  36. u8 mcu_hw_info; // 5
  37. INSERT_PADDING_BYTES(0x20 - 0x6); // 6
  38. DateTime date_time_0; // 20
  39. DateTime date_time_1; // 40
  40. u8 wifi_macaddr[6]; // 60
  41. u8 wifi_link_level; // 66
  42. u8 wifi_unknown2; // 67
  43. INSERT_PADDING_BYTES(0x80 - 0x68); // 68
  44. float_le sliderstate_3d; // 80
  45. u8 ledstate_3d; // 84
  46. BatteryState battery_state; // 85
  47. u8 unknown_value; // 86
  48. INSERT_PADDING_BYTES(0xA0 - 0x87); // 87
  49. u64_le menu_title_id; // A0
  50. u64_le active_menu_title_id; // A8
  51. INSERT_PADDING_BYTES(0x1000 - 0xB0); // B0
  52. };
  53. static_assert(sizeof(SharedPageDef) == Memory::SHARED_PAGE_SIZE,
  54. "Shared page structure size is wrong");
  55. extern SharedPageDef shared_page;
  56. void Init();
  57. } // namespace