From 7e1510eb9c384dcf6b82054dfc1165d1e34727a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 19 Jun 2023 17:51:31 +0200 Subject: [PATCH] [HALX86] Implement HalpcGetCmosData and HalpcSetCmosData. --- hal/halx86/generic/cmos.c | 9 ++--- hal/halx86/include/bus.h | 38 +++++++++----------- hal/halx86/legacy/bus/cmosbus.c | 63 ++++++++++++++++++++------------- 3 files changed, 60 insertions(+), 50 deletions(-) diff --git a/hal/halx86/generic/cmos.c b/hal/halx86/generic/cmos.c index 75a09b1bfe2..45ad8840956 100644 --- a/hal/halx86/generic/cmos.c +++ b/hal/halx86/generic/cmos.c @@ -101,10 +101,11 @@ HalpGetCmosData( ULONG NTAPI -HalpSetCmosData(IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length) +HalpSetCmosData( + _In_ ULONG BusNumber, + _In_ ULONG SlotNumber, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length) { PUCHAR Ptr = (PUCHAR)Buffer; ULONG Address = SlotNumber; diff --git a/hal/halx86/include/bus.h b/hal/halx86/include/bus.h index 3e8fa82e13e..af61f0fa67c 100644 --- a/hal/halx86/include/bus.h +++ b/hal/halx86/include/bus.h @@ -427,17 +427,15 @@ HalpGetCmosData( _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, - _In_ ULONG Length -); + _In_ ULONG Length); ULONG NTAPI HalpSetCmosData( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length -); + _In_ ULONG BusNumber, + _In_ ULONG SlotNumber, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Length); CODE_SEG("INIT") VOID @@ -584,24 +582,22 @@ HalpNoBusData( ULONG NTAPI HalpcGetCmosData( - IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length -); + _In_ PBUS_HANDLER BusHandler, + _In_ PBUS_HANDLER RootHandler, + _In_ ULONG SlotNumber, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Offset, + _In_ ULONG Length); ULONG NTAPI HalpcSetCmosData( - IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length -); + _In_ PBUS_HANDLER BusHandler, + _In_ PBUS_HANDLER RootHandler, + _In_ ULONG SlotNumber, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Offset, + _In_ ULONG Length); BOOLEAN NTAPI diff --git a/hal/halx86/legacy/bus/cmosbus.c b/hal/halx86/legacy/bus/cmosbus.c index 88e7981ac51..cc633e8c96f 100644 --- a/hal/halx86/legacy/bus/cmosbus.c +++ b/hal/halx86/legacy/bus/cmosbus.c @@ -1,45 +1,58 @@ /* - * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/legacy/bus/cmosbus.c - * PURPOSE: - * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) + * PROJECT: ReactOS HAL + * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) + * PURPOSE: CMOS bus data handlers + * COPYRIGHT: Copyright 2023 Hermès Bélusca-Maïto */ /* INCLUDES *******************************************************************/ #include -#define NDEBUG -#include - -/* GLOBALS ********************************************************************/ /* PRIVATE FUNCTIONS **********************************************************/ ULONG NTAPI -HalpcGetCmosData(IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length) +HalpcGetCmosData( + _In_ PBUS_HANDLER BusHandler, + _In_ PBUS_HANDLER RootHandler, + _In_ ULONG SlotNumber, + _Out_writes_bytes_(Length) PVOID Buffer, + _In_ ULONG Offset, + _In_ ULONG Length) { - UNIMPLEMENTED_DBGBREAK("CMOS GetData\n"); - return 0; + UNREFERENCED_PARAMETER(RootHandler); + + /* CMOS reads do not support offsets */ + if (Offset != 0) + return 0; + + return HalpGetCmosData(BusHandler->BusNumber, + SlotNumber, + Buffer, + Length); } ULONG NTAPI -HalpcSetCmosData(IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length) +HalpcSetCmosData( + _In_ PBUS_HANDLER BusHandler, + _In_ PBUS_HANDLER RootHandler, + _In_ ULONG SlotNumber, + _In_reads_bytes_(Length) PVOID Buffer, + _In_ ULONG Offset, + _In_ ULONG Length) { - UNIMPLEMENTED_DBGBREAK("CMOS SetData\n"); - return 0; + UNREFERENCED_PARAMETER(RootHandler); + + /* CMOS writes do not support offsets */ + if (Offset != 0) + return 0; + + return HalpSetCmosData(BusHandler->BusNumber, + SlotNumber, + Buffer, + Length); } /* EOF */