-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
kernel_module_loader.hpp
38 lines (32 loc) · 1.43 KB
/
kernel_module_loader.hpp
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
#ifndef _KERNELMODULELOADER_HPP
#define _KERNELMODULELOADER_HPP
#include <dirent.h>
#include <string>
#include <vector>
#include <android-base/file.h>
#include <android-base/strings.h>
#include <modprobe/modprobe.h>
#include <sys/mount.h>
#include <sys/utsname.h>
#include "twcommon.h"
#include "twrp-functions.hpp"
#define VENDOR_MODULE_DIR "/vendor/lib/modules" // Base path for vendor kernel modules to check by TWRP
#define VENDOR_BOOT_MODULE_DIR "/lib/modules" // vendor_boot ramdisk GKI modules to check by TWRP
#define VENDOR_DLKM_MODULE_DIR "/vendor_dlkm/lib/modules" // vendor_dlkm placed modules to check by TWRP
typedef enum {
RECOVERY_FASTBOOT_MODE = 0,
RECOVERY_IN_BOOT_MODE,
FASTBOOTD_MODE
} BOOT_MODE;
class KernelModuleLoader
{
public:
static bool Load_Vendor_Modules(); // Load specific maintainer defined kernel modules in TWRP
private:
static int Try_And_Load_Modules(std::string module_dir, bool vendor_is_mounted); // Use libmodprobe to attempt loading kernel modules
static bool Write_Module_List(std::string module_dir); // Write list of modules to load from TW_LOAD_VENDOR_MODULES
static bool Copy_Modules_To_Tmpfs(std::string module_dir); // Copy modules to ramdisk for loading
static std::vector<string> Skip_Loaded_Kernel_Modules(); // return list of loaded kernel modules already done by init
static BOOT_MODE Get_Boot_Mode(); // For getting the current boot mode
};
#endif // _KERNELMODULELOADER_HPP