bios.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. /* stack at 0x40:0x800 -> 0x800 */
  57. #define SEGMENT 0x40
  58. #define STACK 0x800
  59. /*
  60. * save general registers
  61. * save some segments
  62. * save callers stack segment
  63. * setup BIOS segments
  64. * setup BIOS stackpointer
  65. */
  66. #define MAKE_BIOS_STACK \
  67. pushal; \
  68. pushw %ds; \
  69. pushw %gs; \
  70. pushw %es; \
  71. pushw %ss; \
  72. popw %gs; \
  73. movw $SEGMENT, %ax; \
  74. movw %ax, %ds; \
  75. movw %ax, %es; \
  76. movw %ax, %ss; \
  77. movw %sp, %bp; \
  78. movw $STACK, %sp
  79. /*
  80. * restore callers stack segment
  81. * restore some segments
  82. * restore general registers
  83. */
  84. #define RESTORE_CALLERS_STACK \
  85. pushw %gs; \
  86. popw %ss; \
  87. movw %bp, %sp; \
  88. popw %es; \
  89. popw %gs; \
  90. popw %ds; \
  91. popal
  92. #ifndef __ASSEMBLY__
  93. #define BIOS_DATA ((char *)0x400)
  94. #define BIOS_DATA_SIZE 256
  95. #define BIOS_BASE ((char *)0xf0000)
  96. #define BIOS_CS 0xf000
  97. extern ulong __bios_start;
  98. extern ulong __bios_size;
  99. /* these are defined in a 16bit segment and needs
  100. * to be accessed with the RELOC_16_xxxx() macros below
  101. */
  102. extern u16 ram_in_64kb_chunks;
  103. extern u16 bios_equipment;
  104. extern u8 pci_last_bus;
  105. extern void *rm_int00;
  106. extern void *rm_int01;
  107. extern void *rm_int02;
  108. extern void *rm_int03;
  109. extern void *rm_int04;
  110. extern void *rm_int05;
  111. extern void *rm_int06;
  112. extern void *rm_int07;
  113. extern void *rm_int08;
  114. extern void *rm_int09;
  115. extern void *rm_int0a;
  116. extern void *rm_int0b;
  117. extern void *rm_int0c;
  118. extern void *rm_int0d;
  119. extern void *rm_int0e;
  120. extern void *rm_int0f;
  121. extern void *rm_int10;
  122. extern void *rm_int11;
  123. extern void *rm_int12;
  124. extern void *rm_int13;
  125. extern void *rm_int14;
  126. extern void *rm_int15;
  127. extern void *rm_int16;
  128. extern void *rm_int17;
  129. extern void *rm_int18;
  130. extern void *rm_int19;
  131. extern void *rm_int1a;
  132. extern void *rm_int1b;
  133. extern void *rm_int1c;
  134. extern void *rm_int1d;
  135. extern void *rm_int1e;
  136. extern void *rm_int1f;
  137. extern void *rm_def_int;
  138. #define RELOC_16_LONG(seg, off) (*(u32 *)(seg << 4 | (u32)&off))
  139. #define RELOC_16_WORD(seg, off) (*(u16 *)(seg << 4 | (u32)&off))
  140. #define RELOC_16_BYTE(seg, off) (*(u8 *)(seg << 4 | (u32)&off))
  141. #ifdef PCI_BIOS_DEBUG
  142. extern u32 num_pci_bios_present;
  143. extern u32 num_pci_bios_find_device;
  144. extern u32 num_pci_bios_find_class;
  145. extern u32 num_pci_bios_generate_special_cycle;
  146. extern u32 num_pci_bios_read_cfg_byte;
  147. extern u32 num_pci_bios_read_cfg_word;
  148. extern u32 num_pci_bios_read_cfg_dword;
  149. extern u32 num_pci_bios_write_cfg_byte;
  150. extern u32 num_pci_bios_write_cfg_word;
  151. extern u32 num_pci_bios_write_cfg_dword;
  152. extern u32 num_pci_bios_get_irq_routing;
  153. extern u32 num_pci_bios_set_irq;
  154. extern u32 num_pci_bios_unknown_function;
  155. #endif
  156. #endif
  157. #endif