blob: bf557352f82385c22aefa339e9db7dd33edc95ed (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/ne-foss-org/nekernel
#ifndef DRIVERKIT_OBJECTKIT_DRIVER_BASE_H
#define DRIVERKIT_OBJECTKIT_DRIVER_BASE_H
#include <libDDK/DriverKit/Defines.h>
#define DDK_DRIVER_IMPL \
final: \
public \
::Kernel::DDK::IDriverBase
/// @author Amlal El Mahrouss
/// @brief The DDK C++ API.
namespace Kernel::DDK {
inline constexpr auto kInvalidType = 0;
/// @brief Driver interface type.
class IDriverBase {
public:
IDriverBase() = default;
virtual ~IDriverBase() = default;
IDriverBase& operator=(const IDriverBase&) = default;
IDriverBase(const IDriverBase&) = default;
using PtrType = void*;
virtual constexpr bool IsCastable() { return false; }
virtual constexpr bool IsActive() { return false; }
virtual PtrType Leak() { return nullptr; }
virtual constexpr int32_t Type() { return kInvalidType; }
};
/// @brief This concept requires the Driver to be IDriverBase compliant.
/// @author @amlel-el-mahrouss
template <typename Driver>
concept IsValidDriver = requires(Driver drv) {
{drv.IsActive() && drv.Type() > kInvalidType};
};
} // namespace Kernel::DDK
#endif
|