bios.h 2.1 KB

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