ACPIParser.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include <Kernel/ACPI/ACPIParser.h>
  27. namespace Kernel {
  28. namespace ACPI {
  29. static Parser* s_acpi_parser;
  30. Parser& Parser::the()
  31. {
  32. ASSERT(s_acpi_parser != nullptr);
  33. return *s_acpi_parser;
  34. }
  35. void Parser::initialize_limited()
  36. {
  37. if (!Parser::is_initialized()) {
  38. s_acpi_parser = new Parser(false);
  39. }
  40. }
  41. bool Parser::is_initialized()
  42. {
  43. return (s_acpi_parser != nullptr);
  44. }
  45. Parser::Parser(bool usable)
  46. {
  47. if (usable) {
  48. klog() << "ACPI: Setting up a functional parser";
  49. } else {
  50. klog() << "ACPI: Limited Initialization. Vital functions are disabled by a request";
  51. }
  52. s_acpi_parser = this;
  53. }
  54. PhysicalAddress Parser::find_table(const char*)
  55. {
  56. klog() << "ACPI: Requested to search for a table, Abort!";
  57. return {};
  58. }
  59. void Parser::do_acpi_reboot()
  60. {
  61. klog() << "ACPI: Cannot invoke reboot!";
  62. ASSERT_NOT_REACHED();
  63. }
  64. void Parser::do_acpi_shutdown()
  65. {
  66. klog() << "ACPI: Cannot invoke shutdown!";
  67. ASSERT_NOT_REACHED();
  68. }
  69. void Parser::enable_aml_interpretation()
  70. {
  71. klog() << "ACPI: No AML Interpretation Allowed";
  72. ASSERT_NOT_REACHED();
  73. }
  74. void Parser::enable_aml_interpretation(File&)
  75. {
  76. klog() << "ACPI: No AML Interpretation Allowed";
  77. ASSERT_NOT_REACHED();
  78. }
  79. void Parser::enable_aml_interpretation(u8*, u32)
  80. {
  81. klog() << "ACPI: No AML Interpretation Allowed";
  82. ASSERT_NOT_REACHED();
  83. }
  84. void Parser::disable_aml_interpretation()
  85. {
  86. klog() << "ACPI Limited: No AML Interpretation Allowed";
  87. ASSERT_NOT_REACHED();
  88. }
  89. bool Parser::is_operable()
  90. {
  91. return false;
  92. }
  93. }
  94. }