bios.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * (C) Copyright 2002
  3. * Daniel Engström, Omicron Ceti AB, daniel@omicron.se
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _BIOS_H_
  24. #define _BIOS_H_
  25. #define OFFS_ES 0 /* 16bit */
  26. #define OFFS_GS 2 /* 16bit */
  27. #define OFFS_DS 4 /* 16bit */
  28. #define OFFS_EDI 6 /* 32bit */
  29. #define OFFS_DI 6 /* low 16 bits of EDI */
  30. #define OFFS_ESI 10 /* 32bit */
  31. #define OFFS_SI 10 /* low 16 bits of ESI */
  32. #define OFFS_EBP 14 /* 32bit */
  33. #define OFFS_BP 14 /* low 16 bits of EBP */
  34. #define OFFS_ESP 18 /* 32bit */
  35. #define OFFS_SP 18 /* low 16 bits of ESP */
  36. #define OFFS_EBX 22 /* 32bit */
  37. #define OFFS_BX 22 /* low 16 bits of EBX */
  38. #define OFFS_BL 22 /* low 8 bits of BX */
  39. #define OFFS_BH 23 /* high 8 bits of BX */
  40. #define OFFS_EDX 26 /* 32bit */
  41. #define OFFS_DX 26 /* low 16 bits of EBX */
  42. #define OFFS_DL 26 /* low 8 bits of BX */
  43. #define OFFS_DH 27 /* high 8 bits of BX */
  44. #define OFFS_ECX 30 /* 32bit */
  45. #define OFFS_CX 30 /* low 16 bits of EBX */
  46. #define OFFS_CL 30 /* low 8 bits of BX */
  47. #define OFFS_CH 31 /* high 8 bits of BX */
  48. #define OFFS_EAX 34 /* 32bit */
  49. #define OFFS_AX 34 /* low 16 bits of EBX */
  50. #define OFFS_AL 34 /* low 8 bits of BX */
  51. #define OFFS_AH 35 /* high 8 bits of BX */
  52. #define OFFS_VECTOR 38 /* 16bit */
  53. #define OFFS_IP 40 /* 16bit */
  54. #define OFFS_CS 42 /* 16bit */
  55. #define OFFS_FLAGS 44 /* 16bit */
  56. #define SEGMENT 0x40
  57. #define STACK 0x800 /* stack at 0x40:0x800 -> 0x800 */
  58. /* save general registers */
  59. /* save some segments */
  60. /* save callers stack segment .. */
  61. /* ... in gs */
  62. /* setup my segments */
  63. /* setup BIOS stackpointer */
  64. #define MAKE_BIOS_STACK \
  65. pushal ; \
  66. pushw %ds ; \
  67. pushw %gs ; \
  68. pushw %es ; \
  69. pushw %ss ; \
  70. popw %gs ; \
  71. movw $SEGMENT,%ax ; \
  72. movw %ax,%ds ; \
  73. movw %ax,%es ; \
  74. movw %ax,%ss ; \
  75. movw %sp,%bp ; \
  76. movw $STACK,%sp
  77. #define RESTORE_CALLERS_STACK \
  78. pushw %gs ; /* restore callers stack segment */ \
  79. popw %ss ; \
  80. movw %bp,%sp ; /* restore stackpointer */ \
  81. \
  82. popw %es ; /* restore segment selectors */ \
  83. popw %gs ; \
  84. popw %ds ; \
  85. \
  86. popal /* restore GP registers */
  87. #endif