blob: de28bd29caa1ca9d8cee9d00d67626fb58a5edb2 [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>
bigbiff850fa282021-10-09 12:37:29 -04009#include <sys/mount.h>
bigbiff22851b92021-09-01 16:46:57 -040010#include <sys/utsname.h>
11
12#include "twcommon.h"
13#include "twrp-functions.hpp"
14
15#define VENDOR_MODULE_DIR "/vendor/lib/modules" // Base path for vendor kernel modules to check by TWRP
16#define VENDOR_BOOT_MODULE_DIR "/lib/modules" // vendor_boot ramdisk GKI modules to check by TWRP
17typedef enum {
18 RECOVERY_FASTBOOT_MODE = 0,
19 RECOVERY_IN_BOOT_MODE,
20 FASTBOOTD_MODE
21} BOOT_MODE;
22
23class KernelModuleLoader
24{
25public:
bigbiff850fa282021-10-09 12:37:29 -040026 static bool Load_Vendor_Modules(); // Load specific maintainer defined kernel modules in TWRP
bigbiff22851b92021-09-01 16:46:57 -040027
28private:
bigbiff850fa282021-10-09 12:37:29 -040029 static int Try_And_Load_Modules(std::string module_dir, bool vendor_is_mounted); // Use libmodprobe to attempt loading kernel modules
bigbiff22851b92021-09-01 16:46:57 -040030 static bool Write_Module_List(std::string module_dir); // Write list of modules to load from TW_LOAD_VENDOR_MODULES
31 static bool Copy_Modules_To_Tmpfs(std::string module_dir); // Copy modules to ramdisk for loading
bigbiff850fa282021-10-09 12:37:29 -040032 static std::vector<string> Skip_Loaded_Kernel_Modules(); // return list of loaded kernel modules already done by init
bigbiff22851b92021-09-01 16:46:57 -040033};
34
35#endif // _KERNELMODULELOADER_HPP