biosemui.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /****************************************************************************
  2. *
  3. * BIOS emulator and interface
  4. * to Realmode X86 Emulator Library
  5. *
  6. * Copyright (C) 2007 Freescale Semiconductor, Inc.
  7. * Jason Jin <Jason.jin@freescale.com>
  8. *
  9. * Copyright (C) 1996-1999 SciTech Software, Inc.
  10. *
  11. * ========================================================================
  12. *
  13. * Permission to use, copy, modify, distribute, and sell this software and
  14. * its documentation for any purpose is hereby granted without fee,
  15. * provided that the above copyright notice appear in all copies and that
  16. * both that copyright notice and this permission notice appear in
  17. * supporting documentation, and that the name of the authors not be used
  18. * in advertising or publicity pertaining to distribution of the software
  19. * without specific, written prior permission. The authors makes no
  20. * representations about the suitability of this software for any purpose.
  21. * It is provided "as is" without express or implied warranty.
  22. *
  23. * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  24. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  25. * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  26. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  27. * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  28. * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  29. * PERFORMANCE OF THIS SOFTWARE.
  30. *
  31. * ========================================================================
  32. *
  33. * Language: ANSI C
  34. * Environment: Any
  35. * Developer: Kendall Bennett
  36. *
  37. * Description: Internal header file for the BIOS emulator library.
  38. *
  39. * Jason ported this file to u-boot, Added some architecture
  40. * related Macro.
  41. *
  42. ****************************************************************************/
  43. #ifndef __BIOSEMUI_H
  44. #define __BIOSEMUI_H
  45. #include "biosemu.h"
  46. #include <asm/io.h>
  47. /*---------------------- Macros and type definitions ----------------------*/
  48. #ifdef CONFIG_X86EMU_DEBUG
  49. #define DB(x) x
  50. #else
  51. #define DB(x) do{}while(0);
  52. #endif
  53. #define BIOS_SEG 0xfff0
  54. extern X86EMU_sysEnv _X86EMU_env;
  55. #define M _X86EMU_env
  56. /* Macros to read and write values to x86 emulator memory. Memory is always
  57. * considered to be little endian, so we use macros to do endian swapping
  58. * where necessary.
  59. */
  60. #ifdef __BIG_ENDIAN__
  61. #define readb_le(base) *((u8*)(base))
  62. #define readw_le(base) ((u16)readb_le(base) | ((u16)readb_le((base) + 1) << 8))
  63. #define readl_le(base) ((u32)readb_le((base) + 0) | ((u32)readb_le((base) + 1) << 8) | \
  64. ((u32)readb_le((base) + 2) << 16) | ((u32)readb_le((base) + 3) << 24))
  65. #define writeb_le(base, v) *((u8*)(base)) = (v)
  66. #define writew_le(base, v) writeb_le(base + 0, (v >> 0) & 0xff), \
  67. writeb_le(base + 1, (v >> 8) & 0xff)
  68. #define writel_le(base, v) writeb_le(base + 0, (v >> 0) & 0xff), \
  69. writeb_le(base + 1, (v >> 8) & 0xff), \
  70. writeb_le(base + 2, (v >> 16) & 0xff), \
  71. writeb_le(base + 3, (v >> 24) & 0xff)
  72. #else
  73. #define readb_le(base) *((u8*)(base))
  74. #define readw_le(base) *((u16*)(base))
  75. #define readl_le(base) *((u32*)(base))
  76. #define writeb_le(base, v) *((u8*)(base)) = (v)
  77. #define writew_le(base, v) *((u16*)(base)) = (v)
  78. #define writel_le(base, v) *((u32*)(base)) = (v)
  79. #endif
  80. /****************************************************************************
  81. REMARKS:
  82. Function codes passed to the emulated I/O port functions to determine the
  83. type of operation to perform.
  84. ****************************************************************************/
  85. typedef enum {
  86. REG_READ_BYTE = 0,
  87. REG_READ_WORD = 1,
  88. REG_READ_DWORD = 2,
  89. REG_WRITE_BYTE = 3,
  90. REG_WRITE_WORD = 4,
  91. REG_WRITE_DWORD = 5
  92. } RegisterFlags;
  93. /****************************************************************************
  94. REMARKS:
  95. Function codes passed to the emulated I/O port functions to determine the
  96. type of operation to perform.
  97. ****************************************************************************/
  98. typedef enum {
  99. PORT_BYTE = 1,
  100. PORT_WORD = 2,
  101. PORT_DWORD = 3,
  102. } PortInfoFlags;
  103. /****************************************************************************
  104. REMARKS:
  105. Data structure used to describe the details for the BIOS emulator system
  106. environment as used by the X86 emulator library.
  107. HEADER:
  108. biosemu.h
  109. MEMBERS:
  110. type - Type of port access (1 = byte, 2 = word, 3 = dword)
  111. defVal - Default power on value
  112. finalVal - Final value
  113. ****************************************************************************/
  114. typedef struct {
  115. u8 type;
  116. u32 defVal;
  117. u32 finalVal;
  118. } BE_portInfo;
  119. #define PM_inpb(port) inb(port+VIDEO_IO_OFFSET)
  120. #define PM_inpw(port) inw(port+VIDEO_IO_OFFSET)
  121. #define PM_inpd(port) inl(port+VIDEO_IO_OFFSET)
  122. #define PM_outpb(port,val) outb(val,port+VIDEO_IO_OFFSET)
  123. #define PM_outpw(port,val) outw(val,port+VIDEO_IO_OFFSET)
  124. #define PM_outpd(port,val) outl(val,port+VIDEO_IO_OFFSET)
  125. #define LOG_inpb(port) PM_inpb(port)
  126. #define LOG_inpw(port) PM_inpw(port)
  127. #define LOG_inpd(port) PM_inpd(port)
  128. #define LOG_outpb(port,val) PM_outpb(port,val)
  129. #define LOG_outpw(port,val) PM_outpw(port,val)
  130. #define LOG_outpd(port,val) PM_outpd(port,val)
  131. /*-------------------------- Function Prototypes --------------------------*/
  132. /* bios.c */
  133. void _BE_bios_init(u32 * intrTab);
  134. void _BE_setup_funcs(void);
  135. /* besys.c */
  136. #define DEBUG_IO() (M.x86.debug & DEBUG_IO_TRACE_F)
  137. u8 X86API BE_rdb(u32 addr);
  138. u16 X86API BE_rdw(u32 addr);
  139. u32 X86API BE_rdl(u32 addr);
  140. void X86API BE_wrb(u32 addr, u8 val);
  141. void X86API BE_wrw(u32 addr, u16 val);
  142. void X86API BE_wrl(u32 addr, u32 val);
  143. u8 X86API BE_inb(X86EMU_pioAddr port);
  144. u16 X86API BE_inw(X86EMU_pioAddr port);
  145. u32 X86API BE_inl(X86EMU_pioAddr port);
  146. void X86API BE_outb(X86EMU_pioAddr port, u8 val);
  147. void X86API BE_outw(X86EMU_pioAddr port, u16 val);
  148. void X86API BE_outl(X86EMU_pioAddr port, u32 val);
  149. #endif
  150. /* __BIOSEMUI_H */