Skip to content

Commit

Permalink
Add a proper UART swapper
Browse files Browse the repository at this point in the history
The previously used method of swapping UARTs relied on a kernel's
function available during init only. Additionally, that function
was used after tinkering with the internal structures of the
console indexes. Overall a very hacky way. Previous attempts to
make it normal failed. However, this one should be stable and
robust as it doesn't really hack much around. It should handle
many edge cases, which are unimaginable for the current ttyS0/ttyS1
swapping needs. We felt the project deserves a complete solution
for that problem, which if needed for something else can be
extracted and used as a standalone library.
  • Loading branch information
ttg-public committed Jan 1, 1970
1 parent e4f350c commit 22d4019
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -767,4 +767,4 @@ add_definitions(-DCONFIG_SERIAL_8250_NR_UARTS=4)
add_definitions(-DCONFIG_SYNO_BOOT_SATA_DOM) # only some platforms support that, notably 3615xs while 918+ doesn't

add_executable(redpill
redpill_main.c redpill_main.h internal/call_protected.c internal/call_protected.h common.h config/cmdline_delegate.c config/cmdline_delegate.h shim/boot_device_shim.c shim/boot_device_shim.h internal/stealth.c internal/stealth.h config/runtime_config.c config/runtime_config.h test.c shim/bios_shim.c shim/bios_shim.h internal/override_symbol.c internal/override_symbol.h shim/bios/bios_shims_collection.c shim/bios/bios_shims_collection.h shim/block_fw_update_shim.c shim/block_fw_update_shim.h internal/intercept_execve.c internal/intercept_execve.h shim/disable_exectutables.c shim/disable_exectutables.h debug/debug_execve.c debug/debug_execve.h compat/string_compat.c compat/string_compat.h internal/stealth/sanitize_cmdline.c internal/stealth/sanitize_cmdline.h internal/virtual_pci.c internal/virtual_pci.h shim/pci_shim.c shim/pci_shim.h shim/bios/rtc_proxy.c shim/bios/rtc_proxy.h shim/bios/rtc_proxy.c shim/bios/rtc_proxy.h internal/uart/virtual_uart.c internal/uart/virtual_uart.h shim/uart_fixer.c shim/uart_fixer.h internal/uart/uart_defs.h debug/debug_vuart.h internal/uart/vuart_virtual_irq.c internal/uart/vuart_virtual_irq.h internal/uart/vuart_internal.h shim/boot_dev/usb_boot_shim.c shim/boot_dev/usb_boot_shim.h shim/boot_dev/sata_boot_shim.c shim/boot_dev/sata_boot_shim.h)
redpill_main.c redpill_main.h internal/call_protected.c internal/call_protected.h common.h config/cmdline_delegate.c config/cmdline_delegate.h shim/boot_device_shim.c shim/boot_device_shim.h internal/stealth.c internal/stealth.h config/runtime_config.c config/runtime_config.h test.c shim/bios_shim.c shim/bios_shim.h internal/override_symbol.c internal/override_symbol.h shim/bios/bios_shims_collection.c shim/bios/bios_shims_collection.h shim/block_fw_update_shim.c shim/block_fw_update_shim.h internal/intercept_execve.c internal/intercept_execve.h shim/disable_exectutables.c shim/disable_exectutables.h debug/debug_execve.c debug/debug_execve.h compat/string_compat.c compat/string_compat.h internal/stealth/sanitize_cmdline.c internal/stealth/sanitize_cmdline.h internal/virtual_pci.c internal/virtual_pci.h shim/pci_shim.c shim/pci_shim.h shim/bios/rtc_proxy.c shim/bios/rtc_proxy.h shim/bios/rtc_proxy.c shim/bios/rtc_proxy.h internal/uart/virtual_uart.c internal/uart/virtual_uart.h shim/uart_fixer.c shim/uart_fixer.h internal/uart/uart_defs.h debug/debug_vuart.h internal/uart/vuart_virtual_irq.c internal/uart/vuart_virtual_irq.h internal/uart/vuart_internal.h shim/boot_dev/usb_boot_shim.c shim/boot_dev/usb_boot_shim.h shim/boot_dev/sata_boot_shim.c shim/boot_dev/sata_boot_shim.h internal/uart/uart_swapper.c internal/uart/uart_swapper.h)
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -11,7 +11,7 @@ SRCS-y += compat/string_compat.c \
\
internal/override_symbol.c internal/intercept_execve.c internal/call_protected.c \
internal/stealth/sanitize_cmdline.c internal/stealth.c internal/virtual_pci.c \
internal/uart/vuart_virtual_irq.c internal/uart/virtual_uart.c \
internal/uart/uart_swapper.c internal/uart/vuart_virtual_irq.c internal/uart/virtual_uart.c \
\
config/cmdline_delegate.c config/runtime_config.c \
\
Expand Down
2 changes: 1 addition & 1 deletion internal/call_protected.c
Expand Up @@ -93,7 +93,7 @@ DEFINE_UNEXPORTED_SHIM(int, scsi_scan_host_selected, CP_LIST(struct Scsi_Host *s
#endif

DEFINE_UNEXPORTED_SHIM(int, early_serial_setup, CP_LIST(struct uart_port *port), port, -EIO);
DEFINE_UNEXPORTED_SHIM(int, update_console_cmdline, CP_LIST(char *name, int idx, char *name_new, int idx_new, char *options), CP_LIST(name, idx, name_new, idx_new, options), -EIO);
DEFINE_UNEXPORTED_SHIM(int, serial8250_find_port, CP_LIST(struct uart_port *p), CP_LIST(p), -EIO);

DEFINE_DYNAMIC_SHIM(void, usb_register_notify, CP_LIST(struct notifier_block *nb), CP_LIST(nb), __VOID_RETURN__);
DEFINE_DYNAMIC_SHIM(void, usb_unregister_notify, CP_LIST(struct notifier_block *nb), CP_LIST(nb), __VOID_RETURN__);
3 changes: 2 additions & 1 deletion internal/call_protected.h
Expand Up @@ -58,7 +58,8 @@ CP_DECLARE_SHIM(struct filename *, getname, CP_LIST(const char __user *name));

typedef struct uart_port *uart_port_p;
CP_DECLARE_SHIM(int, early_serial_setup, CP_LIST(struct uart_port *port));
CP_DECLARE_SHIM(int, update_console_cmdline, CP_LIST(char *name, int idx, char *name_new, int idx_new, char *options));
CP_DECLARE_SHIM(int, serial8250_find_port, CP_LIST(struct uart_port *p));


#ifdef CONFIG_SYNO_BOOT_SATA_DOM
struct Scsi_Host;
Expand Down

0 comments on commit 22d4019

Please sign in to comment.