mirror of
https://github.com/AuxXxilium/redpill-lkm5.git
synced 2024-11-23 15:01:01 +07:00
feat: update power status and others (#2)
* remove outdated ioscheduler_fixer * block exec syno_oob_fw_upgrade * support get power status
This commit is contained in:
parent
41fc4fd882
commit
89f524913a
2
Makefile
2
Makefile
@ -13,7 +13,7 @@ SRCS-y += compat/string_compat.c \
|
||||
internal/override/override_symbol.c internal/override/override_syscall.c internal/intercept_execve.c \
|
||||
internal/call_protected.c internal/intercept_driver_register.c internal/stealth/sanitize_cmdline.c \
|
||||
internal/stealth.c internal/virtual_pci.c internal/uart/uart_swapper.c internal/uart/vuart_virtual_irq.c \
|
||||
internal/uart/virtual_uart.c internal/ioscheduler_fixer.c \
|
||||
internal/uart/virtual_uart.c \
|
||||
\
|
||||
config/cmdline_delegate.c config/runtime_config.c \
|
||||
\
|
||||
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* This very simple submodule which prevents kernel log from being flooded with "I/O scheduler elevator not found"
|
||||
*
|
||||
* When this shim is loaded as a I/O scheduler (to load very early) it is being set as a I/O scheduler. As we later
|
||||
* remove the module file the system will constantly try to load now non-existing module "elevator-iosched". By
|
||||
* resetting the "chosen_elevator" using the same function called by "elevator=" handler we can pretend no custom
|
||||
* I/O scheduler was ever set (so that the system uses default one and stops complaining)
|
||||
*/
|
||||
#include "ioscheduler_fixer.h"
|
||||
#include "../common.h"
|
||||
#include "call_protected.h" //is_system_booting(), elevator_setup()
|
||||
#include <linux/kernel.h> //system_state
|
||||
|
||||
#define SHIM_NAME "I/O scheduler fixer"
|
||||
|
||||
int reset_elevator(void)
|
||||
{
|
||||
if (!is_system_booting()) {
|
||||
pr_loc_wrn("Cannot reset I/O scheduler / elevator= set - system is past booting stage (state=%d)",
|
||||
system_state);
|
||||
return 0; //This is not an error technically speaking
|
||||
}
|
||||
|
||||
pr_loc_dbg("Resetting I/O scheduler to default");
|
||||
return _elevator_setup("") == 1 ? 0 : -EINVAL;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#ifndef REDPILL_IOSCHEDULER_FIXER_H
|
||||
#define REDPILL_IOSCHEDULER_FIXER_H
|
||||
|
||||
int reset_elevator(void);
|
||||
|
||||
#endif //REDPILL_IOSCHEDULER_FIXER_H
|
@ -4,7 +4,6 @@
|
||||
#include "common.h" //commonly used headers in this module
|
||||
#include "internal/intercept_execve.h" //Handling of execve() replacement
|
||||
#include "internal/scsi/scsi_notifier.h" //the missing pub/sub handler for SCSI driver
|
||||
#include "internal/ioscheduler_fixer.h" //reset_elevator() to correct elevator= boot cmdline
|
||||
#include "config/cmdline_delegate.h" //Parsing of kernel cmdline
|
||||
#include "shim/boot_device_shim.h" //Registering & deciding between boot device shims
|
||||
#include "shim/bios_shim.h" //Shimming various mfgBIOS functions to make them happy
|
||||
@ -64,7 +63,6 @@ static int __init init_(void)
|
||||
|| (out = register_disk_smart_shim()) != 0 //provide fake SMART to userspace
|
||||
|| (out = register_pmu_shim(current_config.hw_config)) != 0 //this is used as early as mfgBIOS loads (=late)
|
||||
|| (out = initialize_stealth(¤t_config)) != 0 //Should be after any shims to let shims have real stuff
|
||||
|| (out = reset_elevator()) != 0 //Cosmetic, can be the last one
|
||||
)
|
||||
goto error_out;
|
||||
|
||||
|
@ -39,6 +39,13 @@ static int bios_get_buz_clr(unsigned char *state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bios_get_power_status(POWER_INFO *power)
|
||||
{
|
||||
power->power_1 = POWER_STATUS_GOOD;
|
||||
power->power_2 = POWER_STATUS_GOOD;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************** Debug shims for unknown bios functions **************************************/
|
||||
DECLARE_NULL_ZERO_INT(VTK_SET_FAN_STATE);
|
||||
DECLARE_NULL_ZERO_INT(VTK_SET_DISK_LED);
|
||||
@ -137,6 +144,7 @@ bool shim_bios_module(const struct hw_config *hw, struct module *mod, unsigned l
|
||||
SHIM_TO_NULL_ZERO_INT(VTK_SET_ALR_LED);
|
||||
_shim_bios_module_entry(VTK_GET_BUZ_CLR, bios_get_buz_clr);
|
||||
SHIM_TO_NULL_ZERO_INT(VTK_SET_BUZ_CLR);
|
||||
_shim_bios_module_entry(VTK_GET_PWR_STATUS, bios_get_power_status);
|
||||
SHIM_TO_NULL_ZERO_INT(VTK_SET_CPU_FAN_STATUS);
|
||||
SHIM_TO_NULL_ZERO_INT(VTK_SET_PHY_LED);
|
||||
SHIM_TO_NULL_ZERO_INT(VTK_SET_HDD_ACT_LED);
|
||||
|
@ -182,6 +182,16 @@ enum MfgCompatCopyBtnState {
|
||||
MFGC_BTN_UP = 1, //aka not pressed
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
POWER_STATUS_BAD = 0,
|
||||
POWER_STATUS_GOOD,
|
||||
} SYNO_POWER_STATUS;
|
||||
|
||||
typedef struct _tag_POWER_INFO {
|
||||
SYNO_POWER_STATUS power_1;
|
||||
SYNO_POWER_STATUS power_2;
|
||||
} POWER_INFO;
|
||||
|
||||
typedef int (*mfgc_void_cb)(void); //int f(void)
|
||||
typedef int (*mfgc_time_cb)(struct MfgCompatTime *); //int f(MfgCompatTime *)
|
||||
typedef int (*mfgc_get_fan_state_cb)(int, enum MfgCompatFanStatus *); //int f(int, MfgCompatFanStatus *)
|
||||
|
@ -5,7 +5,7 @@
|
||||
* The process relies on the fact that the original BIOS module keeps a vtable table in memory. That vtable contains
|
||||
* pointers to various functions used to communicate with the hardware. The most tricky part here is finding the vtable
|
||||
* and replacing calls in it with our own. Original ELF contains unscrambled symbols for the table under "synobios_ops"
|
||||
* name (see: readelf --syms /usr/lib/modules/synobios-dis.ko | grep 'synobios_ops'). However this is NOT a symbol which
|
||||
* name (see: readelf --syms /usr/lib/modules/synobios.ko | grep 'synobios_ops'). However this is NOT a symbol which
|
||||
* gets exported to the kernel.
|
||||
*
|
||||
* When the Linux kernel loads a module it does a couple of things after loading the .ko file. From the important ones
|
||||
@ -25,7 +25,7 @@
|
||||
* arch/x86/kernel/module.c:apply_relocate_add(). Since this function is external it can be "gently" replaced.
|
||||
*
|
||||
* During the lifetime of apply_relocate_add(), which is redirected to _apply_relocate_add() here, the full ELF with
|
||||
* symbol table is available and thus the vtable can be located using process_bios_symbols(). However, it cannot be
|
||||
* symbol table is available and thus the vtable can be located using process_bios_symbols(). However, it cannot be
|
||||
* just like that modified at this moment (remember: we're way before module init is called) as 1) functions it points
|
||||
* to may be relocated still, and 2) it's hardware-dependent (as seen by doing print_debug_symbols() before & after
|
||||
* init). We need to hook to the module notification API and shim what's needed AFTER module started initializing.
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define BOOTLOADER_UPDATE1_PATH "uboot_do_upd.sh"
|
||||
#define BOOTLOADER_UPDATE2_PATH "./uboot_do_upd.sh"
|
||||
#define SAS_FW_UPDATE_PATH "/tmpData/upd@te/sas_fw_upgrade_tool"
|
||||
#define OOB_FW_UPDATE_PATH "/usr/syno/sbin/syno_oob_fw_upgrade"
|
||||
|
||||
int register_disable_executables_shim(void)
|
||||
{
|
||||
@ -20,6 +21,7 @@ int register_disable_executables_shim(void)
|
||||
|| (out = add_blocked_execve_filename(BOOTLOADER_UPDATE2_PATH)) != 0
|
||||
|| (out = add_blocked_execve_filename(PSTORE_PATH)) != 0
|
||||
|| (out = add_blocked_execve_filename(SAS_FW_UPDATE_PATH)) != 0
|
||||
|| (out = add_blocked_execve_filename(OOB_FW_UPDATE_PATH)) != 0
|
||||
) {
|
||||
pr_loc_bug("Failed to disable some executables");
|
||||
return out;
|
||||
|
Loading…
Reference in New Issue
Block a user