blob: 0115ce4c25d901881618c821d8163216fc322d10 [file] [log] [blame]
bigbiff22851b92021-09-01 16:46:57 -04001#ifndef _KERNELMODULELOADER_HPP
2#define _KERNELMODULELOADER_HPP
3
4#include <dirent.h>
5#include <string>
6#include <vector>
7#include <android-base/strings.h>
8#include <modprobe/modprobe.h>
9#include <sys/utsname.h>
10
11#include "twcommon.h"
12#include "twrp-functions.hpp"
13
14#define VENDOR_MODULE_DIR "/vendor/lib/modules" // Base path for vendor kernel modules to check by TWRP
15#define VENDOR_BOOT_MODULE_DIR "/lib/modules" // vendor_boot ramdisk GKI modules to check by TWRP
16typedef enum {
17 RECOVERY_FASTBOOT_MODE = 0,
18 RECOVERY_IN_BOOT_MODE,
19 FASTBOOTD_MODE
20} BOOT_MODE;
21
22class KernelModuleLoader
23{
24public:
25 static bool Load_Vendor_Modules(BOOT_MODE mode); // Load specific maintainer defined kernel modules in TWRP
26
27private:
bigbiffe3aa02e2021-10-01 13:07:38 -040028 static int Try_And_Load_Modules(std::string module_dir); // Use libmodprobe to attempt loading kernel modules
bigbiff22851b92021-09-01 16:46:57 -040029 static bool Write_Module_List(std::string module_dir); // Write list of modules to load from TW_LOAD_VENDOR_MODULES
30 static bool Copy_Modules_To_Tmpfs(std::string module_dir); // Copy modules to ramdisk for loading
31};
32
33#endif // _KERNELMODULELOADER_HPP