summaryrefslogtreecommitdiff
path: root/Kernel/Firmware/PowerStateSwitch.h
blob: e96540f202a1559a1385867a41c4c2f92d61e698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/RefPtr.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/FileSystem/SysFS.h>
#include <Kernel/Firmware/SysFSFirmware.h>
#include <Kernel/KBuffer.h>
#include <Kernel/Memory/MappedROM.h>
#include <Kernel/Memory/Region.h>
#include <Kernel/PhysicalAddress.h>
#include <Kernel/VirtualAddress.h>

namespace Kernel {

class PowerStateSwitchNode final : public SysFSComponent {
public:
    static NonnullRefPtr<PowerStateSwitchNode> must_create(FirmwareSysFSDirectory&);
    virtual mode_t permissions() const override;
    virtual KResultOr<size_t> write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override;

private:
    PowerStateSwitchNode(FirmwareSysFSDirectory&);

    void reboot();
    void poweroff();
};

}