andyp73

Bootblock hack

Aug 20th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. .globl bootblock_protected_mode_entry
  2. bootblock_protected_mode_entry:
  3.  
  4. /* Save the BIST value */
  5. movl %eax, %ebp
  6.  
  7. post_code(POST_ENTER_PROTECTED_MODE)
  8.  
  9. movw $ROM_DATA_SEG, %ax
  10. movw %ax, %ds
  11. movw %ax, %es
  12. movw %ax, %ss
  13. movw %ax, %fs
  14. movw %ax, %gs
  15.  
  16. /* Restore the BIST value to %eax */
  17. movl %ebp, %eax
  18.  
  19. /*
  20. * Add some test code to see if we can flash the keyboard
  21. * backlight as a way to try to determine if there is any
  22. * life at all or whether the CSE has something against us.
  23. *
  24. * The LPC device implemented in the chipset is PCI device
  25. * 1f.0 and the Apollo Lake documentation suggests that it
  26. * is enabled by default. Enable the decode of the IO ranges
  27. * for the EC and then send some commands to it!
  28. *
  29. * The LPC PCI device has two 16bit registers - IO decode (IOD)
  30. * at offset 0x80 and IO Enable (IOE) at offset 0x82. We need
  31. * to set bits 13..10 in the IOE register.
  32. */
  33. movl $0x8000f880 , %eax
  34. movw $0xcf8, %dx
  35. outl %eax, %dx
  36.  
  37. movl $0x3c030000, %eax /* <-- Is this byte order correct? */
  38. movw $0xcfc, %dx
  39. outl %eax, %dx
  40.  
  41. switch_on:
  42. /* Send the command to the EC to turn the keyboard backlight on */
  43. movb $0x81, %al /* EC write command */
  44. movw $0x66, %dx
  45. outb %al, %dx
  46.  
  47. movb $0x19, %al /* Register 0x19 */
  48. movw $0x62, %dx
  49. outb %al, %dx
  50.  
  51. movb $0xee, %al /* Value 0xee */
  52. outb %al, %dx
  53.  
  54. /* Delay for a while */
  55. wait1:
  56. movl $0x00010000, %ecx
  57. nop
  58. loop wait1
  59.  
  60. /* Send the command to the EC to turn the keyboard backlight off */
  61. movb $0x81, %al /* EC write command */
  62. movw $0x66, %dx
  63. outb %al, %dx
  64.  
  65. movb $0x19, %al /* Register 0x19 */
  66. movw $0x62, %dx
  67. outb %al, %dx
  68.  
  69. movb $0x00, %al /* Value 0x00 */
  70. outb %al, %dx
  71.  
  72. /* Delay for a while */
  73. wait2:
  74. movl $0x00010000, %ecx
  75. nop
  76. loop wait2
  77.  
  78. jmp switch_on
  79.  
Advertisement
Add Comment
Please, Sign In to add comment