Repository navigation
Expand file tree
/
Copy pathLpcACPIEC.p
More file actions
67 lines (57 loc) · 2.05 KB
/
Copy pathLpcACPIEC.p
File metadata and controls
67 lines (57 loc) · 2.05 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// PawnIO Modules - Modules for various hardware to be used with PawnIO.
// Copyright (C) 2023 namazso <admin@namazso.eu>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <pawnio.inc>
is_port_allowed(port) {
return port == 0x62 || port == 0x66;
}
/// Read byte from ACPI EC.
///
/// @param in [0] = Port
/// @param in_size Must be 1
/// @param out [0] = Value read
/// @param out_size Must be 1
/// @return An NTSTATUS
/// @warning You should acquire the "\BaseNamedObjects\Access_EC" mutant before calling this
DEFINE_IOCTL_SIZED(ioctl_pio_read, 1, 1) {
new port = in[0] & 0xFFFF;
if (!is_port_allowed(port))
return STATUS_ACCESS_DENIED;
out[0] = io_in_byte(port);
return STATUS_SUCCESS;
}
/// Write byte to ACPI EC.
///
/// @param in [0] = Port, [1] = Value
/// @param in_size Must be 2
/// @param out Unused
/// @param out_size Unused
/// @return An NTSTATUS
/// @warning You should acquire the "\BaseNamedObjects\Access_EC" mutant before calling this
DEFINE_IOCTL_SIZED(ioctl_pio_write, 2, 0) {
new port = in[0] & 0xFFFF;
new value = in[1];
if (!is_port_allowed(port))
return STATUS_ACCESS_DENIED;
io_out_byte(port, value);
return STATUS_SUCCESS;
}
// TODO: Should probably move register read and write from usermode
NTSTATUS:main() {
return STATUS_SUCCESS;
}