bios.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * From Coreboot file device/oprom/realmode/x86.h
  4. *
  5. * Copyright (C) 2007 Advanced Micro Devices, Inc.
  6. * Copyright (C) 2009-2010 coresystems GmbH
  7. */
  8. #ifndef _X86_LIB_BIOS_H
  9. #define _X86_LIB_BIOS_H
  10. #include <linux/linkage.h>
  11. #define REALMODE_BASE 0x600
  12. #ifdef __ASSEMBLY__
  13. #define PTR_TO_REAL_MODE(x) (x - asm_realmode_code + REALMODE_BASE)
  14. #else
  15. /* Convert a symbol address to our real mode area */
  16. #define PTR_TO_REAL_MODE(sym)\
  17. (void *)(REALMODE_BASE + ((char *)&(sym) - (char *)&asm_realmode_code))
  18. /*
  19. * The following symbols cannot be used directly. They need to be fixed up
  20. * to point to the correct address location after the code has been copied
  21. * to REALMODE_BASE. Absolute symbols are not used because those symbols are
  22. * relocated by U-Boot.
  23. */
  24. extern unsigned char asm_realmode_call, __realmode_interrupt;
  25. extern unsigned char asm_realmode_buffer;
  26. #define DOWNTO8(A) \
  27. union { \
  28. struct { \
  29. union { \
  30. struct { \
  31. uint8_t A##l; \
  32. uint8_t A##h; \
  33. } __packed; \
  34. uint16_t A##x; \
  35. } __packed; \
  36. uint16_t h##A##x; \
  37. } __packed; \
  38. uint32_t e##A##x; \
  39. } __packed;
  40. #define DOWNTO16(A) \
  41. union { \
  42. struct { \
  43. uint16_t A; \
  44. uint16_t h##A; \
  45. } __packed; \
  46. uint32_t e##A; \
  47. } __packed;
  48. struct eregs {
  49. DOWNTO8(a);
  50. DOWNTO8(c);
  51. DOWNTO8(d);
  52. DOWNTO8(b);
  53. DOWNTO16(sp);
  54. DOWNTO16(bp);
  55. DOWNTO16(si);
  56. DOWNTO16(di);
  57. uint32_t vector;
  58. uint32_t error_code;
  59. uint32_t eip;
  60. uint32_t cs;
  61. uint32_t eflags;
  62. };
  63. struct realmode_idt {
  64. u16 offset, cs;
  65. };
  66. void x86_exception(struct eregs *info);
  67. /* From x86_asm.S */
  68. extern unsigned char __idt_handler;
  69. extern unsigned int __idt_handler_size;
  70. extern unsigned char asm_realmode_code;
  71. extern unsigned int asm_realmode_code_size;
  72. asmlinkage void (*realmode_call)(u32 addr, u32 eax, u32 ebx, u32 ecx, u32 edx,
  73. u32 esi, u32 edi);
  74. asmlinkage void (*realmode_interrupt)(u32 intno, u32 eax, u32 ebx, u32 ecx,
  75. u32 edx, u32 esi, u32 edi);
  76. int int10_handler(void);
  77. int int12_handler(void);
  78. int int16_handler(void);
  79. int int1a_handler(void);
  80. #endif /*__ASSEMBLY__ */
  81. #endif